Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource3/src/core/GraphicsManager.h @ 5677

Last change on this file since 5677 was 5677, checked in by rgrieder, 15 years ago

Merged most of revision 5614 and its fixes from revisions 5628, 5658, 5662 and 5670:

  • Creating Ogre::Root in non graphics mode as well. This allows to always make use of the ResourceGroupManager.
  • Switched to smart pointers for the destruction code in GraphicsManager
  • Property svn:eol-style set to native
File size: 4.0 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@file
32@brief
33    Declaration of GraphicsManager Singleton.
34 */
35
36#ifndef _GraphicsManager_H__
37#define _GraphicsManager_H__
38
39#include "CorePrereqs.h"
40
41#include <cassert>
42#include <string>
43#include <OgreLog.h>
44#include <boost/scoped_ptr.hpp>
45
46#include "util/Singleton.h"
47#include "OrxonoxClass.h"
48
49namespace orxonox
50{
51    using boost::scoped_ptr;
52
53    /**
54    @brief
55        Graphics engine manager class
56    */
57    class _CoreExport GraphicsManager : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener
58    {
59        friend class Singleton<GraphicsManager>;
60    public:
61        GraphicsManager(bool bLoadRenderer = true);
62        ~GraphicsManager();
63
64        void setConfigValues();
65
66        void update(const Clock& time);
67
68        Ogre::Viewport* getViewport()         { return this->viewport_; }
69        Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
70
71        void upgradeToGraphics();
72        bool rendererLoaded() const { return renderWindow_ != NULL; }
73
74        void setCamera(Ogre::Camera* camera);
75
76    private:
77        GraphicsManager(GraphicsManager&); // don't mess with singletons
78
79        // OGRE initialisation
80        void loadOgreRoot();
81        void loadOgrePlugins();
82        void declareResources();
83        void loadRenderer();
84        void initialiseResources();
85
86        // event from Ogre::LogListener
87        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
88            bool maskDebug, const std::string& logName);
89
90        // console commands
91        void printScreen();
92
93    private:
94        scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
95        scoped_ptr<Ogre::LogManager>        ogreLogger_;
96        scoped_ptr<Ogre::Root>              ogreRoot_;                //!< Ogre's root
97        Ogre::RenderWindow* renderWindow_;             //!< the one and only render window
98        Ogre::Viewport*     viewport_;                 //!< default full size viewport
99
100        // config values
101        std::string         resourceFile_;             //!< resources file name
102        std::string         ogreConfigFile_;           //!< ogre config file name
103        std::string         ogrePluginsFolder_;        //!< Folder where the Ogre plugins are located
104        std::string         ogrePlugins_;              //!< Comma separated list of all plugins to load
105        std::string         ogreLogFile_;              //!< log file name for Ogre log messages
106        int                 ogreLogLevelTrivial_;      //!< Corresponding Orxonx debug level for LL_TRIVIAL
107        int                 ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
108        int                 ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
109
110        // console commands
111        ConsoleCommand*     ccPrintScreen_;
112
113        static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
114    };
115}
116
117#endif /* _GraphicsManager_H__ */
Note: See TracBrowser for help on using the repository browser.