LCOV - code coverage report
Current view: top level - source/renderer/backend/gl - Framebuffer.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 9 0.0 %
Date: 2026-12-03 01:19:39 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2026 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #ifndef INCLUDED_RENDERER_BACKEND_GL_FRAMEBUFFER
      19             : #define INCLUDED_RENDERER_BACKEND_GL_FRAMEBUFFER
      20             : 
      21             : #include "graphics/Color.h"
      22             : #include "lib/config2.h"
      23             : #include "renderer/backend/IFramebuffer.h"
      24             : 
      25             : #if CONFIG2_GLES
      26             : #include "external_libraries/opengles2_wrapper.h"
      27             : #else
      28             : #include <glad/gl.h>
      29             : #endif
      30             : 
      31             : #include <cstdint>
      32             : #include <memory>
      33             : 
      34             : namespace Renderer
      35             : {
      36             : 
      37             : namespace Backend
      38             : {
      39             : 
      40             : namespace GL
      41             : {
      42             : 
      43             : class CDevice;
      44             : 
      45             : class CFramebuffer final : public IFramebuffer
      46             : {
      47             : public:
      48             :     ~CFramebuffer() override;
      49             : 
      50             :     IDevice* GetDevice() override;
      51             : 
      52           0 :     const CColor& GetClearColor() const override { return m_ClearColor; }
      53             : 
      54           0 :     uint32_t GetWidth() const override { return m_Width; }
      55           0 :     uint32_t GetHeight() const override { return m_Height; }
      56             : 
      57           0 :     GLuint GetHandle() const { return m_Handle; }
      58           0 :     GLbitfield GetAttachmentMask() const { return m_AttachmentMask; }
      59             : 
      60           0 :     AttachmentLoadOp GetColorAttachmentLoadOp() const { return m_ColorAttachmentLoadOp; }
      61           0 :     AttachmentStoreOp GetColorAttachmentStoreOp() const { return m_ColorAttachmentStoreOp; }
      62           0 :     AttachmentLoadOp GetDepthStencilAttachmentLoadOp() const { return m_DepthStencilAttachmentLoadOp; }
      63           0 :     AttachmentStoreOp GetDepthStencilAttachmentStoreOp() const { return m_DepthStencilAttachmentStoreOp; }
      64             : 
      65             : private:
      66             :     friend class CDevice;
      67             :     friend class CSwapChain;
      68             : 
      69             :     static std::unique_ptr<CFramebuffer> Create(
      70             :         CDevice* device, const char* name, SColorAttachment* colorAttachment,
      71             :         SDepthStencilAttachment* depthStencilAttachment);
      72             :     static std::unique_ptr<CFramebuffer> CreateBackbuffer(
      73             :         CDevice* device,
      74             :         const int surfaceDrawableWidth, const int surfaceDrawableHeight,
      75             :         const AttachmentLoadOp colorAttachmentLoadOp,
      76             :         const AttachmentStoreOp colorAttachmentStoreOp,
      77             :         const AttachmentLoadOp depthStencilAttachmentLoadOp,
      78             :         const AttachmentStoreOp depthStencilAttachmentStoreOp);
      79             : 
      80             :     CFramebuffer();
      81             : 
      82             :     CDevice* m_Device = nullptr;
      83             : 
      84             :     GLuint m_Handle = 0;
      85             :     uint32_t m_Width = 0, m_Height = 0;
      86             :     GLbitfield m_AttachmentMask = 0;
      87             : 
      88             :     CColor m_ClearColor;
      89             : 
      90             :     AttachmentLoadOp m_ColorAttachmentLoadOp = AttachmentLoadOp::DONT_CARE;
      91             :     AttachmentStoreOp m_ColorAttachmentStoreOp = AttachmentStoreOp::DONT_CARE;
      92             :     AttachmentLoadOp m_DepthStencilAttachmentLoadOp = AttachmentLoadOp::DONT_CARE;
      93             :     AttachmentStoreOp m_DepthStencilAttachmentStoreOp = AttachmentStoreOp::DONT_CARE;
      94             : };
      95             : 
      96             : } // namespace GL
      97             : 
      98             : } // namespace Backend
      99             : 
     100             : } // namespace Renderer
     101             : 
     102             : #endif // INCLUDED_RENDERER_BACKEND_GL_FRAMEBUFFER

Generated by: LCOV version 1.16