void GameSettings::update() { Root* root = Ogre::Root::getSingletonPtr(); Ogre::RenderSystem* renderer = root->getRenderSystem(); #if OGRE_VERSION_MINOR == 7 || OGRE_VERSION_MINOR == 8 const RenderSystemList& renderers = root->getAvailableRenderers(); #else const RenderSystemList renderers = *root->getAvailableRenderers(); #endif createElements(mVideoRenderer, renderers.size()); for (unsigned int i = 0; i < renderers.size(); ++i) { Ogre::RenderSystem* cur = renderers[i]; ListboxItem* item = mVideoRenderer->getListboxItemFromIndex(i); item->setText(cur->getName()); if (cur == renderer) { mVideoRenderer->setItemSelectState(item, true); } } ConfigOptionMap config = renderer->getConfigOptions(); setOption(config, "Full Screen", mVideoFullscreen); std::vector<RadioButton*> videoColorDepth; videoColorDepth.push_back(mVideoColorDepth32); videoColorDepth.push_back(mVideoColorDepth16); setOption(config, "Colour Depth", videoColorDepth); std::vector<RadioButton*> videoAntiAliasing; videoAntiAliasing.push_back(mVideoFsaa0); videoAntiAliasing.push_back(mVideoFsaa2); videoAntiAliasing.push_back(mVideoFsaa4); videoAntiAliasing.push_back(mVideoFsaa8); setOption(config, "FSAA", videoAntiAliasing); std::vector<RadioButton*> videoRttMode; videoRttMode.push_back(mVideoRttModeFBO); videoRttMode.push_back(mVideoRttModePBuffer); videoRttMode.push_back(mVideoRttModeCopy); setOption(config, "RTT Preferred Mode", videoRttMode); setOption(config, "Video Mode", mVideoResolution); }
void CLASS::UpdateControls() { int valuecounter = 0; // Going to be usefull for selections //Lang (Still not done) if (!IsLoaded) { m_lang->addItem("English (U.S.)"); } m_lang->setIndexSelected(0); //TODO if (!IsLoaded) { m_gearbox_mode->addItem("Automatic shift"); m_gearbox_mode->addItem("Manual shift - Auto clutch"); m_gearbox_mode->addItem("Fully Manual: sequential shift"); m_gearbox_mode->addItem("Fully Manual: stick shift"); m_gearbox_mode->addItem("Fully Manual: stick shift with ranges"); } //Gearbox Ogre::String gearbox_mode = GameSettingsMap["GearboxMode"]; if (gearbox_mode == "Manual shift - Auto clutch") m_gearbox_mode->setIndexSelected(1); else if (gearbox_mode == "Fully Manual: sequential shift") m_gearbox_mode->setIndexSelected(2); else if (gearbox_mode == "Fully Manual: stick shift") m_gearbox_mode->setIndexSelected(3); else if (gearbox_mode == "Fully Manual: stick shift with ranges") m_gearbox_mode->setIndexSelected(4); else m_gearbox_mode->setIndexSelected(0); Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem(); // add all rendersystems to the list if (m_render_sys->getItemCount() == 0) { const Ogre::RenderSystemList list = Application::GetOgreSubsystem()->GetOgreRoot()->getAvailableRenderers(); int selection = 0; for (Ogre::RenderSystemList::const_iterator it = list.begin(); it != list.end(); it++, valuecounter++) { if (rs && rs->getName() == (*it)->getName()) { ExOgreSettingsMap["Render System"] = rs->getName(); selection = valuecounter; } else if (!rs) { LOG("Error: No Ogre Render System found"); } if (!IsLoaded) { m_render_sys->addItem(Ogre::String((*it)->getName())); } } m_render_sys->setIndexSelected(selection); } Ogre::ConfigFile cfg; cfg.load(SSETTING("ogre.cfg", "ogre.cfg")); //Few GameSettingsMap Ogre::String bFullScreen = cfg.getSetting("Full Screen", rs->getName()); if (bFullScreen == "Yes") { ExOgreSettingsMap["Full Screen"] = "Yes"; m_fullscreen->setStateCheck(true); } else { ExOgreSettingsMap["Full Screen"] = "No"; m_fullscreen->setStateCheck(false); } Ogre::String bVsync = cfg.getSetting("VSync", rs->getName()); if (bVsync == "Yes") { ExOgreSettingsMap["VSync"] = "Yes"; m_vsync->setStateCheck(true); } else { ExOgreSettingsMap["VSync"] = "No"; m_vsync->setStateCheck(false); } // store available rendering devices and available resolutions Ogre::ConfigOptionMap& CurrentRendererOptions = rs->getConfigOptions(); Ogre::ConfigOptionMap::iterator configItr = CurrentRendererOptions.begin(); Ogre::StringVector mFoundResolutions; Ogre::StringVector mFoundFSAA; while (configItr != CurrentRendererOptions.end()) { if ((configItr)->first == "Video Mode") { // Store Available Resolutions mFoundResolutions = ((configItr)->second.possibleValues); } if ((configItr)->first == "FSAA") { // Store Available Resolutions mFoundFSAA = ((configItr)->second.possibleValues); } configItr++; } //Loop thru the vector for the resolutions valuecounter = 0; //Back to default Ogre::StringVector::iterator iterRes = mFoundResolutions.begin(); for (; iterRes != mFoundResolutions.end(); iterRes++) { if (!IsLoaded) { m_resolution->addItem(Ogre::String((iterRes)->c_str())); } if ((iterRes)->c_str() == cfg.getSetting("Video Mode", rs->getName())) { ExOgreSettingsMap["Video Mode"] = (iterRes)->c_str(); m_resolution->setIndexSelected(valuecounter); } valuecounter++; } //Loop thru the vector for the FSAAs valuecounter = 0; //Back to default Ogre::StringVector::iterator iterFSAA = mFoundFSAA.begin(); for (; iterFSAA != mFoundFSAA.end(); iterFSAA++) { if (!IsLoaded) { m_fsaa->addItem(Ogre::String((iterFSAA)->c_str())); } if ((iterFSAA)->c_str() == cfg.getSetting("FSAA", rs->getName())) { ExOgreSettingsMap["FSAA"] = (iterFSAA)->c_str(); m_fsaa->setIndexSelected(valuecounter); } valuecounter++; } //Few GameSettingsMap if (GameSettingsMap["ArcadeControls"] == "Yes") m_arc_mode->setStateCheck(true); else m_arc_mode->setStateCheck(false); if (GameSettingsMap["External Camera Mode"] == "Static") m_d_cam_pitch->setStateCheck(true); else m_d_cam_pitch->setStateCheck(false); if (GameSettingsMap["Creak Sound"] == "No") m_d_creak_sound->setStateCheck(true); else m_d_creak_sound->setStateCheck(false); //Fov m_fovexternal->setCaption(GameSettingsMap["FOV External"]); m_fovinternal->setCaption(GameSettingsMap["FOV Internal"]); //Texture Filtering Ogre::String texfilter = GameSettingsMap["Texture Filtering"]; if (texfilter == "Bilinear") m_tex_filter->setIndexSelected(1); else if (texfilter == "Trilinear") m_tex_filter->setIndexSelected(2); else if (texfilter == "Anisotropic (best looking)") m_tex_filter->setIndexSelected(3); else m_tex_filter->setIndexSelected(0); if (!IsLoaded) { m_water_type->addItem("Hydrax"); //It's working good enough to be here now. } if (BSETTING("DevMode", false) && !IsLoaded) { //Things that aren't ready to be used yet. m_sky_type->addItem("SkyX (best looking, slower)"); m_shadow_type->addItem("Parallel-split Shadow Maps"); } //Sky effects Ogre::String skytype = GameSettingsMap["Sky effects"]; if (skytype == "Caelum (best looking, slower)") m_sky_type->setIndexSelected(1); else if (skytype == "SkyX (best looking, slower)" && BSETTING("DevMode", false)) m_sky_type->setIndexSelected(2); else m_sky_type->setIndexSelected(0); //Shadow technique Ogre::String shadowtype = GameSettingsMap["Shadow technique"]; if (shadowtype == "Texture shadows") m_shadow_type->setIndexSelected(1); else if (shadowtype == "Stencil shadows (best looking)") m_shadow_type->setIndexSelected(2); else if (shadowtype == "Parallel-split Shadow Maps" && BSETTING("DevMode", false)) m_shadow_type->setIndexSelected(3); else m_shadow_type->setIndexSelected(0); //Water effects Ogre::String watertype = GameSettingsMap["Water effects"]; if (watertype == "Reflection") m_water_type->setIndexSelected(1); else if (watertype == "Reflection + refraction (speed optimized)") m_water_type->setIndexSelected(2); else if (watertype == "Reflection + refraction (quality optimized)") m_water_type->setIndexSelected(3); else if (watertype == "Hydrax") m_water_type->setIndexSelected(4); else m_water_type->setIndexSelected(0); //Vegetation Ogre::String vegetationtype = GameSettingsMap["Vegetation"]; if (vegetationtype == "20%") m_vegetation->setIndexSelected(1); else if (vegetationtype == "50%") m_vegetation->setIndexSelected(2); else if (vegetationtype == "Full (best looking, slower)") m_vegetation->setIndexSelected(3); else m_vegetation->setIndexSelected(0); //Light source effects Ogre::String lightstype = GameSettingsMap["Lights"]; if (lightstype == "Only current vehicle, main lights") m_light_source_effects->setIndexSelected(1); else if (lightstype == "All vehicles, main lights") m_light_source_effects->setIndexSelected(2); else if (lightstype == "All vehicles, all lights") m_light_source_effects->setIndexSelected(3); else m_light_source_effects->setIndexSelected(0); //Speed until selection Ogre::String speedunit = GameSettingsMap["SpeedUnit"]; if (speedunit == "Metric") m_speed_unit->setIndexSelected(1); else m_speed_unit->setIndexSelected(0); //Other configs if (GameSettingsMap["DigitalSpeedo"] == "Yes") m_digital_speedo->setStateCheck(true); else m_digital_speedo->setStateCheck(false); if (GameSettingsMap["Particles"] == "Yes") m_psystem->setStateCheck(true); else m_psystem->setStateCheck(false); if (GameSettingsMap["HeatHaze"] == "Yes") m_heathaze->setStateCheck(true); else m_heathaze->setStateCheck(false); if (GameSettingsMap["Mirrors"] == "Yes") m_mirrors->setStateCheck(true); else m_mirrors->setStateCheck(false); if (GameSettingsMap["Sunburn"] == "Yes") m_sunburn->setStateCheck(true); else m_sunburn->setStateCheck(false); if (GameSettingsMap["HDR"] == "Yes") m_hdr->setStateCheck(true); else m_hdr->setStateCheck(false); if (GameSettingsMap["Motion blur"] == "Yes") m_mblur->setStateCheck(true); else m_mblur->setStateCheck(false); if (GameSettingsMap["Skidmarks"] == "Yes") m_skidmarks->setStateCheck(true); else m_skidmarks->setStateCheck(false); if (GameSettingsMap["Envmap"] == "Yes") m_hq_ref->setStateCheck(true); else m_hq_ref->setStateCheck(false); if (GameSettingsMap["Glow"] == "Yes") m_glow->setStateCheck(true); else m_glow->setStateCheck(false); if (GameSettingsMap["DOF"] == "Yes") m_dof->setStateCheck(true); else m_dof->setStateCheck(false); if (GameSettingsMap["Waves"] == "Yes") m_e_waves->setStateCheck(true); else m_e_waves->setStateCheck(false); if (GameSettingsMap["Shadow optimizations"] == "Yes") m_sh_pf_opti->setStateCheck(true); else m_sh_pf_opti->setStateCheck(false); if (GameSettingsMap["AsynchronousPhysics"] == "Yes") m_enable_async_physics->setStateCheck(true); else m_enable_async_physics->setStateCheck(false); if (GameSettingsMap["DisableCollisions"] == "Yes") m_disable_inter_collsion->setStateCheck(true); else m_disable_inter_collsion->setStateCheck(false); if (GameSettingsMap["DisableSelfCollisions"] == "Yes") m_disable_intra_collision->setStateCheck(true); else m_disable_intra_collision->setStateCheck(false); if (GameSettingsMap["Multi-threading"] == "No") m_disable_multithreading->setStateCheck(true); else m_disable_multithreading->setStateCheck(false); //Volume slider long sound_volume = Ogre::StringConverter::parseLong(GameSettingsMap["Sound Volume"], 100); m_volume_slider->setScrollRange(101); m_volume_slider->setScrollPosition(sound_volume -1); if (m_volume_slider->getScrollPosition() >= 100) m_volume_indicator->setCaption("100%"); else m_volume_indicator->setCaption(Ogre::StringConverter::toString(sound_volume) + "%"); //Audio Devices valuecounter = 0; //Back to default char *devices = (char *)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); while (devices && *devices != 0) { if (!IsLoaded) { m_audio_dev->addItem(Ogre::String(devices)); } if (Ogre::String(devices) == GameSettingsMap["AudioDevice"]) m_audio_dev->setIndexSelected(valuecounter); devices += strlen(devices) + 1; //next device valuecounter++; } //FPS Limiter slider long fps_limit = Ogre::StringConverter::parseLong(GameSettingsMap["FPS-Limiter"], 60); m_fps_limiter_slider->setScrollRange(200); m_fps_limiter_slider->setScrollPosition(fps_limit -1); if (fps_limit >= 199) m_fps_limiter_indicator->setCaption("Unlimited"); else m_fps_limiter_indicator->setCaption(Ogre::StringConverter::toString(fps_limit) + " FPS"); //SightRange slider long sight_range = Ogre::StringConverter::parseLong(GameSettingsMap["SightRange"], 5000); m_sightrange->setScrollRange(5000); m_sightrange->setScrollPosition(sight_range -1); if (sight_range >= 4999) m_sightrange_indicator->setCaption("Unlimited"); else m_sightrange_indicator->setCaption(Ogre::StringConverter::toString(sight_range) + " m"); if (GameSettingsMap["Replay mode"] == "Yes") m_enable_replay->setStateCheck(true); else m_enable_replay->setStateCheck(false); if (GameSettingsMap["Screenshot Format"] == "png (bigger, no quality loss)") m_hq_screenshots->setStateCheck(true); else m_hq_screenshots->setStateCheck(false); if (GameSettingsMap["ChatAutoHide"] == "Yes") m_autohide_chatbox->setStateCheck(true); else m_autohide_chatbox->setStateCheck(false); }
void App::initOgre() { // Config file class is an utility that parses and stores values from a .cfg file Ogre::ConfigFile cf; std::string configFilePathPrefix = "cfg/"; // configuration files default location when app is installed #ifdef _DEBUG std::string pluginsFileName = "plugins_d.cfg"; // plugins config file name (Debug mode) #else std::string pluginsFileName = "plugins.cfg"; // plugins config file name (Release mode) #endif std::string resourcesFileName = "resources.cfg"; // resources config file name (Debug/Release mode) // LOAD OGRE PLUGINS // Try to load load up a valid config file (and don't start the program if none is found) try { //This will work ONLY when application is installed (only Release application)! cf.load(configFilePathPrefix + pluginsFileName); } catch (Ogre::FileNotFoundException &e) { try { // if no existing config, or could not restore it, try to load from a different location configFilePathPrefix = "../cfg/"; //This will work ONLY when application is in development (Debug/Release configuration) cf.load(configFilePathPrefix + pluginsFileName); } catch (Ogre::FileNotFoundException &e) { // launch exception if no valid config file is found! - PROGRAM WON'T START! throw e; } } // INSTANCIATE OGRE ROOT (IT INSTANCIATES ALSO ALL OTHER OGRE COMPONENTS) // In Ogre, the singletons are instanciated explicitly (with new) the first time, // then it can be accessed with Ogre::Root::getSingleton() // Plugins are passed as argument to the "Root" constructor mRoot = new Ogre::Root(configFilePathPrefix + pluginsFileName, configFilePathPrefix + "ogre.cfg", "ogre.log"); // No Ogre::FileNotFoundException is thrown by this, that's why we tried to open it first with ConfigFile::load() // LOAD OGRE RESOURCES // Load up resources according to resources.cfg ("cf" variable is reused) try { //This will work ONLY when application is installed! cf.load("cfg/resources.cfg"); } catch (Ogre::FileNotFoundException &e) // It works, no need to change anything { try { //This will work ONLY when application is in development (Debug/Release configuration) cf.load("../cfg/resources.cfg"); } catch (Ogre::FileNotFoundException &e) { // launch exception if no valid config file is found! - PROGRAM WON'T START! throw e; } } // Go through all sections & settings in the file Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); Ogre::String secName, typeName, archName; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; //For each section/key-value, add a resource to ResourceGroupManager Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); } } // Then setup THIS CLASS INSTANCE as a frame listener // This means that Ogre will call frameStarted(), frameRenderingQueued() and frameEnded() // automatically and periodically if defined in this class mRoot->addFrameListener(this); // SELECT AND CUSTOMIZE OGRE RENDERING (OpenGL) // Get a reference of the RenderSystem in Ogre that I want to customize Ogre::RenderSystem* pRS = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem"); // Get current config RenderSystem options in a ConfigOptionMap Ogre::ConfigOptionMap cfgMap = pRS->getConfigOptions(); // Modify them cfgMap["Full Screen"].currentValue = "No"; cfgMap["VSync"].currentValue = "Yes"; #ifdef _DEBUG cfgMap["FSAA"].currentValue = "0"; #else cfgMap["FSAA"].currentValue = "8"; #endif cfgMap["Video Mode"].currentValue = "1200 x 800"; // Set them back into the RenderSystem for(Ogre::ConfigOptionMap::iterator iter = cfgMap.begin(); iter != cfgMap.end(); iter++) pRS->setConfigOption(iter->first, iter->second.currentValue); // Set this RenderSystem as the one I want to use mRoot->setRenderSystem(pRS); // Initialize it: "false" is DO NOT CREATE A WINDOW FOR ME mRoot->initialise(false, "Oculus Rift Visualization"); // CREATE WINDOWS /* REMOVED: Rift class creates the window if no null is passed to its constructor // Options for Window 1 (rendering window) Ogre::NameValuePairList miscParams; if( NO_RIFT ) miscParams["monitorIndex"] = Ogre::StringConverter::toString(0); else miscParams["monitorIndex"] = Ogre::StringConverter::toString(1); miscParams["border "] = "none"; */ /* // Create Window 1 if( !ROTATE_VIEW ) mWindow = mRoot->createRenderWindow("Oculus Rift Liver Visualization", 1280, 800, true, &miscParams); //mWindow = mRoot->createRenderWindow("Oculus Rift Liver Visualization", 1920*0.5, 1080*0.5, false, &miscParams); else mWindow = mRoot->createRenderWindow("Oculus Rift Liver Visualization", 1080, 1920, true, &miscParams); */ // Options for Window 2 (debug window) // This window will simply show what the two cameras see in two different viewports Ogre::NameValuePairList miscParamsSmall; miscParamsSmall["monitorIndex"] = Ogre::StringConverter::toString(0); // Create Window 2 if( DEBUG_WINDOW ) mSmallWindow = mRoot->createRenderWindow("DEBUG Oculus Rift Liver Visualization", 1920*debugWindowSize, 1080*debugWindowSize, false, &miscParamsSmall); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); }
void App::initOgre() { #ifdef _DEBUG mRoot = new Ogre::Root("plugins_d.cfg"); #else mRoot = new Ogre::Root("plugins.cfg"); #endif mRoot->addFrameListener(this); // Load up resources according to resources.cfg: Ogre::ConfigFile cf; cf.load("resources.cfg"); // Go through all sections & settings in the file Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); Ogre::String secName, typeName, archName; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); } } Ogre::RenderSystem* pRS = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem"); Ogre::ConfigOptionMap cfgMap = pRS->getConfigOptions(); cfgMap["Full Screen"].currentValue = "No"; cfgMap["VSync"].currentValue = "Yes"; #ifdef _DEBUG cfgMap["FSAA"].currentValue = "0"; #else cfgMap["FSAA"].currentValue = "8"; #endif cfgMap["Video Mode"].currentValue = "1200 x 800"; for(Ogre::ConfigOptionMap::iterator iter = cfgMap.begin(); iter != cfgMap.end(); iter++) pRS->setConfigOption(iter->first, iter->second.currentValue); mRoot->setRenderSystem(pRS); mRoot->initialise(false, "Oculus Rift Visualization"); // Create the Windows: Ogre::NameValuePairList miscParams; if( NO_RIFT ) miscParams["monitorIndex"] = Ogre::StringConverter::toString(0); else miscParams["monitorIndex"] = Ogre::StringConverter::toString(1); miscParams["border "] = "none"; Ogre::NameValuePairList miscParamsSmall; miscParamsSmall["monitorIndex"] = Ogre::StringConverter::toString(0); if( !ROTATE_VIEW ) mWindow = mRoot->createRenderWindow("ShowARoom", WIDTH, HEIGHT, FULL_SCREEN, &miscParams); //mWindow = mRoot->createRenderWindow("Oculus Rift Liver Visualization", 1920*0.5, 1080*0.5, false, &miscParams); else mWindow = mRoot->createRenderWindow("ShowARoom", HEIGHT, WIDTH, FULL_SCREEN, &miscParams); if( DEBUG_WINDOW ) mSmallWindow = mRoot->createRenderWindow("DEBUG ShowARoom", 1920*debugWindowSize, 1080*debugWindowSize, false, &miscParamsSmall); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); }