Merge pull request #7822 from Teivaz/v3_WP8

Added method for custom precompiled shader program loading in WP8
This commit is contained in:
minggo 2014-08-20 11:22:26 +08:00
commit d91dc842de
2 changed files with 20 additions and 0 deletions

View File

@ -135,6 +135,25 @@ void CCPrecompiledShaders::loadPrecompiledPrograms()
#endif #endif
} }
void CCPrecompiledShaders::addPrecompiledProgram(const char* key, const unsigned char* program, int programLength)
{
std::string id = key;
PrecompiledProgram* p = nullptr;
auto it = m_precompiledPrograms.find(id);
if (it != m_precompiledPrograms.end())
{
p = it->second;
}
else
{
p = new PrecompiledProgram();
m_precompiledPrograms[id] = p;
}
p->key = key;
p->program = program;
p->length = programLength;
}
bool CCPrecompiledShaders::loadProgram(GLuint program, const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) bool CCPrecompiledShaders::loadProgram(GLuint program, const GLchar* vShaderByteArray, const GLchar* fShaderByteArray)
{ {
std::string id = computeHash(vShaderByteArray, fShaderByteArray); std::string id = computeHash(vShaderByteArray, fShaderByteArray);

View File

@ -70,6 +70,7 @@ public:
*/ */
static CCPrecompiledShaders* getInstance(); static CCPrecompiledShaders* getInstance();
void addPrecompiledProgram(const char* key, const unsigned char* program, int programLength);
std::string addShaders(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); std::string addShaders(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray);
bool addProgram(GLuint program, const std::string& id); bool addProgram(GLuint program, const std::string& id);