OgreRoot.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __ROOT__
29 #define __ROOT__
30 
31 // Precompiler options
32 #include "OgrePrerequisites.h"
33 
34 #include "OgreSingleton.h"
35 #include "OgreString.h"
38 #include "OgreLodStrategyManager.h"
39 #include "OgreWorkQueue.h"
40 
41 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
43 #endif
44 
45 #include <exception>
46 
47 namespace Ogre
48 {
57 
71  class _OgreExport Root : public Singleton<Root>, public RootAlloc
72  {
73  // To allow update of active renderer if
74  // RenderSystem::initialise is used directly
75  friend class RenderSystem;
76  protected:
77  RenderSystemList mRenderers;
81  bool mQueuedEnd;
84 
85  // Singletons
90  SceneManagerStack mSceneManagerStack;
97 
101 
102 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
103  AndroidLogListener* mAndroidLogger;
104 #endif
105 
114 
121  unsigned long mNextFrame;
125 
126  public:
129  protected:
131  PluginLibList mPluginLibs;
133  PluginInstanceList mPlugins;
134 
136  MovableObjectFactoryMap mMovableObjectFactoryMap;
138  // stock movable factories
145 
147  RenderQueueInvocationSequenceMap mRQSequenceMap;
148 
151 
153 
158 
166  void loadPlugins(const String& pluginsfile = "plugins" OGRE_BUILD_SUFFIX ".cfg");
170  void initialisePlugins();
174  void shutdownPlugins();
175 
178  void unloadPlugins();
179 
181  void oneTimePostWindowInit(void);
182 
185 
189  void _syncAddedRemovedFrameListeners();
190 
193  FETT_ANY = 0,
194  FETT_STARTED = 1,
195  FETT_QUEUED = 2,
196  FETT_ENDED = 3,
197  FETT_COUNT = 4
198  };
199 
202  EventTimesQueue mEventTimes[FETT_COUNT];
203 
208  Real calculateEventTime(unsigned long now, FrameEventTimeType type);
209 
211  void populateFrameEvent(FrameEventTimeType type, FrameEvent& evtToUpdate);
212 
213  public:
214 
224  Root(const String& pluginFileName = "plugins" OGRE_BUILD_SUFFIX ".cfg",
225  const String& configFileName = "ogre.cfg",
226  const String& logFileName = "Ogre.log");
227  ~Root();
228 
234  void saveConfig(void);
235 
248  bool restoreConfig(void);
249 
266  bool showConfigDialog(void);
267 
279  void addRenderSystem(RenderSystem* newRend);
280 
287  const RenderSystemList& getAvailableRenderers(void);
288 
295  RenderSystem* getRenderSystemByName(const String& name);
296 
314  void setRenderSystem(RenderSystem* system);
315 
318  RenderSystem* getRenderSystem(void);
319 
335  RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window",
336  const String& customCapabilitiesConfig = StringUtil::BLANK);
337 
339  bool isInitialised(void) const { return mIsInitialised; }
340 
346  void useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities);
347 
351  bool getRemoveRenderQueueStructuresOnClear() const { return mRemoveQueueStructuresOnClear; }
352 
356  void setRemoveRenderQueueStructuresOnClear(bool r) { mRemoveQueueStructuresOnClear = r; }
357 
363  void addSceneManagerFactory(SceneManagerFactory* fact);
364 
367  void removeSceneManagerFactory(SceneManagerFactory* fact);
368 
378  const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
379 
383  SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
384 
396  SceneManager* createSceneManager(const String& typeName,
397  const String& instanceName = StringUtil::BLANK);
398 
411  SceneManager* createSceneManager(SceneTypeMask typeMask,
412  const String& instanceName = StringUtil::BLANK);
413 
415  void destroySceneManager(SceneManager* sm);
416 
421  SceneManager* getSceneManager(const String& instanceName) const;
422 
426  bool hasSceneManager(const String& instanceName) const;
428  SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
429 
445  TextureManager* getTextureManager(void);
446 
452  MeshManager* getMeshManager(void);
453 
457  String getErrorDescription(long errorNumber);
458 
475  void addFrameListener(FrameListener* newListener);
476 
481  void removeFrameListener(FrameListener* oldListener);
482 
491  void queueEndRendering(bool state = true);
492 
499  bool endRenderingQueued(void);
500 
528  void startRendering(void);
529 
535  bool renderOneFrame(void);
536 
543  bool renderOneFrame(Real timeSinceLastFrame);
544 
552  void shutdown(void);
553 
600  void addResourceLocation(const String& name, const String& locType,
602  bool recursive = false);
603 
610  void removeResourceLocation(const String& name,
612 
634  DataStreamPtr createFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
635  bool overwrite = false, const String& locationPattern = StringUtil::BLANK);
636 
651  DataStreamPtr openFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
652  const String& locationPattern = StringUtil::BLANK);
653 
662  void convertColourValue(const ColourValue& colour, uint32* pDest);
663 
672  RenderWindow* getAutoCreatedWindow(void);
673 
676  RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
677  bool fullScreen, const NameValuePairList *miscParams = 0) ;
678 
681  bool createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions,
682  RenderWindowList& createdWindows);
683 
689  RenderTarget* detachRenderTarget( RenderTarget* pWin );
690 
696  RenderTarget* detachRenderTarget( const String & name );
697 
700  void destroyRenderTarget(RenderTarget* target);
701 
704  void destroyRenderTarget(const String &name);
705 
708  RenderTarget * getRenderTarget(const String &name);
709 
720  void loadPlugin(const String& pluginName);
721 
731  void unloadPlugin(const String& pluginName);
732 
743  void installPlugin(Plugin* plugin);
744 
753  void uninstallPlugin(Plugin* plugin);
754 
756  const PluginInstanceList& getInstalledPlugins() const { return mPlugins; }
757 
759  Timer* getTimer(void);
760 
780  bool _fireFrameStarted(FrameEvent& evt);
790  bool _fireFrameRenderingQueued(FrameEvent& evt);
791 
808  bool _fireFrameEnded(FrameEvent& evt);
826  bool _fireFrameStarted();
837  bool _fireFrameRenderingQueued();
852  bool _fireFrameEnded();
853 
862  unsigned long getNextFrameNumber(void) const { return mNextFrame; }
863 
869  SceneManager* _getCurrentSceneManager(void) const;
874  void _pushCurrentSceneManager(SceneManager* sm);
879  void _popCurrentSceneManager(SceneManager* sm);
880 
891  bool _updateAllRenderTargets(void);
892 
904  bool _updateAllRenderTargets(FrameEvent& evt);
905 
910  RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
911  const String& name);
912 
916  RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
917  const String& name);
918 
924  void destroyRenderQueueInvocationSequence(
925  const String& name);
926 
931  void destroyAllRenderQueueInvocationSequences(void);
932 
948  static Root& getSingleton(void);
964  static Root* getSingletonPtr(void);
965 
974  void clearEventTimes(void);
975 
988  void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
990  Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
991 
1004  void addMovableObjectFactory(MovableObjectFactory* fact,
1005  bool overrideExisting = false);
1013  void removeMovableObjectFactory(MovableObjectFactory* fact);
1015  bool hasMovableObjectFactory(const String& typeName) const;
1017  MovableObjectFactory* getMovableObjectFactory(const String& typeName);
1023  uint32 _allocateNextMovableObjectTypeFlag(void);
1024 
1029  MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
1030 
1034  unsigned int getDisplayMonitorCount() const;
1035 
1042  WorkQueue* getWorkQueue() const { return mWorkQueue; }
1043 
1052  void setWorkQueue(WorkQueue* queue);
1053 
1060  void setBlendIndicesGpuRedundant(bool redundant) { mIsBlendIndicesGpuRedundant = redundant; }
1064  bool isBlendIndicesGpuRedundant() const { return mIsBlendIndicesGpuRedundant; }
1065 
1072  void setBlendWeightsGpuRedundant(bool redundant) { mIsBlendWeightsGpuRedundant = redundant; }
1076  bool isBlendWeightsGpuRedundant() const { return mIsBlendWeightsGpuRedundant; }
1077 
1082  void setDefaultMinPixelSize(Real pixelSize) { mDefaultMinPixelSize = pixelSize; }
1083 
1086  Real getDefaultMinPixelSize() { return mDefaultMinPixelSize; }
1087 
1088 
1089  };
1092 } // Namespace Ogre
1093 #endif
A 'canvas' which can receive the results of a rendering operation.
RenderSystem * mActiveRenderer
Definition: OgreRoot.h:78
MeshManager * mMeshManager
Definition: OgreRoot.h:94
LogManager * mLogManager
Definition: OgreRoot.h:86
vector< RenderSystem * >::type RenderSystemList
Definition: OgreRoot.h:56
MovableObjectFactory * mManualObjectFactory
Definition: OgreRoot.h:142
WorkQueue * mWorkQueue
Definition: OgreRoot.h:152
ConstMapIterator< MovableObjectFactoryMap > MovableObjectFactoryIterator
Definition: OgreRoot.h:1025
set< FrameListener * >::type mRemovedFrameListeners
Set of frame listeners marked for removal and addition.
Definition: OgreRoot.h:187
SceneManagerStack mSceneManagerStack
Definition: OgreRoot.h:90
Class for loading & managing textures.
vector< DynLib * >::type PluginLibList
Definition: OgreRoot.h:127
void setRemoveRenderQueueStructuresOnClear(bool r)
Set whether the entire render queue structure should be emptied on clearing, or whether just the obje...
Definition: OgreRoot.h:356
SkeletonManager * mSkeletonManager
Definition: OgreRoot.h:96
Class for managing RenderSystemCapabilities database for Ogre.
#define _OgreExport
Definition: OgrePlatform.h:257
FrameEventTimeType
Indicates the type of event to be considered by calculateEventTime().
Definition: OgreRoot.h:192
Profiler * mProfiler
Definition: OgreRoot.h:117
std::set< T, P, A > type
bool isBlendIndicesGpuRedundant() const
Returns whether blend indices information needs to be passed to the GPU see setBlendIndicesGpuRedunda...
Definition: OgreRoot.h:1064
Singleton Class which handles the registering and control of texture plugins.
Manager for LOD strategies.
HighLevelGpuProgramManager * mHighLevelGpuProgramManager
Definition: OgreRoot.h:118
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:70
ArchiveFactory * mFileSystemArchiveFactory
Definition: OgreRoot.h:100
ScriptCompilerManager * mCompilerManager
Definition: OgreRoot.h:110
Injects the output of a request to the mesh in a thread safe way.
vector< Plugin * >::type PluginInstanceList
Definition: OgreRoot.h:128
SceneManagerEnumerator * mSceneManagerEnum
Definition: OgreRoot.h:88
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
set< FrameListener * >::type mAddedFrameListeners
Definition: OgreRoot.h:188
#define OGRE_BUILD_SUFFIX
Definition: OgrePlatform.h:355
Concrete IteratorWrapper for const access to the underlying key-value container.
Class which will create instances of a given SceneManager.
Real mFrameSmoothingTime
Definition: OgreRoot.h:122
Handles the management of skeleton resources.
PluginLibList mPluginLibs
List of plugin DLLs loaded.
Definition: OgreRoot.h:131
Class representing colour.
float Real
Software floating point type.
PMInjector * mPMInjector
Definition: OgreRoot.h:113
vector< RenderWindowDescription >::type RenderWindowDescriptionList
Render window creation parameters container.
Definition: OgreCommon.h:761
MaterialManager * mMaterialManager
Definition: OgreRoot.h:93
RenderSystemList mRenderers
Definition: OgreRoot.h:77
static String DEFAULT_RESOURCE_GROUP_NAME
Default resource group name.
unsigned long mNextFrame
Definition: OgreRoot.h:121
Timer class.
Class for managing Material settings for Ogre.
Real mDefaultMinPixelSize
Definition: OgreRoot.h:124
bool mQueuedEnd
Definition: OgreRoot.h:81
bool mIsBlendWeightsGpuRedundant
Tells whether blend weights information needs to be passed to the GPU.
Definition: OgreRoot.h:157
vector< RenderWindow * >::type RenderWindowList
Render window container.
Definition: OgreCommon.h:764
PluginInstanceList mPlugins
List of Plugin instances registered.
Definition: OgreRoot.h:133
uint16 SceneTypeMask
Bitmask containing scene types.
Class to hold a linear sequence of RenderQueueInvocation objects.
MovableObjectFactory * mLightFactory
Definition: OgreRoot.h:140
String mVersion
Definition: OgreRoot.h:79
The profiler allows you to measure the performance of your code.
Definition: OgreProfiler.h:280
Class for managing Compositor settings for Ogre.
bool mIsInitialised
Are we initialised yet?
Definition: OgreRoot.h:150
bool mIsBlendIndicesGpuRedundant
Tells whether blend indices information needs to be passed to the GPU.
Definition: OgreRoot.h:155
Class for managing Controller instances.
PMWorker * mPMWorker
Definition: OgreRoot.h:112
MovableObjectFactory * mEntityFactory
Definition: OgreRoot.h:139
ShadowTextureManager * mShadowTextureManager
Definition: OgreRoot.h:108
MovableObjectFactory * mRibbonTrailFactory
Definition: OgreRoot.h:144
Defines the functionality of a 3D API.
void setBlendIndicesGpuRedundant(bool redundant)
Sets whether blend indices information needs to be passed to the GPU.
Definition: OgreRoot.h:1060
Struct containing information about a frame event.
void setBlendWeightsGpuRedundant(bool redundant)
Sets whether blend weights information needs to be passed to the GPU.
Definition: OgreRoot.h:1072
Enumerates the SceneManager classes available to applications.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
ParticleSystemManager * mParticleManager
Definition: OgreRoot.h:95
Real getDefaultMinPixelSize()
Get the default minimum pixel size for object to be rendered by.
Definition: OgreRoot.h:1086
ArchiveFactory * mEmbeddedZipArchiveFactory
Definition: OgreRoot.h:99
MovableObjectFactory * mBillboardSetFactory
Definition: OgreRoot.h:141
RenderSystemCapabilitiesManager * mRenderSystemCapabilitiesManager
Definition: OgreRoot.h:109
_StringBase String
Structure containing information about a scene manager.
CompositorManager * mCompositorManager
Definition: OgreRoot.h:120
Class defining a generic OGRE plugin.
Definition: OgrePlugin.h:79
unsigned long getNextFrameNumber(void) const
Gets the number of the next frame to be rendered.
Definition: OgreRoot.h:862
set< FrameListener * >::type mFrameListeners
Set of registered frame listeners.
Definition: OgreRoot.h:184
map< String, RenderQueueInvocationSequence * >::type RenderQueueInvocationSequenceMap
Definition: OgreRoot.h:146
This class is used to perform Resource operations in a background thread.
ArchiveManager * mArchiveManager
Definition: OgreRoot.h:92
void setDefaultMinPixelSize(Real pixelSize)
Set the default minimum pixel size for object to be rendered by.
Definition: OgreRoot.h:1082
Manager for Dynamic-loading Libraries.
Class to manage the available shadow textures which may be shared between many SceneManager instances...
singleton class for storing the capabilities of the graphics card.
ResourceBackgroundQueue * mResourceBackgroundQueue
Definition: OgreRoot.h:107
Manages threaded compilation of scripts.
RenderWindow * mAutoWindow
Definition: OgreRoot.h:116
Abstract factory class, archive codec plugins can register concrete subclasses of this...
Real getFrameSmoothingPeriod(void) const
Gets the period over which OGRE smooths out fluctuations in frame times.
Definition: OgreRoot.h:990
Handles the management of mesh resources.
This class manages the available ArchiveFactory plugins.
RenderQueueInvocationSequenceMap mRQSequenceMap
Definition: OgreRoot.h:147
unsigned int uint32
Definition: OgrePlatform.h:359
ResourceGroupManager * mResourceGroupManager
Definition: OgreRoot.h:106
This ResourceManager manages high-level vertex and fragment programs.
The log manager handles the creation and retrieval of logs for the application.
bool getRemoveRenderQueueStructuresOnClear() const
Get whether the entire render queue structure should be emptied on clearing, or whether just the obje...
Definition: OgreRoot.h:351
DynLibManager * mDynLibManager
Definition: OgreRoot.h:91
const PluginInstanceList & getInstalledPlugins() const
Gets a read-only list of the currently installed plugins.
Definition: OgreRoot.h:756
Manages the target rendering window.
This singleton class manages the list of resource groups, and notifying the various resource managers...
MovableObjectFactoryMap mMovableObjectFactoryMap
Definition: OgreRoot.h:136
deque< SceneManager * >::type SceneManagerStack
Definition: OgreRoot.h:89
bool mFirstTimePostWindowInit
In case multiple render windows are created, only once are the resources loaded.
Definition: OgreRoot.h:83
Concrete IteratorWrapper for const access to the underlying container.
MovableObjectFactory * mBillboardChainFactory
Definition: OgreRoot.h:143
Timer * mTimer
Definition: OgreRoot.h:115
bool mRemoveQueueStructuresOnClear
Definition: OgreRoot.h:123
String mConfigFileName
Definition: OgreRoot.h:80
uint32 mNextMovableObjectTypeFlag
Definition: OgreRoot.h:137
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
bool isInitialised(void) const
Returns whether the system is initialised or not.
Definition: OgreRoot.h:339
LodStrategyManager * mLodStrategyManager
Definition: OgreRoot.h:111
ExternalTextureSourceManager * mExternalTextureSourceManager
Definition: OgreRoot.h:119
map< String, MovableObjectFactory * >::type MovableObjectFactoryMap
Definition: OgreRoot.h:135
Manages the organisation and rendering of a 'scene' i.e.
ArchiveFactory * mZipArchiveFactory
Definition: OgreRoot.h:98
WorkQueue * getWorkQueue() const
Get the WorkQueue for processing background tasks.
Definition: OgreRoot.h:1042
Manages particle systems, particle system scripts (templates) and the available emitter & affector fa...
The root class of the Ogre system.
Definition: OgreRoot.h:71
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
deque< unsigned long >::type EventTimesQueue
Contains the times of recently fired events.
Definition: OgreRoot.h:201
bool isBlendWeightsGpuRedundant() const
Returns whether blend weights information needs to be passed to the GPU see setBlendWeightsGpuRedunda...
Definition: OgreRoot.h:1076
A interface class defining a listener which can be used to receive notifications of frame events...
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
ControllerManager * mControllerManager
Definition: OgreRoot.h:87
void setFrameSmoothingPeriod(Real period)
Sets the period over which OGRE smooths out fluctuations in frame times.
Definition: OgreRoot.h:988

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sat Sep 20 2014 20:06:37