Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cpp11_v2/src/libraries/core/GraphicsManager.h @ 10920

Last change on this file since 10920 was 10845, checked in by landauf, 10 years ago

always use 'virtual' in the declaration of virtual functions even if they are inherited

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
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
11 *   of the License, or (at your option) any later version.
12 *
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:
23 *      Reto Grieder
24 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
25 *   Co-authors:
26 *      Felix Schulthess
27 *
28 */
29
30/**
31    @defgroup Graphics Graphics and GUI
32    @ingroup Core
33*/
34
35/**
36@file
37@ingroup Graphics
38@brief
39    Declaration of GraphicsManager Singleton.
40 */
41
42#ifndef _GraphicsManager_H__
43#define _GraphicsManager_H__
44
45#include "CorePrereqs.h"
46
47#include <cassert>
48#include <string>
49#include <memory>
50
51#include <OgreLog.h>
52
53#include "util/DestructionHelper.h"
54#include "util/Singleton.h"
55#include "config/Configurable.h"
56
57// tolua_begin
58namespace orxonox
59{
60    /**
61    @brief
62        Graphics engine manager class
63    */
64    class _CoreExport GraphicsManager
65// tolua_end
66        : public Singleton<GraphicsManager>, public Configurable, public Ogre::LogListener
67    { // tolua_export
68        friend class Singleton<GraphicsManager>;
69    public:
70        GraphicsManager(bool bLoadRenderer = true);
71
72        //! Leave empty and use cleanup() instead
73        ~GraphicsManager() {}
74        /// Destructor that also executes when object fails to construct
75        void destroy();
76
77        void setConfigValues();
78
79        void postUpdate(const Clock& time);
80
81        Ogre::Viewport* getViewport()         { return this->viewport_; }
82        Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
83        size_t getRenderWindowHandle();
84
85// tolua_begin
86        static GraphicsManager& getInstance() { return Singleton<GraphicsManager>::getInstance(); } // tolua_export
87
88        bool isFullScreen() const;
89        unsigned int getWindowWidth() const;
90        unsigned int getWindowHeight() const;
91
92        bool hasVSyncEnabled() const;
93        std::string getFSAAMode() const;
94// tolua_end
95
96        void upgradeToGraphics();
97        void loadDebugOverlay();
98        void unloadDebugOverlay();
99        bool rendererLoaded() const { return renderWindow_ != nullptr; }
100
101        void setCamera(Ogre::Camera* camera);
102
103    private:
104        GraphicsManager(GraphicsManager&); // don't mess with singletons
105
106        // OGRE initialisation
107        void loadOgreRoot();
108        void loadOgrePlugins();
109        void loadRenderer();
110
111        // event from Ogre::LogListener
112#if OGRE_VERSION >= 0x010800
113        virtual void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName, bool& skipThisMessage) override;
114#else
115        virtual void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName) override;
116#endif
117
118        // console commands
119        void printScreen();
120        std::string setScreenResolution(unsigned int width, unsigned int height, bool fullscreen);
121        std::string setFSAA(const std::string& mode);
122        std::string setVSync(bool vsync);
123
124        OgreWindowEventListener* ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
125        Ogre::LogManager*        ogreLogger_;
126        Ogre::Root*              ogreRoot_;                //!< Ogre's root
127        Ogre::RenderWindow* renderWindow_;             //!< the one and only render window
128        Ogre::Viewport*     viewport_;                 //!< default full size viewport
129        float               lastFrameStartTime_;       //!< Time stamp of the beginning of the last frame
130        float               lastFrameEndTime_;         //!< Time stamp of the end of the last frame
131
132        // XML files for the resources and the debug overlay
133        std::shared_ptr<XMLFile> resources_;           //!< XML with resource locations
134        std::shared_ptr<XMLFile> extResources_;        //!< XML with resource locations in the external path (only for dev runs)
135        std::shared_ptr<XMLFile> debugOverlay_;        //!< XML with various debug overlays
136
137        // config values
138        std::string         ogreConfigFile_;           //!< ogre config filename
139        std::string         ogrePlugins_;              //!< Comma separated list of all plugins to load
140        std::string         ogreLogFile_;              //!< log filename for Ogre log messages
141
142        /// Helper object that executes the surrogate destructor destroy()
143        DestructionHelper<GraphicsManager> destructionHelper_;
144
145        static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
146// tolua_begin
147    };
148}
149// tolua_end
150
151#endif /* _GraphicsManager_H__ */
Note: See TracBrowser for help on using the repository browser.