CmGLGpuProgram.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 __GLGpuProgram_H__
  25. #define __GLGpuProgram_H__
  26. #include "CmGLPrerequisites.h"
  27. #include "CmGpuProgram.h"
  28. #include "CmHardwareVertexBuffer.h"
  29. namespace CamelotEngine {
  30. /** Generalised low-level GL program, can be applied to multiple types (eg ARB and NV) */
  31. class CM_RSGL_EXPORT GLGpuProgram : public GpuProgram
  32. {
  33. public:
  34. virtual ~GLGpuProgram();
  35. /// Execute the binding functions for this program
  36. virtual void bindProgram(void) {}
  37. /// Execute the binding functions for this program
  38. virtual void unbindProgram(void) {}
  39. /// Execute the param binding functions for this program
  40. virtual void bindProgramParameters(GpuProgramParametersSharedPtr params, UINT16 mask) {}
  41. /// Get the assigned GL program id
  42. const GLuint getProgramID(void) const
  43. { return mProgramID; }
  44. /** Get the attribute index for a given semantic.
  45. @remarks
  46. This can be used to identify the attribute index to bind non-builtin
  47. attributes like tangent and binormal.
  48. */
  49. virtual GLuint getAttributeIndex(VertexElementSemantic semantic, UINT32 index);
  50. /** Test whether attribute index for a given semantic is valid.
  51. */
  52. virtual bool isAttributeValid(VertexElementSemantic semantic, UINT32 index);
  53. /** Get the fixed attribute bindings normally used by GL for a semantic. */
  54. static GLuint getFixedAttributeIndex(VertexElementSemantic semantic, UINT32 index);
  55. protected:
  56. GLGpuProgram(const String& source, const String& entryPoint, const String& language,
  57. GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired = false);
  58. /** Overridden from GpuProgram, do nothing */
  59. void loadFromSource(void) {}
  60. /// @copydoc Resource::unloadImpl
  61. void unloadImpl(void) {}
  62. GLuint mProgramID;
  63. GLenum mProgramType;
  64. };
  65. /** Specialisation of the GL low-level program for ARB programs. */
  66. class CM_RSGL_EXPORT GLArbGpuProgram : public GLGpuProgram
  67. {
  68. public:
  69. virtual ~GLArbGpuProgram();
  70. /// Execute the binding functions for this program
  71. void bindProgram(void);
  72. /// Execute the unbinding functions for this program
  73. void unbindProgram(void);
  74. /// Execute the param binding functions for this program
  75. void bindProgramParameters(GpuProgramParametersSharedPtr params, UINT16 mask);
  76. /// Get the GL type for the program
  77. const GLuint getProgramType(void) const
  78. { return mProgramType; }
  79. protected:
  80. friend GpuProgram* createGLArbGpuProgram(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile);
  81. GLArbGpuProgram(const String& source, const String& entryPoint, const String& language,
  82. GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired = false);
  83. void loadFromSource(void);
  84. /// @copydoc Resource::unloadImpl
  85. void unloadImpl(void);
  86. };
  87. }; // namespace CamelotEngine
  88. #endif // __GLGpuProgram_H__