From fdc0fad9351096d50a37b92f54e4101717e7ee43 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 27 Aug 2014 14:46:24 +0800 Subject: [PATCH] tmp work --- cocos/3d/CCSprite3D.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 5de394fac0..f5bfa07225 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -293,19 +293,32 @@ void Sprite3D::genGLProgramState() bool textured = mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_TEX_COORD); bool hasSkin = mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_BLEND_INDEX) && mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_BLEND_WEIGHT); + bool hasNormal = mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_NORMAL); GLProgram* glProgram = nullptr; + const char* shader = nullptr; if(textured) { if (hasSkin) - glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_SKINPOSITION_TEXTURE); + { + if (hasNormal) + shader = GLProgram::SHADER_3D_SKINPOSITION_NORMAL_TEXTURE; + else + shader = GLProgram::SHADER_3D_SKINPOSITION_TEXTURE; + } else + { + if (hasNormal) + shader = GLProgram::SHADER_3D_POSITION_NORMAL_TEXTURE; glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_POSITION_TEXTURE); + } } else { glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_POSITION); } + if (shader) + glProgram = GLProgramCache::getInstance()->getGLProgram(shader); auto programstate = GLProgramState::create(glProgram); long offset = 0;