Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cocos/2d/CCSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,12 @@ 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