From eb31a1311e24adfb8b99e706643951d39d1e0472 Mon Sep 17 00:00:00 2001 From: Jens Hemprich <31758696+jenshemprich@users.noreply.github.com> Date: Mon, 20 Aug 2007 10:57:16 +0000 Subject: [PATCH] Saved some cycles --- MacGLide/OpenGLide/GLRenderUpdateState.cpp | 23 +++++++++++----------- MacGLide/OpenGLide/grguBuffer.cpp | 5 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/MacGLide/OpenGLide/GLRenderUpdateState.cpp b/MacGLide/OpenGLide/GLRenderUpdateState.cpp index 6708724..e51b9d6 100644 --- a/MacGLide/OpenGLide/GLRenderUpdateState.cpp +++ b/MacGLide/OpenGLide/GLRenderUpdateState.cpp @@ -211,13 +211,14 @@ void RenderUpdateState() bool active_texture_unit_not_coloralpha1 = false; bool active_texture_unit_client_state_not_coloralpha1 = false; + const bool useCompiledVertexArrays = InternalConfig.EXT_compiled_vertex_array; // color or alpha inversion also triggers a fog mode state so we don't have to check explicitly if (s_bUpdateFogModeState || s_bUpdateFogColorState) { if (InternalConfig.FogMode == OpenGLideFogEmulation_EnvCombine) { glActiveTextureARB(OpenGL.FogTextureUnit); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glClientActiveTextureARB(OpenGL.FogTextureUnit); active_texture_unit_client_state_not_coloralpha1 = true; @@ -239,7 +240,7 @@ void RenderUpdateState() if (Glide.State.FogMode & (GR_FOG_WITH_ITERATED_ALPHA | GR_FOG_WITH_TABLE)) { glEnable(GL_TEXTURE_2D); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(1, GL_FLOAT, 0, &OGLRender.TFog[0]); @@ -279,7 +280,7 @@ void RenderUpdateState() // because the minimal fog value is chosen. However, choosing replace might // save some vram memory access cycles glEnable(GL_TEXTURE_2D); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(1, GL_FLOAT, 0, &OGLRender.TFog[0]); @@ -292,7 +293,7 @@ void RenderUpdateState() } else { - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glDisableClientState(GL_TEXTURE_COORD_ARRAY); // On MacOS9 (Classic?) the texcoord pointer needs to be reset @@ -329,7 +330,7 @@ void RenderUpdateState() glReportError(); // Change the fog color in order to emulate the correct fog equation // (Imperfect emulation) - static const GLfloat ZeroColor[ 4 ] = { 0.0f, 0.0f, 0.0f, 0.0f }; + static const GLfloat ZeroColor[4] = {0.0f, 0.0f, 0.0f, 0.0f}; GrFogMode_t modeAdd = Glide.State.FogMode & (GR_FOG_MULT2 | GR_FOG_ADD2); switch (modeAdd) { @@ -352,7 +353,7 @@ void RenderUpdateState() { active_texture_unit_not_coloralpha1 = true; glActiveTextureARB(OpenGL.FogTextureUnit); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glClientActiveTextureARB(OpenGL.FogTextureUnit); active_texture_unit_client_state_not_coloralpha1 = true; @@ -482,7 +483,7 @@ void RenderUpdateState() if (set_active_texture_unit) { glActiveTextureARB(OpenGL.ColorAlphaUnit1 + unit_index); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glClientActiveTextureARB(OpenGL.ColorAlphaUnit1 + unit_index); active_texture_unit_client_state_not_coloralpha1 = (unit_index != 0); @@ -490,7 +491,7 @@ void RenderUpdateState() active_texture_unit_not_coloralpha1 = (unit_index != 0); glReportError(); } - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glDisableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(4, GL_FLOAT, 0, NULL); @@ -535,7 +536,7 @@ void RenderUpdateState() #endif // Enable the texture unit glEnable(GL_TEXTURE_2D); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glClientActiveTextureARB(OpenGL.ColorAlphaUnit1 + unit_index); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -857,7 +858,7 @@ void RenderUpdateState() if (OpenGL.Texture) { glEnable(GL_TEXTURE_2D); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(4, GL_FLOAT, 0, &OGLRender.TTexture[0]); @@ -865,7 +866,7 @@ void RenderUpdateState() } else { - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glDisableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(4, GL_FLOAT, 0, NULL); diff --git a/MacGLide/OpenGLide/grguBuffer.cpp b/MacGLide/OpenGLide/grguBuffer.cpp index 132572c..386f7b2 100644 --- a/MacGLide/OpenGLide/grguBuffer.cpp +++ b/MacGLide/OpenGLide/grguBuffer.cpp @@ -48,10 +48,11 @@ void gapfixSetSimpleColorState() { glDisable(GL_COLOR_SUM_EXT); } + const bool useCompiledVertexArrays = InternalConfig.EXT_compiled_vertex_array; if (OpenGL.Fog && OpenGL.FogTextureUnit) { glActiveTextureARB(OpenGL.FogTextureUnit); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glClientActiveTextureARB(OpenGL.FogTextureUnit); glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -64,7 +65,7 @@ void gapfixSetSimpleColorState() for(long unit_index = 1; unit_index >= 0; unit_index--) { glActiveTextureARB(OpenGL.ColorAlphaUnit1 + unit_index); - if (InternalConfig.EXT_compiled_vertex_array) + if (useCompiledVertexArrays) { glClientActiveTextureARB(OpenGL.ColorAlphaUnit1 + unit_index); glDisableClientState(GL_TEXTURE_COORD_ARRAY);