Skip to content

Commit

Permalink
Merge pull request cocos2d#15039 from Shulepov/scale9sprite_shaders_s…
Browse files Browse the repository at this point in the history
…upport

Scale9Sprite: allow to set custom shaders (fix cocos2d#12753)
  • Loading branch information
zilongshanren committed Feb 15, 2016
2 parents c1013d1 + 19e2434 commit 9d8d003
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
26 changes: 20 additions & 6 deletions cocos/ui/UIScale9Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,11 @@ namespace ui {
}

applyBlendFunc();
this->setState(_brightState);
if (getGLProgramState()) {
_scale9Image->setGLProgramState(getGLProgramState());
} else {
this->setState(_brightState);
}
if(this->_isPatch9)
{
size.width = size.width - 2;
Expand Down Expand Up @@ -604,11 +608,7 @@ namespace ui {
break;
}

if (nullptr != _scale9Image)
{
_scale9Image->setGLProgramState(glState);
}

setGLProgramState(glState);
_brightState = state;
}

Expand Down Expand Up @@ -979,6 +979,20 @@ namespace ui {
child->updateDisplayedOpacity(255);
}
}

void Scale9Sprite::setGLProgram(GLProgram *glprogram) {
Node::setGLProgram(glprogram);
if (_scale9Image) {
_scale9Image->setGLProgram(glprogram);
}
}

void Scale9Sprite::setGLProgramState(GLProgramState *glProgramState) {
Node::setGLProgramState(glProgramState);
if (_scale9Image) {
_scale9Image->setGLProgramState(glProgramState);
}
}

Sprite* Scale9Sprite::getSprite()const
{
Expand Down
3 changes: 2 additions & 1 deletion cocos/ui/UIScale9Sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ namespace ui {
virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual void disableCascadeColor() override;
virtual void disableCascadeOpacity() override;

virtual void setGLProgram(GLProgram *glprogram) override;
virtual void setGLProgramState(GLProgramState *glProgramState) override;

/**
* @brief Get the original no 9-sliced sprite
Expand Down

0 comments on commit 9d8d003

Please sign in to comment.