CmGLRenderTexture.h 4.7 KB

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