Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core7/src/libraries/core/GraphicsManager.cc @ 10380

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

registered missing classes.
WorldEntityCollisionShape is the only class which was really missing, all other classes are singletons or part of the framework.

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