CmGLRenderTexture.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 __GLRENDERTEXTURE_H__
  25. #define __GLRENDERTEXTURE_H__
  26. #include "CmGLTexture.h"
  27. #include "CmModule.h"
  28. namespace CamelotEngine {
  29. /** GL surface descriptor. Points to a 2D surface that can be rendered to.
  30. */
  31. struct GLSurfaceDesc
  32. {
  33. public:
  34. GLHardwarePixelBuffer *buffer;
  35. size_t zoffset;
  36. UINT32 numSamples;
  37. GLSurfaceDesc() :buffer(0), zoffset(0), numSamples(0) {}
  38. };
  39. /** Base class for GL Render Textures
  40. */
  41. class CM_RSGL_EXPORT GLRenderTexture: public RenderTexture
  42. {
  43. public:
  44. GLRenderTexture(const String &name, const GLSurfaceDesc &target, bool writeGamma, UINT32 fsaa);
  45. virtual ~GLRenderTexture();
  46. bool requiresTextureFlipping() const { return true; }
  47. };
  48. /** Manager/factory for RenderTextures.
  49. */
  50. class CM_RSGL_EXPORT GLRTTManager: public Module<GLRTTManager>
  51. {
  52. public:
  53. virtual ~GLRTTManager();
  54. /** Create a texture rendertarget object
  55. */
  56. virtual RenderTexture *createRenderTexture(const String &name, const GLSurfaceDesc &target, bool writeGamma, UINT32 fsaa) = 0;
  57. /** Check if a certain format is usable as rendertexture format
  58. */
  59. virtual bool checkFormat(PixelFormat format) = 0;
  60. /** Bind a certain render target.
  61. */
  62. virtual void bind(RenderTarget *target) = 0;
  63. /** Unbind a certain render target. This is called before binding another RenderTarget, and
  64. before the context is switched. It can be used to do a copy, or just be a noop if direct
  65. binding is used.
  66. */
  67. virtual void unbind(RenderTarget *target) = 0;
  68. /** Create a multi render target
  69. */
  70. virtual MultiRenderTarget* createMultiRenderTarget(const String & name);
  71. /** Get the closest supported alternative format. If format is supported, returns format.
  72. */
  73. virtual PixelFormat getSupportedAlternative(PixelFormat format);
  74. };
  75. /** RenderTexture for simple copying from frame buffer
  76. */
  77. class GLCopyingRTTManager;
  78. class CM_RSGL_EXPORT GLCopyingRenderTexture: public GLRenderTexture
  79. {
  80. public:
  81. GLCopyingRenderTexture(GLCopyingRTTManager *manager, const String &name, const GLSurfaceDesc &target,
  82. bool writeGamma, UINT32 fsaa);
  83. virtual void getCustomAttribute(const String& name, void* pData);
  84. };
  85. /** Simple, copying manager/factory for RenderTextures. This is only used as the last fallback if
  86. both PBuffers and FBOs aren't supported.
  87. */
  88. class CM_RSGL_EXPORT GLCopyingRTTManager: public GLRTTManager
  89. {
  90. public:
  91. GLCopyingRTTManager();
  92. virtual ~GLCopyingRTTManager();
  93. /** @copydoc GLRTTManager::createRenderTexture
  94. */
  95. virtual RenderTexture *createRenderTexture(const String &name, const GLSurfaceDesc &target, bool writeGamma, UINT32 fsaa);
  96. /** @copydoc GLRTTManager::checkFormat
  97. */
  98. virtual bool checkFormat(PixelFormat format);
  99. /** @copydoc GLRTTManager::bind
  100. */
  101. virtual void bind(RenderTarget *target);
  102. /** @copydoc GLRTTManager::unbind
  103. */
  104. virtual void unbind(RenderTarget *target);
  105. };
  106. }
  107. #endif // __GLTEXTURE_H__