CmGLRenderSystem.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __GLRenderSystem_H__
  25. #define __GLRenderSystem_H__
  26. #include "CmGLPrerequisites.h"
  27. #include "CmRenderSystem.h"
  28. #include "CmGLHardwareBufferManager.h"
  29. #include "CmGLGpuProgramManager.h"
  30. #include "CmGLSLProgramFactory.h"
  31. #include "CmCgProgramFactory.h"
  32. #include "CmVector4.h"
  33. namespace CamelotFramework {
  34. /**
  35. Implementation of GL as a rendering system.
  36. */
  37. class CM_RSGL_EXPORT GLRenderSystem : public RenderSystem
  38. {
  39. public:
  40. GLRenderSystem();
  41. ~GLRenderSystem();
  42. /**
  43. * @copydoc RenderSystem::getName()
  44. */
  45. const String& getName(void) const;
  46. /**
  47. * @copydoc RenderSystem::getShadingLanguageName()
  48. */
  49. const String& getShadingLanguageName() const;
  50. /**
  51. * @copydoc RenderSystem::setRenderTarget()
  52. */
  53. void setRenderTarget(RenderTargetPtr target);
  54. /**
  55. * @copydoc RenderSystem::setVertexBuffer()
  56. */
  57. void setVertexBuffer(UINT32 index, const VertexBufferPtr& buffer);
  58. /**
  59. * @copydoc RenderSystem::setIndexBuffer()
  60. */
  61. void setIndexBuffer(const IndexBufferPtr& buffer);
  62. /**
  63. * @copydoc RenderSystem::setVertexDeclaration()
  64. */
  65. void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration);
  66. /**
  67. * @copydoc RenderSystem::setDrawOperation()
  68. */
  69. void setDrawOperation(DrawOperationType op);
  70. /**
  71. * @copydoc RenderSystem::setScissorRect()
  72. */
  73. void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom);
  74. /**
  75. * @copydoc RenderSystem::setTexture()
  76. */
  77. void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const TexturePtr &tex);
  78. /**
  79. * @copydoc RenderSystem::setSamplerState()
  80. */
  81. void setSamplerState(GpuProgramType gptype, UINT16 unit, const SamplerStatePtr& state);
  82. /**
  83. * @copydoc RenderSystem::setBlendState()
  84. */
  85. void setBlendState(const BlendStatePtr& blendState);
  86. /**
  87. * @copydoc RenderSystem::setRasterizerState()
  88. */
  89. void setRasterizerState(const RasterizerStatePtr& rasterizerState);
  90. /**
  91. * @copydoc RenderSystem::setDepthStencilState()
  92. */
  93. void setDepthStencilState(const DepthStencilStatePtr& depthStencilState, UINT32 stencilRefValue);
  94. /**
  95. * @copydoc RenderSystem::setViewport()
  96. */
  97. void setViewport(const ViewportPtr& vp);
  98. /**
  99. * @copydoc RenderSystem::bindGpuProgram()
  100. */
  101. void bindGpuProgram(HGpuProgram prg);
  102. /**
  103. * @copydoc RenderSystem::unbindGpuProgram()
  104. */
  105. void unbindGpuProgram(GpuProgramType gptype);
  106. /**
  107. * @copydoc RenderSystem::bindGpuParams()
  108. */
  109. void bindGpuParams(GpuProgramType gptype, BindableGpuParams& params);
  110. /**
  111. * @copydoc RenderSystem::beginFrame()
  112. */
  113. void beginFrame(void);
  114. /**
  115. * @copydoc RenderSystem::endFrame()
  116. */
  117. void endFrame(void);
  118. /**
  119. * @copydoc RenderSystem::draw()
  120. */
  121. void draw(UINT32 vertexCount);
  122. /**
  123. * @copydoc RenderSystem::drawIndexed()
  124. */
  125. void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexCount);
  126. /**
  127. * @copydoc RenderSystem::clearRenderTarget()
  128. */
  129. void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0);
  130. /**
  131. * @copydoc RenderSystem::clearViewport()
  132. */
  133. void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0);
  134. /**
  135. * @copydoc RenderSystem::getColorVertexElementType()
  136. */
  137. VertexElementType getColorVertexElementType(void) const;
  138. /**
  139. * @copydoc RenderSystem::getHorizontalTexelOffset()
  140. */
  141. float getHorizontalTexelOffset(void);
  142. /**
  143. * @copydoc RenderSystem::getVerticalTexelOffset()
  144. */
  145. float getVerticalTexelOffset(void);
  146. /**
  147. * @copydoc RenderSystem::getMinimumDepthInputValue()
  148. */
  149. float getMinimumDepthInputValue(void);
  150. /**
  151. * @copydoc RenderSystem::getMaximumDepthInputValue()
  152. */
  153. float getMaximumDepthInputValue(void);
  154. /**
  155. * @copydoc RenderSystem::convertProjectionMatrix()
  156. */
  157. void convertProjectionMatrix(const Matrix4& matrix,
  158. Matrix4& dest, bool forGpuProgram = false);
  159. /************************************************************************/
  160. /* Internal use by OpenGL RenderSystem only */
  161. /************************************************************************/
  162. bool isContextInitialized() const { return mGLInitialised; }
  163. GLContext* getMainContext() const { return mMainContext; }
  164. GLSupport* getGLSupport() const { return mGLSupport; }
  165. private:
  166. // Scissor test
  167. UINT32 mScissorTop, mScissorBottom, mScissorLeft, mScissorRight;
  168. UINT32 mViewportLeft, mViewportTop, mViewportWidth, mViewportHeight;
  169. UINT32 mStencilReadMask;
  170. UINT32 mStencilWriteMask;
  171. UINT32 mStencilRefValue;
  172. CompareFunction mStencilCompareFront;
  173. CompareFunction mStencilCompareBack;
  174. /// View matrix to set world against
  175. Matrix4 mViewMatrix;
  176. /// Last min & mip filtering options, so we can combine them
  177. FilterOptions mMinFilter;
  178. FilterOptions mMipFilter;
  179. /// Holds texture type settings for every stage
  180. UINT32 mNumTextureTypes;
  181. GLenum* mTextureTypes;
  182. void initInputDevices(void);
  183. void processInputDevices(void);
  184. void makeGLMatrix(GLfloat gl_matrix[16], const Matrix4& m);
  185. GLint getBlendMode(BlendFactor ogreBlend) const;
  186. GLint getTextureAddressingMode(TextureAddressingMode tam) const;
  187. void initializeContext(GLContext* primary);
  188. /** See
  189. RenderSystem
  190. */
  191. virtual RenderSystemCapabilities* createRenderSystemCapabilities() const;
  192. /** See
  193. RenderSystem
  194. */
  195. void initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps);
  196. /// Store last depth write state
  197. bool mDepthWrite;
  198. /// Store last colour write state
  199. bool mColorWrite[4];
  200. GLint convertCompareFunction(CompareFunction func) const;
  201. GLint convertStencilOp(StencilOperation op, bool invert = false) const;
  202. /// Internal method for anisotropy validation
  203. GLfloat _getCurrentAnisotropy(UINT16 unit);
  204. /// GL support class, used for creating windows etc.
  205. GLSupport* mGLSupport;
  206. /// Check if the GL system has already been initialised
  207. bool mGLInitialised;
  208. GLSLProgramFactory* mGLSLProgramFactory;
  209. CgProgramFactory* mCgProgramFactory;
  210. GLSLProgramPipelineManager* mProgramPipelineManager;
  211. GLuint getCombinedMinMipFilter(void) const;
  212. GLSLGpuProgramPtr mCurrentVertexProgram;
  213. GLSLGpuProgramPtr mCurrentFragmentProgram;
  214. GLSLGpuProgramPtr mCurrentGeometryProgram;
  215. GLSLGpuProgramPtr mCurrentHullProgram;
  216. GLSLGpuProgramPtr mCurrentDomainProgram;
  217. const GLSLProgramPipeline* mActivePipeline;
  218. UINT32 mFragmentTexOffset;
  219. UINT32 mVertexTexOffset;
  220. UINT32 mGeometryTexOffset;
  221. UINT32 mFragmentUBOffset;
  222. UINT32 mVertexUBOffset;
  223. UINT32 mGeometryUBOffset;
  224. UINT32 mHullUBOffset;
  225. UINT32 mDomainUBOffset;
  226. UINT32 mComputeUBOffset;
  227. UnorderedMap<UINT32, VertexBufferPtr>::type mBoundVertexBuffers;
  228. VertexDeclarationPtr mBoundVertexDeclaration;
  229. IndexBufferPtr mBoundIndexBuffer;
  230. DrawOperationType mCurrentDrawOperation;
  231. GLContext *mMainContext;
  232. GLContext *mCurrentContext;
  233. Vector<GLuint>::type mBoundAttributes; // Only full between begin/endDraw calls
  234. bool mDrawCallInProgress;
  235. UINT16 mActiveTextureUnit;
  236. protected:
  237. /**
  238. * @copydoc RenderSystem::initialize_internal().
  239. */
  240. void initialize_internal(AsyncOp& asyncOp);
  241. /**
  242. * @copydoc RenderSystem::destroy_internal().
  243. */
  244. void destroy_internal(void);
  245. void setClipPlanesImpl(const PlaneList& clipPlanes);
  246. bool activateGLTextureUnit(UINT16 unit);
  247. /** See
  248. RenderSystem
  249. */
  250. String getErrorDescription(long errorNumber) const;
  251. /** See
  252. RenderSystem
  253. */
  254. void setClipPlane (UINT16 index, float A, float B, float C, float D);
  255. /** See
  256. RenderSystem
  257. */
  258. void enableClipPlane (UINT16 index, bool enable);
  259. /************************************************************************/
  260. /* Sampler states */
  261. /************************************************************************/
  262. /** Sets the texture addressing mode for a texture unit.*/
  263. void setTextureAddressingMode(UINT16 stage, const UVWAddressingMode& uvw);
  264. /** Sets the texture border color for a texture unit.*/
  265. void setTextureBorderColor(UINT16 stage, const Color& color);
  266. /** Sets the mipmap bias value for a given texture unit.
  267. @remarks
  268. This allows you to adjust the mipmap calculation up or down for a
  269. given texture unit. Negative values force a larger mipmap to be used,
  270. positive values force a smaller mipmap to be used. Units are in numbers
  271. of levels, so +1 forces the mipmaps to one smaller level.
  272. @note Only does something if render system has capability RSC_MIPMAP_LOD_BIAS.
  273. */
  274. void setTextureMipmapBias(UINT16 unit, float bias);
  275. /** Sets a single filter for a given texture unit.
  276. @param unit The texture unit to set the filtering options for
  277. @param ftype The filter type
  278. @param filter The filter to be used
  279. */
  280. void setTextureFiltering(UINT16 unit, FilterType ftype, FilterOptions filter);
  281. /** Sets the maximal anisotropy for the specified texture unit.*/
  282. void setTextureAnisotropy(UINT16 unit, unsigned int maxAnisotropy);
  283. /************************************************************************/
  284. /* Blend states */
  285. /************************************************************************/
  286. /** Sets the global blending factors for combining subsequent renders with the existing frame contents.
  287. The result of the blending operation is:</p>
  288. <p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
  289. Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
  290. enumerated type.
  291. By changing the operation you can change addition between the source and destination pixels to a different operator.
  292. @param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
  293. @param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
  294. @param op The blend operation mode for combining pixels
  295. */
  296. void setSceneBlending( BlendFactor sourceFactor, BlendFactor destFactor, BlendOperation op );
  297. /** Sets the global blending factors for combining subsequent renders with the existing frame contents.
  298. The result of the blending operation is:</p>
  299. <p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
  300. Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
  301. enumerated type.
  302. @param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
  303. @param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
  304. @param sourceFactorAlpha The source factor in the above calculation for the alpha channel, i.e. multiplied by the texture alpha components.
  305. @param destFactorAlpha The destination factor in the above calculation for the alpha channel, i.e. multiplied by the pixel alpha components.
  306. @param op The blend operation mode for combining pixels
  307. @param alphaOp The blend operation mode for combining pixel alpha values
  308. */
  309. void setSceneBlending( BlendFactor sourceFactor, BlendFactor destFactor, BlendFactor sourceFactorAlpha,
  310. BlendFactor destFactorAlpha, BlendOperation op, BlendOperation alphaOp );
  311. /** Sets the global alpha rejection approach for future renders.
  312. By default images are rendered regardless of texture alpha. This method lets you change that.
  313. @param func The comparison function which must pass for a pixel to be written.
  314. @param val The value to compare each pixels alpha value to (0-255)
  315. */
  316. void setAlphaTest(CompareFunction func, unsigned char value);
  317. /**
  318. * @brief Enable alpha coverage if supported.
  319. */
  320. void setAlphaToCoverage(bool enabled);
  321. /** Sets whether or not colour buffer writing is enabled, and for which channels.
  322. @remarks
  323. For some advanced effects, you may wish to turn off the writing of certain colour
  324. channels, or even all of the colour channels so that only the depth buffer is updated
  325. in a rendering pass. However, the chances are that you really want to use this option
  326. through the Material class.
  327. @param red, green, blue, alpha Whether writing is enabled for each of the 4 colour channels. */
  328. void setColorBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
  329. /************************************************************************/
  330. /* Rasterizer states */
  331. /************************************************************************/
  332. /** Sets the culling mode for the render system based on the 'vertex winding'.
  333. A typical way for the rendering engine to cull triangles is based on the
  334. 'vertex winding' of triangles. Vertex winding refers to the direction in
  335. which the vertices are passed or indexed to in the rendering operation as viewed
  336. from the camera, and will wither be clockwise or anticlockwise (that's 'counterclockwise' for
  337. you Americans out there ;) The default is CULL_CLOCKWISE i.e. that only triangles whose vertices
  338. are passed/indexed in anticlockwise order are rendered - this is a common approach and is used in 3D studio models
  339. for example. You can alter this culling mode if you wish but it is not advised unless you know what you are doing.
  340. You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex
  341. winding is uncertain.
  342. */
  343. void setCullingMode(CullingMode mode);
  344. /** Sets how to rasterise triangles, as points, wireframe or solid polys. */
  345. void setPolygonMode(PolygonMode level);
  346. /** Sets the depth bias, NB you should use the Material version of this.
  347. @remarks
  348. When polygons are coplanar, you can get problems with 'depth fighting' where
  349. the pixels from the two polys compete for the same screen pixel. This is particularly
  350. a problem for decals (polys attached to another surface to represent details such as
  351. bulletholes etc.).
  352. @par
  353. A way to combat this problem is to use a depth bias to adjust the depth buffer value
  354. used for the decal such that it is slightly higher than the true value, ensuring that
  355. the decal appears on top.
  356. @note
  357. The final bias value is a combination of a constant bias and a bias proportional
  358. to the maximum depth slope of the polygon being rendered. The final bias
  359. is constantBias + slopeScaleBias * maxslope. Slope scale biasing is
  360. generally preferable but is not available on older hardware.
  361. @param constantBias The constant bias value, expressed as a value in
  362. homogeneous depth coordinates.
  363. @param slopeScaleBias The bias value which is factored by the maximum slope
  364. of the polygon, see the description above. This is not supported by all
  365. cards.
  366. */
  367. void setDepthBias(float constantBias, float slopeScaleBias);
  368. /**
  369. * @brief Scissor test allows you to 'mask off' rendering in all but a given rectangular area
  370. * identified by the rectangle set by setScissorRect().
  371. */
  372. void setScissorTestEnable(bool enable);
  373. /************************************************************************/
  374. /* Depth stencil state */
  375. /************************************************************************/
  376. /** Sets the mode of operation for depth buffer tests from this point onwards.
  377. Sometimes you may wish to alter the behaviour of the depth buffer to achieve
  378. special effects. Because it's unlikely that you'll set these options for an entire frame,
  379. but rather use them to tweak settings between rendering objects, this is an internal
  380. method (indicated by the '_' prefix) which will be used by a SceneManager implementation
  381. rather than directly from the client application.
  382. If this method is never called the settings are automatically the same as the default parameters.
  383. @param depthTest If true, the depth buffer is tested for each pixel and the frame buffer is only updated
  384. if the depth function test succeeds. If false, no test is performed and pixels are always written.
  385. @param depthWrite If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
  386. If false, the depth buffer is left unchanged even if a new pixel is written.
  387. @param depthFunction Sets the function required for the depth test.
  388. */
  389. void setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL);
  390. /** Sets whether or not the depth buffer check is performed before a pixel write.
  391. @param enabled If true, the depth buffer is tested for each pixel and the frame buffer is only updated
  392. if the depth function test succeeds. If false, no test is performed and pixels are always written.
  393. */
  394. void setDepthBufferCheckEnabled(bool enabled = true);
  395. /** Sets whether or not the depth buffer is updated after a pixel write.
  396. @param enabled If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
  397. If false, the depth buffer is left unchanged even if a new pixel is written.
  398. */
  399. void setDepthBufferWriteEnabled(bool enabled = true);
  400. /** Sets the comparison function for the depth buffer check.
  401. Advanced use only - allows you to choose the function applied to compare the depth values of
  402. new and existing pixels in the depth buffer. Only an issue if the deoth buffer check is enabled
  403. (see _setDepthBufferCheckEnabled)
  404. @param func The comparison between the new depth and the existing depth which must return true
  405. for the new pixel to be written.
  406. */
  407. void setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
  408. /** Turns stencil buffer checking on or off.
  409. @remarks
  410. Stencilling (masking off areas of the rendering target based on the stencil
  411. buffer) can be turned on or off using this method. By default, stencilling is
  412. disabled.
  413. */
  414. void setStencilCheckEnabled(bool enabled);
  415. /** This method allows you to set stencil buffer operations in one call.
  416. @param stencilFailOp The action to perform when the stencil check fails
  417. @param depthFailOp The action to perform when the stencil check passes, but the
  418. depth buffer check still fails
  419. @param passOp The action to take when both the stencil and depth check pass.
  420. @param ccw If set to true, the stencil operations will be applied to counterclockwise
  421. faces. Otherwise they will be applied to clockwise faces.
  422. */
  423. void setStencilBufferOperations(StencilOperation stencilFailOp = SOP_KEEP,
  424. StencilOperation depthFailOp = SOP_KEEP, StencilOperation passOp = SOP_KEEP,
  425. bool front = true);
  426. /**
  427. * @brief Sets a stencil buffer comparison function. The result of this will cause one of 3 actions depending on whether the test fails,
  428. * succeeds but with the depth buffer check still failing, or succeeds with the
  429. * depth buffer check passing too.
  430. * @param mask The bitmask applied to both the stencil value and the reference value
  431. * before comparison
  432. * @param ccw If set to true, the stencil operations will be applied to counterclockwise
  433. * faces. Otherwise they will be applied to clockwise faces.
  434. */
  435. void setStencilBufferFunc(CompareFunction func = CMPF_ALWAYS_PASS, UINT32 mask = 0xFFFFFFFF, bool front = true);
  436. /**
  437. * @brief The bitmask applied to the stencil value before writing it to the stencil buffer.
  438. */
  439. void setStencilBufferWriteMask(UINT32 mask = 0xFFFFFFFF);
  440. /**
  441. * @brief Sets a reference values used for stencil buffer comparisons.
  442. * Actual comparison function and stencil operations are set by setting the DepthStencilState.
  443. */
  444. void setStencilRefValue(UINT32 refValue);
  445. /** One time initialization for the RenderState of a context. Things that
  446. only need to be set once, like the LightingModel can be defined here.
  447. */
  448. void oneTimeContextInitialization();
  449. /** Switch GL context, dealing with involved internal cached states too
  450. */
  451. void switchContext(GLContext *context);
  452. /**
  453. * @brief Checks if there are any OpenGL errors and prints them to the log.
  454. */
  455. bool checkForErrors() const;
  456. /**
  457. * @brief OpenGL shares all texture slots, but the engine prefers to keep textures
  458. * separate per-stage. This will convert texture unit that is set per stage
  459. * into a global texture unit usable by OpenGL.
  460. */
  461. UINT32 getGLTextureUnit(GpuProgramType gptype, UINT32 unit);
  462. /**
  463. * @brief OpenGL shares all buffer bindings, but the engine prefers to keep buffers
  464. * separate per-stage. This will convert block buffer binding that is set per stage
  465. * into a global block buffer binding usable by OpenGL.
  466. */
  467. UINT32 getGLUniformBlockBinding(GpuProgramType gptype, UINT32 binding);
  468. /**
  469. * @brief Returns the OpenGL specific mode used for drawing, depending on the
  470. * currently set draw operation;
  471. */
  472. GLint getGLDrawMode() const;
  473. /**
  474. * @brief Call before doing a draw operation, this method sets everything up.
  475. */
  476. void beginDraw();
  477. /**
  478. * @brief Needs to accompany every beginDraw after you are done with a single draw operation.
  479. */
  480. void endDraw();
  481. void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, const Rect& clearArea = Rect::EMPTY);
  482. void setActiveProgram(GpuProgramType gptype, GLSLGpuProgramPtr program);
  483. GLSLGpuProgramPtr getActiveProgram(GpuProgramType gptype) const;
  484. };
  485. }
  486. #endif