FramebufferImpl.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Gr/Framebuffer.h>
  7. #include <AnKi/Gr/gl/GlObject.h>
  8. namespace anki
  9. {
  10. /// @addtogroup opengl
  11. /// @{
  12. /// Framebuffer implementation.
  13. class FramebufferImpl final : public Framebuffer, public GlObject
  14. {
  15. public:
  16. FramebufferImpl(GrManager* manager, CString name)
  17. : Framebuffer(manager, name)
  18. {
  19. }
  20. ~FramebufferImpl()
  21. {
  22. destroyDeferred(getManager(), glDeleteFramebuffers);
  23. }
  24. /// Set all the attachments. It will overwrite the previous state. If the initalizer list is empty the it will bind
  25. /// the default framebuffer
  26. ANKI_USE_RESULT Error init(const FramebufferInitInfo& init);
  27. /// Bind it to the state. Call it in rendering thread
  28. void bind(const GlState& state, U32 minx, U32 miny, U32 width, U32 height) const;
  29. void endRenderPass() const;
  30. U getColorBufferCount() const
  31. {
  32. return m_in.m_colorAttachmentCount;
  33. }
  34. private:
  35. FramebufferInitInfo m_in;
  36. Array<U32, 2> m_fbSize = {};
  37. Array<GLenum, MAX_COLOR_ATTACHMENTS> m_drawBuffers;
  38. Array<GLenum, MAX_COLOR_ATTACHMENTS + 1> m_invalidateBuffers;
  39. U8 m_invalidateBuffersCount = 0;
  40. Bool m_clearDepth = false;
  41. Bool m_clearStencil = false;
  42. /// Attach a texture
  43. static void attachTextureInternal(GLenum attachment, const TextureViewImpl& view,
  44. const FramebufferAttachmentInfo& info);
  45. /// Create the FBO
  46. ANKI_USE_RESULT Error createFbo(const Array<U, MAX_COLOR_ATTACHMENTS + 1>& layers, GLenum depthStencilBindingPoint);
  47. };
  48. /// @}
  49. } // end namespace anki