FramebufferImpl.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (C) 2009-2023, 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. /// @addtogroup opengl
  10. /// @{
  11. /// Framebuffer implementation.
  12. class FramebufferImpl final : public Framebuffer, public GlObject
  13. {
  14. public:
  15. FramebufferImpl(GrManager* manager, CString name)
  16. : Framebuffer(manager, name)
  17. {
  18. }
  19. ~FramebufferImpl()
  20. {
  21. destroyDeferred(getManager(), glDeleteFramebuffers);
  22. }
  23. /// Set all the attachments. It will overwrite the previous state. If the initalizer list is empty the it will bind
  24. /// the default framebuffer
  25. ANKI_USE_RESULT Error init(const FramebufferInitInfo& init);
  26. /// Bind it to the state. Call it in rendering thread
  27. void bind(const GlState& state, U32 minx, U32 miny, U32 width, U32 height) const;
  28. void endRenderPass() const;
  29. U getColorBufferCount() const
  30. {
  31. return m_in.m_colorAttachmentCount;
  32. }
  33. private:
  34. FramebufferInitInfo m_in;
  35. Array<U32, 2> m_fbSize = {};
  36. Array<GLenum, kMaxColorRenderTargets> m_drawBuffers;
  37. Array<GLenum, kMaxColorRenderTargets + 1> m_invalidateBuffers;
  38. U8 m_invalidateBuffersCount = 0;
  39. Bool m_clearDepth = false;
  40. Bool m_clearStencil = false;
  41. /// Attach a texture
  42. static void attachTextureInternal(GLenum attachment, const TextureViewImpl& view, const FramebufferAttachmentInfo& info);
  43. /// Create the FBO
  44. ANKI_USE_RESULT Error createFbo(const Array<U, kMaxColorRenderTargets + 1>& layers, GLenum depthStencilBindingPoint);
  45. };
  46. /// @}
  47. } // end namespace anki