diff --git a/doomsday/apps/client/src/gl/dgl_common.cpp b/doomsday/apps/client/src/gl/dgl_common.cpp index 442efe6765..f27da4c199 100644 --- a/doomsday/apps/client/src/gl/dgl_common.cpp +++ b/doomsday/apps/client/src/gl/dgl_common.cpp @@ -491,7 +491,7 @@ DENG_EXTERN_C void DGL_SetScissor(RectRaw const *rect) rect->size.width, rect->size.height), Rectanglei::fromSize(game.rule().recti().size())); - GLState::current().setNormalizedScissor(norm).apply(); + GLState::current().setNormalizedScissor(norm); } #undef DGL_SetScissor2 @@ -730,9 +730,6 @@ void DGL_PushState(void) void DGL_PopState(void) { GLState::pop(); - - // Make sure the restored state is immediately in effect. - GLState::current().apply(); } #undef DGL_Enable @@ -810,7 +807,7 @@ void DGL_Disable(int cap) break; case DGL_SCISSOR_TEST: - GLState::current().clearScissor().apply(); + GLState::current().clearScissor(); break; case DGL_LINE_SMOOTH: @@ -834,8 +831,7 @@ void DGL_BlendOp(int op) { GLState::current().setBlendOp(op == DGL_SUBTRACT ? gl::Subtract : op == DGL_REVERSE_SUBTRACT ? gl::ReverseSubtract : - gl::Add) - .apply(); + gl::Add); } #undef DGL_BlendFunc @@ -862,8 +858,7 @@ void DGL_BlendFunc(int param1, int param2) param2 == DGL_ONE_MINUS_SRC_ALPHA ? gl::OneMinusSrcAlpha : param2 == DGL_DST_ALPHA ? gl::DestAlpha : param2 == DGL_ONE_MINUS_DST_ALPHA ? gl::OneMinusDestAlpha : - gl::Zero) - .apply(); + gl::Zero); } #undef DGL_BlendMode diff --git a/doomsday/apps/client/src/gl/dgl_draw.cpp b/doomsday/apps/client/src/gl/dgl_draw.cpp index 9d50009d06..c965d6f637 100644 --- a/doomsday/apps/client/src/gl/dgl_draw.cpp +++ b/doomsday/apps/client/src/gl/dgl_draw.cpp @@ -288,6 +288,9 @@ struct DGLDrawState glUnbindArrays(); } gl->shader.endUse(); + + // Buffers are single-use. + gl->buffer.clear(); } }; diff --git a/doomsday/apps/client/src/gl/gl_draw.cpp b/doomsday/apps/client/src/gl/gl_draw.cpp index 20e03f891d..847e264061 100644 --- a/doomsday/apps/client/src/gl/gl_draw.cpp +++ b/doomsday/apps/client/src/gl/gl_draw.cpp @@ -393,7 +393,7 @@ DENG_EXTERN_C void GL_EndBorderedProjection(dgl_borderedprojectionstate_t* bp) DENG_ASSERT_IN_MAIN_THREAD(); DENG_ASSERT_GL_CONTEXT_ACTIVE(); - GLState::pop().apply(); + GLState::pop(); DGL_MatrixMode(DGL_MODELVIEW); DGL_PopMatrix(); diff --git a/doomsday/apps/client/src/gl/gl_main.cpp b/doomsday/apps/client/src/gl/gl_main.cpp index d553c86a02..f2466dd857 100644 --- a/doomsday/apps/client/src/gl/gl_main.cpp +++ b/doomsday/apps/client/src/gl/gl_main.cpp @@ -352,8 +352,7 @@ void GL_Init2DState() // Here we configure the OpenGL state and set the projection matrix. GLState::current() .setCull(gl::None) - .setDepthTest(false) - .apply(); + .setDepthTest(false); //glDisable(GL_TEXTURE_1D); DGL_Disable(DGL_TEXTURE_2D); @@ -508,62 +507,52 @@ void GL_BlendMode(blendmode_t mode) { case BM_ZEROALPHA: GLState::current().setBlendOp(gl::Add) - .setBlendFunc(gl::One, gl::Zero) - .apply(); + .setBlendFunc(gl::One, gl::Zero); break; case BM_ADD: GLState::current().setBlendOp(gl::Add) - .setBlendFunc(gl::SrcAlpha, gl::One) - .apply(); + .setBlendFunc(gl::SrcAlpha, gl::One); break; case BM_DARK: GLState::current().setBlendOp(gl::Add) - .setBlendFunc(gl::DestColor, gl::OneMinusSrcAlpha) - .apply(); + .setBlendFunc(gl::DestColor, gl::OneMinusSrcAlpha); break; case BM_SUBTRACT: GLState::current().setBlendOp(gl::Subtract) - .setBlendFunc(gl::One, gl::SrcAlpha) - .apply(); + .setBlendFunc(gl::One, gl::SrcAlpha); break; case BM_ALPHA_SUBTRACT: GLState::current().setBlendOp(gl::Subtract) - .setBlendFunc(gl::SrcAlpha, gl::One) - .apply(); + .setBlendFunc(gl::SrcAlpha, gl::One); break; case BM_REVERSE_SUBTRACT: GLState::current().setBlendOp(gl::ReverseSubtract) - .setBlendFunc(gl::SrcAlpha, gl::One) - .apply(); + .setBlendFunc(gl::SrcAlpha, gl::One); break; case BM_MUL: GLState::current().setBlendOp(gl::Add) - .setBlendFunc(gl::Zero, gl::SrcColor) - .apply(); + .setBlendFunc(gl::Zero, gl::SrcColor); break; case BM_INVERSE: GLState::current().setBlendOp(gl::Add) - .setBlendFunc(gl::OneMinusDestColor, gl::OneMinusSrcColor) - .apply(); + .setBlendFunc(gl::OneMinusDestColor, gl::OneMinusSrcColor); break; case BM_INVERSE_MUL: GLState::current().setBlendOp(gl::Add) - .setBlendFunc(gl::Zero, gl::OneMinusSrcColor) - .apply(); + .setBlendFunc(gl::Zero, gl::OneMinusSrcColor); break; default: GLState::current().setBlendOp(gl::Add) - .setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha) - .apply(); + .setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha); break; } } diff --git a/doomsday/apps/client/src/gl/sys_opengl.cpp b/doomsday/apps/client/src/gl/sys_opengl.cpp index 20d2bd2a12..7e570f54ec 100644 --- a/doomsday/apps/client/src/gl/sys_opengl.cpp +++ b/doomsday/apps/client/src/gl/sys_opengl.cpp @@ -294,8 +294,7 @@ void Sys_GLConfigureDefaultState(void) // Configure the default GLState (bottom of the stack). de::GLState::current() - .setBlendFunc(de::gl::SrcAlpha, de::gl::OneMinusSrcAlpha) - .apply(); + .setBlendFunc(de::gl::SrcAlpha, de::gl::OneMinusSrcAlpha); } static de::String omitGLPrefix(de::String str) diff --git a/doomsday/apps/client/src/render/billboard.cpp b/doomsday/apps/client/src/render/billboard.cpp index 63fa13418e..a1239eada5 100644 --- a/doomsday/apps/client/src/render/billboard.cpp +++ b/doomsday/apps/client/src/render/billboard.cpp @@ -560,7 +560,7 @@ void Rend_DrawSprite(vissprite_t const &spr) !(parm.blendMode == BM_NORMAL || parm.blendMode == BM_ZEROALPHA)) { restoreZ = true; - GLState::current().setDepthWrite(false).apply(); + GLState::current().setDepthWrite(false); } dgl_vertex_t vs[4], *v = vs; @@ -607,8 +607,7 @@ void Rend_DrawSprite(vissprite_t const &spr) // Draw the vlight vectors, for debug. GLState::push() .setDepthTest(false) - .setCull(gl::None) - .apply(); + .setCull(gl::None); DGL_MatrixMode(DGL_MODELVIEW); DGL_PushMatrix(); @@ -628,7 +627,7 @@ void Rend_DrawSprite(vissprite_t const &spr) DGL_MatrixMode(DGL_MODELVIEW); DGL_PopMatrix(); - GLState::pop().apply(); + GLState::pop(); } // Need to restore the original modelview matrix? @@ -646,7 +645,7 @@ void Rend_DrawSprite(vissprite_t const &spr) // Enable Z-writing again? if(restoreZ) { - GLState::current().setDepthWrite(true).apply(); + GLState::current().setDepthWrite(true); } } diff --git a/doomsday/apps/client/src/render/cameralensfx.cpp b/doomsday/apps/client/src/render/cameralensfx.cpp index 3dc12d3e0b..6983e28c0e 100644 --- a/doomsday/apps/client/src/render/cameralensfx.cpp +++ b/doomsday/apps/client/src/render/cameralensfx.cpp @@ -116,8 +116,7 @@ void LensFx_Draw(int playerNum) // Now that we've resolved multisampling, further rendering must be done without it. GLState::push() - .setTarget(player.viewCompositor().gameView().resolvedFramebuffer()) - .apply(); + .setTarget(player.viewCompositor().gameView().resolvedFramebuffer()); auto const &effects = player.fxStack().effects; @@ -145,7 +144,7 @@ void LensFx_Draw(int playerNum) effects.at(i)->endFrame(); } - GLState::pop().apply(); + GLState::pop(); } void LensFx_MarkLightVisibleInFrame(IPointLightSource const &lightSource) diff --git a/doomsday/apps/client/src/render/fx/bloom.cpp b/doomsday/apps/client/src/render/fx/bloom.cpp index 1f246cc13b..a5064b7fe4 100644 --- a/doomsday/apps/client/src/render/fx/bloom.cpp +++ b/doomsday/apps/client/src/render/fx/bloom.cpp @@ -138,8 +138,7 @@ DENG2_PIMPL(Bloom) break; } - - GLState::pop().apply(); + GLState::pop(); } /** diff --git a/doomsday/apps/client/src/render/fx/lensflares.cpp b/doomsday/apps/client/src/render/fx/lensflares.cpp index eb651a8a00..8765f5f21c 100644 --- a/doomsday/apps/client/src/render/fx/lensflares.cpp +++ b/doomsday/apps/client/src/render/fx/lensflares.cpp @@ -550,7 +550,7 @@ void LensFlares::draw() d->drawable.draw(); - GLState::pop().apply(); + GLState::pop(); } void LensFlares::consoleRegister() diff --git a/doomsday/apps/client/src/render/modelrenderer.cpp b/doomsday/apps/client/src/render/modelrenderer.cpp index c47cca107e..b8ea44bbfc 100644 --- a/doomsday/apps/client/src/render/modelrenderer.cpp +++ b/doomsday/apps/client/src/render/modelrenderer.cpp @@ -285,7 +285,7 @@ void ModelRenderer::render(vissprite_t const &spr) // Draw the model using the current animation state. GLState::push().setCull(p.model->cull); d->draw(p); - GLState::pop().apply(); + GLState::pop(); } void ModelRenderer::render(vispsprite_t const &pspr, mobj_t const *playerMobj) @@ -312,7 +312,7 @@ void ModelRenderer::render(vispsprite_t const &pspr, mobj_t const *playerMobj) GLState::push().setCull(p.model->cull); d->draw(p); - GLState::pop().apply(); + GLState::pop(); } //--------------------------------------------------------------------------------------- diff --git a/doomsday/apps/client/src/render/rend_font.cpp b/doomsday/apps/client/src/render/rend_font.cpp index 7cf2614ff6..a4f535d3ae 100644 --- a/doomsday/apps/client/src/render/rend_font.cpp +++ b/doomsday/apps/client/src/render/rend_font.cpp @@ -825,8 +825,7 @@ static void drawFlash(Point2Raw const *origin, Size2Raw const *size, bool bright gl::ClampToEdge, gl::ClampToEdge); GLState::current().setBlendFunc(bright? gl::SrcAlpha : gl::Zero, - bright? gl::One : gl::OneMinusSrcAlpha) - .apply(); + bright? gl::One : gl::OneMinusSrcAlpha); DGL_Begin(DGL_QUADS); DGL_TexCoord2f(0, 0, 0); @@ -839,8 +838,7 @@ static void drawFlash(Point2Raw const *origin, Size2Raw const *size, bool bright DGL_Vertex2f(x, y + h); DGL_End(); - GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha) - .apply(); + GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha); } /** diff --git a/doomsday/apps/client/src/render/rend_halo.cpp b/doomsday/apps/client/src/render/rend_halo.cpp index 95a909623b..4ed2ce4bac 100644 --- a/doomsday/apps/client/src/render/rend_halo.cpp +++ b/doomsday/apps/client/src/render/rend_halo.cpp @@ -102,8 +102,7 @@ void H_SetupState(bool dosetup) { GLState::current() .setDepthWrite(false) - .setDepthTest(false) - .apply(); + .setDepthTest(false); GL_BlendMode(BM_ADD); } else @@ -111,8 +110,7 @@ void H_SetupState(bool dosetup) GL_BlendMode(BM_NORMAL); GLState::current() .setDepthWrite(true) - .setDepthTest(true) - .apply(); + .setDepthTest(true); } } diff --git a/doomsday/apps/client/src/render/rend_main.cpp b/doomsday/apps/client/src/render/rend_main.cpp index 548b71a1a5..71b93a265f 100644 --- a/doomsday/apps/client/src/render/rend_main.cpp +++ b/doomsday/apps/client/src/render/rend_main.cpp @@ -3916,10 +3916,10 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) { case DM_SKYMASK: GL_SelectTexUnits(0); - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(true).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::Less).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(true); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::Less); break; case DM_BLENDED: @@ -3931,10 +3931,10 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) // The first texture unit is used for the main texture. texUnitMap[0] = AttributeSpec::TexCoord0; texUnitMap[1] = AttributeSpec::TexCoord1; - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(true).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::Less).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(true); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::Less); // Fog is allowed during this pass. if(fogParams.usingFog) @@ -3942,7 +3942,7 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) DGL_Enable(DGL_FOG); } // All of the surfaces are opaque. - GLState::current().setBlend(false).apply(); + GLState::current().setBlend(false); break; case DM_LIGHT_MOD_TEXTURE: @@ -3961,10 +3961,10 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) texUnitMap[1] = AttributeSpec::ModTexCoord; DGL_ModulateTexture(5); // Texture + light. } - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(true).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::Less).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(true); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::Less); // Fog is allowed during this pass. if(fogParams.usingFog) @@ -3972,7 +3972,7 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) DGL_Enable(DGL_FOG); } // All of the surfaces are opaque. - GLState::current().setBlend(false).apply(); + GLState::current().setBlend(false); break; case DM_FIRST_LIGHT: @@ -3980,12 +3980,12 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) GL_SelectTexUnits(1); texUnitMap[0] = AttributeSpec::ModTexCoord; DGL_ModulateTexture(6); - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(true).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::Less).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(true); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::Less); // All of the surfaces are opaque. - GLState::current().setBlend(false).apply(); + GLState::current().setBlend(false); break; case DM_BLENDED_FIRST_LIGHT: @@ -3993,36 +3993,36 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) GL_SelectTexUnits(1); texUnitMap[0] = AttributeSpec::ModTexCoord; DGL_ModulateTexture(7); // Add light, no color. - GLState::current().setAlphaTest(true).apply(); - GLState::current().setAlphaLimit(1 / 255.0f).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setAlphaLimit(1 / 255.0f); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); // All of the surfaces are opaque. - GLState::current().setBlend(true).apply(); - GLState::current().setBlendFunc(gl::One, gl::One).apply(); + GLState::current().setBlend(true); + GLState::current().setBlendFunc(gl::One, gl::One); break; case DM_WITHOUT_TEXTURE: GL_SelectTexUnits(0); DGL_ModulateTexture(1); - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(true).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::Less).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(true); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::Less); // All of the surfaces are opaque. - GLState::current().setBlend(false).apply(); + GLState::current().setBlend(false); break; case DM_LIGHTS: GL_SelectTexUnits(1); texUnitMap[0] = AttributeSpec::TexCoord0; DGL_ModulateTexture(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setAlphaLimit(1 / 255.0f).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setAlphaLimit(1 / 255.0f); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); if(fogParams.usingFog) { @@ -4030,7 +4030,7 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) DGL_Fogfv(DGL_FOG_COLOR, black); } - GLState::current().setBlend(true).apply(); + GLState::current().setBlend(true); GL_BlendMode(BM_ADD); break; @@ -4040,27 +4040,27 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) // The first texture unit is used for the main texture. texUnitMap[0] = AttributeSpec::TexCoord0; texUnitMap[1] = AttributeSpec::TexCoord1; - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); // All of the surfaces are opaque. - GLState::current().setBlend(true).apply(); + GLState::current().setBlend(true); //glBlendFunc(GL_DST_COLOR, GL_ZERO); - GLState::current().setBlendFunc(gl::DestColor, gl::Zero).apply(); + GLState::current().setBlendFunc(gl::DestColor, gl::Zero); break; case DM_UNBLENDED_TEXTURE_AND_DETAIL: texUnitMap[0] = AttributeSpec::TexCoord0; texUnitMap[1] = AttributeSpec::TexCoord0; - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(true).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::Less).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(true); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::Less); // All of the surfaces are opaque. - GLState::current().setBlend(false).apply(); + GLState::current().setBlend(false); // Fog is allowed. if(fogParams.usingFog) { @@ -4071,28 +4071,28 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) case DM_UNBLENDED_MOD_TEXTURE_AND_DETAIL: texUnitMap[0] = AttributeSpec::TexCoord0; texUnitMap[1] = AttributeSpec::TexCoord0; - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); // All of the surfaces are opaque. - GLState::current().setBlend(true).apply(); - GLState::current().setBlendFunc(gl::DestColor, gl::Zero).apply(); + GLState::current().setBlend(true); + GLState::current().setBlendFunc(gl::DestColor, gl::Zero); break; case DM_ALL_DETAILS: GL_SelectTexUnits(1); texUnitMap[0] = AttributeSpec::TexCoord0; DGL_ModulateTexture(0); - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); // All of the surfaces are opaque. - GLState::current().setBlend(true).apply(); - GLState::current().setBlendFunc(gl::DestColor, gl::SrcColor).apply(); + GLState::current().setBlend(true); + GLState::current().setBlendFunc(gl::DestColor, gl::SrcColor); // Use fog to fade the details, if fog is enabled. if(fogParams.usingFog) { @@ -4107,14 +4107,14 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) texUnitMap[0] = AttributeSpec::TexCoord0; texUnitMap[1] = AttributeSpec::TexCoord1; DGL_ModulateTexture(3); - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); // All of the surfaces are opaque. - GLState::current().setBlend(true).apply(); - GLState::current().setBlendFunc(gl::DestColor, gl::SrcColor).apply(); + GLState::current().setBlend(true); + GLState::current().setBlendFunc(gl::DestColor, gl::SrcColor); // Use fog to fade the details, if fog is enabled. if(fogParams.usingFog) { @@ -4129,18 +4129,18 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) GL_SelectTexUnits(1); texUnitMap[0] = AttributeSpec::TexCoord0; DGL_ModulateTexture(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setAlphaLimit(1 / 255.0f).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setAlphaLimit(1 / 255.0f); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); // Set normal fog, if it's enabled. if(fogParams.usingFog) { DGL_Enable(DGL_FOG); DGL_Fogfv(DGL_FOG_COLOR, fogParams.fogColor); } - GLState::current().setBlend(true).apply(); + GLState::current().setBlend(true); GL_BlendMode(BM_NORMAL); break; @@ -4148,10 +4148,10 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) GL_SelectTexUnits(1); texUnitMap[0] = AttributeSpec::TexCoord0; DGL_ModulateTexture(1); // 8 for multitexture - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); if(fogParams.usingFog) { @@ -4159,7 +4159,7 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) DGL_Enable(DGL_FOG); DGL_Fogfv(DGL_FOG_COLOR, black); } - GLState::current().setBlend(true).apply(); + GLState::current().setBlend(true); GL_BlendMode(BM_ADD); // Purely additive. break; @@ -4168,10 +4168,10 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) texUnitMap[0] = AttributeSpec::TexCoord0; texUnitMap[1] = AttributeSpec::TexCoord1; // the mask DGL_ModulateTexture(8); // same as with details - GLState::current().setAlphaTest(false).apply(); - GLState::current().setDepthWrite(false).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setAlphaTest(false); + GLState::current().setDepthWrite(false); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::LessOrEqual); if(fogParams.usingFog) { @@ -4179,7 +4179,7 @@ static void pushGLStateForPass(DrawMode mode, TexUnitMap &texUnitMap) DGL_Enable(DGL_FOG); DGL_Fogfv(DGL_FOG_COLOR, black); } - GLState::current().setBlend(true).apply(); + GLState::current().setBlend(true); GL_BlendMode(BM_ADD); // Purely additive. break; @@ -4195,8 +4195,8 @@ static void popGLStateForPass(DrawMode mode) case DM_SKYMASK: GL_SelectTexUnits(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); break; case DM_BLENDED: @@ -4204,51 +4204,51 @@ static void popGLStateForPass(DrawMode mode) // Intentional fall-through. case DM_ALL: - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); } - GLState::current().setBlend(true).apply(); + GLState::current().setBlend(true); break; case DM_LIGHT_MOD_TEXTURE: case DM_TEXTURE_PLUS_LIGHT: GL_SelectTexUnits(1); DGL_ModulateTexture(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); } - GLState::current().setBlend(true).apply(); + GLState::current().setBlend(true); break; case DM_FIRST_LIGHT: DGL_ModulateTexture(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); - GLState::current().setBlend(true).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); + GLState::current().setBlend(true); break; case DM_BLENDED_FIRST_LIGHT: DGL_ModulateTexture(1); - GLState::current().setDepthTest(false).apply(); - GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha).apply(); + GLState::current().setDepthTest(false); + GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha); break; case DM_WITHOUT_TEXTURE: GL_SelectTexUnits(1); DGL_ModulateTexture(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); - GLState::current().setBlend(true).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); + GLState::current().setBlend(true); break; case DM_LIGHTS: - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); @@ -4259,15 +4259,15 @@ static void popGLStateForPass(DrawMode mode) case DM_MOD_TEXTURE: case DM_MOD_TEXTURE_MANY_LIGHTS: case DM_BLENDED_MOD_TEXTURE: - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); - GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); + GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha); break; case DM_UNBLENDED_TEXTURE_AND_DETAIL: - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); - GLState::current().setBlend(true).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); + GLState::current().setBlend(true); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); @@ -4275,16 +4275,16 @@ static void popGLStateForPass(DrawMode mode) break; case DM_UNBLENDED_MOD_TEXTURE_AND_DETAIL: - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); - GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); + GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha); break; case DM_ALL_DETAILS: DGL_ModulateTexture(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); - GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); + GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); @@ -4294,9 +4294,9 @@ static void popGLStateForPass(DrawMode mode) case DM_BLENDED_DETAILS: GL_SelectTexUnits(1); DGL_ModulateTexture(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); - GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); + GLState::current().setBlendFunc(gl::SrcAlpha, gl::OneMinusSrcAlpha); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); @@ -4304,7 +4304,7 @@ static void popGLStateForPass(DrawMode mode) break; case DM_SHADOW: - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); @@ -4312,8 +4312,8 @@ static void popGLStateForPass(DrawMode mode) break; case DM_SHINY: - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); @@ -4324,8 +4324,8 @@ static void popGLStateForPass(DrawMode mode) case DM_MASKED_SHINY: GL_SelectTexUnits(1); DGL_ModulateTexture(1); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setDepthTest(false).apply(); + GLState::current().setAlphaTest(true); + GLState::current().setDepthTest(false); if(fogParams.usingFog) { DGL_Disable(DGL_FOG); @@ -4367,8 +4367,7 @@ static void drawSky() GLState::push() .setDepthTest(false) .setDepthWrite(false) - .setColorMask(gl::WriteNone) - .apply(); + .setColorMask(gl::WriteNone); // Mask out stencil buffer, setting the drawn areas to 1. LIBGUI_GL.glEnable(GL_STENCIL_TEST); @@ -4386,7 +4385,7 @@ static void drawSky() } // Restore previous GL state. - GLState::pop().apply(); + GLState::pop(); LIBGUI_GL.glDisable(GL_STENCIL_TEST); // Now, only render where the stencil is set to 1. @@ -4694,12 +4693,12 @@ static void drawAllLists(Map &map) DGL_Disable(DGL_TEXTURE_2D); // The draw lists do not modify these states -ds - GLState::current().setBlend(true).apply(); - GLState::current().setDepthWrite(true).apply(); - GLState::current().setDepthTest(true).apply(); - GLState::current().setDepthFunc(gl::Less).apply(); - GLState::current().setAlphaTest(true).apply(); - GLState::current().setAlphaLimit(0).apply(); + GLState::current().setBlend(true); + GLState::current().setDepthWrite(true); + GLState::current().setDepthTest(true); + GLState::current().setDepthFunc(gl::Less); + GLState::current().setAlphaTest(true); + GLState::current().setAlphaLimit(0); if(fogParams.usingFog) { DGL_Enable(DGL_FOG); @@ -4861,12 +4860,12 @@ static void drawSource(BiasSource *s) drawStar(s->origin(), 25 + s->evaluateIntensity() / 20, Vector4f(s->color(), 1.0f / de::max(float((distToEye - 100) / 1000), 1.f))); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); drawLabel(labelForSource(s), s->origin()); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); DGL_Disable(DGL_TEXTURE_2D); } @@ -4914,9 +4913,9 @@ static void drawBiasEditingVisuals(Map &map) { viewdata_t const *viewData = &viewPlayer->viewport(); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); //glDisable(GL_CULL_FACE); - GLState::push().setCull(gl::None).apply(); + GLState::push().setCull(gl::None); DGL_MatrixMode(DGL_MODELVIEW); DGL_PushMatrix(); @@ -4930,9 +4929,9 @@ static void drawBiasEditingVisuals(Map &map) DGL_MatrixMode(DGL_MODELVIEW); DGL_PopMatrix(); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); //glEnable(GL_CULL_FACE); - GLState::pop().apply(); + GLState::pop(); } coord_t handDistance; @@ -4951,7 +4950,7 @@ static void drawBiasEditingVisuals(Map &map) if((hand.origin() - nearSource->origin()).length() > 2 * handDistance) { // Show where it is. - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); } // The nearest cursor phases blue. @@ -4967,12 +4966,12 @@ static void drawBiasEditingVisuals(Map &map) FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET); FR_SetShadowStrength(UI_SHADOW_STRENGTH); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); drawLabel(labelForSource(nearSource), nearSource->origin()); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); DGL_Disable(DGL_TEXTURE_2D); if(nearSource->isLocked()) @@ -4988,12 +4987,12 @@ static void drawBiasEditingVisuals(Map &map) drawStar(s->origin(), 10000, grabbedColor); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); drawLabel(labelForSource(s), s->origin()); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); DGL_Disable(DGL_TEXTURE_2D); if(s->isLocked()) @@ -5003,12 +5002,12 @@ static void drawBiasEditingVisuals(Map &map) /*BiasSource *s = hand.nearestBiasSource(); if(s && !hand.hasGrabbed(*s)) { - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); glEnable(GL_TEXTURE_2D); drawLabel(labelForSource(s), s->origin()); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); glDisable(GL_TEXTURE_2D); }*/ @@ -5025,7 +5024,7 @@ static void drawBiasEditingVisuals(Map &map) }); } - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); } #endif @@ -5340,10 +5339,10 @@ static void drawMobjBoundingBoxes(Map &map) // if(!dlBBox) // dlBBox = constructBBox(0, .08f); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); //glDisable(GL_CULL_FACE); - GLState::push().setCull(gl::None).apply(); + GLState::push().setCull(gl::None); MaterialAnimator &matAnimator = ClientMaterial::find(de::Uri("System", Path("bbox"))) .getAnimator(Rend_SpriteMaterialSpec()); @@ -5399,9 +5398,9 @@ static void drawMobjBoundingBoxes(Map &map) GL_BlendMode(BM_NORMAL); - GLState::pop().apply(); + GLState::pop(); DGL_Disable(DGL_TEXTURE_2D); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); } static void drawPoint(Vector3d const &origin, Vector4f const &color = Vector4f(1, 1, 1, 1)) @@ -5576,7 +5575,7 @@ static void drawSurfaceTangentVectors(Map &map) if (!::devSurfaceVectors) return; //glDisable(GL_CULL_FACE); - GLState::push().setCull(gl::None).apply(); + GLState::push().setCull(gl::None); map.forAllSectors([] (Sector &sec) { @@ -5588,7 +5587,7 @@ static void drawSurfaceTangentVectors(Map &map) }); //glEnable(GL_CULL_FACE); - GLState::pop().apply(); + GLState::pop(); } static void drawLumobjs(Map &map) @@ -5597,9 +5596,9 @@ static void drawLumobjs(Map &map) if (!devDrawLums) return; - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); //glDisable(GL_CULL_FACE); - GLState::push().setCull(gl::None).apply(); + GLState::push().setCull(gl::None); map.forAllLumobjs([] (Lumobj &lob) { @@ -5643,8 +5642,8 @@ static void drawLumobjs(Map &map) }); //glEnable(GL_CULL_FACE); - GLState::pop().apply(); - GLState::current().setDepthTest(true).apply(); + GLState::pop(); + GLState::current().setDepthTest(true); } static String labelForLineSideSection(LineSide &side, dint sectionId) @@ -5681,7 +5680,7 @@ static void drawSoundEmitters(Map &map) FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET); FR_SetShadowStrength(UI_SHADOW_STRENGTH); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); if(devSoundEmitters & SOF_SIDE) @@ -5729,7 +5728,7 @@ static void drawSoundEmitters(Map &map) }); } - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); DGL_Disable(DGL_TEXTURE_2D); } @@ -5780,7 +5779,7 @@ static void drawGenerators(Map &map) FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET); FR_SetShadowStrength(UI_SHADOW_STRENGTH); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); map.forAllGenerators([] (Generator &gen) @@ -5789,7 +5788,7 @@ static void drawGenerators(Map &map) return LoopContinue; }); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); DGL_Disable(DGL_TEXTURE_2D); } @@ -5862,12 +5861,12 @@ static void drawVertexVisual(Vertex const &vertex, ddouble minHeight, ddouble ma } if(parms.drawLabel) { - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); drawLabel(labelForVertex(&vertex), origin, distToEye / (DENG_GAMEVIEW_WIDTH / 2), opacity); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); DGL_Disable(DGL_TEXTURE_2D); } } @@ -5988,7 +5987,7 @@ static void drawVertexes(Map &map) if (devVertexBars) { - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); LIBGUI_GL.glEnable(GL_LINE_SMOOTH); oldLineWidth = DGL_GetFloat(DGL_LINE_WIDTH); @@ -6012,7 +6011,7 @@ static void drawVertexes(Map &map) return LoopContinue; }); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); } // Draw the vertex origins. @@ -6021,7 +6020,7 @@ static void drawVertexes(Map &map) LIBGUI_GL.glEnable(GL_POINT_SMOOTH); DGL_SetFloat(DGL_POINT_SIZE, 6); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); parms.drawnVerts->fill(false); // Process all again. parms.drawOrigin = true; @@ -6042,7 +6041,7 @@ static void drawVertexes(Map &map) return LoopContinue; }); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); if (devVertexIndices) { @@ -6097,7 +6096,7 @@ static void drawSectors(Map &map) FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET); FR_SetShadowStrength(UI_SHADOW_STRENGTH); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); // Draw a sector label at the center of each subsector: @@ -6116,7 +6115,7 @@ static void drawSectors(Map &map) }); }); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); DGL_Disable(DGL_TEXTURE_2D); } @@ -6140,7 +6139,7 @@ static void drawThinkers(Map &map) FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET); FR_SetShadowStrength(UI_SHADOW_STRENGTH); - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); DGL_Enable(DGL_TEXTURE_2D); map.thinkers().forAll(0x1 | 0x2, [] (thinker_t *th) @@ -6159,7 +6158,7 @@ static void drawThinkers(Map &map) return LoopContinue; }); - GLState::current().setDepthTest(true).apply(); + GLState::current().setDepthTest(true); DGL_Disable(DGL_TEXTURE_2D); } diff --git a/doomsday/apps/client/src/render/rend_model.cpp b/doomsday/apps/client/src/render/rend_model.cpp index 37bc90a944..c7b6e984ec 100644 --- a/doomsday/apps/client/src/render/rend_model.cpp +++ b/doomsday/apps/client/src/render/rend_model.cpp @@ -942,7 +942,7 @@ static void drawSubmodel(uint number, vissprite_t const &spr) if (smf.testFlag(MFF_TWO_SIDED)) { //glDisable(GL_CULL_FACE); - GLState::current().setCull(gl::None).apply(); + GLState::current().setCull(gl::None); } DGL_Enable(DGL_TEXTURE_2D); @@ -967,7 +967,7 @@ static void drawSubmodel(uint number, vissprite_t const &spr) if (shininess > 0) { //glDepthFunc(GL_LEQUAL); - GLState::current().setDepthFunc(gl::LessOrEqual).apply(); + GLState::current().setDepthFunc(gl::LessOrEqual); // Set blending mode, two choices: reflected and specular. if (smf.testFlag(MFF_SHINY_SPECULAR)) @@ -1033,7 +1033,7 @@ static void drawSubmodel(uint number, vissprite_t const &spr) if (smf.testFlag(MFF_TWO_SIDED)) { //glEnable(GL_CULL_FACE); - GLState::current().setCull(gl::Back).apply(); + GLState::current().setCull(gl::Back); } if (zSign < 0) @@ -1041,7 +1041,7 @@ static void drawSubmodel(uint number, vissprite_t const &spr) LIBGUI_GL.glFrontFace(GL_CW); } //glDepthFunc(GL_LESS); - GLState::current().setDepthFunc(gl::Less).apply(); + GLState::current().setDepthFunc(gl::Less); GL_BlendMode(BM_NORMAL); } @@ -1067,7 +1067,7 @@ void Rend_DrawModel(vissprite_t const &spr) if (disableZ) { //glDepthMask(GL_FALSE); - GLState::current().setDepthWrite(false).apply(); + GLState::current().setDepthWrite(false); } drawSubmodel(i, spr); @@ -1075,7 +1075,7 @@ void Rend_DrawModel(vissprite_t const &spr) if (disableZ) { //glDepthMask(GL_TRUE); - GLState::current().setDepthWrite(true).apply(); + GLState::current().setDepthWrite(true); } } } @@ -1087,8 +1087,7 @@ void Rend_DrawModel(vissprite_t const &spr) //glDisable(GL_CULL_FACE); GLState::push() .setDepthTest(false) - .setCull(gl::None) - .apply(); + .setCull(gl::None); DGL_MatrixMode(DGL_MODELVIEW); DGL_PushMatrix(); @@ -1110,7 +1109,7 @@ void Rend_DrawModel(vissprite_t const &spr) //glEnable(GL_CULL_FACE); //glEnable(GL_DEPTH_TEST); - GLState::pop().apply(); + GLState::pop(); } } diff --git a/doomsday/apps/client/src/render/rend_particle.cpp b/doomsday/apps/client/src/render/rend_particle.cpp index 14aa490c2d..edd1669aa3 100644 --- a/doomsday/apps/client/src/render/rend_particle.cpp +++ b/doomsday/apps/client/src/render/rend_particle.cpp @@ -546,16 +546,14 @@ static void drawParticles(dint rtype, bool withBlend) { GLState::current() .setDepthWrite(true) - .setDepthTest(true) - .apply(); + .setDepthTest(true); } else if (tex != 0) { GLState::current() .setDepthWrite(false) .setDepthFunc(gl::LessOrEqual) - .setCull(gl::None) - .apply(); + .setCull(gl::None); GL_BindTextureUnmanaged(tex, gl::ClampToEdge, gl::ClampToEdge); DGL_Enable(DGL_TEXTURE_2D); @@ -814,8 +812,8 @@ static void drawParticles(dint rtype, bool withBlend) { DGL_Vertex3f(center.x, center.y, center.z); DGL_Vertex3f(center.x - FIX2FLT(pinfo.mov[0]), - center.y - FIX2FLT(pinfo.mov[2]), - center.z - FIX2FLT(pinfo.mov[1])); + center.y - FIX2FLT(pinfo.mov[2]), + center.z - FIX2FLT(pinfo.mov[1])); } } @@ -825,14 +823,10 @@ static void drawParticles(dint rtype, bool withBlend) if(tex != 0) { - //glEnable(GL_CULL_FACE); - //glDepthMask(GL_TRUE); - //glDepthFunc(GL_LESS); GLState::current() .setCull(gl::Back) .setDepthWrite(true) - .setDepthFunc(gl::Less) - .apply(); + .setDepthFunc(gl::Less); DGL_Disable(DGL_TEXTURE_2D); } diff --git a/doomsday/apps/client/src/render/skydrawable.cpp b/doomsday/apps/client/src/render/skydrawable.cpp index 8743d300df..7222035c1a 100644 --- a/doomsday/apps/client/src/render/skydrawable.cpp +++ b/doomsday/apps/client/src/render/skydrawable.cpp @@ -422,8 +422,7 @@ DENG2_PIMPL(SkyDrawable) GLState::push() .setCull(gl::None) .setDepthTest(false) - .setDepthWrite(false) - .apply(); + .setDepthWrite(false); // Setup a proper matrix. DGL_MatrixMode(DGL_MODELVIEW); @@ -439,10 +438,7 @@ DENG2_PIMPL(SkyDrawable) DGL_PopMatrix(); // Restore assumed default GL state. - //glEnable(GL_CULL_FACE); - //glDepthMask(GL_TRUE); - //glEnable(GL_DEPTH_TEST); - GLState::pop().apply(); + GLState::pop(); } void drawModels(Animator const *animator) const @@ -454,8 +450,7 @@ DENG2_PIMPL(SkyDrawable) //glDepthMask(GL_TRUE); GLState::current() .setDepthTest(true) - .setDepthWrite(true) - .apply(); + .setDepthWrite(true); LIBGUI_GL.glClear(GL_DEPTH_BUFFER_BIT); DGL_MatrixMode(DGL_MODELVIEW); diff --git a/doomsday/apps/client/src/render/viewports.cpp b/doomsday/apps/client/src/render/viewports.cpp index 45f9d63554..f72b4238e2 100644 --- a/doomsday/apps/client/src/render/viewports.cpp +++ b/doomsday/apps/client/src/render/viewports.cpp @@ -909,8 +909,7 @@ static void changeViewState(ViewState viewState) //, viewport_t const *port, vie case PlayerView3D: GLState::current() .setCull(gl::Back) - .setDepthTest(true) - .apply(); + .setDepthTest(true); // The 3D projection matrix. GL_ProjectionMatrix(); break; @@ -974,7 +973,7 @@ static void changeViewState(ViewState viewState) //, viewport_t const *port, vie // Depth testing must be disabled so that psprite 1 will be drawn // on top of psprite 0 (Doom plasma rifle fire). - GLState::current().setDepthTest(false).apply(); + GLState::current().setDepthTest(false); break; } @@ -982,8 +981,7 @@ static void changeViewState(ViewState viewState) //, viewport_t const *port, vie case Default2D: GLState::current() .setCull(gl::None) - .setDepthTest(false) - .apply(); + .setDepthTest(false); break; } diff --git a/doomsday/apps/client/src/ui/busyvisual.cpp b/doomsday/apps/client/src/ui/busyvisual.cpp index 1375f87234..e88cb23f29 100644 --- a/doomsday/apps/client/src/ui/busyvisual.cpp +++ b/doomsday/apps/client/src/ui/busyvisual.cpp @@ -168,7 +168,7 @@ void Con_DrawTransition(void) GL_BindTextureUnmanaged(texScreenshot, gl::ClampToEdge, gl::ClampToEdge); LIBGUI_GL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - GLState::push().setAlphaTest(false).apply(); + GLState::push().setAlphaTest(false); DGL_Enable(DGL_TEXTURE_2D); switch (transition.style) @@ -248,7 +248,7 @@ void Con_DrawTransition(void) } GL_SetNoTexture(); - GLState::pop().apply(); + GLState::pop(); DGL_MatrixMode(DGL_PROJECTION); DGL_PopMatrix(); diff --git a/doomsday/apps/client/src/ui/clientwindow.cpp b/doomsday/apps/client/src/ui/clientwindow.cpp index 53fcdb5a7d..0fd21ddace 100644 --- a/doomsday/apps/client/src/ui/clientwindow.cpp +++ b/doomsday/apps/client/src/ui/clientwindow.cpp @@ -466,7 +466,7 @@ DENG2_PIMPL(ClientWindow) game->enable(); // Configure a viewport immediately. - GLState::current().setViewport(Rectangleui(0, 0, self().pixelWidth(), self().pixelHeight())).apply(); + GLState::current().setViewport(Rectangleui(0, 0, self().pixelWidth(), self().pixelHeight())); LOG_DEBUG("GameWidget enabled"); diff --git a/doomsday/apps/client/src/ui/infine/finalepagewidget.cpp b/doomsday/apps/client/src/ui/infine/finalepagewidget.cpp index 6af74c29f8..6633c11b6b 100644 --- a/doomsday/apps/client/src/ui/infine/finalepagewidget.cpp +++ b/doomsday/apps/client/src/ui/infine/finalepagewidget.cpp @@ -136,7 +136,7 @@ void FinalePageWidget::draw() const else { //glDisable(GL_BLEND); - GLState::current().setBlend(false).apply(); + GLState::current().setBlend(false); } GL_DrawRectf2TextureColor(0, 0, SCREENWIDTH, SCREENHEIGHT, 64, 64, @@ -144,7 +144,7 @@ void FinalePageWidget::draw() const GL_SetNoTexture(); //glEnable(GL_BLEND); - GLState::current().setBlend(true).apply(); + GLState::current().setBlend(true); } } @@ -161,7 +161,7 @@ void FinalePageWidget::draw() const if (renderWireframe > 1) LIBGUI_GL.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //glEnable(GL_ALPHA_TEST); - GLState::push().setAlphaTest(true).apply(); + GLState::push().setAlphaTest(true); Vector3f worldOrigin(/*-SCREENWIDTH/2*/ - d->offset[VX].value, /*-SCREENHEIGHT/2*/ - d->offset[VY].value, @@ -174,7 +174,7 @@ void FinalePageWidget::draw() const // Restore original matrices and state: back to normal 2D. //glDisable(GL_ALPHA_TEST); - GLState::pop().apply(); + GLState::pop(); // Back from wireframe mode? if (renderWireframe > 1) LIBGUI_GL.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); diff --git a/doomsday/apps/client/src/ui/ui_main.cpp b/doomsday/apps/client/src/ui/ui_main.cpp index d90c7e9400..9bd79d964b 100644 --- a/doomsday/apps/client/src/ui/ui_main.cpp +++ b/doomsday/apps/client/src/ui/ui_main.cpp @@ -173,7 +173,7 @@ void UI_DrawDDBackground(Point2Raw const &origin, Size2Raw const &dimensions, fl else { //glDisable(GL_BLEND); - GLState::current().setBlend(false).apply(); + GLState::current().setBlend(false); } DGL_Color4f(0, 0, 0, alpha); @@ -194,6 +194,6 @@ void UI_DrawDDBackground(Point2Raw const &origin, Size2Raw const &dimensions, fl DGL_End(); //glEnable(GL_BLEND); - GLState::pop().apply(); + GLState::pop(); DGL_Disable(DGL_TEXTURE_2D); } diff --git a/doomsday/apps/client/src/ui/viewcompositor.cpp b/doomsday/apps/client/src/ui/viewcompositor.cpp index 1ada289a99..06774ee24a 100644 --- a/doomsday/apps/client/src/ui/viewcompositor.cpp +++ b/doomsday/apps/client/src/ui/viewcompositor.cpp @@ -192,16 +192,14 @@ void ViewCompositor::renderGameView(std::function renderFunc) GLState::push() .setTarget(d->viewFramebuf) - .setViewport(Rectangleui::fromSize(d->viewFramebuf.size())) - .apply(); + .setViewport(Rectangleui::fromSize(d->viewFramebuf.size())); d->viewFramebuf.clear(GLFramebuffer::ColorDepthStencil); // Rendering is done by the caller-provided callback. renderFunc(d->playerNum); - GLState::pop() - .apply(); + GLState::pop(); } GLTextureFramebuffer &ViewCompositor::gameView() @@ -260,9 +258,7 @@ void ViewCompositor::drawCompositedLayers() if (gx.DrawViewPort) { - GLState::current() - .setBlend(true) - .apply(); + GLState::current().setBlend(true); gx.DrawViewPort(P_ConsoleToLocal(d->playerNum), &vpGeometry, @@ -287,9 +283,7 @@ void ViewCompositor::drawCompositedLayers() Rectanglef const vp { normRect.topLeft * targetSize, normRect.bottomRight * targetSize }; - GLState::push() - .setViewport(vp.toRectangleui()) - .apply(); + GLState::push().setViewport(vp.toRectangleui()); // Finale. { @@ -321,7 +315,7 @@ void ViewCompositor::drawCompositedLayers() } } - GLState::pop().apply(); + GLState::pop(); // Legacy engine/debug UIs (stuff from the old Net_Drawer). { @@ -344,7 +338,7 @@ void ViewCompositor::drawCompositedLayers() displayPlayer = oldDisplayPlayer; GLState::considerNativeStateUndefined(); - GLState::pop().apply(); + GLState::pop(); } PostProcessing &ViewCompositor::postProcessing() diff --git a/doomsday/apps/client/src/ui/widgets/busywidget.cpp b/doomsday/apps/client/src/ui/widgets/busywidget.cpp index 2c655ee1e9..96fc58c5ba 100644 --- a/doomsday/apps/client/src/ui/widgets/busywidget.cpp +++ b/doomsday/apps/client/src/ui/widgets/busywidget.cpp @@ -124,10 +124,9 @@ void BusyWidget::drawContent() { root().painter().flush(); GLState::push() - .setViewport(Rectangleui::fromSize(GLState::current().target().size())) - .apply(); + .setViewport(Rectangleui::fromSize(GLState::current().target().size())); Con_DrawTransition(); - GLState::pop().apply(); + GLState::pop(); } else { @@ -144,8 +143,7 @@ void BusyWidget::drawContent() root().painter().flush(); GLState::push() .setAlphaTest(false) - .setBlend(false) - .apply(); + .setBlend(false); DGL_Enable(DGL_TEXTURE_2D); // Draw the texture. @@ -155,7 +153,7 @@ void BusyWidget::drawContent() Matrix4f::scaleThenTranslate(pos.size(), pos.topLeft); d->drawable.draw(); - GLState::pop().apply(); + GLState::pop(); DGL_Disable(DGL_TEXTURE_2D); } } @@ -196,12 +194,11 @@ void BusyWidget::renderTransitionFrame() GLState::push() .setTarget(d->transitionFrame) - .setViewport(Rectangleui::fromSize(d->transitionFrame.size())) - .apply(); + .setViewport(Rectangleui::fromSize(d->transitionFrame.size())); d->gameWidget->drawComposited(); - GLState::pop().apply(); + GLState::pop(); d->transitionFrame.resolveSamples(); diff --git a/doomsday/apps/client/src/ui/widgets/gamewidget.cpp b/doomsday/apps/client/src/ui/widgets/gamewidget.cpp index 578a55c9dd..21ee8730fb 100644 --- a/doomsday/apps/client/src/ui/widgets/gamewidget.cpp +++ b/doomsday/apps/client/src/ui/widgets/gamewidget.cpp @@ -96,16 +96,14 @@ DENG2_PIMPL(GameWidget) { GLState::push() .setTarget(dest) - .setViewport(Rectangleui::fromSize(dest.size())) - .apply(); + .setViewport(Rectangleui::fromSize(dest.size())); dest.clear(GLFramebuffer::ColorDepthStencil); // Rendering is done by the caller-provided callback. R_RenderViewPort(playerNum); - GLState::pop() - .apply(); + GLState::pop(); } /** @@ -182,15 +180,6 @@ GameWidget::GameWidget(String const &name) requestGeometry(false); } -/* -void GameWidget::glApplyViewport(Rectanglei const &rect) -{ - GLState::current() - .setNormalizedViewport(normalizedRect(rect)) - .apply(); -} -*/ - void GameWidget::pause() { if (App_GameLoaded() && !clientPaused) diff --git a/doomsday/apps/client/src/ui/zonedebug.cpp b/doomsday/apps/client/src/ui/zonedebug.cpp index 28677615bc..30f00f4db0 100644 --- a/doomsday/apps/client/src/ui/zonedebug.cpp +++ b/doomsday/apps/client/src/ui/zonedebug.cpp @@ -148,8 +148,7 @@ void Z_DebugDrawer(void) //glDisable(GL_DEPTH_TEST); GLState::push() .setCull(gl::None) - .setDepthTest(false) - .apply(); + .setDepthTest(false); // Go into screen projection mode. DGL_MatrixMode(DGL_PROJECTION); @@ -186,7 +185,7 @@ void Z_DebugDrawer(void) pd.unlock(); - GLState::pop().apply(); + GLState::pop(); // Cleanup. DGL_MatrixMode(DGL_MODELVIEW); diff --git a/doomsday/sdk/libappfw/src/vrwindowtransform.cpp b/doomsday/sdk/libappfw/src/vrwindowtransform.cpp index 0aaf4dc426..d6bb72a49e 100644 --- a/doomsday/sdk/libappfw/src/vrwindowtransform.cpp +++ b/doomsday/sdk/libappfw/src/vrwindowtransform.cpp @@ -105,8 +105,7 @@ DENG2_PIMPL(VRWindowTransform) // Set render target to offscreen temporarily. GLState::push() .setTarget(unwarpedFB) - .setViewport(Rectangleui::fromSize(unwarpedFB.size())) - .apply(); + .setViewport(Rectangleui::fromSize(unwarpedFB.size())); unwarpedFB.unsetActiveRect(true); GLTextureFramebuffer::Size const fbSize = unwarpedFB.size(); @@ -129,7 +128,7 @@ DENG2_PIMPL(VRWindowTransform) } unwarpedFB.unsetActiveRect(true); - GLState::pop().apply(); + GLState::pop(); vrCfg.enableFrustumShift(); // restore default } @@ -244,25 +243,25 @@ DENG2_PIMPL(VRWindowTransform) case VRConfig::GreenMagenta: // Left eye view vrCfg.setCurrentEye(VRConfig::LeftEye); - GLState::push().setColorMask(gl::WriteGreen | gl::WriteAlpha).apply(); // Left eye view green + GLState::push().setColorMask(gl::WriteGreen | gl::WriteAlpha); // Left eye view green drawContent(); // Right eye view vrCfg.setCurrentEye(VRConfig::RightEye); - GLState::current().setColorMask(gl::WriteRed | gl::WriteBlue | gl::WriteAlpha).apply(); // Right eye view magenta + GLState::current().setColorMask(gl::WriteRed | gl::WriteBlue | gl::WriteAlpha); // Right eye view magenta drawContent(); - GLState::pop().apply(); + GLState::pop(); break; case VRConfig::RedCyan: // Left eye view vrCfg.setCurrentEye(VRConfig::LeftEye); - GLState::push().setColorMask(gl::WriteRed | gl::WriteAlpha).apply(); // Left eye view red + GLState::push().setColorMask(gl::WriteRed | gl::WriteAlpha); // Left eye view red drawContent(); // Right eye view vrCfg.setCurrentEye(VRConfig::RightEye); - GLState::current().setColorMask(gl::WriteGreen | gl::WriteBlue | gl::WriteAlpha).apply(); // Right eye view cyan + GLState::current().setColorMask(gl::WriteGreen | gl::WriteBlue | gl::WriteAlpha); // Right eye view cyan drawContent(); - GLState::pop().apply(); + GLState::pop(); break; case VRConfig::QuadBuffered: @@ -306,11 +305,10 @@ DENG2_PIMPL(VRWindowTransform) rowInterRightFB.colorTexture().glApplyParameters(); GLState::push() .setTarget(rowInterRightFB) - .setViewport(Rectangleui::fromSize(rowInterRightFB.size())) - .apply(); + .setViewport(Rectangleui::fromSize(rowInterRightFB.size())); vrCfg.setCurrentEye(rowParityIsEven ? VRConfig::RightEye : VRConfig::LeftEye); drawContent(); - GLState::pop().apply(); + GLState::pop(); // Draw right eye view to the screen from FBO color texture vrInitRowInterleaved(); diff --git a/doomsday/sdk/libgui/src/glwindow.cpp b/doomsday/sdk/libgui/src/glwindow.cpp index 105f28ed51..06da0e58c6 100644 --- a/doomsday/sdk/libgui/src/glwindow.cpp +++ b/doomsday/sdk/libgui/src/glwindow.cpp @@ -438,7 +438,6 @@ void GLWindow::paintGL() LIBGUI_ASSERT_GL_OK(); // Make sure any changes to the state stack are in effect. - GLState::current().apply(); GLState::current().target().glBind(); draw();