GPUProgram* GPUProgramManager::getCompiledProgram(int uniformsCode, int attributesCode) { #ifdef C_CODE for (std::map<std::string, GPUProgram*>::iterator it = _programs.begin(); it != _programs.end(); ++it) { //#warning GPUProgram getUniformsCode avoid call GPUProgram* p = it->second; if (p->getUniformsCode() == uniformsCode && p->getAttributesCode() == attributesCode) { return p; } } #endif #ifdef JAVA_CODE for (final GPUProgram p : _programs.values()) { if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode)) { return p; } } #endif return NULL; }
GPUProgram* GPUProgramManager::getProgram(GL* gl, int uniformsCode, int attributesCode) { GPUProgram* p = getCompiledProgram(uniformsCode, attributesCode); if (p == NULL) { p = getNewProgram(gl, uniformsCode, attributesCode); if (p == NULL) { ILogger::instance()->logError("Problem at compiling program."); return NULL; } //#warning AVOID getAttributesCode and getUniformsCode calls if (p->getAttributesCode() != attributesCode || p->getUniformsCode() != uniformsCode) { //#warning GIVE MORE DETAIL ILogger::instance()->logError("New compiled program does not match GL state."); } } p->addReference(); return p; }