From 16d9cf1af9d8fc360cf5ba753bf4f6c6ca545618 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 29 Oct 2015 14:21:25 +0800 Subject: [PATCH 1/2] setStateBlock implement --- cocos/renderer/CCRenderState.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos/renderer/CCRenderState.cpp b/cocos/renderer/CCRenderState.cpp index 728045034a..a59f08e5d2 100644 --- a/cocos/renderer/CCRenderState.cpp +++ b/cocos/renderer/CCRenderState.cpp @@ -158,6 +158,13 @@ RenderState::StateBlock* RenderState::getStateBlock() const return _state; } +void RenderState::setStateBlock(RenderState::StateBlock* state) +{ + CC_SAFE_RETAIN(state); + CC_SAFE_RELEASE(_state); + _state = state; +} + void RenderState::cloneInto(RenderState* renderState) const { CCASSERT(renderState, "must be non null"); From 11f5e6cf96a715a25b6dcb6c674f8b9219e77666 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 29 Oct 2015 14:22:13 +0800 Subject: [PATCH 2/2] setGLProgramState should not modify state block --- cocos/3d/CCMesh.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 5d79a10e97..c6e81189ec 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -404,6 +404,8 @@ void Mesh::setGLProgramState(GLProgramState* glProgramState) { // XXX create dummy texture auto material = Material::createWithGLStateProgram(glProgramState); + if (_material) + material->setStateBlock(_material->getStateBlock()); setMaterial(material); }