FramebufferHandle.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright (C) 2009-2015, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #ifndef ANKI_GL_GL_FRAMEBUFFER_HANDLE_H
  6. #define ANKI_GL_GL_FRAMEBUFFER_HANDLE_H
  7. #include "anki/gr/GlContainerHandle.h"
  8. #include "anki/gr/gl/FramebufferImpl.h" // XXX
  9. namespace anki {
  10. /// @addtogroup opengl_other
  11. /// @{
  12. /// Attachment.
  13. struct GlAttachment
  14. {
  15. TextureHandle m_texture;
  16. U32 m_layer = 0;
  17. GlAttachmentLoadOperation m_loadOp;
  18. GlAttachmentStoreOperation m_storeOp;
  19. };
  20. /// GlFramebuffer initializer. XXX
  21. struct GlFramebufferInitializer
  22. {
  23. GlAttachment* m_colorAttachments = nullptr;
  24. U32 m_colorAttachmentsCount = 0;
  25. GlAttachment* m_depthStencilAttachment = nullptr;
  26. };
  27. /// Framebuffer handle
  28. class FramebufferHandle: public GlContainerHandle<FramebufferImpl>
  29. {
  30. public:
  31. using Base = GlContainerHandle<FramebufferImpl>;
  32. using Attachment = FramebufferImpl::Attachment;
  33. using Initializer = GlFramebufferInitializer;
  34. FramebufferHandle();
  35. ~FramebufferHandle();
  36. /// Create a framebuffer
  37. ANKI_USE_RESULT Error create(
  38. CommandBufferHandle& commands,
  39. const std::initializer_list<Attachment>& attachments);
  40. /// Bind it to the state
  41. /// @param commands The command buffer
  42. /// @param invalidate If true invalidate the FB after binding it
  43. void bind(CommandBufferHandle& commands, Bool invalidate);
  44. /// Blit another framebuffer to this
  45. /// @param[in, out] commands The command buffer
  46. /// @param[in] b The sorce framebuffer
  47. /// @param[in] sourceRect The source rectangle
  48. /// @param[in] destRect The destination rectangle
  49. /// @param attachmentMask The attachments to blit
  50. /// @param linear Perform linean filtering
  51. void blit(CommandBufferHandle& commands,
  52. const FramebufferHandle& b,
  53. const Array<U32, 4>& sourceRect,
  54. const Array<U32, 4>& destRect,
  55. GLbitfield attachmentMask,
  56. Bool linear);
  57. };
  58. /// @}
  59. } // end namespace anki
  60. #endif