Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Nov 10, 2020
1 parent 0ddf76a commit 709e03c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frameworks/cocos2d-x/cocos/2d/CCSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,11 @@ void Sprite::setProgramState(backend::ProgramState *programState)

void Sprite::setTexture(Texture2D *texture)
{
auto isETC1 = texture && texture->getAlphaTextureName();
setProgramState((isETC1) ? backend::ProgramType::ETC1 : backend::ProgramType::POSITION_TEXTURE_COLOR);
if (_programState == nullptr || _programState->getProgram()->getProgramType() == backend::ProgramType::POSITION_TEXTURE_COLOR ||
_programState->getProgram()->getProgramType() == backend::ProgramType::ETC1) {
const auto isETC1 = texture && texture->getAlphaTextureName();
setProgramState((isETC1) ? backend::ProgramType::ETC1 : backend::ProgramType::POSITION_TEXTURE_COLOR);
}
CCASSERT(! _batchNode || (texture && texture == _batchNode->getTexture()), "CCSprite: Batched sprites should use the same texture as the batchnode");
// accept texture==nil as argument
CCASSERT( !texture || dynamic_cast<Texture2D*>(texture), "setTexture expects a Texture2D. Invalid argument");
Expand Down

0 comments on commit 709e03c

Please sign in to comment.