[148] | 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" |
---|
| 36 | #include "OgreSceneManagerEnumerator.h" |
---|
| 37 | #include "OgreResourceGroupManager.h" |
---|
| 38 | #include "OgreLodStrategyManager.h" |
---|
| 39 | #include "OgreWorkQueue.h" |
---|
| 40 | |
---|
| 41 | #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID |
---|
| 42 | #include "Android/OgreAndroidLogListener.h" |
---|
| 43 | #endif |
---|
| 44 | |
---|
| 45 | #include <exception> |
---|
| 46 | |
---|
| 47 | namespace Ogre |
---|
| 48 | { |
---|
| 49 | /** \addtogroup Core |
---|
| 50 | * @{ |
---|
| 51 | */ |
---|
| 52 | /** \addtogroup General |
---|
| 53 | * @{ |
---|
| 54 | */ |
---|
| 55 | |
---|
| 56 | typedef vector<RenderSystem*>::type RenderSystemList; |
---|
| 57 | |
---|
| 58 | /** The root class of the Ogre system. |
---|
| 59 | @remarks |
---|
| 60 | The Ogre::Root class represents a starting point for the client |
---|
| 61 | application. From here, the application can gain access to the |
---|
| 62 | fundamentals of the system, namely the rendering systems |
---|
| 63 | available, management of saved configurations, logging, and |
---|
| 64 | access to other classes in the system. Acts as a hub from which |
---|
| 65 | all other objects may be reached. An instance of Root must be |
---|
| 66 | created before any other Ogre operations are called. Once an |
---|
| 67 | instance has been created, the same instance is accessible |
---|
| 68 | throughout the life of that object by using Root::getSingleton |
---|
| 69 | (as a reference) or Root::getSingletonPtr (as a pointer). |
---|
| 70 | */ |
---|
| 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; |
---|
| 78 | RenderSystem* mActiveRenderer; |
---|
| 79 | String mVersion; |
---|
| 80 | String mConfigFileName; |
---|
| 81 | bool mQueuedEnd; |
---|
| 82 | /// In case multiple render windows are created, only once are the resources loaded. |
---|
| 83 | bool mFirstTimePostWindowInit; |
---|
| 84 | |
---|
| 85 | // Singletons |
---|
| 86 | LogManager* mLogManager; |
---|
| 87 | ControllerManager* mControllerManager; |
---|
| 88 | SceneManagerEnumerator* mSceneManagerEnum; |
---|
| 89 | typedef deque<SceneManager*>::type SceneManagerStack; |
---|
| 90 | SceneManagerStack mSceneManagerStack; |
---|
| 91 | DynLibManager* mDynLibManager; |
---|
| 92 | ArchiveManager* mArchiveManager; |
---|
| 93 | MaterialManager* mMaterialManager; |
---|
| 94 | MeshManager* mMeshManager; |
---|
| 95 | ParticleSystemManager* mParticleManager; |
---|
| 96 | SkeletonManager* mSkeletonManager; |
---|
| 97 | |
---|
| 98 | ArchiveFactory *mZipArchiveFactory; |
---|
| 99 | ArchiveFactory *mEmbeddedZipArchiveFactory; |
---|
| 100 | ArchiveFactory *mFileSystemArchiveFactory; |
---|
| 101 | |
---|
| 102 | #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID |
---|
| 103 | AndroidLogListener* mAndroidLogger; |
---|
| 104 | #endif |
---|
| 105 | |
---|
| 106 | ResourceGroupManager* mResourceGroupManager; |
---|
| 107 | ResourceBackgroundQueue* mResourceBackgroundQueue; |
---|
| 108 | ShadowTextureManager* mShadowTextureManager; |
---|
| 109 | RenderSystemCapabilitiesManager* mRenderSystemCapabilitiesManager; |
---|
| 110 | ScriptCompilerManager *mCompilerManager; |
---|
| 111 | LodStrategyManager *mLodStrategyManager; |
---|
| 112 | PMWorker* mPMWorker; |
---|
| 113 | PMInjector* mPMInjector; |
---|
| 114 | |
---|
| 115 | Timer* mTimer; |
---|
| 116 | RenderWindow* mAutoWindow; |
---|
| 117 | Profiler* mProfiler; |
---|
| 118 | HighLevelGpuProgramManager* mHighLevelGpuProgramManager; |
---|
| 119 | ExternalTextureSourceManager* mExternalTextureSourceManager; |
---|
| 120 | CompositorManager* mCompositorManager; |
---|
| 121 | unsigned long mNextFrame; |
---|
| 122 | Real mFrameSmoothingTime; |
---|
| 123 | bool mRemoveQueueStructuresOnClear; |
---|
| 124 | Real mDefaultMinPixelSize; |
---|
| 125 | |
---|
| 126 | public: |
---|
| 127 | typedef vector<DynLib*>::type PluginLibList; |
---|
| 128 | typedef vector<Plugin*>::type PluginInstanceList; |
---|
| 129 | protected: |
---|
| 130 | /// List of plugin DLLs loaded |
---|
| 131 | PluginLibList mPluginLibs; |
---|
| 132 | /// List of Plugin instances registered |
---|
| 133 | PluginInstanceList mPlugins; |
---|
| 134 | |
---|
| 135 | typedef map<String, MovableObjectFactory*>::type MovableObjectFactoryMap; |
---|
| 136 | MovableObjectFactoryMap mMovableObjectFactoryMap; |
---|
| 137 | uint32 mNextMovableObjectTypeFlag; |
---|
| 138 | // stock movable factories |
---|
| 139 | MovableObjectFactory* mEntityFactory; |
---|
| 140 | MovableObjectFactory* mLightFactory; |
---|
| 141 | MovableObjectFactory* mBillboardSetFactory; |
---|
| 142 | MovableObjectFactory* mManualObjectFactory; |
---|
| 143 | MovableObjectFactory* mBillboardChainFactory; |
---|
| 144 | MovableObjectFactory* mRibbonTrailFactory; |
---|
| 145 | |
---|
| 146 | typedef map<String, RenderQueueInvocationSequence*>::type RenderQueueInvocationSequenceMap; |
---|
| 147 | RenderQueueInvocationSequenceMap mRQSequenceMap; |
---|
| 148 | |
---|
| 149 | /// Are we initialised yet? |
---|
| 150 | bool mIsInitialised; |
---|
| 151 | |
---|
| 152 | WorkQueue* mWorkQueue; |
---|
| 153 | |
---|
| 154 | ///Tells whether blend indices information needs to be passed to the GPU |
---|
| 155 | bool mIsBlendIndicesGpuRedundant; |
---|
| 156 | ///Tells whether blend weights information needs to be passed to the GPU |
---|
| 157 | bool mIsBlendWeightsGpuRedundant; |
---|
| 158 | |
---|
| 159 | /** Method reads a plugins configuration file and instantiates all |
---|
| 160 | plugins. |
---|
| 161 | @param |
---|
| 162 | pluginsfile The file that contains plugins information. |
---|
| 163 | Defaults to "plugins.cfg" in release and to "plugins_d.cfg" |
---|
| 164 | in debug build. |
---|
| 165 | */ |
---|
| 166 | void loadPlugins(const String& pluginsfile = "plugins" OGRE_BUILD_SUFFIX ".cfg"); |
---|
| 167 | /** Initialise all loaded plugins - allows plugins to perform actions |
---|
| 168 | once the renderer is initialised. |
---|
| 169 | */ |
---|
| 170 | void initialisePlugins(); |
---|
| 171 | /** Shuts down all loaded plugins - allows things to be tidied up whilst |
---|
| 172 | all plugins are still loaded. |
---|
| 173 | */ |
---|
| 174 | void shutdownPlugins(); |
---|
| 175 | |
---|
| 176 | /** Unloads all loaded plugins. |
---|
| 177 | */ |
---|
| 178 | void unloadPlugins(); |
---|
| 179 | |
---|
| 180 | /// Internal method for one-time tasks after first window creation |
---|
| 181 | void oneTimePostWindowInit(void); |
---|
| 182 | |
---|
| 183 | /** Set of registered frame listeners */ |
---|
| 184 | set<FrameListener*>::type mFrameListeners; |
---|
| 185 | |
---|
| 186 | /** Set of frame listeners marked for removal and addition*/ |
---|
| 187 | set<FrameListener*>::type mRemovedFrameListeners; |
---|
| 188 | set<FrameListener*>::type mAddedFrameListeners; |
---|
| 189 | void _syncAddedRemovedFrameListeners(); |
---|
| 190 | |
---|
| 191 | /** Indicates the type of event to be considered by calculateEventTime(). */ |
---|
| 192 | enum FrameEventTimeType { |
---|
| 193 | FETT_ANY = 0, |
---|
| 194 | FETT_STARTED = 1, |
---|
| 195 | FETT_QUEUED = 2, |
---|
| 196 | FETT_ENDED = 3, |
---|
| 197 | FETT_COUNT = 4 |
---|
| 198 | }; |
---|
| 199 | |
---|
| 200 | /// Contains the times of recently fired events |
---|
| 201 | typedef deque<unsigned long>::type EventTimesQueue; |
---|
| 202 | EventTimesQueue mEventTimes[FETT_COUNT]; |
---|
| 203 | |
---|
| 204 | /** Internal method for calculating the average time between recently fired events. |
---|
| 205 | @param now The current time in ms. |
---|
| 206 | @param type The type of event to be considered. |
---|
| 207 | */ |
---|
| 208 | Real calculateEventTime(unsigned long now, FrameEventTimeType type); |
---|
| 209 | |
---|
| 210 | /** Update a set of event times (note, progressive, only call once for each type per frame) */ |
---|
| 211 | void populateFrameEvent(FrameEventTimeType type, FrameEvent& evtToUpdate); |
---|
| 212 | |
---|
| 213 | public: |
---|
| 214 | |
---|
| 215 | /** Constructor |
---|
| 216 | @param pluginFileName The file that contains plugins information. |
---|
| 217 | Defaults to "plugins.cfg" in release build and to "plugins_d.cfg" |
---|
| 218 | in debug build. May be left blank to ignore. |
---|
| 219 | @param configFileName The file that contains the configuration to be loaded. |
---|
| 220 | Defaults to "ogre.cfg", may be left blank to load nothing. |
---|
| 221 | @param logFileName The logfile to create, defaults to Ogre.log, may be |
---|
| 222 | left blank if you've already set up LogManager & Log yourself |
---|
| 223 | */ |
---|
| 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 | |
---|
| 229 | /** Saves the details of the current configuration |
---|
| 230 | @remarks |
---|
| 231 | Stores details of the current configuration so it may be |
---|
| 232 | restored later on. |
---|
| 233 | */ |
---|
| 234 | void saveConfig(void); |
---|
| 235 | |
---|
| 236 | /** Checks for saved video/sound/etc settings |
---|
| 237 | @remarks |
---|
| 238 | This method checks to see if there is a valid saved configuration |
---|
| 239 | from a previous run. If there is, the state of the system will |
---|
| 240 | be restored to that configuration. |
---|
| 241 | |
---|
| 242 | @return |
---|
| 243 | If a valid configuration was found, <b>true</b> is returned. |
---|
| 244 | @par |
---|
| 245 | If there is no saved configuration, or if the system failed |
---|
| 246 | with the last config settings, <b>false</b> is returned. |
---|
| 247 | */ |
---|
| 248 | bool restoreConfig(void); |
---|
| 249 | |
---|
| 250 | /** Displays a dialog asking the user to choose system settings. |
---|
| 251 | @remarks |
---|
| 252 | This method displays the default dialog allowing the user to |
---|
| 253 | choose the rendering system, video mode etc. If there is are |
---|
| 254 | any settings saved already, they will be restored automatically |
---|
| 255 | before displaying the dialogue. When the user accepts a group of |
---|
| 256 | settings, this will automatically call Root::setRenderSystem, |
---|
| 257 | RenderSystem::setConfigOption and Root::saveConfig with the |
---|
| 258 | user's choices. This is the easiest way to get the system |
---|
| 259 | configured. |
---|
| 260 | @return |
---|
| 261 | If the user clicked 'Ok', <b>true</b> is returned. |
---|
| 262 | @par |
---|
| 263 | If they clicked 'Cancel' (in which case the app should |
---|
| 264 | strongly consider terminating), <b>false</b> is returned. |
---|
| 265 | */ |
---|
| 266 | bool showConfigDialog(void); |
---|
| 267 | |
---|
| 268 | /** Adds a new rendering subsystem to the list of available renderers. |
---|
| 269 | @remarks |
---|
| 270 | Intended for use by advanced users and plugin writers only! |
---|
| 271 | Calling this method with a pointer to a valid RenderSystem |
---|
| 272 | (subclass) adds a rendering API implementation to the list of |
---|
| 273 | available ones. Typical examples would be an OpenGL |
---|
| 274 | implementation and a Direct3D implementation. |
---|
| 275 | @note |
---|
| 276 | <br>This should usually be called from the dllStartPlugin() |
---|
| 277 | function of an extension plug-in. |
---|
| 278 | */ |
---|
| 279 | void addRenderSystem(RenderSystem* newRend); |
---|
| 280 | |
---|
| 281 | /** Retrieve a list of the available render systems. |
---|
| 282 | @remarks |
---|
| 283 | Retrieves a pointer to the list of available renderers as a |
---|
| 284 | list of RenderSystem subclasses. Can be used to build a |
---|
| 285 | custom settings dialog. |
---|
| 286 | */ |
---|
| 287 | const RenderSystemList& getAvailableRenderers(void); |
---|
| 288 | |
---|
| 289 | /** Retrieve a pointer to the render system by the given name |
---|
| 290 | @param |
---|
| 291 | name Name of the render system intend to retrieve. |
---|
| 292 | @return |
---|
| 293 | A pointer to the render system, <b>NULL</b> if no found. |
---|
| 294 | */ |
---|
| 295 | RenderSystem* getRenderSystemByName(const String& name); |
---|
| 296 | |
---|
| 297 | /** Sets the rendering subsystem to be used. |
---|
| 298 | @remarks |
---|
| 299 | This method indicates to OGRE which rendering system is to be |
---|
| 300 | used (e.g. Direct3D, OpenGL etc). This is called |
---|
| 301 | automatically by the default config dialog, and when settings |
---|
| 302 | are restored from a previous configuraion. If used manually |
---|
| 303 | it could be used to set the renderer from a custom settings |
---|
| 304 | dialog. Once this has been done, the renderer can be |
---|
| 305 | initialised using Root::initialise. |
---|
| 306 | @par |
---|
| 307 | This method is also called by render systems if they are |
---|
| 308 | initialised directly. |
---|
| 309 | @param |
---|
| 310 | system Pointer to the render system to use. |
---|
| 311 | @see |
---|
| 312 | RenderSystem |
---|
| 313 | */ |
---|
| 314 | void setRenderSystem(RenderSystem* system); |
---|
| 315 | |
---|
| 316 | /** Retrieve a pointer to the currently selected render system. |
---|
| 317 | */ |
---|
| 318 | RenderSystem* getRenderSystem(void); |
---|
| 319 | |
---|
| 320 | /** Initialises the renderer. |
---|
| 321 | @remarks |
---|
| 322 | This method can only be called after a renderer has been |
---|
| 323 | selected with Root::setRenderSystem, and it will initialise |
---|
| 324 | the selected rendering system ready for use. |
---|
| 325 | @param |
---|
| 326 | autoCreateWindow If true, a rendering window will |
---|
| 327 | automatically be created (saving a call to |
---|
| 328 | Root::createRenderWindow). The window will be |
---|
| 329 | created based on the options currently set on the render |
---|
| 330 | system. |
---|
| 331 | @return |
---|
| 332 | A pointer to the automatically created window, if |
---|
| 333 | requested, otherwise <b>NULL</b>. |
---|
| 334 | */ |
---|
| 335 | RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window", |
---|
| 336 | const String& customCapabilitiesConfig = StringUtil::BLANK); |
---|
| 337 | |
---|
| 338 | /** Returns whether the system is initialised or not. */ |
---|
| 339 | bool isInitialised(void) const { return mIsInitialised; } |
---|
| 340 | |
---|
| 341 | /** Requests active RenderSystem to use custom RenderSystemCapabilities |
---|
| 342 | @remarks |
---|
| 343 | This is useful for testing how the RenderSystem would behave on a machine with |
---|
| 344 | less advanced GPUs. This method MUST be called before creating the first RenderWindow |
---|
| 345 | */ |
---|
| 346 | void useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities); |
---|
| 347 | |
---|
| 348 | /** Get whether the entire render queue structure should be emptied on clearing, |
---|
| 349 | or whether just the objects themselves should be cleared. |
---|
| 350 | */ |
---|
| 351 | bool getRemoveRenderQueueStructuresOnClear() const { return mRemoveQueueStructuresOnClear; } |
---|
| 352 | |
---|
| 353 | /** Set whether the entire render queue structure should be emptied on clearing, |
---|
| 354 | or whether just the objects themselves should be cleared. |
---|
| 355 | */ |
---|
| 356 | void setRemoveRenderQueueStructuresOnClear(bool r) { mRemoveQueueStructuresOnClear = r; } |
---|
| 357 | |
---|
| 358 | /** Register a new SceneManagerFactory, a factory object for creating instances |
---|
| 359 | of specific SceneManagers. |
---|
| 360 | @remarks |
---|
| 361 | Plugins should call this to register as new SceneManager providers. |
---|
| 362 | */ |
---|
| 363 | void addSceneManagerFactory(SceneManagerFactory* fact); |
---|
| 364 | |
---|
| 365 | /** Unregister a SceneManagerFactory. |
---|
| 366 | */ |
---|
| 367 | void removeSceneManagerFactory(SceneManagerFactory* fact); |
---|
| 368 | |
---|
| 369 | /** Get more information about a given type of SceneManager. |
---|
| 370 | @remarks |
---|
| 371 | The metadata returned tells you a few things about a given type |
---|
| 372 | of SceneManager, which can be created using a factory that has been |
---|
| 373 | registered already. |
---|
| 374 | @param typeName The type name of the SceneManager you want to enquire on. |
---|
| 375 | If you don't know the typeName already, you can iterate over the |
---|
| 376 | metadata for all types using getMetaDataIterator. |
---|
| 377 | */ |
---|
| 378 | const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const; |
---|
| 379 | |
---|
| 380 | /** Iterate over all types of SceneManager available for construction, |
---|
| 381 | providing some information about each one. |
---|
| 382 | */ |
---|
| 383 | SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const; |
---|
| 384 | |
---|
| 385 | /** Create a SceneManager instance of a given type. |
---|
| 386 | @remarks |
---|
| 387 | You can use this method to create a SceneManager instance of a |
---|
| 388 | given specific type. You may know this type already, or you may |
---|
| 389 | have discovered it by looking at the results from getMetaDataIterator. |
---|
| 390 | @note |
---|
| 391 | This method throws an exception if the named type is not found. |
---|
| 392 | @param typeName String identifying a unique SceneManager type |
---|
| 393 | @param instanceName Optional name to given the new instance that is |
---|
| 394 | created. If you leave this blank, an auto name will be assigned. |
---|
| 395 | */ |
---|
| 396 | SceneManager* createSceneManager(const String& typeName, |
---|
| 397 | const String& instanceName = StringUtil::BLANK); |
---|
| 398 | |
---|
| 399 | /** Create a SceneManager instance based on scene type support. |
---|
| 400 | @remarks |
---|
| 401 | Creates an instance of a SceneManager which supports the scene types |
---|
| 402 | identified in the parameter. If more than one type of SceneManager |
---|
| 403 | has been registered as handling that combination of scene types, |
---|
| 404 | in instance of the last one registered is returned. |
---|
| 405 | @note This method always succeeds, if a specific scene manager is not |
---|
| 406 | found, the default implementation is always returned. |
---|
| 407 | @param typeMask A mask containing one or more SceneType flags |
---|
| 408 | @param instanceName Optional name to given the new instance that is |
---|
| 409 | created. If you leave this blank, an auto name will be assigned. |
---|
| 410 | */ |
---|
| 411 | SceneManager* createSceneManager(SceneTypeMask typeMask, |
---|
| 412 | const String& instanceName = StringUtil::BLANK); |
---|
| 413 | |
---|
| 414 | /** Destroy an instance of a SceneManager. */ |
---|
| 415 | void destroySceneManager(SceneManager* sm); |
---|
| 416 | |
---|
| 417 | /** Get an existing SceneManager instance that has already been created, |
---|
| 418 | identified by the instance name. |
---|
| 419 | @param instanceName The name of the instance to retrieve. |
---|
| 420 | */ |
---|
| 421 | SceneManager* getSceneManager(const String& instanceName) const; |
---|
| 422 | |
---|
| 423 | /** Determines if a given SceneManager already exists |
---|
| 424 | @param instanceName The name of the instance to retrieve. |
---|
| 425 | */ |
---|
| 426 | bool hasSceneManager(const String& instanceName) const; |
---|
| 427 | /** Get an iterator over all the existing SceneManager instances. */ |
---|
| 428 | SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void); |
---|
| 429 | |
---|
| 430 | /** Retrieves a reference to the current TextureManager. |
---|
| 431 | @remarks |
---|
| 432 | This performs the same function as |
---|
| 433 | TextureManager::getSingleton, but is provided for convenience |
---|
| 434 | particularly to scripting engines. |
---|
| 435 | @par |
---|
| 436 | Note that a TextureManager will NOT be available until the |
---|
| 437 | Ogre system has been initialised by selecting a RenderSystem, |
---|
| 438 | calling Root::initialise and a window having been created |
---|
| 439 | (this may have been done by initialise if required). This is |
---|
| 440 | because the exact runtime subclass which will be implementing |
---|
| 441 | the calls will differ depending on the rendering engine |
---|
| 442 | selected, and these typically require a window upon which to |
---|
| 443 | base texture format decisions. |
---|
| 444 | */ |
---|
| 445 | TextureManager* getTextureManager(void); |
---|
| 446 | |
---|
| 447 | /** Retrieves a reference to the current MeshManager. |
---|
| 448 | @remarks |
---|
| 449 | This performs the same function as MeshManager::getSingleton |
---|
| 450 | and is provided for convenience to scripting engines. |
---|
| 451 | */ |
---|
| 452 | MeshManager* getMeshManager(void); |
---|
| 453 | |
---|
| 454 | /** Utility function for getting a better description of an error |
---|
| 455 | code. |
---|
| 456 | */ |
---|
| 457 | String getErrorDescription(long errorNumber); |
---|
| 458 | |
---|
| 459 | /** Registers a FrameListener which will be called back every frame. |
---|
| 460 | @remarks |
---|
| 461 | A FrameListener is a class which implements methods which |
---|
| 462 | will be called every frame. |
---|
| 463 | @par |
---|
| 464 | See the FrameListener class for more details on the specifics |
---|
| 465 | It is imperitive that the instance passed to this method is |
---|
| 466 | not destroyed before either the rendering loop ends, or the |
---|
| 467 | class is removed from the listening list using |
---|
| 468 | removeFrameListener. |
---|
| 469 | @note |
---|
| 470 | <br>This method can only be called after Root::initialise has |
---|
| 471 | been called. |
---|
| 472 | @see |
---|
| 473 | FrameListener, Root::removeFrameListener |
---|
| 474 | */ |
---|
| 475 | void addFrameListener(FrameListener* newListener); |
---|
| 476 | |
---|
| 477 | /** Removes a FrameListener from the list of listening classes. |
---|
| 478 | @see |
---|
| 479 | FrameListener, Root::addFrameListener |
---|
| 480 | */ |
---|
| 481 | void removeFrameListener(FrameListener* oldListener); |
---|
| 482 | |
---|
| 483 | /** Queues the end of rendering. |
---|
| 484 | @remarks |
---|
| 485 | This method will do nothing unless startRendering() has |
---|
| 486 | been called, in which case before the next frame is rendered |
---|
| 487 | the rendering loop will bail out. |
---|
| 488 | @see |
---|
| 489 | Root, Root::startRendering |
---|
| 490 | */ |
---|
| 491 | void queueEndRendering(bool state = true); |
---|
| 492 | |
---|
| 493 | /** Check for planned end of rendering. |
---|
| 494 | @remarks |
---|
| 495 | This method return true if queueEndRendering() was called before. |
---|
| 496 | @see |
---|
| 497 | Root, Root::queueEndRendering, Root::startRendering |
---|
| 498 | */ |
---|
| 499 | bool endRenderingQueued(void); |
---|
| 500 | |
---|
| 501 | /** Starts / restarts the automatic rendering cycle. |
---|
| 502 | @remarks |
---|
| 503 | This method begins the automatic rendering of the scene. It |
---|
| 504 | will <b>NOT</b> return until the rendering cycle is halted. |
---|
| 505 | @par |
---|
| 506 | During rendering, any FrameListener classes registered using |
---|
| 507 | addFrameListener will be called back for each frame that is |
---|
| 508 | to be rendered, These classes can tell OGRE to halt the |
---|
| 509 | rendering if required, which will cause this method to |
---|
| 510 | return. |
---|
| 511 | @note |
---|
| 512 | <br>Users of the OGRE library do not have to use this |
---|
| 513 | automatic rendering loop. It is there as a convenience and is |
---|
| 514 | most useful for high frame rate applications e.g. games. For |
---|
| 515 | applications that don't need to constantly refresh the |
---|
| 516 | rendering targets (e.g. an editor utility), it is better to |
---|
| 517 | manually refresh each render target only when required by |
---|
| 518 | calling RenderTarget::update, or if you want to run your own |
---|
| 519 | render loop you can update all targets on demand using |
---|
| 520 | Root::renderOneFrame. |
---|
| 521 | @note |
---|
| 522 | This frees up the CPU to do other things in between |
---|
| 523 | refreshes, since in this case frame rate is less important. |
---|
| 524 | @note |
---|
| 525 | This method can only be called after Root::initialise has |
---|
| 526 | been called. |
---|
| 527 | */ |
---|
| 528 | void startRendering(void); |
---|
| 529 | |
---|
| 530 | /** Render one frame. |
---|
| 531 | @remarks |
---|
| 532 | Updates all the render targets automatically and then returns, |
---|
| 533 | raising frame events before and after. |
---|
| 534 | */ |
---|
| 535 | bool renderOneFrame(void); |
---|
| 536 | |
---|
| 537 | /** Render one frame, with custom frame time information. |
---|
| 538 | @remarks |
---|
| 539 | Updates all the render targets automatically and then returns, |
---|
| 540 | raising frame events before and after - all per-frame times are based on |
---|
| 541 | the time value you pass in. |
---|
| 542 | */ |
---|
| 543 | bool renderOneFrame(Real timeSinceLastFrame); |
---|
| 544 | |
---|
| 545 | /** Shuts down the system manually. |
---|
| 546 | @remarks |
---|
| 547 | This is normally done by Ogre automatically so don't think |
---|
| 548 | you have to call this yourself. However this is here for |
---|
| 549 | convenience, especially for dealing with unexpected errors or |
---|
| 550 | for systems which need to shut down Ogre on demand. |
---|
| 551 | */ |
---|
| 552 | void shutdown(void); |
---|
| 553 | |
---|
| 554 | /** Adds a location to the list of searchable locations for a |
---|
| 555 | Resource type. |
---|
| 556 | @remarks |
---|
| 557 | Resource files (textures, models etc) need to be loaded from |
---|
| 558 | specific locations. By calling this method, you add another |
---|
| 559 | search location to the list. Locations added first are preferred |
---|
| 560 | over locations added later. |
---|
| 561 | @par |
---|
| 562 | Locations can be folders, compressed archives, even perhaps |
---|
| 563 | remote locations. Facilities for loading from different |
---|
| 564 | locations are provided by plugins which provide |
---|
| 565 | implementations of the Archive class. |
---|
| 566 | All the application user has to do is specify a 'loctype' |
---|
| 567 | string in order to indicate the type of location, which |
---|
| 568 | should map onto one of the provided plugins. Ogre comes |
---|
| 569 | configured with the 'FileSystem' (folders) and 'Zip' (archive |
---|
| 570 | compressed with the pkzip / WinZip etc utilities) types. |
---|
| 571 | @par |
---|
| 572 | You can also supply the name of a resource group which should |
---|
| 573 | have this location applied to it. The |
---|
| 574 | ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME group is the |
---|
| 575 | default, and one resource group which will always exist. You |
---|
| 576 | should consider defining resource groups for your more specific |
---|
| 577 | resources (e.g. per level) so that you can control loading / |
---|
| 578 | unloading better. |
---|
| 579 | @param |
---|
| 580 | name The name of the location, e.g. './data' or |
---|
| 581 | '/compressed/gamedata.zip' |
---|
| 582 | @param |
---|
| 583 | locType A string identifying the location type, e.g. |
---|
| 584 | 'FileSystem' (for folders), 'Zip' etc. Must map to a |
---|
| 585 | registered plugin which deals with this type (FileSystem and |
---|
| 586 | Zip should always be available) |
---|
| 587 | @param |
---|
| 588 | groupName Type of name of the resource group which this location |
---|
| 589 | should apply to; defaults to the General group which applies to |
---|
| 590 | all non-specific resources. |
---|
| 591 | @param |
---|
| 592 | recursive If the resource location has a concept of recursive |
---|
| 593 | directory traversal, enabling this option will mean you can load |
---|
| 594 | resources in subdirectories using only their unqualified name. |
---|
| 595 | The default is to disable this so that resources in subdirectories |
---|
| 596 | with the same name are still unique. |
---|
| 597 | @see |
---|
| 598 | Archive |
---|
| 599 | */ |
---|
| 600 | void addResourceLocation(const String& name, const String& locType, |
---|
| 601 | const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, |
---|
| 602 | bool recursive = false); |
---|
| 603 | |
---|
| 604 | /** Removes a resource location from the list. |
---|
| 605 | @see addResourceLocation |
---|
| 606 | @param name The name of the resource location as specified in addResourceLocation |
---|
| 607 | @param groupName The name of the resource group to which this location |
---|
| 608 | was assigned. |
---|
| 609 | */ |
---|
| 610 | void removeResourceLocation(const String& name, |
---|
| 611 | const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); |
---|
| 612 | |
---|
| 613 | /** Helper method to assist you in creating writeable file streams. |
---|
| 614 | @remarks |
---|
| 615 | This is a high-level utility method which you can use to find a place to |
---|
| 616 | save a file more easily. If the filename you specify is either an |
---|
| 617 | absolute or relative filename (ie it includes path separators), then |
---|
| 618 | the file will be created in the normal filesystem using that specification. |
---|
| 619 | If it doesn't, then the method will look for a writeable resource location |
---|
| 620 | via ResourceGroupManager::createResource using the other params provided. |
---|
| 621 | @param filename The name of the file to create. If it includes path separators, |
---|
| 622 | the filesystem will be accessed direct. If no path separators are |
---|
| 623 | present the resource system is used, falling back on the raw filesystem after. |
---|
| 624 | @param groupName The name of the group in which to create the file, if the |
---|
| 625 | resource system is used |
---|
| 626 | @param overwrite If true, an existing file will be overwritten, if false |
---|
| 627 | an error will occur if the file already exists |
---|
| 628 | @param locationPattern If the resource group contains multiple locations, |
---|
| 629 | then usually the file will be created in the first writable location. If you |
---|
| 630 | want to be more specific, you can include a location pattern here and |
---|
| 631 | only locations which match that pattern (as determined by StringUtil::match) |
---|
| 632 | will be considered candidates for creation. |
---|
| 633 | */ |
---|
| 634 | DataStreamPtr createFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, |
---|
| 635 | bool overwrite = false, const String& locationPattern = StringUtil::BLANK); |
---|
| 636 | |
---|
| 637 | /** Helper method to assist you in accessing readable file streams. |
---|
| 638 | @remarks |
---|
| 639 | This is a high-level utility method which you can use to find a place to |
---|
| 640 | open a file more easily. It checks the resource system first, and if |
---|
| 641 | that fails falls back on accessing the file system directly. |
---|
| 642 | @param filename The name of the file to open. |
---|
| 643 | @param groupName The name of the group in which to create the file, if the |
---|
| 644 | resource system is used |
---|
| 645 | @param locationPattern If the resource group contains multiple locations, |
---|
| 646 | then usually the file will be created in the first writable location. If you |
---|
| 647 | want to be more specific, you can include a location pattern here and |
---|
| 648 | only locations which match that pattern (as determined by StringUtil::match) |
---|
| 649 | will be considered candidates for creation. |
---|
| 650 | */ |
---|
| 651 | DataStreamPtr openFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, |
---|
| 652 | const String& locationPattern = StringUtil::BLANK); |
---|
| 653 | |
---|
| 654 | /** Generates a packed data version of the passed in ColourValue suitable for |
---|
| 655 | use with the current RenderSystem. |
---|
| 656 | @remarks |
---|
| 657 | Since different render systems have different colour data formats (eg |
---|
| 658 | RGBA for GL, ARGB for D3D) this method allows you to use 1 method for all. |
---|
| 659 | @param colour The colour to convert |
---|
| 660 | @param pDest Pointer to location to put the result. |
---|
| 661 | */ |
---|
| 662 | void convertColourValue(const ColourValue& colour, uint32* pDest); |
---|
| 663 | |
---|
| 664 | /** Retrieves a pointer to the window that was created automatically |
---|
| 665 | @remarks |
---|
| 666 | When Root is initialised an optional window is created. This |
---|
| 667 | method retrieves a pointer to that window. |
---|
| 668 | @note |
---|
| 669 | returns a null pointer when Root has not been initialised with |
---|
| 670 | the option of creating a window. |
---|
| 671 | */ |
---|
| 672 | RenderWindow* getAutoCreatedWindow(void); |
---|
| 673 | |
---|
| 674 | /** @copydoc RenderSystem::_createRenderWindow |
---|
| 675 | */ |
---|
| 676 | RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, |
---|
| 677 | bool fullScreen, const NameValuePairList *miscParams = 0) ; |
---|
| 678 | |
---|
| 679 | /** @copydoc RenderSystem::_createRenderWindows |
---|
| 680 | */ |
---|
| 681 | bool createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions, |
---|
| 682 | RenderWindowList& createdWindows); |
---|
| 683 | |
---|
| 684 | /** Detaches a RenderTarget from the active render system |
---|
| 685 | and returns a pointer to it. |
---|
| 686 | @note |
---|
| 687 | If the render target cannot be found, NULL is returned. |
---|
| 688 | */ |
---|
| 689 | RenderTarget* detachRenderTarget( RenderTarget* pWin ); |
---|
| 690 | |
---|
| 691 | /** Detaches a named RenderTarget from the active render system |
---|
| 692 | and returns a pointer to it. |
---|
| 693 | @note |
---|
| 694 | If the render target cannot be found, NULL is returned. |
---|
| 695 | */ |
---|
| 696 | RenderTarget* detachRenderTarget( const String & name ); |
---|
| 697 | |
---|
| 698 | /** Destroys the given RenderTarget. |
---|
| 699 | */ |
---|
| 700 | void destroyRenderTarget(RenderTarget* target); |
---|
| 701 | |
---|
| 702 | /** Destroys the given named RenderTarget. |
---|
| 703 | */ |
---|
| 704 | void destroyRenderTarget(const String &name); |
---|
| 705 | |
---|
| 706 | /** Retrieves a pointer to a named render target. |
---|
| 707 | */ |
---|
| 708 | RenderTarget * getRenderTarget(const String &name); |
---|
| 709 | |
---|
| 710 | /** Manually load a Plugin contained in a DLL / DSO. |
---|
| 711 | @remarks |
---|
| 712 | Plugins embedded in DLLs can be loaded at startup using the plugin |
---|
| 713 | configuration file specified when you create Root. |
---|
| 714 | This method allows you to load plugin DLLs directly in code. |
---|
| 715 | The DLL in question is expected to implement a dllStartPlugin |
---|
| 716 | method which instantiates a Plugin subclass and calls Root::installPlugin. |
---|
| 717 | It should also implement dllStopPlugin (see Root::unloadPlugin) |
---|
| 718 | @param pluginName Name of the plugin library to load |
---|
| 719 | */ |
---|
| 720 | void loadPlugin(const String& pluginName); |
---|
| 721 | |
---|
| 722 | /** Manually unloads a Plugin contained in a DLL / DSO. |
---|
| 723 | @remarks |
---|
| 724 | Plugin DLLs are unloaded at shutdown automatically. This method |
---|
| 725 | allows you to unload plugins in code, but make sure their |
---|
| 726 | dependencies are decoupled first. This method will call the |
---|
| 727 | dllStopPlugin method defined in the DLL, which in turn should call |
---|
| 728 | Root::uninstallPlugin. |
---|
| 729 | @param pluginName Name of the plugin library to unload |
---|
| 730 | */ |
---|
| 731 | void unloadPlugin(const String& pluginName); |
---|
| 732 | |
---|
| 733 | /** Install a new plugin. |
---|
| 734 | @remarks |
---|
| 735 | This installs a new extension to OGRE. The plugin itself may be loaded |
---|
| 736 | from a DLL / DSO, or it might be statically linked into your own |
---|
| 737 | application. Either way, something has to call this method to get |
---|
| 738 | it registered and functioning. You should only call this method directly |
---|
| 739 | if your plugin is not in a DLL that could otherwise be loaded with |
---|
| 740 | loadPlugin, since the DLL function dllStartPlugin should call this |
---|
| 741 | method when the DLL is loaded. |
---|
| 742 | */ |
---|
| 743 | void installPlugin(Plugin* plugin); |
---|
| 744 | |
---|
| 745 | /** Uninstall an existing plugin. |
---|
| 746 | @remarks |
---|
| 747 | This uninstalls an extension to OGRE. Plugins are automatically |
---|
| 748 | uninstalled at shutdown but this lets you remove them early. |
---|
| 749 | If the plugin was loaded from a DLL / DSO you should call unloadPlugin |
---|
| 750 | which should result in this method getting called anyway (if the DLL |
---|
| 751 | is well behaved). |
---|
| 752 | */ |
---|
| 753 | void uninstallPlugin(Plugin* plugin); |
---|
| 754 | |
---|
| 755 | /** Gets a read-only list of the currently installed plugins. */ |
---|
| 756 | const PluginInstanceList& getInstalledPlugins() const { return mPlugins; } |
---|
| 757 | |
---|
| 758 | /** Gets a pointer to the central timer used for all OGRE timings */ |
---|
| 759 | Timer* getTimer(void); |
---|
| 760 | |
---|
| 761 | /** Method for raising frame started events. |
---|
| 762 | @remarks |
---|
| 763 | This method is only for internal use when you use OGRE's inbuilt rendering |
---|
| 764 | loop (Root::startRendering). However, if you run your own rendering loop then |
---|
| 765 | you should call this method to ensure that FrameListener objects are notified |
---|
| 766 | of frame events; processes like texture animation and particle systems rely on |
---|
| 767 | this. |
---|
| 768 | @par |
---|
| 769 | Calling this method also increments the frame number, which is |
---|
| 770 | important for keeping some elements of the engine up to date. |
---|
| 771 | @note |
---|
| 772 | This method takes an event object as a parameter, so you can specify the times |
---|
| 773 | yourself. If you are happy for OGRE to automatically calculate the frame time |
---|
| 774 | for you, then call the other version of this method with no parameters. |
---|
| 775 | @param evt Event object which includes all the timing information which you have |
---|
| 776 | calculated for yourself |
---|
| 777 | @return False if one or more frame listeners elected that the rendering loop should |
---|
| 778 | be terminated, true otherwise. |
---|
| 779 | */ |
---|
| 780 | bool _fireFrameStarted(FrameEvent& evt); |
---|
| 781 | /** Method for raising frame rendering queued events. |
---|
| 782 | @remarks |
---|
| 783 | This method is only for internal use when you use OGRE's inbuilt rendering |
---|
| 784 | loop (Root::startRendering). However, if you run your own rendering loop then |
---|
| 785 | you should call this method too, to ensure that all state is updated |
---|
| 786 | correctly. You should call it after the windows have been updated |
---|
| 787 | but before the buffers are swapped, or if you are not separating the |
---|
| 788 | update and buffer swap, then after the update just before _fireFrameEnded. |
---|
| 789 | */ |
---|
| 790 | bool _fireFrameRenderingQueued(FrameEvent& evt); |
---|
| 791 | |
---|
| 792 | /** Method for raising frame ended events. |
---|
| 793 | @remarks |
---|
| 794 | This method is only for internal use when you use OGRE's inbuilt rendering |
---|
| 795 | loop (Root::startRendering). However, if you run your own rendering loop then |
---|
| 796 | you should call this method to ensure that FrameListener objects are notified |
---|
| 797 | of frame events; processes like texture animation and particle systems rely on |
---|
| 798 | this. |
---|
| 799 | @note |
---|
| 800 | This method takes an event object as a parameter, so you can specify the times |
---|
| 801 | yourself. If you are happy for OGRE to automatically calculate the frame time |
---|
| 802 | for you, then call the other version of this method with no parameters. |
---|
| 803 | @param evt Event object which includes all the timing information which you have |
---|
| 804 | calculated for yourself |
---|
| 805 | @return False if one or more frame listeners elected that the rendering loop should |
---|
| 806 | be terminated, true otherwise. |
---|
| 807 | */ |
---|
| 808 | bool _fireFrameEnded(FrameEvent& evt); |
---|
| 809 | /** Method for raising frame started events. |
---|
| 810 | @remarks |
---|
| 811 | This method is only for internal use when you use OGRE's inbuilt rendering |
---|
| 812 | loop (Root::startRendering). However, if you run your own rendering loop then |
---|
| 813 | you should call this method to ensure that FrameListener objects are notified |
---|
| 814 | of frame events; processes like texture animation and particle systems rely on |
---|
| 815 | this. |
---|
| 816 | @par |
---|
| 817 | Calling this method also increments the frame number, which is |
---|
| 818 | important for keeping some elements of the engine up to date. |
---|
| 819 | @note |
---|
| 820 | This method calculates the frame timing information for you based on the elapsed |
---|
| 821 | time. If you want to specify elapsed times yourself you should call the other |
---|
| 822 | version of this method which takes event details as a parameter. |
---|
| 823 | @return False if one or more frame listeners elected that the rendering loop should |
---|
| 824 | be terminated, true otherwise. |
---|
| 825 | */ |
---|
| 826 | bool _fireFrameStarted(); |
---|
| 827 | /** Method for raising frame rendering queued events. |
---|
| 828 | @remarks |
---|
| 829 | This method is only for internal use when you use OGRE's inbuilt rendering |
---|
| 830 | loop (Root::startRendering). However, if you run your own rendering loop then |
---|
| 831 | you you may want to call this method too, although nothing in OGRE relies on this |
---|
| 832 | particular event. Really if you're running your own rendering loop at |
---|
| 833 | this level of detail then you can get the same effect as doing your |
---|
| 834 | updates in a frameRenderingQueued callback by just calling |
---|
| 835 | RenderWindow::update with the 'swapBuffers' option set to false. |
---|
| 836 | */ |
---|
| 837 | bool _fireFrameRenderingQueued(); |
---|
| 838 | /** Method for raising frame ended events. |
---|
| 839 | @remarks |
---|
| 840 | This method is only for internal use when you use OGRE's inbuilt rendering |
---|
| 841 | loop (Root::startRendering). However, if you run your own rendering loop then |
---|
| 842 | you should call this method to ensure that FrameListener objects are notified |
---|
| 843 | of frame events; processes like texture animation and particle systems rely on |
---|
| 844 | this. |
---|
| 845 | @note |
---|
| 846 | This method calculates the frame timing information for you based on the elapsed |
---|
| 847 | time. If you want to specify elapsed times yourself you should call the other |
---|
| 848 | version of this method which takes event details as a parameter. |
---|
| 849 | @return False if one or more frame listeners elected that the rendering loop should |
---|
| 850 | be terminated, true otherwise. |
---|
| 851 | */ |
---|
| 852 | bool _fireFrameEnded(); |
---|
| 853 | |
---|
| 854 | /** Gets the number of the next frame to be rendered. |
---|
| 855 | @remarks |
---|
| 856 | Note that this is 'next frame' rather than 'current frame' because |
---|
| 857 | it indicates the frame number that current changes made to the scene |
---|
| 858 | will take effect. It is incremented after all rendering commands for |
---|
| 859 | the current frame have been queued, thus reflecting that if you |
---|
| 860 | start performing changes then, you will actually see them in the |
---|
| 861 | next frame. */ |
---|
| 862 | unsigned long getNextFrameNumber(void) const { return mNextFrame; } |
---|
| 863 | |
---|
| 864 | /** Returns the scene manager currently being used to render a frame. |
---|
| 865 | @remarks |
---|
| 866 | This is only intended for internal use; it is only valid during the |
---|
| 867 | rendering of a frame. |
---|
| 868 | */ |
---|
| 869 | SceneManager* _getCurrentSceneManager(void) const; |
---|
| 870 | /** Pushes the scene manager currently being used to render. |
---|
| 871 | @remarks |
---|
| 872 | This is only intended for internal use. |
---|
| 873 | */ |
---|
| 874 | void _pushCurrentSceneManager(SceneManager* sm); |
---|
| 875 | /** Pops the scene manager currently being used to render. |
---|
| 876 | @remarks |
---|
| 877 | This is only intended for internal use. |
---|
| 878 | */ |
---|
| 879 | void _popCurrentSceneManager(SceneManager* sm); |
---|
| 880 | |
---|
| 881 | /** Internal method used for updating all RenderTarget objects (windows, |
---|
| 882 | renderable textures etc) which are set to auto-update. |
---|
| 883 | @remarks |
---|
| 884 | You don't need to use this method if you're using Ogre's own internal |
---|
| 885 | rendering loop (Root::startRendering). If you're running your own loop |
---|
| 886 | you may wish to call it to update all the render targets which are |
---|
| 887 | set to auto update (RenderTarget::setAutoUpdated). You can also update |
---|
| 888 | individual RenderTarget instances using their own update() method. |
---|
| 889 | @return false if a FrameListener indicated it wishes to exit the render loop |
---|
| 890 | */ |
---|
| 891 | bool _updateAllRenderTargets(void); |
---|
| 892 | |
---|
| 893 | /** Internal method used for updating all RenderTarget objects (windows, |
---|
| 894 | renderable textures etc) which are set to auto-update, with a custom time |
---|
| 895 | passed to the frameRenderingQueued events. |
---|
| 896 | @remarks |
---|
| 897 | You don't need to use this method if you're using Ogre's own internal |
---|
| 898 | rendering loop (Root::startRendering). If you're running your own loop |
---|
| 899 | you may wish to call it to update all the render targets which are |
---|
| 900 | set to auto update (RenderTarget::setAutoUpdated). You can also update |
---|
| 901 | individual RenderTarget instances using their own update() method. |
---|
| 902 | @return false if a FrameListener indicated it wishes to exit the render loop |
---|
| 903 | */ |
---|
| 904 | bool _updateAllRenderTargets(FrameEvent& evt); |
---|
| 905 | |
---|
| 906 | /** Create a new RenderQueueInvocationSequence, useful for linking to |
---|
| 907 | Viewport instances to perform custom rendering. |
---|
| 908 | @param name The name to give the new sequence |
---|
| 909 | */ |
---|
| 910 | RenderQueueInvocationSequence* createRenderQueueInvocationSequence( |
---|
| 911 | const String& name); |
---|
| 912 | |
---|
| 913 | /** Get a RenderQueueInvocationSequence. |
---|
| 914 | @param name The name to identify the sequence |
---|
| 915 | */ |
---|
| 916 | RenderQueueInvocationSequence* getRenderQueueInvocationSequence( |
---|
| 917 | const String& name); |
---|
| 918 | |
---|
| 919 | /** Destroy a RenderQueueInvocationSequence. |
---|
| 920 | @remarks |
---|
| 921 | You must ensure that no Viewports are using this sequence. |
---|
| 922 | @param name The name to identify the sequence |
---|
| 923 | */ |
---|
| 924 | void destroyRenderQueueInvocationSequence( |
---|
| 925 | const String& name); |
---|
| 926 | |
---|
| 927 | /** Destroy all RenderQueueInvocationSequences. |
---|
| 928 | @remarks |
---|
| 929 | You must ensure that no Viewports are using custom sequences. |
---|
| 930 | */ |
---|
| 931 | void destroyAllRenderQueueInvocationSequences(void); |
---|
| 932 | |
---|
| 933 | /** Override standard Singleton retrieval. |
---|
| 934 | @remarks |
---|
| 935 | Why do we do this? Well, it's because the Singleton |
---|
| 936 | implementation is in a .h file, which means it gets compiled |
---|
| 937 | into anybody who includes it. This is needed for the |
---|
| 938 | Singleton template to work, but we actually only want it |
---|
| 939 | compiled into the implementation of the class based on the |
---|
| 940 | Singleton, not all of them. If we don't change this, we get |
---|
| 941 | link errors when trying to use the Singleton-based class from |
---|
| 942 | an outside dll. |
---|
| 943 | @par |
---|
| 944 | This method just delegates to the template version anyway, |
---|
| 945 | but the implementation stays in this single compilation unit, |
---|
| 946 | preventing link errors. |
---|
| 947 | */ |
---|
| 948 | static Root& getSingleton(void); |
---|
| 949 | /** Override standard Singleton retrieval. |
---|
| 950 | @remarks |
---|
| 951 | Why do we do this? Well, it's because the Singleton |
---|
| 952 | implementation is in a .h file, which means it gets compiled |
---|
| 953 | into anybody who includes it. This is needed for the |
---|
| 954 | Singleton template to work, but we actually only want it |
---|
| 955 | compiled into the implementation of the class based on the |
---|
| 956 | Singleton, not all of them. If we don't change this, we get |
---|
| 957 | link errors when trying to use the Singleton-based class from |
---|
| 958 | an outside dll. |
---|
| 959 | @par |
---|
| 960 | This method just delegates to the template version anyway, |
---|
| 961 | but the implementation stays in this single compilation unit, |
---|
| 962 | preventing link errors. |
---|
| 963 | */ |
---|
| 964 | static Root* getSingletonPtr(void); |
---|
| 965 | |
---|
| 966 | /** Clears the history of all event times. |
---|
| 967 | @remarks |
---|
| 968 | OGRE stores a history of the last few event times in order to smooth |
---|
| 969 | out any inaccuracies and temporary fluctuations. However, if you |
---|
| 970 | pause or don't render for a little while this can cause a lurch, so |
---|
| 971 | if you're resuming rendering after a break, call this method to reset |
---|
| 972 | the stored times |
---|
| 973 | */ |
---|
| 974 | void clearEventTimes(void); |
---|
| 975 | |
---|
| 976 | /** Sets the period over which OGRE smooths out fluctuations in frame times. |
---|
| 977 | @remarks |
---|
| 978 | OGRE by default gives you the raw frame time, but can optionally |
---|
| 979 | smooths it out over several frames, in order to reduce the |
---|
| 980 | noticeable effect of occasional hiccups in framerate. |
---|
| 981 | These smoothed values are passed back as parameters to FrameListener |
---|
| 982 | calls. |
---|
| 983 | @par |
---|
| 984 | This method allow you to tweak the smoothing period, and is expressed |
---|
| 985 | in seconds. Setting it to 0 will result in completely unsmoothed |
---|
| 986 | frame times (the default). |
---|
| 987 | */ |
---|
| 988 | void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; } |
---|
| 989 | /** Gets the period over which OGRE smooths out fluctuations in frame times. */ |
---|
| 990 | Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; } |
---|
| 991 | |
---|
| 992 | /** Register a new MovableObjectFactory which will create new MovableObject |
---|
| 993 | instances of a particular type, as identified by the getType() method. |
---|
| 994 | @remarks |
---|
| 995 | Plugin creators can create subclasses of MovableObjectFactory which |
---|
| 996 | construct custom subclasses of MovableObject for insertion in the |
---|
| 997 | scene. This is the primary way that plugins can make custom objects |
---|
| 998 | available. |
---|
| 999 | @param fact Pointer to the factory instance |
---|
| 1000 | @param overrideExisting Set this to true to override any existing |
---|
| 1001 | factories which are registered for the same type. You should only |
---|
| 1002 | change this if you are very sure you know what you're doing. |
---|
| 1003 | */ |
---|
| 1004 | void addMovableObjectFactory(MovableObjectFactory* fact, |
---|
| 1005 | bool overrideExisting = false); |
---|
| 1006 | /** Removes a previously registered MovableObjectFactory. |
---|
| 1007 | @remarks |
---|
| 1008 | All instances of objects created by this factory will be destroyed |
---|
| 1009 | before removing the factory (by calling back the factories |
---|
| 1010 | 'destroyInstance' method). The plugin writer is responsible for actually |
---|
| 1011 | destroying the factory. |
---|
| 1012 | */ |
---|
| 1013 | void removeMovableObjectFactory(MovableObjectFactory* fact); |
---|
| 1014 | /// Checks whether a factory is registered for a given MovableObject type |
---|
| 1015 | bool hasMovableObjectFactory(const String& typeName) const; |
---|
| 1016 | /// Get a MovableObjectFactory for the given type |
---|
| 1017 | MovableObjectFactory* getMovableObjectFactory(const String& typeName); |
---|
| 1018 | /** Allocate the next MovableObject type flag. |
---|
| 1019 | @remarks |
---|
| 1020 | This is done automatically if MovableObjectFactory::requestTypeFlags |
---|
| 1021 | returns true; don't call this manually unless you're sure you need to. |
---|
| 1022 | */ |
---|
| 1023 | uint32 _allocateNextMovableObjectTypeFlag(void); |
---|
| 1024 | |
---|
| 1025 | typedef ConstMapIterator<MovableObjectFactoryMap> MovableObjectFactoryIterator; |
---|
| 1026 | /** Return an iterator over all the MovableObjectFactory instances currently |
---|
| 1027 | registered. |
---|
| 1028 | */ |
---|
| 1029 | MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const; |
---|
| 1030 | |
---|
| 1031 | /** |
---|
| 1032 | * Gets the number of display monitors. |
---|
| 1033 | */ |
---|
| 1034 | unsigned int getDisplayMonitorCount() const; |
---|
| 1035 | |
---|
| 1036 | /** Get the WorkQueue for processing background tasks. |
---|
| 1037 | You are free to add new requests and handlers to this queue to |
---|
| 1038 | process your custom background tasks using the shared thread pool. |
---|
| 1039 | However, you must remember to assign yourself a new channel through |
---|
| 1040 | which to process your tasks. |
---|
| 1041 | */ |
---|
| 1042 | WorkQueue* getWorkQueue() const { return mWorkQueue; } |
---|
| 1043 | |
---|
| 1044 | /** Replace the current work queue with an alternative. |
---|
| 1045 | You can use this method to replace the internal implementation of |
---|
| 1046 | WorkQueue with your own, e.g. to externalise the processing of |
---|
| 1047 | background events. Doing so will delete the existing queue and |
---|
| 1048 | replace it with this one. |
---|
| 1049 | @param queue The new WorkQueue instance. Root will delete this work queue |
---|
| 1050 | at shutdown, so do not destroy it yourself. |
---|
| 1051 | */ |
---|
| 1052 | void setWorkQueue(WorkQueue* queue); |
---|
| 1053 | |
---|
| 1054 | /** Sets whether blend indices information needs to be passed to the GPU. |
---|
| 1055 | When entities use software animation they remove blend information such as |
---|
| 1056 | indices and weights from the vertex buffers sent to the graphic card. This function |
---|
| 1057 | can be used to limit which information is removed. |
---|
| 1058 | @param redundant Set to true to remove blend indices information. |
---|
| 1059 | */ |
---|
| 1060 | void setBlendIndicesGpuRedundant(bool redundant) { mIsBlendIndicesGpuRedundant = redundant; } |
---|
| 1061 | /** Returns whether blend indices information needs to be passed to the GPU |
---|
| 1062 | see setBlendIndicesGpuRedundant() for more information |
---|
| 1063 | */ |
---|
| 1064 | bool isBlendIndicesGpuRedundant() const { return mIsBlendIndicesGpuRedundant; } |
---|
| 1065 | |
---|
| 1066 | /** Sets whether blend weights information needs to be passed to the GPU. |
---|
| 1067 | When entities use software animation they remove blend information such as |
---|
| 1068 | indices and weights from the vertex buffers sent to the graphic card. This function |
---|
| 1069 | can be used to limit which information is removed. |
---|
| 1070 | @param redundant Set to true to remove blend weights information. |
---|
| 1071 | */ |
---|
| 1072 | void setBlendWeightsGpuRedundant(bool redundant) { mIsBlendWeightsGpuRedundant = redundant; } |
---|
| 1073 | /** Returns whether blend weights information needs to be passed to the GPU |
---|
| 1074 | see setBlendWeightsGpuRedundant() for more information |
---|
| 1075 | */ |
---|
| 1076 | bool isBlendWeightsGpuRedundant() const { return mIsBlendWeightsGpuRedundant; } |
---|
| 1077 | |
---|
| 1078 | /** Set the default minimum pixel size for object to be rendered by |
---|
| 1079 | @note |
---|
| 1080 | To use this feature see Camera::setUseMinPixelSize() |
---|
| 1081 | */ |
---|
| 1082 | void setDefaultMinPixelSize(Real pixelSize) { mDefaultMinPixelSize = pixelSize; } |
---|
| 1083 | |
---|
| 1084 | /** Get the default minimum pixel size for object to be rendered by |
---|
| 1085 | */ |
---|
| 1086 | Real getDefaultMinPixelSize() { return mDefaultMinPixelSize; } |
---|
| 1087 | |
---|
| 1088 | |
---|
| 1089 | }; |
---|
| 1090 | /** @} */ |
---|
| 1091 | /** @} */ |
---|
| 1092 | } // Namespace Ogre |
---|
| 1093 | #endif |
---|