mirror of https://github.com/axmolengine/axmol.git
Merge pull request #14698 from super626/v3.10-fixshader
fix Shader-Sprite crash when shader can not compile
This commit is contained in:
commit
e2f94a7a44
|
@ -93,11 +93,14 @@ public:
|
|||
|
||||
if(std::get<0>(effect) >=0)
|
||||
break;
|
||||
QuadCommand &q = std::get<2>(effect);
|
||||
q.init(_globalZOrder, _texture->getName(), std::get<1>(effect)->getGLProgramState(), _blendFunc, &_quad, 1, transform, flags);
|
||||
renderer->addCommand(&q);
|
||||
auto glProgramState = std::get<1>(effect)->getGLProgramState();
|
||||
if (glProgramState)
|
||||
{
|
||||
QuadCommand &q = std::get<2>(effect);
|
||||
q.init(_globalZOrder, _texture->getName(), glProgramState, _blendFunc, &_quad, 1, transform, flags);
|
||||
renderer->addCommand(&q);
|
||||
}
|
||||
idx++;
|
||||
|
||||
}
|
||||
|
||||
// normal effect: order == 0
|
||||
|
@ -144,8 +147,8 @@ bool Effect::initGLProgramState(const std::string &fragmentFilename)
|
|||
_fragSource = fragSource;
|
||||
#endif
|
||||
|
||||
_glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram);
|
||||
_glprogramstate->retain();
|
||||
_glprogramstate = (glprogram == nullptr ? nullptr : GLProgramState::getOrCreateWithGLProgram(glprogram));
|
||||
CC_SAFE_RETAIN(_glprogramstate);
|
||||
|
||||
return _glprogramstate != nullptr;
|
||||
}
|
||||
|
@ -194,6 +197,9 @@ protected:
|
|||
|
||||
void EffectBlur::setTarget(EffectSprite *sprite)
|
||||
{
|
||||
if (_glprogramstate == nullptr)
|
||||
return;
|
||||
|
||||
Size size = sprite->getTexture()->getContentSizeInPixels();
|
||||
_glprogramstate->setUniformVec2("resolution", size);
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
|
|
Loading…
Reference in New Issue