Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/GraphicsManager.cc @ 11057

Last change on this file since 11057 was 10624, checked in by landauf, 9 years ago

merged branch core7 back to trunk

  • Property svn:eol-style set to native
File size: 21.9 KB
RevLine 
[612]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1293]3 *                    > www.orxonox.net <
[612]4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
[1349]11 *   of the License, or (at your option) any later version.
12 *
[612]13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
[1535]23 *      Reto Grieder
[1755]24 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
[612]25 *   Co-authors:
[1755]26 *      Felix Schulthess
[612]27 *
28 */
[1035]29
[2801]30#include "GraphicsManager.h"
[612]31
[8351]32#include <cstdlib>
[2801]33#include <fstream>
[5695]34#include <sstream>
[2801]35#include <boost/filesystem.hpp>
[5695]36#include <boost/shared_array.hpp>
[2801]37
38#include <OgreFrameListener.h>
39#include <OgreRoot.h>
40#include <OgreLogManager.h>
[1755]41#include <OgreRenderWindow.h>
[2801]42#include <OgreRenderSystem.h>
[5695]43#include <OgreResourceGroupManager.h>
[2801]44#include <OgreTextureManager.h>
45#include <OgreViewport.h>
46#include <OgreWindowEventUtilities.h>
[1538]47
[2801]48#include "SpecialConfig.h"
[5929]49#include "util/Clock.h"
[8079]50#include "util/Convert.h"
[2801]51#include "util/Exception.h"
[3280]52#include "util/StringUtils.h"
[2801]53#include "util/SubString.h"
[9667]54#include "config/ConfigValueIncludes.h"
[3346]55#include "CoreIncludes.h"
[7870]56#include "Core.h"
[3346]57#include "Game.h"
58#include "GameMode.h"
[8079]59#include "GUIManager.h"
[5695]60#include "Loader.h"
[10624]61#include "ApplicationPaths.h"
62#include "ConfigurablePaths.h"
[8079]63#include "ViewportEventListener.h"
[3346]64#include "WindowEventListener.h"
[5695]65#include "XMLFile.h"
[10624]66#include "command/ConsoleCommandIncludes.h"
[8079]67#include "input/InputManager.h"
[1032]68
[1625]69namespace orxonox
70{
[8079]71    static const std::string __CC_GraphicsManager_group = "GraphicsManager";
72    static const std::string __CC_setScreenResolution_name = "setScreenResolution";
73    static const std::string __CC_setFSAA_name = "setFSAA";
74    static const std::string __CC_setVSync_name = "setVSync";
75    DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name, &prototype::string__uint_uint_bool);
76    DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name, &prototype::string__string);
77    DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name, &prototype::string__bool);
78
[7284]79    static const std::string __CC_printScreen_name = "printScreen";
80    DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void);
81
[3327]82    class OgreWindowEventListener : public Ogre::WindowEventListener
[2801]83    {
[3327]84    public:
85        void windowResized     (Ogre::RenderWindow* rw)
86            { orxonox::WindowEventListener::resizeWindow(rw->getWidth(), rw->getHeight()); }
87        void windowFocusChange (Ogre::RenderWindow* rw)
[7874]88            { orxonox::WindowEventListener::changeWindowFocus(rw->isActive()); }
[3327]89        void windowClosed      (Ogre::RenderWindow* rw)
90            { orxonox::Game::getInstance().stop(); }
91        void windowMoved       (Ogre::RenderWindow* rw)
92            { orxonox::WindowEventListener::moveWindow(); }
[2801]93    };
[1032]94
[3366]95    GraphicsManager* GraphicsManager::singletonPtr_s = 0;
[1293]96
[10624]97    RegisterAbstractClass(GraphicsManager).inheritsFrom<Configurable>();
98
[5695]99    GraphicsManager::GraphicsManager(bool bLoadRenderer)
100        : ogreWindowEventListener_(new OgreWindowEventListener())
[2801]101        , renderWindow_(0)
102        , viewport_(0)
[8079]103        , lastFrameStartTime_(0.0f)
104        , lastFrameEndTime_(0.0f)
[8423]105        , destructionHelper_(this)
[1024]106    {
[2801]107        RegisterObject(GraphicsManager);
108
[8858]109        orxout(internal_status) << "initializing GraphicsManager..." << endl;
[2801]110        this->setConfigValues();
[612]111
[5695]112        // Ogre setup procedure (creating Ogre::Root)
113        this->loadOgreRoot();
[2801]114
[5695]115        // At first, add the root paths of the data directories as resource locations
[10624]116        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getDataPathString(), "FileSystem");
[5695]117        // Load resources
[6417]118        resources_.reset(new XMLFile("DefaultResources.oxr"));
[5695]119        resources_->setLuaSupport(false);
[10624]120        Loader::getInstance().load(resources_.get(), ClassTreeMask(), false);
[5695]121
[8366]122        // Only for runs in the build directory (not installed)
[10624]123        if (ApplicationPaths::buildDirectoryRun())
124            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getExternalDataPathString(), "FileSystem");
[2801]125
[8351]126        extResources_.reset(new XMLFile("resources.oxr"));
127        extResources_->setLuaSupport(false);
[10624]128        Loader::getInstance().load(extResources_.get(), ClassTreeMask(), false);
[8351]129
[5695]130        if (bLoadRenderer)
[3280]131        {
[5695]132            // Reads the ogre config and creates the render window
133            this->upgradeToGraphics();
[3280]134        }
[8858]135
136        orxout(internal_status) << "finished initializing GraphicsManager" << endl;
[2801]137    }
138
[8423]139    void GraphicsManager::destroy()
[1535]140    {
[8858]141        orxout(internal_status) << "destroying GraphicsManager..." << endl;
142
[8423]143        Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_);
[7284]144        ModifyConsoleCommand(__CC_printScreen_name).resetFunction();
[8079]145        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).resetFunction();
146        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).resetFunction();
147        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).resetFunction();
[5929]148
149        // Undeclare the resources
[10624]150        Loader::getInstance().unload(resources_.get());
151        Loader::getInstance().unload(extResources_.get());
[8423]152
153        safeObjectDelete(&ogreRoot_);
154        safeObjectDelete(&ogreLogger_);
155        safeObjectDelete(&ogreWindowEventListener_);
[8858]156
157        orxout(internal_status) << "finished destroying GraphicsManager" << endl;
[1535]158    }
159
[2801]160    void GraphicsManager::setConfigValues()
[1535]161    {
[2801]162        SetConfigValue(ogreConfigFile_,  "ogre.cfg")
163            .description("Location of the Ogre config file");
[5695]164        SetConfigValue(ogrePlugins_, specialConfig::ogrePlugins)
[2801]165            .description("Comma separated list of all plugins to load.");
166        SetConfigValue(ogreLogFile_,     "ogre.log")
167            .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
[1535]168    }
[612]169
[5695]170    /**
171    @brief
172        Loads the renderer and creates the render window if not yet done so.
173    @remarks
174        This operation is irreversible without recreating the GraphicsManager!
175        So if it throws you HAVE to recreate the GraphicsManager!!!
176        It therefore offers almost no exception safety.
177    */
178    void GraphicsManager::upgradeToGraphics()
[2801]179    {
[5695]180        if (renderWindow_ != NULL)
181            return;
[2801]182
[8858]183        orxout(internal_info) << "GraphicsManager upgrade to graphics" << endl;
184
[6075]185        // load all the required plugins for Ogre
[8861]186        orxout(user_info) << "Loading Ogre plugins..." << endl;
[6075]187        this->loadOgrePlugins();
188
[8861]189        orxout(user_info) << "Creating render window..." << endl;
[5695]190        this->loadRenderer();
[2801]191
[5695]192        // Initialise all resources (do this AFTER the renderer has been loaded!)
193        // Note: You can only do this once! Ogre will check whether a resource group has
194        // already been initialised. If you need to load resources later, you will have to
195        // choose another resource group.
[8861]196        orxout(user_info) << "Initializing all resource groups..." << endl;
[5695]197        Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
[8858]198
199        orxout(internal_info) << "GraphicsManager finished upgrade to graphics" << endl;
[2801]200    }
201
[1755]202    /**
203    @brief
[2801]204        Creates the Ogre Root object and sets up the ogre log.
[1755]205    */
[5695]206    void GraphicsManager::loadOgreRoot()
[1538]207    {
[8858]208        orxout(internal_info) << "Setting up Ogre..." << endl;
[2801]209
[6417]210        if (ogreConfigFile_.empty())
[2801]211        {
[8858]212            orxout(internal_warning) << "Ogre config file set to \"\". Defaulting to config.cfg" << endl;
[2801]213            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
214        }
[6417]215        if (ogreLogFile_.empty())
[2801]216        {
[8858]217            orxout(internal_warning) << "Ogre log file set to \"\". Defaulting to ogre.log" << endl;
[2801]218            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
219        }
220
[10624]221        boost::filesystem::path ogreConfigFilepath(ConfigurablePaths::getConfigPath() / this->ogreConfigFile_);
222        boost::filesystem::path ogreLogFilepath(ConfigurablePaths::getLogPath() / this->ogreLogFile_);
[2801]223
224        // create a new logManager
225        // Ogre::Root will detect that we've already created a Log
[8423]226        ogreLogger_ = new Ogre::LogManager();
[8858]227        orxout(internal_info) << "Ogre LogManager created" << endl;
[2801]228
229        // create our own log that we can listen to
230        Ogre::Log *myLog;
[5695]231        myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
[8858]232        orxout(internal_info) << "Ogre Log created" << endl;
[2801]233
234        myLog->setLogDetail(Ogre::LL_BOREME);
235        myLog->addListener(this);
236
[8858]237        orxout(internal_info) << "Creating Ogre Root..." << endl;
[2801]238
239        // check for config file existence because Ogre displays (caught) exceptions if not
240        if (!boost::filesystem::exists(ogreConfigFilepath))
241        {
242            // create a zero sized file
243            std::ofstream creator;
244            creator.open(ogreConfigFilepath.string().c_str());
245            creator.close();
246        }
247
248        // Leave plugins file empty. We're going to do that part manually later
[8423]249        ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
[2801]250
[8858]251        orxout(internal_info) << "Ogre set up done." << endl;
[1538]252    }
[2801]253
254    void GraphicsManager::loadOgrePlugins()
255    {
[8858]256        orxout(internal_info) << "loading ogre plugins" << endl;
257
[8351]258        // Plugin path can have many different locations...
259        std::string pluginPath = specialConfig::ogrePluginsDirectory;
260#ifdef DEPENDENCY_PACKAGE_ENABLE
[10624]261        if (!ApplicationPaths::buildDirectoryRun())
[8351]262        {
263#  if defined(ORXONOX_PLATFORM_WINDOWS)
[10624]264            pluginPath = ApplicationPaths::getExecutablePathString();
[8351]265#  elif defined(ORXONOX_PLATFORM_APPLE)
266            // TODO: Where are the plugins being installed to?
[10624]267            pluginPath = ApplicationPaths::getExecutablePathString();
[8351]268#  endif
269        }
270#endif
[2801]271
272        // Do some SubString magic to get the comma separated list of plugins
[7284]273        SubString plugins(ogrePlugins_, ",", " ", false, '\\', false, '"', false, '{', '}', false, '\0');
[2801]274        for (unsigned int i = 0; i < plugins.size(); ++i)
[8351]275            ogreRoot_->loadPlugin(pluginPath + '/' + plugins[i]);
[2801]276    }
277
278    void GraphicsManager::loadRenderer()
279    {
[8858]280        orxout(internal_info) << "GraphicsManager: Configuring Renderer" << endl;
[2801]281
[10624]282        bool updatedConfig = Core::getInstance().getConfig()->getOgreConfigTimestamp() > Core::getInstance().getConfig()->getLastLevelTimestamp();
[8079]283        if (updatedConfig)
[8858]284            orxout(user_info)<< "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << endl;
[8079]285
286        if (!ogreRoot_->restoreConfig() || updatedConfig)
[7870]287        {
[2801]288            if (!ogreRoot_->showConfigDialog())
[7868]289                ThrowException(InitialisationFailed, "OGRE graphics configuration dialogue canceled.");
[7870]290            else
[10624]291                Core::getInstance().getConfig()->updateOgreConfigTimestamp();
[7870]292        }
[2801]293
[8858]294        orxout(internal_info) << "Creating render window" << endl;
[2801]295
296        this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
[5695]297        // Propagate the size of the new winodw
[3327]298        this->ogreWindowEventListener_->windowResized(renderWindow_);
[2801]299
[8423]300        Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, ogreWindowEventListener_);
[2801]301
[5695]302        // create a full screen default viewport
303        // Note: This may throw when adding a viewport with an existing z-order!
304        //       But in our case we only have one viewport for now anyway, therefore
305        //       no ScopeGuards or anything to handle exceptions.
306        this->viewport_ = this->renderWindow_->addViewport(0, 0);
307
[6524]308        Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(Ogre::MIP_UNLIMITED);
[2801]309
[10267]310        //Add program icon
[10268]311#if defined(ORXONOX_PLATFORM_WINDOWS)
[10267]312        HWND hwnd;
313        this->renderWindow_->getCustomAttribute("WINDOW", (void*)&hwnd);
314        LONG iconID = (LONG)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(101));
315        SetClassLong(hwnd, GCL_HICON, iconID);
316#endif
317
318
[5695]319        // add console commands
[7284]320        ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this);
[8079]321        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).setFunction(&GraphicsManager::setScreenResolution, this);
322        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).setFunction(&GraphicsManager::setFSAA, this);
323        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).setFunction(&GraphicsManager::setVSync, this);
[2801]324    }
325
[5929]326    void GraphicsManager::loadDebugOverlay()
327    {
328        // Load debug overlay to show info about fps and tick time
[8858]329        orxout(internal_info) << "Loading Debug Overlay..." << endl;
[5929]330        debugOverlay_.reset(new XMLFile("debug.oxo"));
[10624]331        Loader::getInstance().load(debugOverlay_.get(), ClassTreeMask(), false);
[5929]332    }
333
[10624]334    void GraphicsManager::unloadDebugOverlay()
335    {
336        Loader::getInstance().unload(debugOverlay_.get());
337    }
338
[5929]339    /**
340    @note
341        A note about the Ogre::FrameListener: Even though we don't use them,
[8079]342        they still get called.
[5929]343    */
[6417]344    void GraphicsManager::postUpdate(const Clock& time)
[2801]345    {
[8079]346        // Time before rendering
347        uint64_t timeBeforeTick = time.getRealMicroseconds();
348
349        // Ogre's time keeping object
[5695]350        Ogre::FrameEvent evt;
351
[8079]352        // Translate to Ogre float times before the update
353        float temp = lastFrameStartTime_;
354        lastFrameStartTime_ = (float)timeBeforeTick * 0.000001f;
355        evt.timeSinceLastFrame = lastFrameStartTime_ - temp;
356        evt.timeSinceLastEvent = lastFrameStartTime_ - lastFrameEndTime_;
357
358        // Ogre requires the time too
[5695]359        ogreRoot_->_fireFrameStarted(evt);
360
361        // Pump messages in all registered RenderWindows
362        // This calls the WindowEventListener objects.
363        Ogre::WindowEventUtilities::messagePump();
[8079]364        // Make sure the window stays active even when not focused
[5695]365        // (probably only necessary on windows)
366        this->renderWindow_->setActive(true);
367
368        // Render frame
369        ogreRoot_->_updateAllRenderTargets();
370
371        uint64_t timeAfterTick = time.getRealMicroseconds();
372        // Subtract the time used for rendering from the tick time counter
[6502]373        Game::getInstance().subtractTickTime((int32_t)(timeAfterTick - timeBeforeTick));
[5695]374
[8079]375        // Translate to Ogre float times after the update
376        temp = lastFrameEndTime_;
377        lastFrameEndTime_ = (float)timeBeforeTick * 0.000001f;
378        evt.timeSinceLastFrame = lastFrameEndTime_ - temp;
379        evt.timeSinceLastEvent = lastFrameEndTime_ - lastFrameStartTime_;
380
381        // Ogre also needs the time after the frame finished
382        ogreRoot_->_fireFrameEnded(evt);
[2801]383    }
384
[5695]385    void GraphicsManager::setCamera(Ogre::Camera* camera)
386    {
[8079]387        Ogre::Camera* oldCamera = this->viewport_->getCamera();
388
[5695]389        this->viewport_->setCamera(camera);
[8079]390        GUIManager::getInstance().setCamera(camera);
391
392        for (ObjectList<ViewportEventListener>::iterator it = ObjectList<ViewportEventListener>::begin(); it != ObjectList<ViewportEventListener>::end(); ++it)
393            it->cameraChanged(this->viewport_, oldCamera);
[5695]394    }
395
[2801]396    /**
397    @brief
398        Method called by the LogListener interface from Ogre.
399        We use it to capture Ogre log messages and handle it ourselves.
400    @param message
401        The message to be logged
402    @param lml
403        The message level the log is using
404    @param maskDebug
405        If we are printing to the console or not
406    @param logName
407        The name of this log (so you can have several listeners
408        for different logs, and identify them)
[9675]409    @param skipThisMessage
410        If set to true by the messageLogged() implementation message will not be logged
[2801]411    */
[9675]412#if OGRE_VERSION >= 0x010800
[2801]413    void GraphicsManager::messageLogged(const std::string& message,
[9675]414        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName, bool& skipThisMessage)
415        // TODO: do we have to ignore the message if skipThisMessage is set?
416#else
417    void GraphicsManager::messageLogged(const std::string& message,
[2801]418        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
[9675]419#endif
[2801]420    {
[8858]421        OutputLevel orxonoxLevel;
[6417]422        std::string introduction;
423        // Do not show caught OGRE exceptions in front
424        if (message.find("EXCEPTION") != std::string::npos)
[2801]425        {
[8858]426            orxonoxLevel = level::internal_error;
[6417]427            introduction = "Ogre, caught exception: ";
[2801]428        }
[6417]429        else
430        {
431            switch (lml)
432            {
433            case Ogre::LML_TRIVIAL:
[8858]434                orxonoxLevel = level::verbose_more;
[6417]435                break;
436            case Ogre::LML_NORMAL:
[8858]437                orxonoxLevel = level::verbose;
[6417]438                break;
439            case Ogre::LML_CRITICAL:
[8858]440                orxonoxLevel = level::internal_warning;
[6417]441                break;
442            default:
[8858]443                orxonoxLevel = level::debug_output;
[6417]444            }
445            introduction = "Ogre: ";
446        }
[8858]447
448        orxout(orxonoxLevel, context::ogre) << introduction << message << endl;
[2801]449    }
450
[5695]451    size_t GraphicsManager::getRenderWindowHandle()
452    {
453        size_t windowHnd = 0;
454        renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
455        return windowHnd;
456    }
457
458    bool GraphicsManager::isFullScreen() const
459    {
[8079]460        return this->renderWindow_->isFullScreen();
461    }
462
463    unsigned int GraphicsManager::getWindowWidth() const
464    {
465        return this->renderWindow_->getWidth();
466    }
467
468    unsigned int GraphicsManager::getWindowHeight() const
469    {
470        return this->renderWindow_->getHeight();
471    }
472
473    bool GraphicsManager::hasVSyncEnabled() const
474    {
[5695]475        Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions();
[8079]476        Ogre::ConfigOptionMap::iterator it = options.find("VSync");
477        if (it != options.end())
478            return (it->second.currentValue == "Yes");
479        else
480            return false;
481    }
482
483    std::string GraphicsManager::getFSAAMode() const
484    {
485        Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions();
486        Ogre::ConfigOptionMap::iterator it = options.find("FSAA");
487        if (it != options.end())
488            return it->second.currentValue;
489        else
490            return "";
491    }
492
493    std::string GraphicsManager::setScreenResolution(unsigned int width, unsigned int height, bool fullscreen)
494    {
495        // workaround to detect if the colour depth should be written to the config file
496        bool bWriteColourDepth = false;
497        Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions();
498        Ogre::ConfigOptionMap::iterator it = options.find("Video Mode");
499        if (it != options.end())
500            bWriteColourDepth = (it->second.currentValue.find('@') != std::string::npos);
501
502        if (bWriteColourDepth)
[5695]503        {
[8079]504            this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width)
505                                                                    + " x " + multi_cast<std::string>(height)
506                                                                    + " @ " + multi_cast<std::string>(this->getRenderWindow()->getColourDepth()) + "-bit colour");
[5695]507        }
508        else
509        {
[8079]510            this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width)
511                                                                    + " x " + multi_cast<std::string>(height));
[5695]512        }
[8079]513
514        this->ogreRoot_->getRenderSystem()->setConfigOption("Full Screen", fullscreen ? "Yes" : "No");
515
516        std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
517
518        if (validate == "")
519        {
520            GraphicsManager::getInstance().getRenderWindow()->setFullscreen(fullscreen, width, height);
521            this->ogreRoot_->saveConfig();
[10624]522            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
[8079]523            // Also reload the input devices
524            InputManager::getInstance().reload();
525        }
526
527        return validate;
[5695]528    }
529
[8079]530    std::string GraphicsManager::setFSAA(const std::string& mode)
531    {
532        this->ogreRoot_->getRenderSystem()->setConfigOption("FSAA", mode);
533
534        std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
535
536        if (validate == "")
537        {
538            //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
539            this->ogreRoot_->saveConfig();
[10624]540            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
[8079]541        }
542
543        return validate;
544    }
545
546    std::string GraphicsManager::setVSync(bool vsync)
547    {
548        this->ogreRoot_->getRenderSystem()->setConfigOption("VSync", vsync ? "Yes" : "No");
549
550        std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
551
552        if (validate == "")
553        {
554            //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
555            this->ogreRoot_->saveConfig();
[10624]556            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
[8079]557        }
558
559        return validate;
560    }
561
[2801]562    void GraphicsManager::printScreen()
563    {
564        assert(this->renderWindow_);
[10624]565        this->renderWindow_->writeContentsToTimestampedFile(ConfigurablePaths::getLogPathString() + "screenShot_", ".png");
[2801]566    }
[612]567}
Note: See TracBrowser for help on using the repository browser.