mirror of https://github.com/axmolengine/axmol.git
fix #10242, reload shader when light number changed
This commit is contained in:
parent
8ab1dce2a0
commit
69e79ed164
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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:
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue