Merge pull request #12354 from ricardoquesada/minor_fixes_renderstate

Removes not-needed draws
This commit is contained in:
Ricardo Quesada 2015-06-15 12:21:20 -07:00
commit aeb9642150
4 changed files with 8 additions and 25 deletions

View File

@ -410,20 +410,14 @@ void Camera::clearBackground(float depth)
{
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glStencilMask(0);
RenderState::StateBlock::_defaultState->setStencilWrite(0);
oldDepthTest = glIsEnabled(GL_DEPTH_TEST);
glGetIntegerv(GL_DEPTH_FUNC, &oldDepthFunc);
glGetBooleanv(GL_DEPTH_WRITEMASK, &oldDepthMask);
glDepthMask(GL_TRUE);
RenderState::StateBlock::_defaultState->setDepthWrite(true);
glEnable(GL_DEPTH_TEST);
RenderState::StateBlock::_defaultState->setDepthTest(true);
glDepthFunc(GL_ALWAYS);
RenderState::StateBlock::_defaultState->setDepthFunction(RenderState::DEPTH_ALWAYS);
}
//draw
@ -470,18 +464,23 @@ void Camera::clearBackground(float depth)
if(GL_FALSE == oldDepthTest)
{
glDisable(GL_DEPTH_TEST);
RenderState::StateBlock::_defaultState->setDepthTest(false);
}
glDepthFunc(oldDepthFunc);
if(GL_FALSE == oldDepthMask)
{
glDepthMask(GL_FALSE);
RenderState::StateBlock::_defaultState->setDepthWrite(false);
}
/* IMPORTANT: We only need to update the states that are not restored.
Since we don't know what was the previous value of the mask, we update the RenderState
after setting it.
The other values don't need to be updated since they were restored to their original values
*/
glStencilMask(0xFFFFF);
RenderState::StateBlock::_defaultState->setStencilWrite(0xFFFFF);
/* BUG: RenderState does not support glColorMask yet. */
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
}

View File

@ -429,13 +429,7 @@ void ClippingNode::onBeforeVisit()
// if not in inverted mode: set the current layer value to 0 in the stencil buffer
// if in inverted mode: set the current layer value to 1 in the stencil buffer
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
RenderState::StateBlock::_defaultState->setStencilFunction(RenderState::STENCIL_NEVER, mask_layer, mask_layer);
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
RenderState::StateBlock::_defaultState->setStencilOperation(
!_inverted ? RenderState::STENCIL_OP_ZERO : RenderState::STENCIL_OP_REPLACE,
RenderState::STENCIL_OP_KEEP,
RenderState::STENCIL_OP_KEEP);
// draw a fullscreen solid rectangle to clear the stencil buffer
//ccDrawSolidRect(Vec2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));

View File

@ -132,7 +132,6 @@ void Physics3DDebugDrawer::drawImplementation( const Mat4 &transform, uint32_t f
_program->use();
_program->setUniformsForBuiltins(transform);
glEnable(GL_DEPTH_TEST);
RenderState::StateBlock::_defaultState->setDepthTest(true);
GL::blendFunc(_blendFunc.src, _blendFunc.dst);

View File

@ -348,16 +348,7 @@ void Layout::onBeforeVisitStencil()
RenderState::StateBlock::_defaultState->setDepthWrite(false);
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
RenderState::StateBlock::_defaultState->setStencilFunction(
RenderState::STENCIL_NEVER,
mask_layer,
mask_layer);
glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP);
RenderState::StateBlock::_defaultState->setStencilOperation(
RenderState::STENCIL_OP_ZERO,
RenderState::STENCIL_OP_KEEP,
RenderState::STENCIL_OP_KEEP);
this->drawFullScreenQuadClearStencil();