bool OgreSetup::showConfigurationDialog() { OgreConfigurator configurator; OgreConfigurator::Result result; try { result = configurator.configure(); } catch (const std::exception& ex) { delete mRoot; mRoot = 0; createOgreSystem(); throw ex; } delete mRoot; mRoot = 0; if (result == OgreConfigurator::OC_CANCEL) { return false; } createOgreSystem(); if (result == OgreConfigurator::OC_ADVANCED_OPTIONS) { if (!mRoot->showConfigDialog()) { return false; } } else { mRoot->setRenderSystem(mRoot->getRenderSystemByName(configurator.getChosenRenderSystemName())); const Ogre::ConfigOptionMap& configOptions = configurator.getConfigOptions(); for (Ogre::ConfigOptionMap::const_iterator I = configOptions.begin(); I != configOptions.end(); ++I) { mRoot->getRenderSystem()->setConfigOption(I->first, I->second.currentValue); } mRoot->saveConfig(); } return true; }
bool OgreSetup::showConfigurationDialog() { OgreConfigurator configurator; OgreConfigurator::Result result; try { result = configurator.configure(); } catch (const std::exception& ex) { S_LOG_WARNING("Error when showing configuration window." << ex); delete mOverlaySystem; mOverlaySystem = nullptr; delete mRoot; mRoot = nullptr; createOgreSystem(); throw ex; } delete mOverlaySystem; mOverlaySystem = nullptr; delete mRoot; mRoot = nullptr; if (result == OgreConfigurator::OC_CANCEL) { return false; } createOgreSystem(); if (result == OgreConfigurator::OC_ADVANCED_OPTIONS) { Ogre::ConfigDialog* dlg = OGRE_NEW Ogre::ConfigDialog(); bool isOk = mRoot->showConfigDialog(dlg); OGRE_DELETE dlg; if (!isOk) { return false; } } else { mRoot->setRenderSystem(mRoot->getRenderSystemByName(configurator.getChosenRenderSystemName())); const Ogre::ConfigOptionMap& configOptions = configurator.getConfigOptions(); for (const auto& configOption : configOptions) { mRoot->getRenderSystem()->setConfigOption(configOption.first, configOption.second.currentValue); } mRoot->saveConfig(); } return true; }