const T & get( const std::string & id ) const { auto find = m_data.find( id ); if ( find == m_data.end() ) throw InvalidElementException( id ); return *find->second.get(); }
void Scene::gameInit() { //Parsing globals //background float * color = scanNFloat(globals["background"].c_str(), 4); glClearColor(color[0], color[1], color[2], color[3]); // Enables lighting computations glEnable(GL_LIGHTING); glEnable(GL_NORMALIZE); // Sets up some lighting parameters if (lightingGlobals["doublesided"] == "true") glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); else if (lightingGlobals["doublesided"] == "false") glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); else throw InvalidElementException("lightings", "lightings", "doublesided"); if (lightingGlobals["local"] == "true") glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); else if (lightingGlobals["local"] == "false") glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); else throw InvalidElementException("lightings", "lightings", "local"); // Define ambient light if (lightingGlobals["enabled"] == "true") { try { float* ambient = scanNFloat(lightingGlobals["ambient"].c_str(), 4); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); } catch (const exception &) { throw InvalidElementException("lightings", "lightings", "ambient"); } } else if (lightingGlobals["enabled"] != "false") { throw InvalidElementException("lightings", "lightings", "ambient"); } map<string, Light*>::const_iterator it; for(it = lightings.begin(); it != lightings.end(); it++) { lightingsState.push_back( (int) it->second->getState() ); } cameraChange(); //lightsChange(); }