OGLGraphics.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2012 Lasse Oorni
  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 "ArrayPtr.h"
  25. #include "Color.h"
  26. #include "GraphicsDefs.h"
  27. #include "HashMap.h"
  28. #include "Image.h"
  29. #include "Matrix3x4.h"
  30. #include "Object.h"
  31. #include "Rect.h"
  32. namespace Urho3D
  33. {
  34. class Image;
  35. class IndexBuffer;
  36. class Matrix3;
  37. class Matrix4;
  38. class Matrix3x4;
  39. class GPUObject;
  40. class GraphicsImpl;
  41. class RenderSurface;
  42. class ShaderProgram;
  43. class ShaderVariation;
  44. class Texture;
  45. class Texture2D;
  46. class TextureCube;
  47. class Vector3;
  48. class Vector4;
  49. class VertexBuffer;
  50. typedef HashMap<Pair<ShaderVariation*, ShaderVariation*>, SharedPtr<ShaderProgram> > ShaderProgramMap;
  51. static const unsigned NUM_SCREEN_BUFFERS = 2;
  52. static const unsigned NUM_TEMP_MATRICES = 8;
  53. /// CPU-side scratch buffer for vertex data updates.
  54. struct ScratchBuffer
  55. {
  56. ScratchBuffer() :
  57. size_(0),
  58. reserved_(false)
  59. {
  60. }
  61. /// Buffer data.
  62. SharedArrayPtr<unsigned char> data_;
  63. /// Data size.
  64. unsigned size_;
  65. /// Reserved flag.
  66. bool reserved_;
  67. };
  68. /// %Graphics subsystem. Manages the application window, rendering state and GPU resources.
  69. class Graphics : public Object
  70. {
  71. OBJECT(Graphics);
  72. public:
  73. /// Construct.
  74. Graphics(Context* context_);
  75. /// Destruct. Release the OpenGL context and close the window.
  76. virtual ~Graphics();
  77. /// Set external window handle. Only effective before setting the initial screen mode. On Windows it is necessary to set up OpenGL pixel format manually for the window.
  78. void SetExternalWindow(void* window);
  79. /// Set window title.
  80. void SetWindowTitle(const String& windowTitle);
  81. /// Set screen mode. Return true if successful.
  82. bool SetMode(int width, int height, bool fullscreen, bool vsync, bool tripleBuffer, int multiSample);
  83. /// Set screen resolution only. Return true if successful.
  84. bool SetMode(int width, int height);
  85. /// Toggle between full screen and windowed mode.
  86. bool ToggleFullscreen();
  87. /// Close the window.
  88. void Close();
  89. /// Take a screenshot.
  90. bool TakeScreenShot(Image& destImage);
  91. /// Begin frame rendering. Return true if device available and can render.
  92. bool BeginFrame();
  93. /// End frame rendering and swap buffers.
  94. void EndFrame();
  95. /// Clear any or all of rendertarget, depth buffer and stencil buffer.
  96. void Clear(unsigned flags, const Color& color = Color(0.0f, 0.0f, 0.0f, 0.0f), float depth = 1.0f, unsigned stencil = 0);
  97. /// Resolve multisampled backbuffer to a texture rendertarget.
  98. bool ResolveToTexture(Texture2D* destination, const IntRect& viewport);
  99. /// Draw non-indexed geometry.
  100. void Draw(PrimitiveType type, unsigned vertexStart, unsigned vertexCount);
  101. /// Draw indexed geometry.
  102. void Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount);
  103. /// Draw indexed, instanced geometry. No-op on OpenGL.
  104. void DrawInstanced(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount, unsigned instanceCount);
  105. /// Set vertex buffer.
  106. void SetVertexBuffer(VertexBuffer* buffer);
  107. /// Set multiple vertex buffers.
  108. bool SetVertexBuffers(const Vector<VertexBuffer*>& buffers, const PODVector<unsigned>& elementMasks, unsigned instanceOffset = 0);
  109. /// Set multiple vertex buffers.
  110. bool SetVertexBuffers(const Vector<SharedPtr<VertexBuffer> >& buffers, const PODVector<unsigned>& elementMasks, unsigned instanceOffset = 0);
  111. /// Set index buffer.
  112. void SetIndexBuffer(IndexBuffer* buffer);
  113. /// Set shaders.
  114. void SetShaders(ShaderVariation* vs, ShaderVariation* ps);
  115. /// Set shader float constants.
  116. void SetShaderParameter(StringHash param, const float* data, unsigned count);
  117. /// Set shader float constant.
  118. void SetShaderParameter(StringHash param, float value);
  119. /// Set shader color constant.
  120. void SetShaderParameter(StringHash param, const Color& color);
  121. /// Set shader 3x3 matrix constant.
  122. void SetShaderParameter(StringHash param, const Matrix3& matrix);
  123. /// Set shader 3D vector constant.
  124. void SetShaderParameter(StringHash param, const Vector3& vector);
  125. /// Set shader 4x4 matrix constant.
  126. void SetShaderParameter(StringHash param, const Matrix4& matrix);
  127. /// Set shader 4D vector constant.
  128. void SetShaderParameter(StringHash param, const Vector4& vector);
  129. /// Set shader 4x3 matrix constant.
  130. void SetShaderParameter(StringHash param, const Matrix3x4& matrix);
  131. /// Check whether a shader parameter group needs update. Does not actually check whether parameters exist in the shaders.
  132. bool NeedParameterUpdate(ShaderParameterGroup group, const void* source);
  133. /// Check whether a shader parameter exists on the currently set shaders.
  134. bool HasShaderParameter(ShaderType type, StringHash param);
  135. /// Check whether the current pixel shader uses a texture unit.
  136. bool HasTextureUnit(TextureUnit unit);
  137. /// Clear remembered shader parameter source group.
  138. void ClearParameterSource(ShaderParameterGroup group);
  139. /// Clear remembered shader parameter sources.
  140. void ClearParameterSources();
  141. /// Clear remembered transform shader parameter sources.
  142. void ClearTransformSources();
  143. /// Clean up unused shader programs.
  144. void CleanupShaderPrograms();
  145. /// Set texture.
  146. void SetTexture(unsigned index, Texture* texture);
  147. /// Bind texture unit 0 for update. Called by Texture.
  148. void SetTextureForUpdate(Texture* texture);
  149. /// Set default texture filtering mode.
  150. void SetDefaultTextureFilterMode(TextureFilterMode mode);
  151. /// Set texture anisotropy.
  152. void SetTextureAnisotropy(unsigned level);
  153. /// Dirty texture parameters of all textures (when global settings change.)
  154. void SetTextureParametersDirty();
  155. /// Reset all rendertargets, depth-stencil surface and viewport.
  156. void ResetRenderTargets();
  157. /// Reset specific rendertarget.
  158. void ResetRenderTarget(unsigned index);
  159. /// Reset depth-stencil surface.
  160. void ResetDepthStencil();
  161. /// Set rendertarget.
  162. void SetRenderTarget(unsigned index, RenderSurface* renderTarget);
  163. /// Set rendertarget.
  164. void SetRenderTarget(unsigned index, Texture2D* texture);
  165. /// Set depth-stencil surface.
  166. void SetDepthStencil(RenderSurface* depthStencil);
  167. /// Set depth-stencil surface.
  168. void SetDepthStencil(Texture2D* texture);
  169. /// Set view texture (deferred rendering final output rendertarget) to prevent it from being sampled.
  170. void SetViewTexture(Texture* texture);
  171. /// Set viewport.
  172. void SetViewport(const IntRect& rect);
  173. /// Set blending mode.
  174. void SetBlendMode(BlendMode mode);
  175. /// Set color write on/off.
  176. void SetColorWrite(bool enable);
  177. /// Set hardware culling mode.
  178. void SetCullMode(CullMode mode);
  179. /// Set depth bias.
  180. void SetDepthBias(float constantBias, float slopeScaledBias);
  181. /// Set depth compare.
  182. void SetDepthTest(CompareMode mode);
  183. /// Set depth write on/off.
  184. void SetDepthWrite(bool enable);
  185. /// Set polygon fill mode.
  186. void SetFillMode(FillMode mode);
  187. /// Set scissor test.
  188. void SetScissorTest(bool enable, const Rect& rect = Rect::FULL, bool borderInclusive = true);
  189. /// Set scissor test.
  190. void SetScissorTest(bool enable, const IntRect& rect);
  191. /// Set stencil test.
  192. void SetStencilTest(bool enable, CompareMode mode = CMP_ALWAYS, StencilOp pass = OP_KEEP, StencilOp fail = OP_KEEP, StencilOp zFail = OP_KEEP, unsigned stencilRef = 0, unsigned compareMask = M_MAX_UNSIGNED, unsigned writeMask = M_MAX_UNSIGNED);
  193. /// Set vertex buffer stream frequency. No-op on OpenGL.
  194. void SetStreamFrequency(unsigned index, unsigned frequency);
  195. /// Reset stream frequencies. No-op on OpenGL.
  196. void ResetStreamFrequencies();
  197. /// Set force Shader Model 2 flag. No-op on OpenGL.
  198. void SetForceSM2(bool enable);
  199. /// Return whether rendering initialized.
  200. bool IsInitialized() const;
  201. /// Return graphics implementation, which holds the actual API-specific resources.
  202. GraphicsImpl* GetImpl() const { return impl_; }
  203. /// Return OS-specific external window handle. Null if not in use.
  204. void* GetExternalWindow() const { return externalWindow_; }
  205. /// Return window title.
  206. const String& GetWindowTitle() const { return windowTitle_; }
  207. /// Return window width.
  208. int GetWidth() const { return width_; }
  209. /// Return window height.
  210. int GetHeight() const { return height_; }
  211. /// Return multisample mode (1 = no multisampling.)
  212. int GetMultiSample() const { return multiSample_; }
  213. /// Return whether window is fullscreen.
  214. bool GetFullscreen() const { return fullscreen_; }
  215. /// Return whether vertical sync is on.
  216. bool GetVSync() const { return vsync_; }
  217. /// Return whether triple buffering is enabled.
  218. bool GetTripleBuffer() const { return tripleBuffer_; }
  219. /// Return whether device is lost, and can not yet render.
  220. bool IsDeviceLost() const;
  221. /// Return number of primitives drawn this frame.
  222. unsigned GetNumPrimitives() const { return numPrimitives_; }
  223. /// Return number of batches drawn this frame.
  224. unsigned GetNumBatches() const { return numBatches_; }
  225. /// Return dummy color texture format for shadow maps.
  226. unsigned GetDummyColorFormat() const { return 0; }
  227. /// Return shadow map depth texture format, or 0 if not supported.
  228. unsigned GetShadowMapFormat() const { return shadowMapFormat_; }
  229. /// Return 24-bit shadow map depth texture format, or 0 if not supported.
  230. unsigned GetHiresShadowMapFormat() const { return hiresShadowMapFormat_; }
  231. /// Return whether Shader Model 3 is supported. Always false on OpenGL.
  232. bool GetSM3Support() const { return false; }
  233. /// Return whether light pre-pass rendering is supported.
  234. bool GetLightPrepassSupport() const { return lightPrepassSupport_; }
  235. /// Return whether deferred rendering is supported.
  236. bool GetDeferredSupport() const { return deferredSupport_; }
  237. /// Return whether anisotropic texture filtering is supported.
  238. bool GetAnisotropySupport() const { return anisotropySupport_; }
  239. /// Return whether shadow map depth compare is done in hardware. Always true on OpenGL.
  240. bool GetHardwareShadowSupport() const { return true; }
  241. /// Return whether stream offset is supported. Always false on OpenGL.
  242. bool GetStreamOffsetSupport() const { return false; }
  243. /// Return supported fullscreen resolutions.
  244. PODVector<IntVector2> GetResolutions() const;
  245. /// Return supported multisampling levels.
  246. PODVector<int> GetMultiSampleLevels() const;
  247. /// Return hardware format for a compressed image format, or 0 if unsupported.
  248. unsigned GetFormat(CompressedFormat format) const;
  249. /// Return vertex buffer by index.
  250. VertexBuffer* GetVertexBuffer(unsigned index) const;
  251. /// Return index buffer.
  252. IndexBuffer* GetIndexBuffer() const { return indexBuffer_; }
  253. /// Return vertex shader.
  254. ShaderVariation* GetVertexShader() const { return vertexShader_; }
  255. /// Return pixel shader.
  256. ShaderVariation* GetPixelShader() const { return pixelShader_; }
  257. /// Return shader program.
  258. ShaderProgram* GetShaderProgram() const { return shaderProgram_; }
  259. /// Return texture unit index by name.
  260. TextureUnit GetTextureUnit(const String& name);
  261. /// Return texture unit name by index.
  262. const String& GetTextureUnitName(TextureUnit unit);
  263. /// Return texture by texture unit index.
  264. Texture* GetTexture(unsigned index) const;
  265. /// Return default texture filtering mode.
  266. TextureFilterMode GetDefaultTextureFilterMode() const { return defaultTextureFilterMode_; }
  267. /// Return rendertarget by index.
  268. RenderSurface* GetRenderTarget(unsigned index) const;
  269. /// Return depth-stencil surface.
  270. RenderSurface* GetDepthStencil() const { return depthStencil_; }
  271. /// Return readable depth-stencil texture. Not created automatically on OpenGL.
  272. Texture2D* GetDepthTexture() const { return 0; }
  273. /// Return the viewport coordinates.
  274. IntRect GetViewport() const { return viewport_; }
  275. /// Return texture anisotropy.
  276. unsigned GetTextureAnisotropy() const { return textureAnisotropy_; }
  277. /// Return blending mode.
  278. BlendMode GetBlendMode() const { return blendMode_; }
  279. /// Return whether color write is enabled.
  280. bool GetColorWrite() const { return colorWrite_; }
  281. /// Return hardware culling mode.
  282. CullMode GetCullMode() const { return cullMode_; }
  283. /// Return depth constant bias.
  284. float GetDepthConstantBias() const { return constantDepthBias_; }
  285. /// Return depth slope scaled bias.
  286. float GetDepthSlopeScaledBias() const { return slopeScaledDepthBias_; }
  287. /// Return depth compare mode.
  288. CompareMode GetDepthTest() const { return depthTestMode_; }
  289. /// Return whether depth write is enabled.
  290. bool GetDepthWrite() const { return depthWrite_; }
  291. /// Return polygon fill mode.
  292. FillMode GetFillMode() const { return fillMode_; }
  293. /// Return whether stencil test is enabled.
  294. bool GetStencilTest() const { return stencilTest_; }
  295. /// Return whether scissor test is enabled.
  296. bool GetScissorTest() const { return scissorTest_; }
  297. /// Return scissor rectangle coordinates.
  298. const IntRect& GetScissorRect() const { return scissorRect_; }
  299. /// Return stencil compare mode.
  300. CompareMode GetStencilTestMode() const { return stencilTestMode_; }
  301. /// Return stencil operation to do if stencil test passes.
  302. StencilOp GetStencilPass() const { return stencilPass_; }
  303. /// Return stencil operation to do if stencil test fails.
  304. StencilOp GetStencilFail() const { return stencilFail_; }
  305. /// Return stencil operation to do if depth compare fails.
  306. StencilOp GetStencilZFail() const { return stencilZFail_; }
  307. /// Return stencil reference value.
  308. unsigned GetStencilRef() const { return stencilRef_; }
  309. /// Return stencil compare bitmask.
  310. unsigned GetStencilCompareMask() const { return stencilCompareMask_; }
  311. /// Return stencil write bitmask.
  312. unsigned GetStencilWriteMask() const { return stencilWriteMask_; }
  313. /// Return stream frequency by vertex buffer index. Always returns 0 on OpenGL.
  314. unsigned GetStreamFrequency(unsigned index) const { return 0; }
  315. /// Return rendertarget width and height.
  316. IntVector2 GetRenderTargetDimensions() const;
  317. /// Return force Shader Model 2 flag. Always false on OpenGL.
  318. bool GetForceSM2() const { return false; }
  319. /// Add a GPU object to keep track of. Called by GPUObject.
  320. void AddGPUObject(GPUObject* object);
  321. /// Remove a GPU object. Called by GPUObject.
  322. void RemoveGPUObject(GPUObject* object);
  323. /// Reserve a CPU-side scratch buffer.
  324. void* ReserveScratchBuffer(unsigned size);
  325. /// Free a CPU-side scratch buffer.
  326. void FreeScratchBuffer(void* buffer);
  327. /// Clean up too large scratch buffers.
  328. void CleanupScratchBuffers();
  329. /// Release/clear GPU objects and optionally close the window.
  330. void Release(bool clearGPUObjects, bool closeWindow);
  331. /// Restore GPU objects and reinitialize state. Requires an open window.
  332. void Restore();
  333. /// Clean up a render surface from all FBOs.
  334. void CleanupRenderSurface(RenderSurface* surface);
  335. /// Return the API-specific alpha texture format.
  336. static unsigned GetAlphaFormat();
  337. /// Return the API-specific luminance texture format.
  338. static unsigned GetLuminanceFormat();
  339. /// Return the API-specific luminance alpha texture format.
  340. static unsigned GetLuminanceAlphaFormat();
  341. /// Return the API-specific RGB texture format.
  342. static unsigned GetRGBFormat();
  343. /// Return the API-specific RGBA texture format.
  344. static unsigned GetRGBAFormat();
  345. /// Return the API-specific RGBA 16-bit texture format.
  346. static unsigned GetRGBA16Format();
  347. /// Return the API-specific RGBA 16-bit float texture format.
  348. static unsigned GetRGBAFloat16Format();
  349. /// Return the API-specific RGBA 32-bit float texture format.
  350. static unsigned GetRGBAFloat32Format();
  351. /// Return the API-specific RG 16-bit texture format.
  352. static unsigned GetRG16Format();
  353. /// Return the API-specific RG 16-bit float texture format.
  354. static unsigned GetRGFloat16Format();
  355. /// Return the API-specific RG 32-bit float texture format.
  356. static unsigned GetRGFloat32Format();
  357. /// Return the API-specific single channel 16-bit float texture format.
  358. static unsigned GetFloat16Format();
  359. /// Return the API-specific single channel 32-bit float texture format.
  360. static unsigned GetFloat32Format();
  361. /// Return the API-specific linear depth texture format.
  362. static unsigned GetLinearDepthFormat();
  363. /// Return the API-specific hardware depth-stencil texture format.
  364. static unsigned GetDepthStencilFormat();
  365. /// Return the API-specific texture format from a textual description, for example "rgb".
  366. static unsigned GetFormat(const String& formatName);
  367. private:
  368. /// Check supported rendering features.
  369. void CheckFeatureSupport(String& extensions);
  370. /// Select FBO and commit changes.
  371. void CommitFramebuffer();
  372. /// Check FBO completeness.
  373. bool CheckFramebuffer();
  374. /// Cleanup unused and unbound FBO's.
  375. void CleanupFramebuffers(bool contextLost);
  376. /// Reset cached rendering state.
  377. void ResetCachedState();
  378. /// Initialize texture unit mappings.
  379. void SetTextureUnitMappings();
  380. /// Implementation.
  381. GraphicsImpl* impl_;
  382. /// Window title.
  383. String windowTitle_;
  384. /// External window, null if not in use (default.)
  385. void* externalWindow_;
  386. /// Window width.
  387. int width_;
  388. /// Window height.
  389. int height_;
  390. /// Multisampling mode.
  391. int multiSample_;
  392. /// Fullscreen flag.
  393. bool fullscreen_;
  394. /// Vertical sync flag.
  395. bool vsync_;
  396. /// Triple buffering flag.
  397. bool tripleBuffer_;
  398. /// Light prepass support flag.
  399. bool lightPrepassSupport_;
  400. /// Deferred rendering support flag.
  401. bool deferredSupport_;
  402. /// Anisotropic filtering support flag.
  403. bool anisotropySupport_;
  404. /// DXT format support flag.
  405. bool dxtTextureSupport_;
  406. /// ETC1 format support flag.
  407. bool etcTextureSupport_;
  408. /// PVRTC formats support flag.
  409. bool pvrtcTextureSupport_;
  410. /// Number of primitives this frame.
  411. unsigned numPrimitives_;
  412. /// Number of batches this frame.
  413. unsigned numBatches_;
  414. /// Largest scratch buffer request this frame.
  415. unsigned maxScratchBufferRequest_;
  416. /// GPU objects.
  417. Vector<GPUObject*> gpuObjects_;
  418. /// Scratch buffers.
  419. Vector<ScratchBuffer> scratchBuffers_;
  420. /// Shadow map depth texture format.
  421. unsigned shadowMapFormat_;
  422. /// Shadow map 24-bit depth texture format.
  423. unsigned hiresShadowMapFormat_;
  424. /// Vertex buffers in use.
  425. VertexBuffer* vertexBuffers_[MAX_VERTEX_STREAMS];
  426. /// Element mask in use.
  427. unsigned elementMasks_[MAX_VERTEX_STREAMS];
  428. /// Index buffer in use.
  429. IndexBuffer* indexBuffer_;
  430. /// Vertex shader in use.
  431. ShaderVariation* vertexShader_;
  432. /// Pixel shader in use.
  433. ShaderVariation* pixelShader_;
  434. /// Shader program in use.
  435. ShaderProgram* shaderProgram_;
  436. /// Linked shader programs.
  437. ShaderProgramMap shaderPrograms_;
  438. /// Textures in use.
  439. Texture* textures_[MAX_TEXTURE_UNITS];
  440. /// OpenGL texture types in use.
  441. unsigned textureTypes_[MAX_TEXTURE_UNITS];
  442. /// Texture unit mappings.
  443. HashMap<String, TextureUnit> textureUnits_;
  444. /// Rendertargets in use.
  445. RenderSurface* renderTargets_[MAX_RENDERTARGETS];
  446. /// Depth-stencil surface in use.
  447. RenderSurface* depthStencil_;
  448. /// View texture.
  449. Texture* viewTexture_;
  450. /// Viewport coordinates.
  451. IntRect viewport_;
  452. /// Texture anisotropy level.
  453. unsigned textureAnisotropy_;
  454. /// Blending mode.
  455. BlendMode blendMode_;
  456. /// Color write enable.
  457. bool colorWrite_;
  458. /// Hardware culling mode.
  459. CullMode cullMode_;
  460. /// Depth constant bias.
  461. float constantDepthBias_;
  462. /// Depth slope scaled bias.
  463. float slopeScaledDepthBias_;
  464. /// Depth compare mode.
  465. CompareMode depthTestMode_;
  466. /// Depth write enable flag.
  467. bool depthWrite_;
  468. /// Polygon fill mode.
  469. FillMode fillMode_;
  470. /// Scissor test rectangle.
  471. IntRect scissorRect_;
  472. /// Scissor test enable flag.
  473. bool scissorTest_;
  474. /// Stencil test compare mode.
  475. CompareMode stencilTestMode_;
  476. /// Stencil operation on pass.
  477. StencilOp stencilPass_;
  478. /// Stencil operation on fail.
  479. StencilOp stencilFail_;
  480. /// Stencil operation on depth fail.
  481. StencilOp stencilZFail_;
  482. /// Stencil test enable flag.
  483. bool stencilTest_;
  484. /// Stencil test reference value.
  485. unsigned stencilRef_;
  486. /// Stencil compare bitmask.
  487. unsigned stencilCompareMask_;
  488. /// Stencil write bitmask.
  489. unsigned stencilWriteMask_;
  490. /// Default texture filtering mode.
  491. TextureFilterMode defaultTextureFilterMode_;
  492. /// Map for additional depth textures, to emulate Direct3D9 ability to mix render texture and backbuffer rendering.
  493. HashMap<int, SharedPtr<Texture2D> > depthTextures_;
  494. /// Remembered shader parameter sources.
  495. const void* shaderParameterSources_[MAX_SHADER_PARAMETER_GROUPS];
  496. /// Temp matrices for transposing shader parameters.
  497. Matrix3 tempMatrices3_[NUM_TEMP_MATRICES];
  498. /// Temp matrices for transposing shader parameters.
  499. Matrix4 tempMatrices4_[NUM_TEMP_MATRICES];
  500. /// Releasing GPU objects flag.
  501. bool releasingGPUObjects_;
  502. };
  503. /// Register Graphics library objects.
  504. void RegisterGraphicsLibrary(Context* context_);
  505. }