From 9d2fca6d3421fa8907f041d1eec59fe728a5748b Mon Sep 17 00:00:00 2001 From: yangxiao Date: Mon, 9 Nov 2015 10:42:12 +0800 Subject: [PATCH] fix cull face for render queue --- cocos/renderer/CCRenderer.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index acda214a5a..50f27d1dbb 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -557,6 +557,9 @@ void Renderer::visitRenderQueue(RenderQueue& queue) RenderState::StateBlock::_defaultState->setDepthWrite(false); RenderState::StateBlock::_defaultState->setBlend(true); } + glDisable(GL_CULL_FACE); + RenderState::StateBlock::_defaultState->setCullFace(false); + for (auto it = zNegQueue.cbegin(); it != zNegQueue.cend(); ++it) { processRenderCommand(*it); @@ -574,9 +577,11 @@ void Renderer::visitRenderQueue(RenderQueue& queue) glEnable(GL_DEPTH_TEST); glDepthMask(true); glDisable(GL_BLEND); + glEnable(GL_CULL_FACE); RenderState::StateBlock::_defaultState->setDepthTest(true); RenderState::StateBlock::_defaultState->setDepthWrite(true); RenderState::StateBlock::_defaultState->setBlend(false); + RenderState::StateBlock::_defaultState->setCullFace(true); for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) @@ -595,10 +600,12 @@ void Renderer::visitRenderQueue(RenderQueue& queue) glEnable(GL_DEPTH_TEST); glDepthMask(false); glEnable(GL_BLEND); + glEnable(GL_CULL_FACE); RenderState::StateBlock::_defaultState->setDepthTest(true); RenderState::StateBlock::_defaultState->setDepthWrite(false); RenderState::StateBlock::_defaultState->setBlend(true); + RenderState::StateBlock::_defaultState->setCullFace(true); for (auto it = transQueue.cbegin(); it != transQueue.cend(); ++it) @@ -636,6 +643,9 @@ void Renderer::visitRenderQueue(RenderQueue& queue) RenderState::StateBlock::_defaultState->setBlend(true); } + glDisable(GL_CULL_FACE); + RenderState::StateBlock::_defaultState->setCullFace(false); + for (auto it = zZeroQueue.cbegin(); it != zZeroQueue.cend(); ++it) { processRenderCommand(*it); @@ -671,6 +681,8 @@ void Renderer::visitRenderQueue(RenderQueue& queue) RenderState::StateBlock::_defaultState->setBlend(true); } + glDisable(GL_CULL_FACE); + RenderState::StateBlock::_defaultState->setCullFace(false); for (auto it = zPosQueue.cbegin(); it != zPosQueue.cend(); ++it) {