CmGLPBRenderTexture.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 __GLPBRENDERTEXTURE_H__
  25. #define __GLPBRENDERTEXTURE_H__
  26. #include "CmGLRenderTexture.h"
  27. #include "CmGLPBuffer.h"
  28. namespace CamelotEngine {
  29. /** RenderTexture that uses a PBuffer (offscreen rendering context) for rendering.
  30. */
  31. class GLPBRTTManager;
  32. class _OgreGLExport GLPBRenderTexture: public GLRenderTexture
  33. {
  34. public:
  35. GLPBRenderTexture(GLPBRTTManager *manager, const String &name, const GLSurfaceDesc &target, bool writeGamma, UINT32 fsaa);
  36. virtual ~GLPBRenderTexture();
  37. virtual void getCustomAttribute(const String& name, void* pData);
  38. protected:
  39. GLPBRTTManager *mManager;
  40. PixelComponentType mPBFormat;
  41. };
  42. /** Manager for rendertextures and PBuffers (offscreen rendering contexts)
  43. */
  44. class _OgreGLExport GLPBRTTManager: public GLRTTManager
  45. {
  46. public:
  47. GLPBRTTManager(GLSupport *support, RenderTarget *mainwindow);
  48. virtual ~GLPBRTTManager();
  49. /** @copydoc GLRTTManager::createRenderTexture
  50. */
  51. virtual RenderTexture *createRenderTexture(const String &name,
  52. const GLSurfaceDesc &target, bool writeGamma, UINT32 fsaa);
  53. /** @copydoc GLRTTManager::checkFormat
  54. */
  55. virtual bool checkFormat(PixelFormat format);
  56. /** @copydoc GLRTTManager::bind
  57. */
  58. virtual void bind(RenderTarget *target);
  59. /** @copydoc GLRTTManager::unbind
  60. */
  61. virtual void unbind(RenderTarget *target);
  62. /** Create PBuffer for a certain pixel format and size
  63. */
  64. void requestPBuffer(PixelComponentType ctype, size_t width, size_t height);
  65. /** Release PBuffer for a certain pixel format
  66. */
  67. void releasePBuffer(PixelComponentType ctype);
  68. /** Get GL rendering context for a certain component type and size.
  69. */
  70. GLContext *getContextFor(PixelComponentType ctype, size_t width, size_t height);
  71. protected:
  72. /** GLSupport reference, used to create PBuffers */
  73. GLSupport *mSupport;
  74. /** Primary window reference */
  75. RenderTarget *mMainWindow;
  76. /** Primary window context */
  77. GLContext *mMainContext;
  78. /** Reference to a PBuffer, with refcount */
  79. struct PBRef
  80. {
  81. PBRef(): pb(0),refcount(0) {}
  82. GLPBuffer* pb;
  83. size_t refcount;
  84. };
  85. /** Type to map each component type to a PBuffer */
  86. PBRef mPBuffers[PCT_COUNT];
  87. };
  88. }
  89. #endif // __GLPBRENDERTEXTURE_H__