Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreRoot.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __ROOT__
00026 #define __ROOT__
00027 
00028 // Precompiler options
00029 #include "OgrePrerequisites.h"
00030 
00031 #include "OgreSingleton.h"
00032 #include "OgreString.h"
00033 #include "OgreSceneManagerEnumerator.h"
00034 #include "OgreMeshManager.h"
00035 #include "OgreTextureManager.h"
00036 #include "OgreDynLibManager.h"
00037 #include "OgrePlatformManager.h"
00038 #include "OgreArchiveManager.h"
00039 
00040 #include <exception>
00041 
00042 #if OGRE_COMPILER == COMPILER_MSVC || OGRE_COMPILER == COMPILER_BORL
00043 #   define SET_TERM_HANDLER { set_terminate( &Ogre::Root::termHandler ); }
00044 #else
00045 #   define SET_TERM_HANDLER { std::set_terminate( &Ogre::Root::termHandler ); }
00046 #endif
00047 
00048 namespace Ogre
00049 {
00050     typedef std::vector<RenderSystem*> RenderSystemList;
00051 
00065     class _OgreExport Root : public Singleton<Root>
00066     {
00067         // To allow update of active renderer if
00068         // RenderSystem::initialise is used directly
00069         friend class RenderSystem;
00070     private:
00071         RenderSystemList mRenderers;
00072         RenderSystem* mActiveRenderer;
00073         String mVersion;
00074                 String mConfigFileName;
00075 
00076         // Singletons
00077         LogManager* mLogManager;
00078         ControllerManager* mControllerManager;
00079         SceneManagerEnumerator* mSceneManagerEnum;
00080         DynLibManager* mDynLibManager;
00081         PlatformManager* mPlatformManager;
00082         ArchiveManager* mArchiveManager;
00083         MaterialManager* mMaterialManager;
00084         MeshManager* mMeshManager;
00085         ParticleSystemManager* mParticleManager;
00086         SkeletonManager* mSkeletonManager;
00087         GuiManager* mGuiManager;
00088         OverlayManager* mOverlayManager;
00089         FontManager* mFontManager;
00090         ArchiveFactory *mZipArchiveFactory;
00091         Codec* mPNGCodec, *mJPGCodec, *mJPEGCodec, *mTGACodec, *mDDSCodec, *mBMPCodec;
00092         Timer* mTimer;
00093         RenderWindow* mAutoWindow;
00094         Profiler* mProfiler;
00095         HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
00096 
00097         std::vector<DynLib*> mPluginLibs;
00104         void loadPlugins( const String& pluginsfile = "plugins.cfg" );
00107         void unloadPlugins();
00108 
00109         // Internal method for one-time tasks after first window creation
00110         void oneTimePostWindowInit(void);
00111 
00113         std::set<FrameListener*> mFrameListeners;
00114 
00115 
00117         enum FrameEventTimeType {
00118             FETT_ANY, FETT_STARTED, FETT_ENDED
00119         };
00120 
00122         std::deque<unsigned long> mEventTimes[3];
00123 
00128         Real calculateEventTime(unsigned long now, FrameEventTimeType type);
00129     public:
00130 
00131         static void termHandler();
00132 
00138         Root(const String& pluginFileName = "plugins.cfg", const String& configFileName = "ogre.cfg", const String& logFileName = "Ogre.log");
00139         ~Root();
00140 
00146         void saveConfig(void);
00147 
00160         bool restoreConfig(void);
00161 
00178         bool showConfigDialog(void);
00179 
00191         void addRenderSystem(RenderSystem* newRend);
00192 
00200         void setSceneManager(SceneType sType, SceneManager* sm);
00201 
00208         RenderSystemList* getAvailableRenderers(void);
00209 
00227         void setRenderSystem(RenderSystem* system);
00228 
00231         RenderSystem* getRenderSystem(void);
00232 
00248         RenderWindow* initialise(bool autoCreateWindow);
00249 
00276         SceneManager* getSceneManager(SceneType sceneType);
00277 
00293         TextureManager* getTextureManager(void);
00294 
00300         MeshManager* getMeshManager(void);
00301 
00305         String getErrorDescription(long errorNumber);
00306 
00323         void addFrameListener(FrameListener* newListener);
00324 
00329         void removeFrameListener(FrameListener* oldListener);
00330 
00356         void startRendering(void);
00357 
00365         void shutdown(void);
00381         static Root& getSingleton(void);
00382 
00424         void addResourceLocation(const String& name, const String& locType, ResourceType resType = RESTYPE_ALL);
00425 
00434         void convertColourValue(const ColourValue& colour, unsigned long* pDest);
00435 
00444         RenderWindow* getAutoCreatedWindow(void);
00445 
00482         RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, unsigned int colourDepth,
00483             bool fullScreen, int left = 0, int top = 0, bool depthBuffer = true,
00484             RenderWindow* parentWindowHandle = 0);
00485 
00488         void detachRenderTarget( RenderTarget* pWin );
00489 
00492         void detachRenderTarget( const String & name );
00493 
00496         RenderTarget * getRenderTarget(const String &name);
00497 
00514         void loadPlugin(const String& pluginName);
00515 
00523         void unloadPlugin(const String& pluginName);
00524 
00526         Timer* getTimer(void);
00527 
00544         bool _fireFrameStarted(FrameEvent& evt);
00561         bool _fireFrameEnded(FrameEvent& evt);
00576         bool _fireFrameStarted();
00591         bool _fireFrameEnded();
00592     };
00593 } // Namespace Ogre
00594 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:25 2004