mirror of https://github.com/axmolengine/axmol.git
setGLProgramState support
This commit is contained in:
parent
bd4aec4bcd
commit
fcf4d79b06
|
@ -961,7 +961,7 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE GLProgram* getShaderProgram() const { return getGLProgram(); }
|
||||
|
||||
GLProgramState *getGLProgramState() const;
|
||||
void setGLProgramState(GLProgramState *glProgramState);
|
||||
virtual void setGLProgramState(GLProgramState *glProgramState);
|
||||
|
||||
/**
|
||||
* Sets the shader program for this node
|
||||
|
@ -974,7 +974,7 @@ public:
|
|||
*
|
||||
* @param shaderProgram The shader program
|
||||
*/
|
||||
void setGLProgram(GLProgram *glprogram);
|
||||
virtual void setGLProgram(GLProgram *glprogram);
|
||||
CC_DEPRECATED_ATTRIBUTE void setShaderProgram(GLProgram *glprogram) { setGLProgram(glprogram); }
|
||||
/// @} end of Shader Program
|
||||
|
||||
|
|
|
@ -414,7 +414,9 @@ void Sprite3D::setTexture(const std::string& texFile)
|
|||
|
||||
void Sprite3D::setTexture(Texture2D* texture)
|
||||
{
|
||||
_subMeshStates.at(0)->setTexture(texture);
|
||||
for (auto& state : _subMeshStates) {
|
||||
state->setTexture(texture);
|
||||
}
|
||||
}
|
||||
AttachNode* Sprite3D::getAttachNode(const std::string& boneName)
|
||||
{
|
||||
|
@ -474,8 +476,6 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
auto submesh = submeshstate->getSubMesh();
|
||||
meshCommand.init(_globalZOrder, textureID, programstate, _blend, submesh->getMesh()->getVertexBuffer(), submesh->getIndexBuffer(), (GLenum)submesh->getPrimitiveType(), (GLenum)submesh->getIndexFormat(), submesh->getIndexCount(), transform);
|
||||
|
||||
meshCommand.setCullFaceEnabled(true);
|
||||
meshCommand.setDepthTestEnabled(true);
|
||||
auto skin = submeshstate->getSkin();
|
||||
if (skin)
|
||||
{
|
||||
|
@ -488,11 +488,28 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
}
|
||||
}
|
||||
|
||||
void Sprite3D::setGLProgramState(GLProgramState *glProgramState)
|
||||
{
|
||||
Node::setGLProgramState(glProgramState);
|
||||
for (auto& state : _subMeshStates) {
|
||||
state->setGLProgramState(glProgramState);
|
||||
}
|
||||
}
|
||||
void Sprite3D::setGLProgram(GLProgram *glprogram)
|
||||
{
|
||||
Node::setGLProgram(glprogram);
|
||||
setGLProgramState(getGLProgramState());
|
||||
}
|
||||
|
||||
void Sprite3D::setBlendFunc(const BlendFunc &blendFunc)
|
||||
{
|
||||
if(_blend.src != blendFunc.src || _blend.dst != blendFunc.dst)
|
||||
{
|
||||
_blend = blendFunc;
|
||||
for(auto& state : _subMeshStates)
|
||||
{
|
||||
state->setBlendFunc(blendFunc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,12 @@ public:
|
|||
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||
virtual const BlendFunc &getBlendFunc() const override;
|
||||
|
||||
// overrides
|
||||
/** set GLProgramState, you should bind attributes by yourself */
|
||||
virtual void setGLProgramState(GLProgramState *glProgramState) override;
|
||||
/** just rember bind attributes */
|
||||
virtual void setGLProgram(GLProgram *glprogram) override;
|
||||
|
||||
/*
|
||||
* Get AABB
|
||||
* If the sprite has animation, it can't be calculated accuratly,
|
||||
|
|
|
@ -169,6 +169,8 @@ void SubMeshState::bindMeshCommand()
|
|||
{
|
||||
GLuint texID = _texture ? _texture->getName() : 0;
|
||||
_meshCommand.genMaterialID(texID, _glProgramState, _subMesh->getMesh()->getVertexBuffer(), _subMesh->getIndexBuffer(), _blend);
|
||||
_meshCommand.setCullFaceEnabled(true);
|
||||
_meshCommand.setDepthTestEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue