OGLGraphics.h 23 KB

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