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