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         bool mQueuedEnd;
    00076         // In case multiple render windows are created, only once are the resources loaded.
    00077         bool mFirstTimePostWindowInit;
    00078
    00079         // Singletons
    00080         LogManager* mLogManager;
    00081         ControllerManager* mControllerManager;
    00082         SceneManagerEnumerator* mSceneManagerEnum;
    00083         SceneManager* mCurrentSceneManager;
    00084         DynLibManager* mDynLibManager;
    00085         PlatformManager* mPlatformManager;
    00086         ArchiveManager* mArchiveManager;
    00087         MaterialManager* mMaterialManager;
    00088         MeshManager* mMeshManager;
    00089         ParticleSystemManager* mParticleManager;
    00090         SkeletonManager* mSkeletonManager;
    00091         GuiManager* mGuiManager;
    00092         OverlayManager* mOverlayManager;
    00093         FontManager* mFontManager;
    00094         ArchiveFactory *mZipArchiveFactory;
    00095
    00096         Timer* mTimer;
    00097         RenderWindow* mAutoWindow;
    00098         Profiler* mProfiler;
    00099         HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
    00100         ExternalTextureSourceManager* mExternalTextureSourceManager;
    00101         unsigned long mCurrentFrame;
    00102
    00103         std::vector<DynLib*> mPluginLibs;
    00110         void loadPlugins( const String& pluginsfile = "plugins.cfg" );
    00113         void unloadPlugins();
    00114
    00115         // Internal method for one-time tasks after first window creation
    00116         void oneTimePostWindowInit(void);
    00117
    00119         std::set<FrameListener*> mFrameListeners;
    00120
    00121
    00123         enum FrameEventTimeType {
    00124             FETT_ANY, FETT_STARTED, FETT_ENDED
    00125         };
    00126
    00128         std::deque<unsigned long> mEventTimes[3];
    00129
    00134         Real calculateEventTime(unsigned long now, FrameEventTimeType type);
    00135     public:
    00136
    00137         static void termHandler();
    00138
    00144         Root(const String& pluginFileName = "plugins.cfg", const String& configFileName = "ogre.cfg", const String& logFileName = "Ogre.log");
    00145         ~Root();
    00146
    00152         void saveConfig(void);
    00153
    00166         bool restoreConfig(void);
    00167
    00184         bool showConfigDialog(void);
    00185
    00197         void addRenderSystem(RenderSystem* newRend);
    00198
    00206         void setSceneManager(SceneType sType, SceneManager* sm);
    00207
    00214         RenderSystemList* getAvailableRenderers(void);
    00215
    00233         void setRenderSystem(RenderSystem* system);
    00234
    00237         RenderSystem* getRenderSystem(void);
    00238
    00254         RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
    00255
    00282         SceneManager* getSceneManager(SceneType sceneType);
    00283
    00299         TextureManager* getTextureManager(void);
    00300
    00306         MeshManager* getMeshManager(void);
    00307
    00311         String getErrorDescription(long errorNumber);
    00312
    00329         void addFrameListener(FrameListener* newListener);
    00330
    00335         void removeFrameListener(FrameListener* oldListener);
    00336
    00345         void queueEndRendering(void);
    00346
    00372         void startRendering(void);
    00373
    00379         bool renderOneFrame(void);
    00387         void shutdown(void);
    00388
    00430         void addResourceLocation(const String& name, const String& locType, ResourceType resType = RESTYPE_ALL);
    00431
    00440         void convertColourValue(const ColourValue& colour, unsigned long* pDest);
    00441
    00450         RenderWindow* getAutoCreatedWindow(void);
    00451
    00488         RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, unsigned int colourDepth,
    00489             bool fullScreen, int left = 0, int top = 0, bool depthBuffer = true,
    00490             RenderWindow* parentWindowHandle = 0);
    00491
    00494         void detachRenderTarget( RenderTarget* pWin );
    00495
    00498         void detachRenderTarget( const String & name );
    00499
    00502         RenderTarget * getRenderTarget(const String &name);
    00503
    00520         void loadPlugin(const String& pluginName);
    00521
    00529         void unloadPlugin(const String& pluginName);
    00530
    00532         Timer* getTimer(void);
    00533
    00553         bool _fireFrameStarted(FrameEvent& evt);
    00570         bool _fireFrameEnded(FrameEvent& evt);
    00588         bool _fireFrameStarted();
    00603         bool _fireFrameEnded();
    00604
    00606         unsigned long getCurrentFrameNumber(void) { return mCurrentFrame; }
    00607
    00613         SceneManager* _getCurrentSceneManager(void) { return mCurrentSceneManager; }
    00618         void _setCurrentSceneManager(SceneManager* sm) { mCurrentSceneManager = sm; }
    00619
    00629         void _updateAllRenderTargets(void);
    00630
    00646         static Root& getSingleton(void);
    00662         static Root* getSingletonPtr(void);
    00663
    00664     };
    00665 } // Namespace Ogre
    00666 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:43 2004