From aa3cab87d2f07979bbe0dad547377335b2930b2e Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Wed, 16 Oct 2024 22:52:10 +0300 Subject: [PATCH] skip switching texture modes when they're the same as the last used --- src/rendering/twn_gl_15_rendering.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rendering/twn_gl_15_rendering.c b/src/rendering/twn_gl_15_rendering.c index 4a98ac3..c800734 100644 --- a/src/rendering/twn_gl_15_rendering.c +++ b/src/rendering/twn_gl_15_rendering.c @@ -147,6 +147,7 @@ typedef struct { } DeferredCommand; +static TextureMode texture_mode_last_used = -1; static Pipeline pipeline_last_used = PIPELINE_NO; @@ -401,6 +402,7 @@ static void finally_use_space_pipeline(void) { glMatrixMode(GL_MODELVIEW); glLoadMatrixf(&camera_look_at_matrix.row[0].x); + texture_mode_last_used = -1; pipeline_last_used = PIPELINE_SPACE; } @@ -452,6 +454,7 @@ static void finally_use_2d_pipeline(void) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + texture_mode_last_used = -1; pipeline_last_used = PIPELINE_2D; } @@ -501,6 +504,9 @@ void use_texture_mode(TextureMode mode) { static void finally_use_texture_mode(TextureMode mode) { + if (texture_mode_last_used == mode) + return; + static GLuint lists = 0; if (!lists) { lists = glGenLists(3); @@ -539,6 +545,8 @@ static void finally_use_texture_mode(TextureMode mode) { } else { glCallList(lists + 2); } + + texture_mode_last_used = mode; }