OgreGLFrameBufferObject.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 __OgreGLFBO_H__
  25. #define __OgreGLFBO_H__
  26. #include "OgreGLRenderTexture.h"
  27. #include "OgreGLContext.h"
  28. namespace Ogre {
  29. /** Frame Buffer Object abstraction.
  30. */
  31. class _OgreGLExport GLFrameBufferObject
  32. {
  33. public:
  34. GLFrameBufferObject(GLFBOManager *manager, uint fsaa);
  35. ~GLFrameBufferObject();
  36. //void bindSurface(size_t attachment, RenderTarget *target);
  37. /** Bind a surface to a certain attachment point.
  38. attachment: 0..OGRE_MAX_MULTIPLE_RENDER_TARGETS-1
  39. */
  40. void bindSurface(size_t attachment, const GLSurfaceDesc &target);
  41. /** Unbind attachment
  42. */
  43. void unbindSurface(size_t attachment);
  44. /** Bind FrameBufferObject
  45. */
  46. void bind();
  47. /** Swap buffers - only useful when using multisample buffers.
  48. */
  49. void swapBuffers();
  50. /// Get the GL id for the FBO
  51. GLuint getGLFBOID() const { return mFB; }
  52. /// Get the GL id for the multisample FBO
  53. GLuint getGLMultisampleFBOID() const { return mMultisampleFB; }
  54. /// Accessors
  55. size_t getWidth();
  56. size_t getHeight();
  57. PixelFormat getFormat();
  58. GLFBOManager *getManager() { return mManager; }
  59. const GLSurfaceDesc &getSurface(size_t attachment) { return mColour[attachment]; }
  60. private:
  61. GLFBOManager *mManager;
  62. GLsizei mNumSamples;
  63. GLuint mFB;
  64. GLuint mMultisampleFB;
  65. GLSurfaceDesc mMultisampleColourBuffer;
  66. GLSurfaceDesc mDepth;
  67. GLSurfaceDesc mStencil;
  68. // Arbitrary number of texture surfaces
  69. GLSurfaceDesc mColour[OGRE_MAX_MULTIPLE_RENDER_TARGETS];
  70. /** Initialise object (find suitable depth and stencil format).
  71. Must be called every time the bindings change.
  72. It fails with an exception (ERR_INVALIDPARAMS) if:
  73. - Attachment point 0 has no binding
  74. - Not all bound surfaces have the same size
  75. - Not all bound surfaces have the same internal format
  76. */
  77. void initialise();
  78. };
  79. }
  80. #endif