Merge pull request #14264 from super626/v3

Fix: Mesh::setGLProgramState may modify state block
This commit is contained in:
pandamicro 2015-10-30 10:11:23 +08:00
commit b58e656620
2 changed files with 9 additions and 0 deletions

View File

@ -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);
}

View File

@ -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");