mirror of https://github.com/axmolengine/axmol.git
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:
parent
e6210874dd
commit
7894c5c4a3
|
@ -371,9 +371,11 @@ void Sprite::setTexture(const std::string &filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::setTexture(Texture2D *texture)
|
void Sprite::setTexture(Texture2D *texture)
|
||||||
|
{
|
||||||
|
if(_glProgramState == nullptr)
|
||||||
{
|
{
|
||||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
|
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
|
||||||
|
}
|
||||||
// If batchnode, then texture id should be the same
|
// 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");
|
CCASSERT(! _batchNode || (texture && texture->getName() == _batchNode->getTexture()->getName()), "CCSprite: Batched sprites should use the same texture as the batchnode");
|
||||||
// accept texture==nil as argument
|
// accept texture==nil as argument
|
||||||
|
|
Loading…
Reference in New Issue