OGLGraphics.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  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. #pragma once
  24. #include "Color.h"
  25. #include "HashMap.h"
  26. #include "Matrix3x4.h"
  27. #include "Object.h"
  28. #include "Rect.h"
  29. #include "GraphicsDefs.h"
  30. class Image;
  31. class IndexBuffer;
  32. class Matrix3;
  33. class Matrix4;
  34. class Matrix3x4;
  35. class GPUObject;
  36. class GraphicsImpl;
  37. class RenderSurface;
  38. class ShaderProgram;
  39. class ShaderVariation;
  40. class Texture;
  41. class Texture2D;
  42. class TextureCube;
  43. class Vector3;
  44. class Vector4;
  45. class VertexBuffer;
  46. typedef Map<Pair<ShaderVariation*, ShaderVariation*>, SharedPtr<ShaderProgram> > ShaderProgramMap;
  47. /// Graphics subsystem. Manages the application window, rendering state and GPU resources
  48. class Graphics : public Object
  49. {
  50. OBJECT(Graphics);
  51. public:
  52. /// Construct
  53. Graphics(Context* context_);
  54. /// Destruct. Close the window and release the Direct3D9 device
  55. virtual ~Graphics();
  56. /// Set window title
  57. void SetWindowTitle(const String& windowTitle);
  58. /// Set screen mode. In deferred rendering modes multisampling means edge filtering instead of MSAA
  59. bool SetMode(RenderMode mode, int width, int height, bool fullscreen, bool vsync, int multiSample);
  60. /// Set screen resolution only
  61. bool SetMode(int width, int height);
  62. /// Set rendering mode only
  63. bool SetMode(RenderMode mode);
  64. /// Toggle between full screen and windowed mode
  65. bool ToggleFullscreen();
  66. /// Close the window
  67. void Close();
  68. /// Take a screenshot
  69. bool TakeScreenShot(Image& destImage);
  70. /// Set whether to flush GPU command queue at the end of each frame. Default true
  71. void SetFlushGPU(bool enable);
  72. /// Begin frame rendering
  73. bool BeginFrame();
  74. /// End frame rendering and swap buffers
  75. void EndFrame();
  76. /// Clear any or all of render target, depth buffer and stencil buffer
  77. void Clear(unsigned flags, const Color& color = Color(0.0f, 0.0f, 0.0f, 0.0f), float depth = 1.0f, unsigned stencil = 0);
  78. /// Draw non-indexed geometry
  79. void Draw(PrimitiveType type, unsigned vertexStart, unsigned vertexCount);
  80. /// Draw indexed geometry
  81. void Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount);
  82. /// Draw indexed, instanced geometry. No-op on OpenGL
  83. void DrawInstanced(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount, unsigned instanceCount);
  84. /// Set vertex buffer
  85. void SetVertexBuffer(VertexBuffer* buffer);
  86. /// Set multiple vertex buffers
  87. bool SetVertexBuffers(const Vector<VertexBuffer*>& buffers, const PODVector<unsigned>& elementMasks, unsigned instanceOffset = 0);
  88. /// Set multiple vertex buffers
  89. bool SetVertexBuffers(const Vector<SharedPtr<VertexBuffer> >& buffers, const PODVector<unsigned>& elementMasks, unsigned instanceOffset = 0);
  90. /// Set index buffer
  91. void SetIndexBuffer(IndexBuffer* buffer);
  92. /// Set shaders
  93. void SetShaders(ShaderVariation* vs, ShaderVariation* ps);
  94. /// Set shader bool constants
  95. void SetShaderParameter(StringHash param, const bool* data, unsigned count);
  96. /// Set shader float constants
  97. void SetShaderParameter(StringHash param, const float* data, unsigned count);
  98. /// Set shader int constants
  99. void SetShaderParameter(StringHash param, const int* data, unsigned count);
  100. /// Set shader float constant
  101. void SetShaderParameter(StringHash param, float value);
  102. /// Set shader color constant
  103. void SetShaderParameter(StringHash param, const Color& color);
  104. /// Set shader 3x3 matrix constant
  105. void SetShaderParameter(StringHash param, const Matrix3& matrix);
  106. /// Set shader 3D vector constant
  107. void SetShaderParameter(StringHash param, const Vector3& vector);
  108. /// Set shader 4x4 matrix constant
  109. void SetShaderParameter(StringHash param, const Matrix4& matrix);
  110. /// Set shader 4D vector constant
  111. void SetShaderParameter(StringHash param, const Vector4& vector);
  112. /// Set shader 4x3 matrix constant
  113. void SetShaderParameter(StringHash param, const Matrix3x4& matrix);
  114. /// Check whether a shader parameter in the currently set shaders needs update
  115. bool NeedParameterUpdate(StringHash param, const void* source);
  116. /// Check whether the current pixel shader uses a texture unit
  117. bool NeedTextureUnit(TextureUnit unit);
  118. /// Clear remembered shader parameter sources
  119. void ClearParameterSources();
  120. /// Clear remembered transform shader parameter sources
  121. void ClearTransformSources();
  122. /// Clean up unused shader programs
  123. void CleanupShaderPrograms();
  124. /// Set texture
  125. void SetTexture(unsigned index, Texture* texture);
  126. /// Bind texture unit 0 for update. Called by Texture
  127. void SetTextureForUpdate(Texture* texture);
  128. /// Set default texture filtering mode
  129. void SetDefaultTextureFilterMode(TextureFilterMode mode);
  130. /// Set texture anisotropy
  131. void SetTextureAnisotropy(unsigned level);
  132. /// Dirty texture parameters of all textures (when global settings change)
  133. void SetTextureParametersDirty();
  134. /// Reset all render targets and depth buffer (render to back buffer and back buffer depth stencil)
  135. void ResetRenderTargets();
  136. /// Reset specific render target
  137. void ResetRenderTarget(unsigned index);
  138. /// Reset depth stencil
  139. void ResetDepthStencil();
  140. /// Set render target
  141. void SetRenderTarget(unsigned index, RenderSurface* renderTarget);
  142. /// Set render target
  143. void SetRenderTarget(unsigned index, Texture2D* renderTexture);
  144. /// Set depth stencil buffer
  145. void SetDepthStencil(RenderSurface* depthStencil);
  146. /// Set depth stencil buffer
  147. void SetDepthStencil(Texture2D* depthTexture);
  148. /// Set viewport
  149. void SetViewport(const IntRect& rect);
  150. /// Set "view texture" to prevent sampling from the destination render target
  151. void SetViewTexture(Texture* texture);
  152. /// Set alpha test
  153. void SetAlphaTest(bool enable, CompareMode mode = CMP_ALWAYS, float alphaRef = 0.5f);
  154. /// Set blending mode
  155. void SetBlendMode(BlendMode mode);
  156. /// Set color write on/off
  157. void SetColorWrite(bool enable);
  158. /// Set hardware culling mode
  159. void SetCullMode(CullMode mode);
  160. /// Set depth bias
  161. void SetDepthBias(float constantBias, float slopeScaledBias);
  162. /// Set depth compare
  163. void SetDepthTest(CompareMode mode);
  164. /// Set depth write on/off
  165. void SetDepthWrite(bool enable);
  166. /// Set polygon fill mode
  167. void SetFillMode(FillMode mode);
  168. /// Set scissor test
  169. void SetScissorTest(bool enable, const Rect& rect = Rect::FULL, bool borderInclusive = true);
  170. /// Set scissor test
  171. void SetScissorTest(bool enable, const IntRect& rect);
  172. /// Set stencil test
  173. void SetStencilTest(bool enable, CompareMode mode = CMP_ALWAYS, StencilOp pass = OP_KEEP, StencilOp fail = OP_KEEP, StencilOp zFail = OP_KEEP, unsigned stencilRef = 0, unsigned stencilMask = M_MAX_UNSIGNED);
  174. /// Set vertex buffer stream frequency. No-op on OpenGL
  175. void SetStreamFrequency(unsigned index, unsigned frequency);
  176. /// Reset stream frequencies. No-op on OpenGL
  177. void ResetStreamFrequencies();
  178. /// Begin immediate rendering command
  179. bool BeginImmediate(PrimitiveType type, unsigned vertexCount, unsigned elementMask);
  180. /// Define immediate vertex
  181. bool DefineVertex(const Vector3& vertex);
  182. /// Define immediate normal
  183. bool DefineNormal(const Vector3& normal);
  184. /// Define immediate texture coordinate
  185. bool DefineTexCoord(const Vector2& texCoord);
  186. /// Define immediate color
  187. bool DefineColor(const Color& color);
  188. /// Define immediate color
  189. bool DefineColor(unsigned color);
  190. /// End immediate rendering command and render
  191. void EndImmediate();
  192. /// Set force Shader Model 2 flag. No effect on OpenGL
  193. void SetForceSM2(bool enable);
  194. /// Return whether rendering initialized
  195. bool IsInitialized() const;
  196. /// Return graphics implementation, which holds the actual API-specific resources
  197. GraphicsImpl* GetImpl() const { return impl_; }
  198. /// Return window title
  199. const String& GetWindowTitle() const { return windowTitle_; }
  200. /// Return rendering mode
  201. RenderMode GetRenderMode() const { return mode_; }
  202. /// Return window width
  203. int GetWidth() const { return width_; }
  204. /// Return window height
  205. int GetHeight() const { return height_; }
  206. /// Return multisample mode (1 = no multisampling)
  207. int GetMultiSample() const { return multiSample_; }
  208. /// Return whether window is fullscreen
  209. bool GetFullscreen() const { return fullscreen_; }
  210. /// Return whether vertical sync is on
  211. bool GetVSync() const { return vsync_; }
  212. /// Return whether GPU command queue is flushed at the end of each frame
  213. bool GetFlushGPU() const { return flushGPU_; }
  214. /// Return whether device is lost, and can not yet render. Always false on OpenGL
  215. bool IsDeviceLost() const { return false; }
  216. /// Return immediate rendering data pointer
  217. unsigned char* GetImmediateDataPtr() const;
  218. /// Return window handle
  219. void* GetWindowHandle() const;
  220. /// Return number of primitives drawn this frame
  221. unsigned GetNumPrimitives() const { return numPrimitives_; }
  222. /// Return number of batches drawn this frame
  223. unsigned GetNumBatches() const { return numBatches_; }
  224. /// Return dummy color texture format for shadow maps. Is always 0 on OpenGL
  225. unsigned GetDummyColorFormat() const { return 0; }
  226. /// Return shadow map depth texture format, or 0 if not supported
  227. unsigned GetShadowMapFormat() const { return shadowMapFormat_; }
  228. /// Return 24-bit shadow map depth texture format, or 0 if not supported
  229. unsigned GetHiresShadowMapFormat() const { return hiresShadowMapFormat_; }
  230. /// Return whether texture render targets are supported
  231. bool GetRenderTargetSupport() const { return renderTargetSupport_; }
  232. /// Return whether deferred rendering is supported
  233. bool GetDeferredSupport() const { return deferredSupport_; }
  234. /// Return whether Shader Model 3 is supported. Always false on OpenGL
  235. bool GetSM3Support() const { return false; }
  236. /// Return whether shadow map depth compare is done in hardware. Always false on OpenGL to avoid the HW suffix in shaders
  237. bool GetHardwareShadowSupport() const { return false; }
  238. /// Return whether 24-bit shadow maps are supported. Assume true on OpenGL
  239. bool GetHiresShadowSupport() const { return true; }
  240. /// Return whether stream offset is supported. Always false on OpenGL
  241. bool GetStreamOffsetSupport() const { return false; }
  242. /// Return supported fullscreen resolutions
  243. PODVector<IntVector2> GetResolutions() const;
  244. /// Return supported multisampling levels
  245. PODVector<int> GetMultiSampleLevels() const;
  246. /// Return vertex buffer by index
  247. VertexBuffer* GetVertexBuffer(unsigned index) const;
  248. /// Return index buffer
  249. IndexBuffer* GetIndexBuffer() const { return indexBuffer_; }
  250. /// Return vertex shader
  251. ShaderVariation* GetVertexShader() const { return vertexShader_; }
  252. /// Return pixel shader
  253. ShaderVariation* GetPixelShader() const { return pixelShader_; }
  254. /// Return shader program
  255. ShaderProgram* GetShaderProgram() const { return shaderProgram_; }
  256. /// Return texture unit index by name
  257. TextureUnit GetTextureUnit(const String& name);
  258. /// Return texture unit name by index
  259. const String& GetTextureUnitName(TextureUnit unit);
  260. /// Return texture by texture unit index
  261. Texture* GetTexture(unsigned index) const;
  262. /// Return the "view texture"
  263. Texture* GetViewTexture() const { return viewTexture_; }
  264. /// Return default texture filtering mode
  265. TextureFilterMode GetDefaultTextureFilterMode() const { return defaultTextureFilterMode_; }
  266. /// Return render target by index
  267. RenderSurface* GetRenderTarget(unsigned index) const;
  268. /// Return depth stencil buffer
  269. RenderSurface* GetDepthStencil() const { return depthStencil_; }
  270. /// Return the viewport coordinates
  271. IntRect GetViewport() const { return viewport_; }
  272. /// Return whether alpha testing is enabled
  273. bool GetAlphaTest() const { return alphaTest_; }
  274. /// Return alpha test compare mode
  275. CompareMode GetAlphaTestMode() const { return alphaTestMode_; }
  276. /// Return texture anisotropy
  277. unsigned GetTextureAnisotropy() const { return textureAnisotropy_; }
  278. /// Return alpha test reference value
  279. float GetAlphaRef() const { return alphaRef_; }
  280. /// Return blending mode
  281. BlendMode GetBlendMode() const { return blendMode_; }
  282. /// Return whether color write is enabled
  283. bool GetColorWrite() const { return colorWrite_; }
  284. /// Return hardware culling mode
  285. CullMode GetCullMode() const { return cullMode_; }
  286. /// Return depth constant bias
  287. float GetDepthConstantBias() const { return constantDepthBias_; }
  288. /// Return depth slope scaled bias
  289. float GetDepthSlopeScaledBias() const { return slopeScaledDepthBias_; }
  290. /// Return depth compare mode
  291. CompareMode GetDepthTest() const { return depthTestMode_; }
  292. /// Return whether depth write is enabled
  293. bool GetDepthWrite() const { return depthWrite_; }
  294. /// Return polygon fill mode
  295. FillMode GetFillMode() const { return fillMode_; }
  296. /// Return whether stencil test is enabled
  297. bool GetStencilTest() const { return stencilTest_; }
  298. /// Return whether scissor test is enabled
  299. bool GetScissorTest() const { return scissorTest_; }
  300. /// Return scissor rectangle coordinates
  301. const IntRect& GetScissorRect() const { return scissorRect_; }
  302. /// Return stencil compare mode
  303. CompareMode GetStencilTestMode() const { return stencilTestMode_; }
  304. /// Return stencil operation to do if stencil test passes
  305. StencilOp GetStencilPass() const { return stencilPass_; }
  306. /// Return stencil operation to do if stencil test fails
  307. StencilOp GetStencilFail() const { return stencilFail_; }
  308. /// Return stencil operation to do if depth compare fails
  309. StencilOp GetStencilZFail() const { return stencilZFail_; }
  310. /// Return stencil reference value
  311. unsigned GetStencilRef() const { return stencilRef_; }
  312. /// Return stencil compare bitmask
  313. unsigned GetStencilMask() const { return stencilMask_; }
  314. /// Return stream frequency by vertex buffer index. Always returns 0 on OpenGL
  315. unsigned GetStreamFrequency(unsigned index) const { return 0; }
  316. /// Return render target width and height
  317. IntVector2 GetRenderTargetDimensions() const;
  318. /// Return diffuse buffer for deferred rendering
  319. Texture2D* GetDiffBuffer() const { return diffBuffer_; }
  320. /// Return normal buffer for deferred rendering
  321. Texture2D* GetNormalBuffer() const { return normalBuffer_; }
  322. /// Return depth buffer for deferred rendering. If reading hardware depth is supported, return a depth texture
  323. Texture2D* GetDepthBuffer() const { return depthBuffer_; }
  324. /// Return screen buffer for post-processing
  325. Texture2D* GetScreenBuffer() const { return screenBuffer_; }
  326. /// Add a GPU object to keep track of. Called by GPUObject.
  327. void AddGPUObject(GPUObject* object);
  328. /// Remove a GPU object. Called by GPUObject
  329. void RemoveGPUObject(GPUObject* object);
  330. /// Return the API-specific alpha texture format
  331. static unsigned GetAlphaFormat();
  332. /// Return the API-specific luminance texture format
  333. static unsigned GetLuminanceFormat();
  334. /// Return the API-specific luminance alpha texture format
  335. static unsigned GetLuminanceAlphaFormat();
  336. /// Return the API-specific RGB texture format
  337. static unsigned GetRGBFormat();
  338. /// Return the API-specific RGBA texture format
  339. static unsigned GetRGBAFormat();
  340. /// Return the API-specific deferred rendering depth texture format
  341. static unsigned GetDepthFormat();
  342. /// Return the API-specific depth stencil texture format
  343. static unsigned GetDepthStencilFormat();
  344. private:
  345. /// Create the application window. Return true if successful
  346. bool OpenWindow(int width, int height);
  347. /// Get the pixel format for a given multisample level. Return nonzero if successful
  348. int GetPixelFormat(RenderMode mode, int multiSample);
  349. /// Change to a fullscreen mode. Return true if successful
  350. bool SetScreenMode(int newWidth, int newHeight);
  351. /// Restore desktop mode
  352. void RestoreScreenMode();
  353. /// Adjust the window for new resolution and fullscreen mode
  354. void AdjustWindow(int newWidth, int newHeight, bool newFullscreen);
  355. /// Create deferred rendering render targets
  356. void CreateRenderTargets();
  357. /// Reset cached rendering state
  358. void ResetCachedState();
  359. /// Set draw buffer(s) on the FBO
  360. void SetDrawBuffers();
  361. /// Release GPU objects and close the window
  362. void Release();
  363. /// Initialize texture unit mappings
  364. void SetTextureUnitMappings();
  365. /// Implementation
  366. GraphicsImpl* impl_;
  367. /// Window title
  368. String windowTitle_;
  369. /// Rendering mode
  370. RenderMode mode_;
  371. /// Window width
  372. int width_;
  373. /// Window height
  374. int height_;
  375. /// Multisampling mode
  376. int multiSample_;
  377. /// Fullscreen flag
  378. bool fullscreen_;
  379. /// Vertical sync flag
  380. bool vsync_;
  381. /// Flush GPU command queue flag
  382. bool flushGPU_;
  383. /// Texture render target support flag
  384. bool renderTargetSupport_;
  385. /// Deferred rendering support flag
  386. bool deferredSupport_;
  387. /// Number of primitives this frame
  388. unsigned numPrimitives_;
  389. /// Number of batches this frame
  390. unsigned numBatches_;
  391. /// Immediate rendering primitive type
  392. PrimitiveType immediateType_;
  393. /// Immediate rendering total number of vertices
  394. unsigned immediateVertexCount_;
  395. /// Immediate rendering vertex size
  396. unsigned immediateVertexSize_;
  397. /// Immediate rendering vertex element mask
  398. unsigned immediateElementMask_;
  399. /// Immediate rendering current vertex number
  400. unsigned immediateCurrentVertex_;
  401. /// Immediate rendering data pointer
  402. unsigned char* immediateDataPtr_;
  403. /// Immediate rendering data buffer
  404. PODVector<unsigned char> immediateVertexData_;
  405. /// Immediate rendering element offsets
  406. unsigned immediateElementOffsets_[MAX_IMMEDIATE_ELEMENTS];
  407. /// GPU objects
  408. Vector<GPUObject*> gpuObjects_;
  409. /// Deferred rendering diffuse buffer
  410. SharedPtr<Texture2D> diffBuffer_;
  411. /// Deferred rendering normal buffer
  412. SharedPtr<Texture2D> normalBuffer_;
  413. /// Deferred rendering depth buffer
  414. SharedPtr<Texture2D> depthBuffer_;
  415. /// Screen buffer for post processing
  416. SharedPtr<Texture2D> screenBuffer_;
  417. /// Shadow map depth texture format
  418. unsigned shadowMapFormat_;
  419. /// Shadow map 24-bit depth texture format
  420. unsigned hiresShadowMapFormat_;
  421. /// Vertex buffers in use
  422. VertexBuffer* vertexBuffers_[MAX_VERTEX_STREAMS];
  423. /// Element mask in use
  424. unsigned elementMasks_[MAX_VERTEX_STREAMS];
  425. /// Index buffer in use
  426. IndexBuffer* indexBuffer_;
  427. /// Vertex shader in use
  428. ShaderVariation* vertexShader_;
  429. /// Pixel shader in use
  430. ShaderVariation* pixelShader_;
  431. /// Shader program in use
  432. ShaderProgram* shaderProgram_;
  433. /// Linked shader programs
  434. ShaderProgramMap shaderPrograms_;
  435. /// Shader parameters global frame number
  436. unsigned shaderParameterFrame_;
  437. /// Textures in use
  438. Texture* textures_[MAX_TEXTURE_UNITS];
  439. /// OpenGL texture types in use
  440. unsigned textureTypes_[MAX_TEXTURE_UNITS];
  441. /// "View texture" to prevent sampling the destination render target
  442. Texture* viewTexture_;
  443. /// Texture unit mappings
  444. Map<String, TextureUnit> textureUnits_;
  445. /// Render targets in use
  446. RenderSurface* renderTargets_[MAX_RENDERTARGETS];
  447. /// Depth stencil buffer in use
  448. RenderSurface* depthStencil_;
  449. /// Viewport coordinates
  450. IntRect viewport_;
  451. /// Alpha test enable flag
  452. bool alphaTest_;
  453. /// Alpha test compare mode
  454. CompareMode alphaTestMode_;
  455. /// Alpha test reference value
  456. float alphaRef_;
  457. /// Texture anisotropy level
  458. unsigned textureAnisotropy_;
  459. /// Blending mode
  460. BlendMode blendMode_;
  461. /// Color write enable
  462. bool colorWrite_;
  463. /// Hardware culling mode
  464. CullMode cullMode_;
  465. /// Depth constant bias
  466. float constantDepthBias_;
  467. /// Depth slope scaled bias
  468. float slopeScaledDepthBias_;
  469. /// Depth compare mode
  470. CompareMode depthTestMode_;
  471. /// Depth write enable flag
  472. bool depthWrite_;
  473. /// Polygon fill mode
  474. FillMode fillMode_;
  475. /// Scissor test rectangle
  476. IntRect scissorRect_;
  477. /// Scissor test enable flag
  478. bool scissorTest_;
  479. /// Stencil test compare mode
  480. CompareMode stencilTestMode_;
  481. /// Stencil operation on pass
  482. StencilOp stencilPass_;
  483. /// Stencil operation on fail
  484. StencilOp stencilFail_;
  485. /// Stencil operation on depth fail
  486. StencilOp stencilZFail_;
  487. /// Stencil test enable flag
  488. bool stencilTest_;
  489. /// Stencil test reference value
  490. unsigned stencilRef_;
  491. /// Stencil compare bitmask
  492. unsigned stencilMask_;
  493. /// Default texture filtering mode
  494. TextureFilterMode defaultTextureFilterMode_;
  495. /// Map for additional depth textures, to emulate Direct3D9 ability to mix rendertarget and backbuffer rendering
  496. HashMap<int, SharedPtr<Texture2D> > depthTextures_;
  497. };
  498. /// Register Graphics library objects
  499. void RegisterGraphicsLibrary(Context* context_);