# 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 (c) 2000-2005 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 "OgreResourceGroupManager.h"
    00035
    00036 #include <exception>
    00037
    00038 #if OGRE_COMPILER == OGRE_COMPILER_MSVC || OGRE_COMPILER == OGRE_COMPILER_BORL
    00039 #   define SET_TERM_HANDLER { set_terminate( &Ogre::Root::termHandler ); }
    00040 #else
    00041 #   define SET_TERM_HANDLER { std::set_terminate( &Ogre::Root::termHandler ); }
    00042 #endif
    00043
    00044 namespace Ogre
    00045 {
    00046     typedef std::vector<RenderSystem*> RenderSystemList;
    00047
    00061     class _OgreExport Root : public Singleton<Root>
    00062     {
    00063         // To allow update of active renderer if
    00064         // RenderSystem::initialise is used directly
    00065         friend class RenderSystem;
    00066     private:
    00067         RenderSystemList mRenderers;
    00068         RenderSystem* mActiveRenderer;
    00069         String mVersion;
    00070         String mConfigFileName;
    00071         bool mQueuedEnd;
    00072         // In case multiple render windows are created, only once are the resources loaded.
    00073         bool mFirstTimePostWindowInit;
    00074
    00075         // Singletons
    00076         LogManager* mLogManager;
    00077         ControllerManager* mControllerManager;
    00078         SceneManagerEnumerator* mSceneManagerEnum;
    00079         SceneManager* mCurrentSceneManager;
    00080         DynLibManager* mDynLibManager;
    00081         PlatformManager* mPlatformManager;
    00082         ArchiveManager* mArchiveManager;
    00083         MaterialManager* mMaterialManager;
    00084         MeshManager* mMeshManager;
    00085         ParticleSystemManager* mParticleManager;
    00086         SkeletonManager* mSkeletonManager;
    00087         OverlayElementFactory* mPanelFactory;
    00088         OverlayElementFactory* mBorderPanelFactory;
    00089         OverlayElementFactory* mTextAreaFactory;
    00090         OverlayManager* mOverlayManager;
    00091         FontManager* mFontManager;
    00092         ArchiveFactory *mZipArchiveFactory;
    00093         ArchiveFactory *mFileSystemArchiveFactory;
    00094         ResourceGroupManager* mResourceGroupManager;
    00095         ResourceBackgroundQueue* mResourceBackgroundQueue;
    00096
    00097         Timer* mTimer;
    00098         RenderWindow* mAutoWindow;
    00099         Profiler* mProfiler;
    00100         HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
    00101         ExternalTextureSourceManager* mExternalTextureSourceManager;
    00102         unsigned long mCurrentFrame;
    00103
    00104         std::vector<DynLib*> mPluginLibs;
    00111         void loadPlugins( const String& pluginsfile = "plugins.cfg" );
    00115         void shutdownPlugins();
    00116
    00119         void unloadPlugins();
    00120
    00121         // Internal method for one-time tasks after first window creation
    00122         void oneTimePostWindowInit(void);
    00123
    00125         std::set<FrameListener*> mFrameListeners;
    00126
    00128         std::set<FrameListener*> mRemovedFrameListeners;
    00129
    00131         enum FrameEventTimeType {
    00132             FETT_ANY, FETT_STARTED, FETT_ENDED
    00133         };
    00134
    00136         std::deque<unsigned long> mEventTimes[3];
    00137
    00142         Real calculateEventTime(unsigned long now, FrameEventTimeType type);
    00143     public:
    00144
    00145         static void termHandler();
    00146
    00152         Root(const String& pluginFileName = "plugins.cfg", const String& configFileName = "ogre.cfg", const String& logFileName = "Ogre.log");
    00153         ~Root();
    00154
    00160         void saveConfig(void);
    00161
    00174         bool restoreConfig(void);
    00175
    00192         bool showConfigDialog(void);
    00193
    00205         void addRenderSystem(RenderSystem* newRend);
    00206
    00214         void setSceneManager(SceneType sType, SceneManager* sm);
    00215
    00222         RenderSystemList* getAvailableRenderers(void);
    00223
    00241         void setRenderSystem(RenderSystem* system);
    00242
    00245         RenderSystem* getRenderSystem(void);
    00246
    00262         RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
    00263
    00290         SceneManager* getSceneManager(SceneType sceneType);
    00291
    00307         TextureManager* getTextureManager(void);
    00308
    00314         MeshManager* getMeshManager(void);
    00315
    00319         String getErrorDescription(long errorNumber);
    00320
    00337         void addFrameListener(FrameListener* newListener);
    00338
    00343         void removeFrameListener(FrameListener* oldListener);
    00344
    00353         void queueEndRendering(void);
    00354
    00380         void startRendering(void);
    00381
    00387         bool renderOneFrame(void);
    00395         void shutdown(void);
    00396
    00443         void addResourceLocation(const String& name, const String& locType,
    00444             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    00445             bool recursive = false);
    00446
    00453         void removeResourceLocation(const String& name,
    00454             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    00455
    00464         void convertColourValue(const ColourValue& colour, uint32* pDest);
    00465
    00474         RenderWindow* getAutoCreatedWindow(void);
    00475
    00478         RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
    00479             bool fullScreen, const NameValuePairList *miscParams = 0) ;
    00480
    00483         void detachRenderTarget( RenderTarget* pWin );
    00484
    00487         void detachRenderTarget( const String & name );
    00488
    00491         RenderTarget * getRenderTarget(const String &name);
    00492
    00509         void loadPlugin(const String& pluginName);
    00510
    00518         void unloadPlugin(const String& pluginName);
    00519
    00521         Timer* getTimer(void);
    00522
    00542         bool _fireFrameStarted(FrameEvent& evt);
    00559         bool _fireFrameEnded(FrameEvent& evt);
    00577         bool _fireFrameStarted();
    00592         bool _fireFrameEnded();
    00593
    00595         unsigned long getCurrentFrameNumber(void) const { return mCurrentFrame; }
    00596
    00602         SceneManager* _getCurrentSceneManager(void) const { return mCurrentSceneManager; }
    00607         void _setCurrentSceneManager(SceneManager* sm) { mCurrentSceneManager = sm; }
    00608
    00618         void _updateAllRenderTargets(void);
    00619
    00635         static Root& getSingleton(void);
    00651         static Root* getSingletonPtr(void);
    00652
    00661         void clearEventTimes(void);
    00662
    00663     };
    00664 } // Namespace Ogre
    00665 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:51 2006