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