diff --git a/cocos/base/CCConfiguration.cpp b/cocos/base/CCConfiguration.cpp index 0667ccc8d7..99dd467251 100644 --- a/cocos/base/CCConfiguration.cpp +++ b/cocos/base/CCConfiguration.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "base/CCConfiguration.h" #include "platform/CCFileUtils.h" +#include "renderer/CCGLProgramCache.h" NS_CC_BEGIN @@ -366,6 +367,9 @@ void Configuration::loadConfigFile(const std::string& filename) _animate3DQuality = (Animate3DQuality)_valueDict[name].asInt(); else _valueDict[name] = Value((int)_animate3DQuality); + + if (GLProgramCache::isInstanceCreated()) + GLProgramCache::getInstance()->reloadDefaultGLProgramsRelativeToLights(); } NS_CC_END diff --git a/cocos/renderer/CCGLProgramCache.cpp b/cocos/renderer/CCGLProgramCache.cpp index e5093c7169..50c204c293 100644 --- a/cocos/renderer/CCGLProgramCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -80,6 +80,11 @@ GLProgramCache* GLProgramCache::getInstance() return _sharedGLProgramCache; } +bool GLProgramCache::isInstanceCreated() +{ + return _sharedGLProgramCache != 0; +} + void GLProgramCache::destroyInstance() { CC_SAFE_RELEASE_NULL(_sharedGLProgramCache); @@ -395,6 +400,21 @@ void GLProgramCache::reloadDefaultGLPrograms() loadDefaultGLProgram(p, kShaderType_CameraClear); } +void GLProgramCache::reloadDefaultGLProgramsRelativeToLights() +{ + GLProgram *p = getGLProgram(GLProgram::SHADER_3D_POSITION_NORMAL); + p->reset(); + loadDefaultGLProgram(p, kShaderType_3DPositionNormal); + + p = getGLProgram(GLProgram::SHADER_3D_POSITION_NORMAL_TEXTURE); + p->reset(); + loadDefaultGLProgram(p, kShaderType_3DPositionNormalTex); + + p = getGLProgram(GLProgram::SHADER_3D_SKINPOSITION_NORMAL_TEXTURE); + p->reset(); + loadDefaultGLProgram(p, kShaderType_3DSkinPositionNormalTex); +} + void GLProgramCache::loadDefaultGLProgram(GLProgram *p, int type) { switch (type) { diff --git a/cocos/renderer/CCGLProgramCache.h b/cocos/renderer/CCGLProgramCache.h index 7ff61e26cc..df2b4d4380 100644 --- a/cocos/renderer/CCGLProgramCache.h +++ b/cocos/renderer/CCGLProgramCache.h @@ -63,6 +63,9 @@ public: /** returns the shared instance */ static GLProgramCache* getInstance(); + + /** Is the GLProgrameCache instance created? */ + static bool isInstanceCreated(); /** purges the cache. It releases the retained instance. */ static void destroyInstance(); @@ -90,6 +93,9 @@ public: /** adds a GLProgram to the cache for a given name */ void addGLProgram(GLProgram* program, const std::string &key); CC_DEPRECATED_ATTRIBUTE void addProgram(GLProgram* program, const std::string &key) { addGLProgram(program, key); } + + /** reload default programs these are relative to light */ + void reloadDefaultGLProgramsRelativeToLights(); private: /**