From 3d448e86efe0be83fb3fd5d9ba7a7bdb365fe33c Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 6 Nov 2014 12:25:55 -0800 Subject: [PATCH] fixes some compiler warnings don't call deprecated functions --- cocos/renderer/CCGLProgramCache.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cocos/renderer/CCGLProgramCache.cpp b/cocos/renderer/CCGLProgramCache.cpp index f8bb1a3d55..1626bc30d9 100644 --- a/cocos/renderer/CCGLProgramCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -439,7 +439,7 @@ GLProgram* GLProgramCache::getGLProgram(const std::string &key) void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key) { // release old one - auto prev = getProgram(key); + auto prev = getGLProgram(key); if( prev == program ) return; @@ -447,17 +447,21 @@ void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key) CC_SAFE_RELEASE_NULL(prev); if (program) - program->retain(); + program->retain(); _programs[key] = program; } std::string GLProgramCache::getShaderMacrosForLight() const { GLchar def[256]; - sprintf(def, "\n#define MAX_DIRECTIONAL_LIGHT_NUM %d \n" + auto conf = Configuration::getInstance(); + + snprintf(def, sizeof(def)-1, "\n#define MAX_DIRECTIONAL_LIGHT_NUM %d \n" "\n#define MAX_POINT_LIGHT_NUM %d \n" - "\n#define MAX_SPOT_LIGHT_NUM %d \n" - , Configuration::getInstance()->getMaxSupportDirLightInShader(), Configuration::getInstance()->getMaxSupportPointLightInShader(), Configuration::getInstance()->getMaxSupportSpotLightInShader()); + "\n#define MAX_SPOT_LIGHT_NUM %d \n", + conf->getMaxSupportDirLightInShader(), + conf->getMaxSupportPointLightInShader(), + conf->getMaxSupportSpotLightInShader()); return std::string(def); }