Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/GraphicsManager.h @ 8086

Last change on this file since 8086 was 8079, checked in by landauf, 14 years ago

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
  • Property svn:eol-style set to native
File size: 5.2 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 <OgreLog.h>
50#include <boost/scoped_ptr.hpp>
51#include <boost/shared_ptr.hpp>
52
53#include "util/Singleton.h"
54#include "OrxonoxClass.h"
55
56// tolua_begin
57namespace orxonox
58{
59    /**
60    @brief
61        Graphics engine manager class
62    */
63    class _CoreExport GraphicsManager
64// tolua_end
65        : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener
66    { // tolua_export
67        friend class Singleton<GraphicsManager>;
68    public:
69        GraphicsManager(bool bLoadRenderer = true);
70        ~GraphicsManager();
71
72        void setConfigValues();
73
74        void postUpdate(const Clock& time);
75
76        Ogre::Viewport* getViewport()         { return this->viewport_; }
77        Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
78        size_t getRenderWindowHandle();
79
80// tolua_begin
81        static GraphicsManager& getInstance() { return Singleton<GraphicsManager>::getInstance(); } // tolua_export
82
83        bool isFullScreen() const;
84        unsigned int getWindowWidth() const;
85        unsigned int getWindowHeight() const;
86
87        bool hasVSyncEnabled() const;
88        std::string getFSAAMode() const;
89// tolua_end
90
91        void upgradeToGraphics();
92        void loadDebugOverlay();
93        bool rendererLoaded() const { return renderWindow_ != NULL; }
94
95        void setCamera(Ogre::Camera* camera);
96
97    private:
98        GraphicsManager(GraphicsManager&); // don't mess with singletons
99
100        // OGRE initialisation
101        void loadOgreRoot();
102        void loadOgrePlugins();
103        void loadRenderer();
104
105        // event from Ogre::LogListener
106        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
107            bool maskDebug, const std::string& logName);
108
109        // console commands
110        void printScreen();
111        std::string setScreenResolution(unsigned int width, unsigned int height, bool fullscreen);
112        std::string setFSAA(const std::string& mode);
113        std::string setVSync(bool vsync);
114
115        scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
116#if OGRE_VERSION < 0x010600
117        scoped_ptr<MemoryArchiveFactory>    memoryArchiveFactory_;    //!< Stores the modified particle scripts
118#endif
119        scoped_ptr<Ogre::LogManager>        ogreLogger_;
120        scoped_ptr<Ogre::Root>              ogreRoot_;                //!< Ogre's root
121        Ogre::RenderWindow* renderWindow_;             //!< the one and only render window
122        Ogre::Viewport*     viewport_;                 //!< default full size viewport
123        float               lastFrameStartTime_;       //!< Time stamp of the beginning of the last frame
124        float               lastFrameEndTime_;         //!< Time stamp of the end of the last frame
125
126        // XML files for the resources and the debug overlay
127        shared_ptr<XMLFile> resources_;                //!< XML with resource locations
128        shared_ptr<XMLFile> extResources_;             //!< XML with resource locations in the external path (only for dev runs)
129        shared_ptr<XMLFile> debugOverlay_;             //!< XML with various debug overlays
130
131        // config values
132        std::string         ogreConfigFile_;           //!< ogre config filename
133        std::string         ogrePluginsDirectory_;     //!< Directory where the Ogre plugins are located
134        std::string         ogrePlugins_;              //!< Comma separated list of all plugins to load
135        std::string         ogreLogFile_;              //!< log filename for Ogre log messages
136        int                 ogreLogLevelTrivial_;      //!< Corresponding Orxonox debug level for LL_TRIVIAL
137        int                 ogreLogLevelNormal_;       //!< Corresponding Orxonox debug level for LL_NORMAL
138        int                 ogreLogLevelCritical_;     //!< Corresponding Orxonox debug level for LL_CRITICAL
139
140        static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
141// tolua_begin
142    };
143}
144// tolua_end
145
146#endif /* _GraphicsManager_H__ */
Note: See TracBrowser for help on using the repository browser.