Merge pull request #409 from knoxHuang/v1.3

reset stencil program when alpha threshold is set to 1
This commit is contained in:
Wang Nan
2016-11-25 10:38:21 +08:00
committed by GitHub
2 changed files with 13 additions and 1 deletions
+12 -1
View File
@@ -57,6 +57,7 @@ static void setProgram(Node *n, GLProgram *p)
ClippingNode::ClippingNode()
: _stencil(nullptr)
,_stencilStateManager(new StencilStateManager())
,_originStencilProgram(nullptr)
{
}
@@ -228,7 +229,6 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
// we need to recursively apply this shader to all the nodes in the stencil node
// FIXME: we should have a way to apply shader to all nodes without having to do this
setProgram(_stencil, program);
#endif
}
@@ -315,6 +315,9 @@ void ClippingNode::setStencil(Node *stencil)
_stencil->onEnterTransitionDidFinish();
}
}
if (_stencil != nullptr)
_originStencilProgram = _stencil->getGLProgram();
}
bool ClippingNode::hasContent() const
@@ -329,6 +332,14 @@ GLfloat ClippingNode::getAlphaThreshold() const
void ClippingNode::setAlphaThreshold(GLfloat alphaThreshold)
{
#if CC_CLIPPING_NODE_OPENGLES
if (alphaThreshold == 1 && alphaThreshold != _stencilStateManager->getAlphaThreshold())
{
// should reset program used by _stencil
setProgram(_stencil, _originStencilProgram);
}
#endif
_stencilStateManager->setAlphaThreshold(alphaThreshold);
}
+1
View File
@@ -154,6 +154,7 @@ CC_CONSTRUCTOR_ACCESS:
protected:
Node* _stencil;
GLProgram* _originStencilProgram;
StencilStateManager* _stencilStateManager;