OGLGraphics.h 22 KB

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