Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource2/src/core/GraphicsManager.h @ 5654

Last change on this file since 5654 was 5654, checked in by rgrieder, 15 years ago
  • Implemented file management via resource manager and loading of resource locations via XML. Changes made:
    • SoundManager loads via memory stream rather than via file
    • Loader uses LuaState::includeFile() to load an XML file and passes the lua tag remover function to its LuaState.
    • ConfigFileManager still loads with hard paths because the files are required before Ogre gets created
  • Renamed LuaBind to LuaState, deSingletonised it and added new features:
    • doFile(), doString(), includeFile(), includeString() where include will preparse the string with a function provided with LuaState::setIncludeParser
    • Moved lua tags replace function to Loader (since it's actually an XML related task)
    • Using data_path/lua/LuaInitScript.lua to provide the following functions
      • logMessage(level, message)
      • doFile, dofile, include (all working with relative paths but within the same resource group)
  • Modified Script class to work with LuaState and fixed its XML Loader
  • Adjusted all level and include files (both "include" and "dofile" lua commands)
  • Property svn:eol-style set to native
File size: 4.3 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#include <boost/shared_ptr.hpp>
46
47#include "util/Singleton.h"
48#include "OrxonoxClass.h"
49
50namespace orxonox
51{
52    /**
53    @brief
54        Graphics engine manager class
55    */
56    class _CoreExport GraphicsManager : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener
57    {
58        friend class Singleton<GraphicsManager>;
59    public:
60        GraphicsManager(bool bLoadRenderer = true);
61        ~GraphicsManager();
62
63        void setConfigValues();
64
65        void update(const Clock& time);
66
67        Ogre::Viewport* getViewport()         { return this->viewport_; }
68        Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
69
70        void upgradeToGraphics();
71        bool rendererLoaded() const { return renderWindow_ != NULL; }
72
73        void setCamera(Ogre::Camera* camera);
74
75    private:
76        GraphicsManager(GraphicsManager&); // don't mess with singletons
77
78        // OGRE initialisation
79        void loadOgreRoot();
80        void loadOgrePlugins();
81        void loadRenderer();
82
83        // event from Ogre::LogListener
84        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
85            bool maskDebug, const std::string& logName);
86
87        // console commands
88        void printScreen();
89
90        scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
91        scoped_ptr<Ogre::LogManager>        ogreLogger_;
92        scoped_ptr<Ogre::Root>              ogreRoot_;                //!< Ogre's root
93        Ogre::RenderWindow* renderWindow_;             //!< the one and only render window
94        Ogre::Viewport*     viewport_;                 //!< default full size viewport
95
96        // XML files for the resources
97        shared_ptr<XMLFile> resources_;                //!< XML with resource locations
98        shared_ptr<XMLFile> extResources_;             //!< XML with resource locations in the external path (only for dev runs)
99        shared_ptr<XMLFile> resourcesGraphics_;        //!< XML with resource locations (with renderer)
100        shared_ptr<XMLFile> extResourcesGraphics_;     //!< XML with resource locations in the external path (only for dev runs) (with renderer)
101
102        // config values
103        std::string         ogreConfigFile_;           //!< ogre config file name
104        std::string         ogrePluginsDirectory_;     //!< Directory where the Ogre plugins are located
105        std::string         ogrePlugins_;              //!< Comma separated list of all plugins to load
106        std::string         ogreLogFile_;              //!< log file name for Ogre log messages
107        int                 ogreLogLevelTrivial_;      //!< Corresponding Orxonx debug level for LL_TRIVIAL
108        int                 ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
109        int                 ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
110
111        // console commands
112        ConsoleCommand*     ccPrintScreen_;
113
114        static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
115    };
116}
117
118#endif /* _GraphicsManager_H__ */
Note: See TracBrowser for help on using the repository browser.