Save _vertShader & _fragShader for PC platform only to decrease memory usage for mobile platform.

This commit is contained in:
XiaoFeng 2015-11-17 14:29:56 +08:00
parent acd3b5cbc4
commit 50889c1c6c
2 changed files with 12 additions and 2 deletions

View File

@ -220,7 +220,11 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar*
std::string replacedDefines = "";
replaceDefines(compileTimeDefines, replacedDefines);
#if CC_TARGET_PLATFORM != CC_PLATFORM_MAC && CC_TARGET_PLATFORM != CC_PLATFORM_WIN32
_vertShader = _fragShader = 0;
#else
clearShader();
#endif
if (vShaderByteArray)
{
@ -543,6 +547,12 @@ bool GLProgram::link()
parseVertexAttribs();
parseUniforms();
#if CC_TARGET_PLATFORM != CC_PLATFORM_MAC && CC_TARGET_PLATFORM != CC_PLATFORM_WIN32
// Keep _vertShader & _fragShader on PC for cocos studio, because them
// are needed for 3d object click detection in 3d scene editing.
clearShader();
#endif
#if DEBUG || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
glGetProgramiv(_program, GL_LINK_STATUS, &status);
@ -913,7 +923,7 @@ void GLProgram::reset()
_hashForUniforms.clear();
}
void GLProgram::clearShader()
inline void GLProgram::clearShader()
{
if (_vertShader)
{

View File

@ -505,7 +505,7 @@ protected:
/**Indicate whether it has a offline shader compiler or not.*/
bool _hasShaderCompiler;
void clearShader();
inline void clearShader();
struct flag_struct {
unsigned int usesTime:1;