This commit is contained in:
songchengjiang 2014-10-10 16:33:09 +08:00
commit 3687504982
2 changed files with 5 additions and 10 deletions

View File

@ -300,15 +300,10 @@ void Sprite3D::createAttachSprite3DNode(NodeData* nodedata,const MaterialDatas&
createAttachSprite3DNode(it,matrialdatas);
}
}
void Sprite3D::genGLProgramState()
void Sprite3D::genGLProgramState(bool useLight)
{
const auto& lights = Director::getInstance()->getRunningScene()->getLights();
_shaderUsingLight = false;
for (const auto light : lights) {
_shaderUsingLight = ((unsigned int)light->getLightFlag() & _lightMask) > 0;
if (_shaderUsingLight)
break;
}
_shaderUsingLight = useLight;
std::unordered_map<const MeshVertexData*, GLProgramState*> glProgramestates;
for(auto& mesh : _meshVertexDatas)
{
@ -532,7 +527,7 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
break;
}
if (usingLight != _shaderUsingLight)
genGLProgramState();
genGLProgramState(usingLight);
int i = 0;
for (auto& mesh : _meshes) {

View File

@ -137,7 +137,7 @@ CC_CONSTRUCTOR_ACCESS:
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
/**generate default GLProgramState*/
void genGLProgramState();
void genGLProgramState(bool useLight = false);
void createNode(NodeData* nodedata, Node* root, const MaterialDatas& matrialdatas, bool singleSprite);
void createAttachSprite3DNode(NodeData* nodedata,const MaterialDatas& matrialdatas);