CmGLRenderSystem.h 23 KB

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