OgreGLSLGpuProgram.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 __GLSLGpuProgram_H__
  25. #define __GLSLGpuProgram_H__
  26. // Precompiler options
  27. #include "OgreGLSLExtSupport.h"
  28. #include "OgreGLGpuProgram.h"
  29. namespace Ogre {
  30. /** GLSL low level compiled shader object - this class is used to get at the linked program object
  31. and provide an interface for GLRenderSystem calls. GLSL does not provide access to the
  32. low level code of the shader so this class is really just a dummy place holder.
  33. GLSL uses a program object to represent the active vertex and fragment programs used
  34. but Ogre materials maintain seperate instances of the active vertex and fragment programs
  35. which creates a small problem for GLSL integration. The GLSLGpuProgram class provides the
  36. interface between the GLSLLinkProgramManager , GLRenderSystem, and the active GLSLProgram
  37. instances.
  38. */
  39. class _OgreGLExport GLSLGpuProgram : public GLGpuProgram
  40. {
  41. private:
  42. /// GL Handle for the shader object
  43. GLSLProgram* mGLSLProgram;
  44. /// keep track of the number of vertex shaders created
  45. static GLuint mVertexShaderCount;
  46. /// keep track of the number of fragment shaders created
  47. static GLuint mFragmentShaderCount;
  48. /// keep track of the number of geometry shaders created
  49. static GLuint mGeometryShaderCount;
  50. public:
  51. GLSLGpuProgram(GLSLProgram* parent);
  52. ~GLSLGpuProgram();
  53. /// Execute the binding functions for this program
  54. void bindProgram(void);
  55. /// Execute the unbinding functions for this program
  56. void unbindProgram(void);
  57. /// Execute the param binding functions for this program
  58. void bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask);
  59. /// Execute the pass iteration param binding functions for this program
  60. void bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params);
  61. /// Get the assigned GL program id
  62. const GLuint getProgramID(void) const
  63. { return mProgramID; }
  64. /// get the GLSLProgram for the shader object
  65. GLSLProgram* getGLSLProgram(void) const { return mGLSLProgram; }
  66. /// @copydoc GLGpuProgram::getAttributeIndex
  67. GLuint getAttributeIndex(VertexElementSemantic semantic, uint index);
  68. /// @copydoc GLGpuProgram::isAttributeValid
  69. bool isAttributeValid(VertexElementSemantic semantic, uint index);
  70. protected:
  71. /// Overridden from GpuProgram
  72. void loadFromSource(void);
  73. /// @copydoc Resource::unloadImpl
  74. void unloadImpl(void);
  75. /// @copydoc Resource::loadImpl
  76. void loadImpl(void);
  77. };
  78. }
  79. #endif // __GLSLGpuProgram_H__