OgreGLGpuProgram.h 4.3 KB

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