Setting new texture for Sprite will reset the program state that is changed (#17938)

In my project:
1.set default texture.
2.set mine shader program
3.set new texture.

then, the sprite will reset my shader program.
This commit is contained in:
Y-way 2017-06-20 09:02:58 +08:00 committed by minggo
parent e6210874dd
commit 7894c5c4a3
1 changed files with 4 additions and 2 deletions

View File

@ -372,8 +372,10 @@ void Sprite::setTexture(const std::string &filename)
void Sprite::setTexture(Texture2D *texture)
{
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
if(_glProgramState == nullptr)
{
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
}
// If batchnode, then texture id should be the same
CCASSERT(! _batchNode || (texture && texture->getName() == _batchNode->getTexture()->getName()), "CCSprite: Batched sprites should use the same texture as the batchnode");
// accept texture==nil as argument