Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/src/orxonox/GraphicsEngine.h @ 1640

Last change on this file since 1640 was 1640, checked in by rgrieder, 16 years ago

When starting with no arguments, the GUI is loaded, which consists merely of 2 buttons: start and exit (quite self explanatory). But it does work on my box (still no cmake support).

  • Property svn:eol-style set to native
File size: 4.9 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 *   Co-authors:
25 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007, Felix Schulthess
26 *
27 */
28
29/**
30  @file
31  @brief Declaration of GraphicsEngine Singleton.
32  @author Benjamin Knecht <beni_at_orxonox.net>
33 */
34
35#ifndef _GraphicsEngine_H__
36#define _GraphicsEngine_H__
37
38#include "OrxonoxPrereqs.h"
39
40#include <string>
41
42#include <OgrePrerequisites.h>
43#include <OgreLog.h>
44#include <OgreRenderWindow.h>
45#include <OgreWindowEventUtilities.h>
46#include "core/OrxonoxClass.h"
47
48
49namespace orxonox
50{
51    /**
52    @brief Graphics engine manager class
53    */
54    class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public Ogre::LogListener, public OrxonoxClass
55    {
56    public:
57        GraphicsEngine();
58        ~GraphicsEngine();
59
60        void setConfigValues();
61        void setup();
62        void declareRessourceLocations();
63        bool loadRenderer();
64        bool initialiseResources();
65        bool createNewScene();
66
67        void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
68        Ogre::SceneManager* getLevelSceneManager() { return levelSceneManager_; }
69
70        Ogre::Viewport* getViewport() { return this->viewport_; }
71
72        // several window properties
73        Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
74        size_t getWindowHandle();
75        int getWindowWidth() const;
76        int getWindowHeight() const;
77        float getWindowAspectRatio() const;
78        float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
79        float getAverageTickTime() const          { return this->avgTickTime_; }
80        void setAverageTickTime(float tickTime)   { this->avgTickTime_ = tickTime; }
81        void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
82
83        void setWindowActivity(bool activity)
84        { if (this->renderWindow_) this->renderWindow_->setActive(activity); }
85
86        inline unsigned int getDetailLevelParticle() const
87        { return this->detailLevelParticle_; }
88
89        static GraphicsEngine& getSingleton();
90        static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
91
92    private:
93        // don't mess with singletons
94        GraphicsEngine(GraphicsEngine&) { }
95
96        //! Method called by the LogListener from Ogre
97        void messageLogged(const std::string&, Ogre::LogMessageLevel,
98            bool, const std::string&);
99
100        // window events from Ogre::WindowEventListener
101        void windowMoved       (Ogre::RenderWindow* rw);
102        void windowResized     (Ogre::RenderWindow* rw);
103        void windowFocusChanged(Ogre::RenderWindow* rw);
104        void windowClosed      (Ogre::RenderWindow* rw);
105
106        Ogre::Root*         root_;                  //!< Ogre's root
107        Ogre::RenderWindow* renderWindow_;          //!< the current render window
108        Ogre::SceneManager* levelSceneManager_;     //!< scene manager of the game
109        Ogre::Viewport*     viewport_;              //!< default full size viewport
110
111        // stats
112        float               avgTickTime_;           //!< time in ms to tick() one frame
113        float               avgFramesPerSecond_;    //!< number of frames processed in one second
114
115        // config values
116        std::string         resourceFile_;          //!< resources file name
117        std::string         ogreConfigFile_;        //!< ogre config file name
118        std::string         ogrePluginsFile_;       //!< ogre plugins file name
119        std::string         ogreLogFile_;           //!< log file name for Ogre log messages
120        int                 ogreLogLevelTrivial_;   //!< Corresponding Orxonx debug level for LL_TRIVIAL
121        int                 ogreLogLevelNormal_;    //!< Corresponding Orxonx debug level for LL_NORMAL
122        int                 ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
123        unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
124
125        static GraphicsEngine* singletonRef_s;      //!< Pointer to the Singleton
126    };
127}
128
129#endif /* _GraphicsEngine_H__ */
Note: See TracBrowser for help on using the repository browser.