FramebufferImpl.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright (C) 2009-2017, 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)
  17. : Framebuffer(manager)
  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. Bool8 m_bindDefault = false;
  41. Bool8 m_clearDepth = false;
  42. Bool8 m_clearStencil = false;
  43. /// Attach a texture
  44. static void attachTextureInternal(
  45. GLenum attachment, const TextureViewImpl& view, const FramebufferAttachmentInfo& info);
  46. /// Create the FBO
  47. ANKI_USE_RESULT Error createFbo(const Array<U, MAX_COLOR_ATTACHMENTS + 1>& layers, GLenum depthStencilBindingPoint);
  48. };
  49. /// @}
  50. } // end namespace anki