Orxonox  0.0.5 Codename: Arcturus
GraphicsManager.h
Go to the documentation of this file.
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 
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/OgreForwardRefs.h"
55 #include "util/Singleton.h"
56 #include "config/Configurable.h"
57 
58 // tolua_begin
59 namespace orxonox
60 {
66 // tolua_end
67  : public Singleton<GraphicsManager>, public Configurable, public Ogre::LogListener
68  { // tolua_export
69  friend class Singleton<GraphicsManager>;
70  public:
71  GraphicsManager(bool bLoadRenderer = true);
72 
74  ~GraphicsManager() = default;
76  void destroy();
77 
78  void setConfigValues();
79 
80  void postUpdate(const Clock& time);
81 
82  Ogre::Viewport* getViewport() { return this->viewport_; }
83  Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
84  Ogre::OverlaySystem* getOverlaySystem() { return this->overlaySystem_; }
85  size_t getRenderWindowHandle();
86 
87 // tolua_begin
89 
90  bool isFullScreen() const;
91  unsigned int getWindowWidth() const;
92  unsigned int getWindowHeight() const;
93 
94  bool hasVSyncEnabled() const;
95  std::string getFSAAMode() const;
96 // tolua_end
97 
98  void upgradeToGraphics();
99  void loadDebugOverlay();
100  void unloadDebugOverlay();
101  bool rendererLoaded() const { return renderWindow_ != nullptr; }
102 
103  void setCamera(Ogre::Camera* camera);
104 
105  private:
106  // non-copyable:
107  GraphicsManager(const GraphicsManager&) = delete;
108  GraphicsManager& operator=(const GraphicsManager&) = delete;
109 
110  // OGRE initialisation
111  void loadOgreRoot();
112  void loadOgrePlugins();
113  void loadRenderer();
114 
115  // event from Ogre::LogListener
116 #if OGRE_VERSION >= 0x010800
117  virtual void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName, bool& skipThisMessage) override;
118 #else
119  virtual void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName) override;
120 #endif
121 
122  // console commands
123  void printScreen();
124  std::string setScreenResolution(unsigned int width, unsigned int height, bool fullscreen);
125  std::string setFSAA(const std::string& mode);
126  std::string setVSync(bool vsync);
127 
129  Ogre::LogManager* ogreLogger_;
130  Ogre::Root* ogreRoot_;
131  Ogre::RenderWindow* renderWindow_;
132  Ogre::Viewport* viewport_;
133  Ogre::OverlaySystem* overlaySystem_;
137 
138  // XML files for the resources and the debug overlay
139  std::shared_ptr<XMLFile> resources_;
140  std::shared_ptr<XMLFile> extResources_;
141  std::shared_ptr<XMLFile> debugOverlay_;
142 
143  // config values
147 
150 
152 // tolua_begin
153  };
154 }
155 // tolua_end
156 
157 #endif /* _GraphicsManager_H__ */
std::string ogrePlugins_
Comma separated list of all plugins to load.
Definition: GraphicsManager.h:145
Ogre::Viewport * viewport_
default full size viewport
Definition: GraphicsManager.h:132
Ogre::RenderWindow * getRenderWindow()
Definition: GraphicsManager.h:83
DestructionHelper< GraphicsManager > destructionHelper_
Helper object that executes the surrogate destructor destroy()
Definition: GraphicsManager.h:149
std::string ogreLogFile_
log filename for Ogre log messages
Definition: GraphicsManager.h:146
Ogre::Root * ogreRoot_
Ogre&#39;s root.
Definition: GraphicsManager.h:130
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
static GraphicsManager * singletonPtr_s
Pointer to the Singleton.
Definition: GraphicsManager.h:151
float lastFrameEndTime_
Time stamp of the end of the last frame.
Definition: GraphicsManager.h:136
Output level, used for messages directed to the user (e.g. "Press any key to continue") ...
Definition: OutputDefinitions.h:89
The MetaPickup destroys all the PickupCarriers&#39; Pickupables.
This is the base class of all objects which may contain config values.
Definition: Configurable.h:47
float lastFrameStartTime_
Time stamp of the beginning of the last frame.
Definition: GraphicsManager.h:135
static GraphicsManager & getInstance()
Definition: GraphicsManager.h:88
Ogre::LogManager * ogreLogger_
Definition: GraphicsManager.h:129
Base for singleton classes.
Definition: Singleton.h:114
Graphics engine manager class.
Definition: GraphicsManager.h:65
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
#define _CoreExport
Definition: CorePrereqs.h:61
Utility class that helps to create a special kind of destructor that also executes if the destruction...
Definition: DestructionHelper.h:75
std::shared_ptr< XMLFile > extResources_
XML with resource locations in the external path (only for dev runs)
Definition: GraphicsManager.h:140
Declaration of Configurable, the base class of all objects which may contain config values...
Ogre::OverlaySystem * overlaySystem_
Definition: GraphicsManager.h:133
std::shared_ptr< XMLFile > resources_
XML with resource locations.
Definition: GraphicsManager.h:139
Ogre::OverlaySystem * getOverlaySystem()
Definition: GraphicsManager.h:84
Definition of the Singleton template that is used as base class for classes that allow only one insta...
Definition: GlowMaterialListener.h:9
Simple real time clock based on Ogre::Timer.
Definition: Clock.h:57
bool rendererLoaded() const
Definition: GraphicsManager.h:101
OgreWindowEventListener * ogreWindowEventListener_
Pimpl to hide OgreWindowUtilities.h.
Definition: GraphicsManager.h:128
GlowMaterialListener * glowMaterialListener_
Material Listener for the &#39;Glow&#39; compositor.
Definition: GraphicsManager.h:134
Ogre::RenderWindow * renderWindow_
the one and only render window
Definition: GraphicsManager.h:131
std::shared_ptr< XMLFile > debugOverlay_
XML with various debug overlays.
Definition: GraphicsManager.h:141
static T & getInstance()
Returns a reference to the singleton instance.
Definition: Singleton.h:118
Definition: GraphicsManager.cc:86
std::string ogreConfigFile_
ogre config filename
Definition: GraphicsManager.h:144
Ogre::Viewport * getViewport()
Definition: GraphicsManager.h:82