CmRenderSystem.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  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. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __RenderSystem_H_
  25. #define __RenderSystem_H_
  26. // Precompiler options
  27. #include "CmPrerequisites.h"
  28. #include <memory>
  29. #include "CmString.h"
  30. #include "CmSamplerState.h"
  31. #include "CmCommon.h"
  32. #include "CmRenderOperation.h"
  33. #include "CmRenderSystemCapabilities.h"
  34. #include "CmRenderTarget.h"
  35. #include "CmRenderTexture.h"
  36. #include "CmGpuProgram.h"
  37. #include "CmPlane.h"
  38. #include "boost/function.hpp"
  39. #include "boost/signal.hpp"
  40. namespace CamelotEngine
  41. {
  42. /** \addtogroup Core
  43. * @{
  44. */
  45. /** \addtogroup RenderSystem
  46. * @{
  47. */
  48. typedef multimap<UINT8, RenderTarget * >::type RenderTargetPriorityMap;
  49. class TextureManager;
  50. /** Defines the functionality of a 3D API
  51. @remarks
  52. The RenderSystem class provides a base interface
  53. which abstracts the general functionality of the 3D API
  54. e.g. Direct3D or OpenGL. Whilst a few of the general
  55. methods have implementations, most of this class is
  56. abstract, requiring a subclass based on a specific API
  57. to be constructed to provide the full functionality.
  58. Note there are 2 levels to the interface - one which
  59. will be used often by the caller of the Ogre library,
  60. and one which is at a lower level and will be used by the
  61. other classes provided by Ogre. These lower level
  62. methods are prefixed with '_' to differentiate them.
  63. The advanced user of the library may use these lower
  64. level methods to access the 3D API at a more fundamental
  65. level (dealing direct with render states and rendering
  66. primitives), but still benefiting from Ogre's abstraction
  67. of exactly which 3D API is in use.
  68. @author
  69. Steven Streeting
  70. @version
  71. 1.0
  72. */
  73. class CM_EXPORT RenderSystem
  74. {
  75. public:
  76. /** Default Constructor.
  77. */
  78. RenderSystem();
  79. /** Destructor.
  80. */
  81. virtual ~RenderSystem();
  82. /** Returns the name of the rendering system.
  83. */
  84. virtual const String& getName(void) const = 0;
  85. /* @brief Start up the RenderSystem. Call before doing any operations on the render system.
  86. * Make sure all subsequent calls to the RenderSystem are done from the same thread it was started on.
  87. *
  88. * @remark If you want to access the render system from other threads, call RenderSystem::createRenderContext,
  89. * set the active context using RenderSystem::setActiveRenderContext and call the render system normally.
  90. * By default an automatically created primary render context is used.
  91. */
  92. void startUp();
  93. // TODO - Classes below (shutdown to getErrorDescription) are not yet thread safe
  94. /** Shutdown the renderer and cleanup resources.
  95. */
  96. void shutdown(void);
  97. /** Creates a new rendering window.
  98. @remarks
  99. This method creates a new rendering window as specified
  100. by the paramteters. The rendering system could be
  101. responible for only a single window (e.g. in the case
  102. of a game), or could be in charge of multiple ones (in the
  103. case of a level editor). The option to create the window
  104. as a child of another is therefore given.
  105. This method will create an appropriate subclass of
  106. RenderWindow depending on the API and platform implementation.
  107. @par
  108. After creation, this window can be retrieved using getRenderTarget().
  109. @param
  110. name The name of the window. Used in other methods
  111. later like setRenderTarget and getRenderTarget.
  112. @param
  113. width The width of the new window.
  114. @param
  115. height The height of the new window.
  116. @param
  117. fullScreen Specify true to make the window full screen
  118. without borders, title bar or menu bar.
  119. @param
  120. miscParams A NameValuePairList describing the other parameters for the new rendering window.
  121. Options are case sensitive. Unrecognised parameters will be ignored silently.
  122. These values might be platform dependent, but these are present for all platforms unless
  123. indicated otherwise:
  124. <table>
  125. <tr>
  126. <td><b>Key</b></td>
  127. <td><b>Type/Values</b></td>
  128. <td><b>Default</b></td>
  129. <td><b>Description</b></td>
  130. <td><b>Notes</b></td>
  131. </tr>
  132. <tr>
  133. <td>title</td>
  134. <td>Any string</td>
  135. <td>RenderTarget name</td>
  136. <td>The title of the window that will appear in the title bar</td>
  137. <td>&nbsp;</td>
  138. </tr>
  139. <tr>
  140. <td>colourDepth</td>
  141. <td>16, 32</td>
  142. <td>Desktop depth</td>
  143. <td>Colour depth of the resulting rendering window; only applies if fullScreen</td>
  144. <td>Win32 Specific</td>
  145. </tr>
  146. <tr>
  147. <td>left</td>
  148. <td>Positive integers</td>
  149. <td>Centred</td>
  150. <td>Screen x coordinate from left</td>
  151. <td>&nbsp;</td>
  152. </tr>
  153. <tr>
  154. <td>top</td>
  155. <td>Positive integers</td>
  156. <td>Centred</td>
  157. <td>Screen y coordinate from left</td>
  158. <td>&nbsp;</td>
  159. </tr>
  160. <tr>
  161. <td>depthBuffer</td>
  162. <td>true, false</td>
  163. <td>true</td>
  164. <td>Use depth buffer</td>
  165. <td>DirectX9 specific</td>
  166. </tr>
  167. <tr>
  168. <td>externalWindowHandle</td>
  169. <td>Win32: HWND as integer<br/>
  170. GLX: poslong:posint:poslong (display*:screen:windowHandle) or poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)</td>
  171. <td>0 (none)</td>
  172. <td>External window handle, for embedding the OGRE render in an existing window</td>
  173. <td>&nbsp;</td>
  174. </tr>
  175. <tr>
  176. <td>externalGLControl</td>
  177. <td>true, false</td>
  178. <td>false</td>
  179. <td>Let the external window control OpenGL i.e. don't select a pixel format for the window,
  180. do not change v-sync and do not swap buffer. When set to true, the calling application
  181. is responsible of OpenGL initialization and buffer swapping. It should also create an
  182. OpenGL context for its own rendering, Ogre will create one for its use. Then the calling
  183. application must also enable Ogre OpenGL context before calling any Ogre function and
  184. restore its OpenGL context after these calls.</td>
  185. <td>OpenGL specific</td>
  186. </tr>
  187. <tr>
  188. <td>externalGLContext</td>
  189. <td>Context as Unsigned Long</td>
  190. <td>0 (create own context)</td>
  191. <td>Use an externally created GL context</td>
  192. <td>OpenGL Specific</td>
  193. </tr>
  194. <tr>
  195. <td>parentWindowHandle</td>
  196. <td>Win32: HWND as integer<br/>
  197. GLX: poslong:posint:poslong (display*:screen:windowHandle) or poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)</td>
  198. <td>0 (none)</td>
  199. <td>Parent window handle, for embedding the engine in a child of an external window</td>
  200. <td>&nbsp;</td>
  201. </tr>
  202. <tr>
  203. <td>macAPI</td>
  204. <td>String: "cocoa" or "carbon"</td>
  205. <td>"carbon"</td>
  206. <td>Specifies the type of rendering window on the Mac Platform.</td>
  207. <td>&nbsp;</td>
  208. </tr>
  209. <tr>
  210. <td>macAPICocoaUseNSView</td>
  211. <td>bool "true" or "false"</td>
  212. <td>"false"</td>
  213. <td>On the Mac platform the most diffused method to embed engine in a custom application is to use Interface Builder
  214. and add to the interface an instance of OgreView.
  215. The pointer to this instance is then used as "externalWindowHandle".
  216. However, there are cases where you are NOT using Interface Builder and you get the Cocoa NSView* of an existing interface.
  217. For example, this is happens when you want to render into a Java/AWT interface.
  218. In short, by setting this flag to "true" the Ogre::Root::createRenderWindow interprets the "externalWindowHandle" as a NSView*
  219. instead of an OgreView*. See OgreOSXCocoaView.h/mm.
  220. </td>
  221. <td>&nbsp;</td>
  222. </tr>
  223. <tr>
  224. <td>FSAA</td>
  225. <td>Positive integer (usually 0, 2, 4, 8, 16)</td>
  226. <td>0</td>
  227. <td>Full screen antialiasing factor</td>
  228. <td>&nbsp;</td>
  229. </tr>
  230. <tr>
  231. <td>FSAAHint</td>
  232. <td>Depends on RenderSystem and hardware. Currently supports:<br/>
  233. "Quality": on systems that have an option to prefer higher AA quality over speed, use it</td>
  234. <td>Blank</td>
  235. <td>Full screen antialiasing hint</td>
  236. <td>&nbsp;</td>
  237. </tr>
  238. <tr>
  239. <td>displayFrequency</td>
  240. <td>Refresh rate in Hertz (e.g. 60, 75, 100)</td>
  241. <td>Desktop vsync rate</td>
  242. <td>Display frequency rate, for fullscreen mode</td>
  243. <td>&nbsp;</td>
  244. </tr>
  245. <tr>
  246. <td>vsync</td>
  247. <td>true, false</td>
  248. <td>false</td>
  249. <td>Synchronize buffer swaps to monitor vsync, eliminating tearing at the expense of a fixed frame rate</td>
  250. <td>&nbsp;</td>
  251. </tr>
  252. <tr>
  253. <td>vsyncInterval</td>
  254. <td>1, 2, 3, 4</td>
  255. <td>1</td>
  256. <td>If vsync is enabled, the minimum number of vertical blanks that should occur between renders.
  257. For example if vsync is enabled, the refresh rate is 60 and this is set to 2, then the
  258. frame rate will be locked at 30.</td>
  259. <td>&nbsp;</td>
  260. </tr>
  261. <tr>
  262. <td>border</td>
  263. <td>none, fixed, resize</td>
  264. <td>resize</td>
  265. <td>The type of window border (in windowed mode)</td>
  266. <td>&nbsp;</td>
  267. </tr>
  268. <tr>
  269. <td>outerDimensions</td>
  270. <td>true, false</td>
  271. <td>false</td>
  272. <td>Whether the width/height is expressed as the size of the
  273. outer window, rather than the content area</td>
  274. <td>&nbsp;</td>
  275. </tr>
  276. <tr>
  277. <td>useNVPerfHUD</td>
  278. <td>true, false</td>
  279. <td>false</td>
  280. <td>Enable the use of nVidia NVPerfHUD</td>
  281. <td>&nbsp;</td>
  282. </tr>
  283. <tr>
  284. <td>gamma</td>
  285. <td>true, false</td>
  286. <td>false</td>
  287. <td>Enable hardware conversion from linear colour space to gamma
  288. colour space on rendering to the window.</td>
  289. <td>&nbsp;</td>
  290. </tr>
  291. */
  292. RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
  293. bool fullScreen, const NameValuePairList *miscParams = 0);
  294. virtual void createRenderWindow_internal(const String &name, unsigned int width, unsigned int height,
  295. bool fullScreen, const NameValuePairList& miscParams, AsyncOp& asyncOp) = 0;
  296. /** Attaches the passed render target to the render system.
  297. */
  298. virtual void attachRenderTarget_internal(RenderTarget &target);
  299. /** Detaches the render target from the render system.
  300. @note
  301. If the render target cannot be found, NULL is returned.
  302. */
  303. virtual void detachRenderTarget_internal(RenderTarget& renderTarget);
  304. /** Destroys a render window */
  305. virtual void destroyRenderWindow_internal(RenderWindow* renderWindow);
  306. /** Destroys a render texture */
  307. virtual void destroyRenderTexture_internal(RenderTexture* renderTexture);
  308. /** Destroys a render target of any sort */
  309. virtual void destroyRenderTarget_internal(RenderTarget* renderTarget);
  310. /** Defines whether or now fullscreen render windows wait for the vertical blank before flipping buffers.
  311. @remarks
  312. By default, all rendering windows wait for a vertical blank (when the CRT beam turns off briefly to move
  313. from the bottom right of the screen back to the top left) before flipping the screen buffers. This ensures
  314. that the image you see on the screen is steady. However it restricts the frame rate to the refresh rate of
  315. the monitor, and can slow the frame rate down. You can speed this up by not waiting for the blank, but
  316. this has the downside of introducing 'tearing' artefacts where part of the previous frame is still displayed
  317. as the buffers are switched. Speed vs quality, you choose.
  318. @note
  319. Has NO effect on windowed mode render targets. Only affects fullscreen mode.
  320. @param
  321. enabled If true, the system waits for vertical blanks - quality over speed. If false it doesn't - speed over quality.
  322. */
  323. void setWaitForVerticalBlank(bool enabled);
  324. void setWaitForVerticalBlank_internal(bool enabled);
  325. /** Returns true if the system is synchronising frames with the monitor vertical blank.
  326. */
  327. bool getWaitForVerticalBlank(void) const;
  328. bool getWaitForVerticalBlank_internal(void) const;
  329. // ------------------------------------------------------------------------
  330. // Internal Rendering Access
  331. // All methods below here are normally only called by other Camelot classes
  332. // They can be called by library user if required
  333. // ------------------------------------------------------------------------
  334. /** Utility function for setting all the properties of a texture unit at once.
  335. This method is also worth using over the individual texture unit settings because it
  336. only sets those settings which are different from the current settings for this
  337. unit, thus minimising render state changes.
  338. */
  339. void setTextureUnitSettings(UINT16 texUnit, const TexturePtr& texture, const SamplerState& samplerState);
  340. virtual void setTextureUnitSettings_internal(UINT16 texUnit, const TexturePtr& texture, const SamplerState& samplerState);
  341. /** Turns off a texture unit. */
  342. void disableTextureUnit(UINT16 texUnit);
  343. virtual void disableTextureUnit_internal(UINT16 texUnit);
  344. /** Disables all texture units from the given unit upwards */
  345. void disableTextureUnitsFrom(UINT16 texUnit);
  346. virtual void disableTextureUnitsFrom_internal(UINT16 texUnit);
  347. /** Sets the size of points and how they are attenuated with distance.
  348. @remarks
  349. When performing point rendering or point sprite rendering,
  350. point size can be attenuated with distance. The equation for
  351. doing this is attenuation = 1 / (constant + linear * dist + quadratic * d^2) .
  352. @par
  353. For example, to disable distance attenuation (constant screensize)
  354. you would set constant to 1, and linear and quadratic to 0. A
  355. standard perspective attenuation would be 0, 1, 0 respectively.
  356. */
  357. void setPointParameters(float size, bool attenuationEnabled,
  358. float constant, float linear, float quadratic, float minSize, float maxSize);
  359. virtual void setPointParameters_internal(float size, bool attenuationEnabled,
  360. float constant, float linear, float quadratic, float minSize, float maxSize) = 0;
  361. /**
  362. Sets the texture to bind to a given texture unit.
  363. User processes would not normally call this direct unless rendering
  364. primitives themselves.
  365. @param unit The index of the texture unit to modify. Multitexturing
  366. hardware can support multiple units (see
  367. RenderSystemCapabilites::getNumTextureUnits)
  368. @param enabled Boolean to turn the unit on/off
  369. @param texPtr Pointer to the texture to use.
  370. */
  371. void setTexture(UINT16 unit, bool enabled,
  372. const TexturePtr &texPtr);
  373. virtual void setTexture_internal(UINT16 unit, bool enabled,
  374. const TexturePtr &texPtr) = 0;
  375. /** Binds a texture to a vertex sampler.
  376. @remarks
  377. Not all rendersystems support separate vertex samplers. For those that
  378. do, you can set a texture for them, separate to the regular texture
  379. samplers, using this method. For those that don't, you should use the
  380. regular texture samplers which are shared between the vertex and
  381. fragment units; calling this method will throw an exception.
  382. @see RenderSystemCapabilites::getVertexTextureUnitsShared
  383. */
  384. void setVertexTexture(UINT16 unit, const TexturePtr& tex);
  385. virtual void setVertexTexture_internal(UINT16 unit, const TexturePtr& tex);
  386. /** Sets the filtering options for a given texture unit.
  387. @param unit The texture unit to set the filtering options for
  388. @param minFilter The filter used when a texture is reduced in size
  389. @param magFilter The filter used when a texture is magnified
  390. @param mipFilter The filter used between mipmap levels, FO_NONE disables mipmapping
  391. */
  392. void setTextureFiltering(UINT16 unit, FilterOptions minFilter,
  393. FilterOptions magFilter, FilterOptions mipFilter);
  394. virtual void setTextureFiltering_internal(UINT16 unit, FilterOptions minFilter,
  395. FilterOptions magFilter, FilterOptions mipFilter);
  396. /** Sets a single filter for a given texture unit.
  397. @param unit The texture unit to set the filtering options for
  398. @param ftype The filter type
  399. @param filter The filter to be used
  400. */
  401. void setTextureFiltering(UINT16 unit, FilterType ftype, FilterOptions filter);
  402. virtual void setTextureFiltering_internal(UINT16 unit, FilterType ftype, FilterOptions filter) = 0;
  403. /** Sets the maximal anisotropy for the specified texture unit.*/
  404. void setTextureAnisotropy(UINT16 unit, unsigned int maxAnisotropy);
  405. virtual void setTextureAnisotropy_internal(UINT16 unit, unsigned int maxAnisotropy) = 0;
  406. /** Sets the texture addressing mode for a texture unit.*/
  407. void setTextureAddressingMode(UINT16 unit, const SamplerState::UVWAddressingMode& uvw);
  408. virtual void setTextureAddressingMode_internal(UINT16 unit, const SamplerState::UVWAddressingMode& uvw) = 0;
  409. /** Sets the texture border color for a texture unit.*/
  410. void setTextureBorderColor(UINT16 unit, const Color& color);
  411. virtual void setTextureBorderColor_internal(UINT16 unit, const Color& color) = 0;
  412. /** Sets the mipmap bias value for a given texture unit.
  413. @remarks
  414. This allows you to adjust the mipmap calculation up or down for a
  415. given texture unit. Negative values force a larger mipmap to be used,
  416. positive values force a smaller mipmap to be used. Units are in numbers
  417. of levels, so +1 forces the mipmaps to one smaller level.
  418. @note Only does something if render system has capability RSC_MIPMAP_LOD_BIAS.
  419. */
  420. void setTextureMipmapBias(UINT16 unit, float bias);
  421. virtual void setTextureMipmapBias_internal(UINT16 unit, float bias) = 0;
  422. /** Sets the global blending factors for combining subsequent renders with the existing frame contents.
  423. The result of the blending operation is:</p>
  424. <p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
  425. Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
  426. enumerated type.
  427. By changing the operation you can change addition between the source and destination pixels to a different operator.
  428. @param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
  429. @param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
  430. @param op The blend operation mode for combining pixels
  431. */
  432. void setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op = SBO_ADD);
  433. virtual void setSceneBlending_internal(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op = SBO_ADD) = 0;
  434. /** Sets the global blending factors for combining subsequent renders with the existing frame contents.
  435. The result of the blending operation is:</p>
  436. <p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
  437. Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
  438. enumerated type.
  439. @param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
  440. @param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
  441. @param sourceFactorAlpha The source factor in the above calculation for the alpha channel, i.e. multiplied by the texture alpha components.
  442. @param destFactorAlpha The destination factor in the above calculation for the alpha channel, i.e. multiplied by the pixel alpha components.
  443. @param op The blend operation mode for combining pixels
  444. @param alphaOp The blend operation mode for combining pixel alpha values
  445. */
  446. void setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha,
  447. SceneBlendFactor destFactorAlpha, SceneBlendOperation op = SBO_ADD, SceneBlendOperation alphaOp = SBO_ADD);
  448. virtual void setSeparateSceneBlending_internal(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha,
  449. SceneBlendFactor destFactorAlpha, SceneBlendOperation op = SBO_ADD, SceneBlendOperation alphaOp = SBO_ADD) = 0;
  450. /** Sets the global alpha rejection approach for future renders.
  451. By default images are rendered regardless of texture alpha. This method lets you change that.
  452. @param func The comparison function which must pass for a pixel to be written.
  453. @param val The value to compare each pixels alpha value to (0-255)
  454. @param alphaToCoverage Whether to enable alpha to coverage, if supported
  455. */
  456. void setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage);
  457. virtual void setAlphaRejectSettings_internal(CompareFunction func, unsigned char value, bool alphaToCoverage) = 0;
  458. /**
  459. * Signifies the beginning of a frame, i.e. the start of rendering on a single viewport. Will occur
  460. * several times per complete frame if multiple viewports exist.
  461. */
  462. void beginFrame(void);
  463. virtual void beginFrame_internal(void) = 0;
  464. /**
  465. * Ends rendering of a frame to the current viewport.
  466. */
  467. void endFrame(void);
  468. virtual void endFrame_internal(void) = 0;
  469. /**
  470. Sets the provided viewport as the active one for future
  471. rendering operations. This viewport is aware of it's own
  472. camera and render target. Must be implemented by subclass.
  473. @param target Viewport to render to.
  474. */
  475. void setViewport(const Viewport& vp);
  476. virtual void setViewport_internal(const Viewport& vp) = 0;
  477. /** Get the current active viewport for rendering. */
  478. virtual Viewport getViewport_internal(void);
  479. /** Sets the culling mode for the render system based on the 'vertex winding'.
  480. A typical way for the rendering engine to cull triangles is based on the
  481. 'vertex winding' of triangles. Vertex winding refers to the direction in
  482. which the vertices are passed or indexed to in the rendering operation as viewed
  483. from the camera, and will wither be clockwise or anticlockwise (that's 'counterclockwise' for
  484. you Americans out there ;) The default is CULL_CLOCKWISE i.e. that only triangles whose vertices
  485. are passed/indexed in anticlockwise order are rendered - this is a common approach and is used in 3D studio models
  486. for example. You can alter this culling mode if you wish but it is not advised unless you know what you are doing.
  487. You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex
  488. winding is uncertain.
  489. */
  490. void setCullingMode(CullingMode mode);
  491. virtual void setCullingMode_internal(CullingMode mode) = 0;
  492. CullingMode getCullingMode_internal(void) const;
  493. virtual CullingMode getCullingMode(void) const;
  494. /** Sets the mode of operation for depth buffer tests from this point onwards.
  495. Sometimes you may wish to alter the behaviour of the depth buffer to achieve
  496. special effects. Because it's unlikely that you'll set these options for an entire frame,
  497. but rather use them to tweak settings between rendering objects, this is an internal
  498. method (indicated by the '_' prefix) which will be used by a SceneManager implementation
  499. rather than directly from the client application.
  500. If this method is never called the settings are automatically the same as the default parameters.
  501. @param depthTest If true, the depth buffer is tested for each pixel and the frame buffer is only updated
  502. if the depth function test succeeds. If false, no test is performed and pixels are always written.
  503. @param depthWrite If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
  504. If false, the depth buffer is left unchanged even if a new pixel is written.
  505. @param depthFunction Sets the function required for the depth test.
  506. */
  507. void setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL);
  508. virtual void setDepthBufferParams_internal(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
  509. /** Sets whether or not the depth buffer check is performed before a pixel write.
  510. @param enabled If true, the depth buffer is tested for each pixel and the frame buffer is only updated
  511. if the depth function test succeeds. If false, no test is performed and pixels are always written.
  512. */
  513. void setDepthBufferCheckEnabled(bool enabled = true);
  514. virtual void setDepthBufferCheckEnabled_internal(bool enabled = true) = 0;
  515. /** Sets whether or not the depth buffer is updated after a pixel write.
  516. @param enabled If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
  517. If false, the depth buffer is left unchanged even if a new pixel is written.
  518. */
  519. void setDepthBufferWriteEnabled(bool enabled = true);
  520. virtual void setDepthBufferWriteEnabled_internal(bool enabled = true) = 0;
  521. /** Sets the comparison function for the depth buffer check.
  522. Advanced use only - allows you to choose the function applied to compare the depth values of
  523. new and existing pixels in the depth buffer. Only an issue if the deoth buffer check is enabled
  524. (see _setDepthBufferCheckEnabled)
  525. @param func The comparison between the new depth and the existing depth which must return true
  526. for the new pixel to be written.
  527. */
  528. void setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
  529. virtual void setDepthBufferFunction_internal(CompareFunction func = CMPF_LESS_EQUAL) = 0;
  530. /** Sets whether or not colour buffer writing is enabled, and for which channels.
  531. @remarks
  532. For some advanced effects, you may wish to turn off the writing of certain colour
  533. channels, or even all of the colour channels so that only the depth buffer is updated
  534. in a rendering pass. However, the chances are that you really want to use this option
  535. through the Material class.
  536. @param red, green, blue, alpha Whether writing is enabled for each of the 4 colour channels. */
  537. void setColorBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
  538. virtual void setColorBufferWriteEnabled_internal(bool red, bool green, bool blue, bool alpha) = 0;
  539. /** Sets the depth bias, NB you should use the Material version of this.
  540. @remarks
  541. When polygons are coplanar, you can get problems with 'depth fighting' where
  542. the pixels from the two polys compete for the same screen pixel. This is particularly
  543. a problem for decals (polys attached to another surface to represent details such as
  544. bulletholes etc.).
  545. @par
  546. A way to combat this problem is to use a depth bias to adjust the depth buffer value
  547. used for the decal such that it is slightly higher than the true value, ensuring that
  548. the decal appears on top.
  549. @note
  550. The final bias value is a combination of a constant bias and a bias proportional
  551. to the maximum depth slope of the polygon being rendered. The final bias
  552. is constantBias + slopeScaleBias * maxslope. Slope scale biasing is
  553. generally preferable but is not available on older hardware.
  554. @param constantBias The constant bias value, expressed as a value in
  555. homogeneous depth coordinates.
  556. @param slopeScaleBias The bias value which is factored by the maximum slope
  557. of the polygon, see the description above. This is not supported by all
  558. cards.
  559. */
  560. void setDepthBias(float constantBias, float slopeScaleBias = 0.0f);
  561. virtual void setDepthBias_internal(float constantBias, float slopeScaleBias = 0.0f) = 0;
  562. /** Sets how to rasterise triangles, as points, wireframe or solid polys. */
  563. void setPolygonMode(PolygonMode level);
  564. virtual void setPolygonMode_internal(PolygonMode level) = 0;
  565. /** Turns stencil buffer checking on or off.
  566. @remarks
  567. Stencilling (masking off areas of the rendering target based on the stencil
  568. buffer) can be turned on or off using this method. By default, stencilling is
  569. disabled.
  570. */
  571. void setStencilCheckEnabled(bool enabled);
  572. virtual void setStencilCheckEnabled_internal(bool enabled) = 0;
  573. /** This method allows you to set all the stencil buffer parameters in one call.
  574. @remarks
  575. The stencil buffer is used to mask out pixels in the render target, allowing
  576. you to do effects like mirrors, cut-outs, stencil shadows and more. Each of
  577. your batches of rendering is likely to ignore the stencil buffer,
  578. update it with new values, or apply it to mask the output of the render.
  579. The stencil test is:<PRE>
  580. (Reference Value & Mask) CompareFunction (Stencil Buffer Value & Mask)</PRE>
  581. The result of this will cause one of 3 actions depending on whether the test fails,
  582. succeeds but with the depth buffer check still failing, or succeeds with the
  583. depth buffer check passing too.
  584. @par
  585. Unlike other render states, stencilling is left for the application to turn
  586. on and off when it requires. This is because you are likely to want to change
  587. parameters between batches of arbitrary objects and control the ordering yourself.
  588. In order to batch things this way, you'll want to use OGRE's separate render queue
  589. groups (see RenderQueue) and register a RenderQueueListener to get notifications
  590. between batches.
  591. @par
  592. There are individual state change methods for each of the parameters set using
  593. this method.
  594. Note that the default values in this method represent the defaults at system
  595. start up too.
  596. @param func The comparison function applied.
  597. @param refValue The reference value used in the comparison
  598. @param mask The bitmask applied to both the stencil value and the reference value
  599. before comparison
  600. @param stencilFailOp The action to perform when the stencil check fails
  601. @param depthFailOp The action to perform when the stencil check passes, but the
  602. depth buffer check still fails
  603. @param passOp The action to take when both the stencil and depth check pass.
  604. @param twoSidedOperation If set to true, then if you render both back and front faces
  605. (you'll have to turn off culling) then these parameters will apply for front faces,
  606. and the inverse of them will happen for back faces (keep remains the same).
  607. */
  608. void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS,
  609. UINT32 refValue = 0, UINT32 mask = 0xFFFFFFFF,
  610. StencilOperation stencilFailOp = SOP_KEEP,
  611. StencilOperation depthFailOp = SOP_KEEP,
  612. StencilOperation passOp = SOP_KEEP,
  613. bool twoSidedOperation = false);
  614. virtual void setStencilBufferParams_internal(CompareFunction func = CMPF_ALWAYS_PASS,
  615. UINT32 refValue = 0, UINT32 mask = 0xFFFFFFFF,
  616. StencilOperation stencilFailOp = SOP_KEEP,
  617. StencilOperation depthFailOp = SOP_KEEP,
  618. StencilOperation passOp = SOP_KEEP,
  619. bool twoSidedOperation = false) = 0;
  620. /** Sets the current vertex declaration, ie the source of vertex data. */
  621. virtual void setVertexDeclaration_internal(VertexDeclarationPtr decl) = 0;
  622. /** Sets the current vertex buffer binding state. */
  623. virtual void setVertexBufferBinding_internal(VertexBufferBinding* binding) = 0;
  624. /**
  625. Render something to the active viewport.
  626. Low-level rendering interface to perform rendering
  627. operations. Unlikely to be used directly by client
  628. applications, since the SceneManager and various support
  629. classes will be responsible for calling this method.
  630. Can only be called between _beginScene and _endScene
  631. @param op A rendering operation instance, which contains
  632. details of the operation to be performed.
  633. */
  634. void render(const RenderOperation& op);
  635. virtual void render_internal(const RenderOperation& op);
  636. /** Gets the capabilities of the render system. */
  637. const RenderSystemCapabilities* getCapabilities_internal(void) const;
  638. /** Returns the driver version.
  639. */
  640. virtual const DriverVersion& getDriverVersion_internal(void) const;
  641. /** Binds a given GpuProgram (but not the parameters).
  642. @remarks Only one GpuProgram of each type can be bound at once, binding another
  643. one will simply replace the existing one.
  644. */
  645. void bindGpuProgram(GpuProgramHandle prg);
  646. virtual void bindGpuProgram_internal(GpuProgramHandle prg);
  647. /** Bind Gpu program parameters.
  648. @param gptype The type of program to bind the parameters to
  649. @param params The parameters to bind
  650. @param variabilityMask A mask of GpuParamVariability identifying which params need binding
  651. */
  652. void bindGpuProgramParameters(GpuProgramType gptype,
  653. GpuProgramParametersSharedPtr params, UINT16 variabilityMask);
  654. virtual void bindGpuProgramParameters_internal(GpuProgramType gptype,
  655. GpuProgramParametersSharedPtr params, UINT16 variabilityMask) = 0;
  656. /** Unbinds GpuPrograms of a given GpuProgramType.
  657. @remarks
  658. This returns the pipeline to fixed-function processing for this type.
  659. */
  660. void unbindGpuProgram(GpuProgramType gptype);
  661. virtual void unbindGpuProgram_internal(GpuProgramType gptype);
  662. /** Returns whether or not a Gpu program of the given type is currently bound. */
  663. virtual bool isGpuProgramBound_internal(GpuProgramType gptype);
  664. /** Sets the user clipping region.
  665. */
  666. void setClipPlanes(const PlaneList& clipPlanes);
  667. virtual void setClipPlanes_internal(const PlaneList& clipPlanes);
  668. /** Add a user clipping plane. */
  669. void addClipPlane(const Plane &p);
  670. virtual void addClipPlane_internal (const Plane &p);
  671. /** Add a user clipping plane. */
  672. void addClipPlane(float A, float B, float C, float D);
  673. virtual void addClipPlane_internal (float A, float B, float C, float D);
  674. /** Clears the user clipping region.
  675. */
  676. void resetClipPlanes();
  677. virtual void resetClipPlanes_internal();
  678. /** Internal method for swapping all the buffers on all render targets,
  679. if _updateAllRenderTargets was called with a 'false' parameter. */
  680. void swapAllRenderTargetBuffers(bool waitForVsync = true);
  681. virtual void swapAllRenderTargetBuffers_internal(bool waitForVsync = true);
  682. /** Sets whether or not vertex windings set should be inverted; this can be important
  683. for rendering reflections. */
  684. void setInvertVertexWinding(bool invert);
  685. virtual void setInvertVertexWinding_internal(bool invert);
  686. /** Indicates whether or not the vertex windings set will be inverted for the current render (e.g. reflections)
  687. @see RenderSystem::setInvertVertexWinding
  688. */
  689. bool getInvertVertexWinding(void) const;
  690. virtual bool getInvertVertexWinding_internal(void) const;
  691. /** Sets the 'scissor region' ie the region of the target in which rendering can take place.
  692. @remarks
  693. This method allows you to 'mask off' rendering in all but a given rectangular area
  694. as identified by the parameters to this method.
  695. @note
  696. Not all systems support this method. Check the RenderSystemCapabilities for the
  697. RSC_SCISSOR_TEST capability to see if it is supported.
  698. @param enabled True to enable the scissor test, false to disable it.
  699. @param left, top, right, bottom The location of the corners of the rectangle, expressed in
  700. <i>pixels</i>.
  701. */
  702. void setScissorTest(bool enabled, UINT32 left = 0, UINT32 top = 0,
  703. UINT32 right = 800, UINT32 bottom = 600);
  704. virtual void setScissorTest_internal(bool enabled, UINT32 left = 0, UINT32 top = 0,
  705. UINT32 right = 800, UINT32 bottom = 600) = 0;
  706. /** Clears one or more frame buffers on the active render target.
  707. @param buffers Combination of one or more elements of FrameBufferType
  708. denoting which buffers are to be cleared
  709. @param colour The colour to clear the colour buffer with, if enabled
  710. @param depth The value to initialise the depth buffer with, if enabled
  711. @param stencil The value to initialise the stencil buffer with, if enabled.
  712. */
  713. void clearFrameBuffer(unsigned int buffers,
  714. const Color& color = Color::Black,
  715. float depth = 1.0f, unsigned short stencil = 0);
  716. virtual void clearFrameBuffer_internal(unsigned int buffers,
  717. const Color& color = Color::Black,
  718. float depth = 1.0f, unsigned short stencil = 0) = 0;
  719. /**
  720. * Set current render target to target, enabling its device context if needed
  721. */
  722. void setRenderTarget(RenderTarget *target);
  723. virtual void setRenderTarget_internal(RenderTarget *target) = 0;
  724. /************************************************************************/
  725. /* UTILITY METHODS */
  726. /************************************************************************/
  727. /** Get the native VertexElementType for a compact 32-bit colour value
  728. for this rendersystem.
  729. */
  730. virtual VertexElementType getColorVertexElementType(void) const = 0;
  731. /** Converts a uniform projection matrix to suitable for this render system.
  732. @remarks
  733. Because different APIs have different requirements (some incompatible) for the
  734. projection matrix, this method allows each to implement their own correctly and pass
  735. back a generic Camelot matrix for storage in the engine.
  736. */
  737. virtual void convertProjectionMatrix(const Matrix4& matrix,
  738. Matrix4& dest, bool forGpuProgram = false) = 0;
  739. /** Returns the horizontal texel offset value required for mapping
  740. texel origins to pixel origins in this rendersystem.
  741. @remarks
  742. Since rendersystems sometimes disagree on the origin of a texel,
  743. mapping from texels to pixels can sometimes be problematic to
  744. implement generically. This method allows you to retrieve the offset
  745. required to map the origin of a texel to the origin of a pixel in
  746. the horizontal direction.
  747. */
  748. virtual float getHorizontalTexelOffset(void) = 0;
  749. /** Returns the vertical texel offset value required for mapping
  750. texel origins to pixel origins in this rendersystem.
  751. @remarks
  752. Since rendersystems sometimes disagree on the origin of a texel,
  753. mapping from texels to pixels can sometimes be problematic to
  754. implement generically. This method allows you to retrieve the offset
  755. required to map the origin of a texel to the origin of a pixel in
  756. the vertical direction.
  757. */
  758. virtual float getVerticalTexelOffset(void) = 0;
  759. /** Gets the minimum (closest) depth value to be used when rendering
  760. using identity transforms.
  761. @remarks
  762. When using identity transforms you can manually set the depth
  763. of a vertex; however the input values required differ per
  764. rendersystem. This method lets you retrieve the correct value.
  765. @see Renderable::getUseIdentityView, Renderable::getUseIdentityProjection
  766. */
  767. virtual float getMinimumDepthInputValue(void) = 0;
  768. /** Gets the maximum (farthest) depth value to be used when rendering
  769. using identity transforms.
  770. @remarks
  771. When using identity transforms you can manually set the depth
  772. of a vertex; however the input values required differ per
  773. rendersystem. This method lets you retrieve the correct value.
  774. @see Renderable::getUseIdentityView, Renderable::getUseIdentityProjection
  775. */
  776. virtual float getMaximumDepthInputValue(void) = 0;
  777. /************************************************************************/
  778. /* INTERNAL DATA & METHODS */
  779. /************************************************************************/
  780. protected:
  781. /** The render targets. */
  782. vector<RenderTarget*>::type mRenderTargets;
  783. /** The render targets, ordered by priority. */
  784. RenderTargetPriorityMap mPrioritisedRenderTargets;
  785. /** The Active render target. */
  786. RenderTarget * mActiveRenderTarget;
  787. /** The Active GPU programs and gpu program parameters*/
  788. GpuProgramParametersSharedPtr mActiveVertexGpuProgramParameters;
  789. GpuProgramParametersSharedPtr mActiveGeometryGpuProgramParameters;
  790. GpuProgramParametersSharedPtr mActiveFragmentGpuProgramParameters;
  791. // Active viewport (dest for future rendering operations)
  792. Viewport mActiveViewport;
  793. CullingMode mCullingMode;
  794. bool mVsync;
  795. unsigned int mVSyncInterval;
  796. bool mInvertVertexWinding;
  797. /// Texture units from this upwards are disabled
  798. UINT16 mDisabledTexUnitsFrom;
  799. bool mVertexProgramBound;
  800. bool mGeometryProgramBound;
  801. bool mFragmentProgramBound;
  802. // Recording user clip planes
  803. PlaneList mClipPlanes;
  804. // Indicator that we need to re-set the clip planes on next render call
  805. bool mClipPlanesDirty;
  806. /// Used to store the capabilities of the graphics card
  807. RenderSystemCapabilities* mCurrentCapabilities;
  808. virtual void startUp_internal();
  809. virtual void shutdown_internal();
  810. /// Internal method used to set the underlying clip planes when needed
  811. virtual void setClipPlanesImpl(const PlaneList& clipPlanes) = 0;
  812. /** Query the real capabilities of the GPU and driver in the RenderSystem*/
  813. virtual RenderSystemCapabilities* createRenderSystemCapabilities() const = 0;
  814. /** Initialize the render system from the capabilities*/
  815. virtual void initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps, RenderTarget* primary) = 0;
  816. /** Create a MultiRenderTarget, which is a render target that renders to multiple RenderTextures
  817. at once. Surfaces can be bound and unbound at will.
  818. This fails if mCapabilities->getNumMultiRenderTargets() is smaller than 2.
  819. */
  820. virtual MultiRenderTarget * createMultiRenderTarget(const String & name) = 0;
  821. /** Returns a description of an error code.
  822. */
  823. virtual String getErrorDescription(long errorNumber) const = 0;
  824. DriverVersion mDriverVersion;
  825. /************************************************************************/
  826. /* THREADING */
  827. /************************************************************************/
  828. class RenderWorkerFunc CM_THREAD_WORKER_INHERIT
  829. {
  830. public:
  831. RenderWorkerFunc(RenderSystem* rs);
  832. void operator()();
  833. private:
  834. RenderSystem* mRS;
  835. };
  836. RenderWorkerFunc* mRenderThreadFunc;
  837. bool mRenderThreadShutdown;
  838. CM_MUTEX(mActiveContextMutex)
  839. CM_THREAD_ID_TYPE mRenderThreadId;
  840. CM_THREAD_SYNCHRONISER(mRenderThreadStartCondition)
  841. CM_MUTEX(mRenderThreadStartMutex)
  842. CM_MUTEX(mCommandQueueMutex)
  843. CM_THREAD_SYNCHRONISER(mCommandReadyCondition)
  844. CM_MUTEX(mCommandNotifyMutex)
  845. CM_THREAD_SYNCHRONISER(mCommandCompleteCondition)
  846. #if CM_THREAD_SUPPORT
  847. CM_THREAD_TYPE* mRenderThread;
  848. #endif
  849. CommandQueue* mCommandQueue;
  850. UINT32 mMaxCommandNotifyId; // ID that will be assigned to the next command with a notifier callback
  851. vector<UINT32>::type mCommandsCompleted; // Completed commands that have notifier callbacks set up
  852. // Currently active context. All new commands will be executed on this context.
  853. mutable RenderSystemContextPtr mActiveContext;
  854. /**
  855. * @brief Initializes a separate render thread. Should only be called once.
  856. */
  857. void initRenderThread();
  858. /**
  859. * @brief Main function of the render thread. Called once thread is started.
  860. */
  861. void runRenderThread();
  862. /**
  863. * @brief Shutdowns the render thread. It will complete all ready commands
  864. * before shutdown.
  865. */
  866. void shutdownRenderThread();
  867. /**
  868. * @brief Throws an exception if current thread isn't the render thread;
  869. */
  870. void throwIfNotRenderThread() const;
  871. /**
  872. * @brief Throws an exception if current thread isn't the thread the active context is initialized on
  873. */
  874. void throwIfInvalidContextThread() const;
  875. /**
  876. * @brief Blocks the calling thread until the command with the specified ID completes.
  877. * Make sure that the specified ID actually exists, otherwise this will block forever.
  878. */
  879. void blockUntilCommandCompleted(UINT32 commandId);
  880. /**
  881. * @brief Callback called by the command list when a specific command finishes executing.
  882. * This is only called on commands that have a special notify on complete flag set.
  883. *
  884. * @param commandId Identifier for the command.
  885. */
  886. void commandCompletedNotify(UINT32 commandId);
  887. public:
  888. /**
  889. * @brief Returns the id of the render thread. If a separate render thread
  890. * is not used, then it returns the id of the thread RenderSystem
  891. * was initialized on.
  892. */
  893. CM_THREAD_ID_TYPE getRenderThreadId() const { return mRenderThreadId; }
  894. /**
  895. * @brief Creates a new render system context that you can use for rendering on
  896. * a non-render thread. You can have as many of these as you wish, the only limitation
  897. * is that you do not use a single instance on more than one thread. Each thread
  898. * requires its own context. The context will be bound to the thread you call this method on.
  899. */
  900. DeferredRenderContextPtr createDeferredContext();
  901. /**
  902. * @brief Queues a new command that will be added to the global command queue. You are allowed to call this from any thread,
  903. * however be aware that it involves possibly slow synchronization primitives, so limit your usage.
  904. *
  905. * @param blockUntilComplete If true the thread will be blocked until the command executes. Be aware that there be many commands queued before it
  906. * and they all need to be executed in order before the current command is reached, which might take a long time.
  907. *
  908. * @see CommandQueue::queueReturn
  909. */
  910. AsyncOp queueReturnCommand(boost::function<void(AsyncOp&)> commandCallback, bool blockUntilComplete = false);
  911. /**
  912. * @brief Queues a new command that will be added to the global command queue.You are allowed to call this from any thread,
  913. * however be aware that it involves possibly slow synchronization primitives, so limit your usage.
  914. *
  915. * @param blockUntilComplete If true the thread will be blocked until the command executes. Be aware that there be many commands queued before it
  916. * and they all need to be executed in order before the current command is reached, which might take a long time.
  917. * @see CommandQueue::queue
  918. */
  919. void queueCommand(boost::function<void()> commandCallback, bool blockUntilComplete = false);
  920. };
  921. /** @} */
  922. /** @} */
  923. }
  924. #endif