GLProgramState* GLProgramState::getOrCreateWithShaders(const std::string& vertexShader, const std::string& fragShader, const std::string& compileTimeDefines) { auto glprogramcache = GLProgramCache::getInstance(); const std::string key = vertexShader + "+" + fragShader + "+" + compileTimeDefines; auto glprogram = glprogramcache->getGLProgram(key); if (!glprogram) { glprogram = GLProgram::createWithFilenames(vertexShader, fragShader, compileTimeDefines); glprogramcache->addGLProgram(glprogram, key); } return create(glprogram); }
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !Scene::init() ) { return false; } // // pre-load shaders // auto p1 = GLProgram::createWithFilenames("Shaders/AEM/AEM_Normal.vsh", "Shaders/AEM/AEM_Normal.fsh"); auto p2 = GLProgram::createWithFilenames("Shaders/AEM/AEM_TrackMatte.vsh", "Shaders/AEM/AEM_TrackMatte.fsh"); auto pc = GLProgramCache::getInstance(); pc->addGLProgram(p1, "AEM_Normal"); pc->addGLProgram(p2, "AEM_TrackMatte"); extension::AEMovieCache::getInstance()->initialize(ex_example_license_hash); Size designSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize(); const bool usePlist = true; if(usePlist) { addMovie(extension::AEMovie::createWithPlist("AEM/Knight/Knight.aem", "knight.plist"), Point(designSize.width / 4, designSize.height / 2), "Knight"); } else { addMovie(extension::AEMovie::create("AEM/Knight/Knight.aem"), Point(designSize.width / 4, designSize.height / 2), "Knight"); } return true; }