Pyrogenesis  trunk
Framebuffer.h
Go to the documentation of this file.
1 /* Copyright (C) 2022 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/ogl.h"
24 
25 #include <cstdint>
26 #include <memory>
27 
28 namespace Renderer
29 {
30 
31 namespace Backend
32 {
33 
34 namespace GL
35 {
36 
37 class CDevice;
38 class CTexture;
39 
40 class CFramebuffer final : public IFramebuffer
41 {
42 public:
43  ~CFramebuffer() override;
44 
45  IDevice* GetDevice() override;
46 
47  const CColor& GetClearColor() const override { return m_ClearColor; }
48 
49  uint32_t GetWidth() const override { return m_Width; }
50  uint32_t GetHeight() const override { return m_Height; }
51 
52  GLuint GetHandle() const { return m_Handle; }
53  GLbitfield GetAttachmentMask() const { return m_AttachmentMask; }
54 
59 
60 private:
61  friend class CDevice;
62 
63  static std::unique_ptr<CFramebuffer> Create(
64  CDevice* device, const char* name, SColorAttachment* colorAttachment,
65  SDepthStencilAttachment* depthStencilAttachment);
66  static std::unique_ptr<CFramebuffer> CreateBackbuffer(
67  CDevice* device,
68  const int surfaceDrawableWidth, const int surfaceDrawableHeight,
69  const AttachmentLoadOp colorAttachmentLoadOp,
70  const AttachmentStoreOp colorAttachmentStoreOp,
71  const AttachmentLoadOp depthStencilAttachmentLoadOp,
72  const AttachmentStoreOp depthStencilAttachmentStoreOp);
73 
74  CFramebuffer();
75 
76  CDevice* m_Device = nullptr;
77 
78  GLuint m_Handle = 0;
80  GLbitfield m_AttachmentMask = 0;
81 
83 
88 };
89 
90 } // namespace GL
91 
92 } // namespace Backend
93 
94 } // namespace Renderer
95 
96 #endif // INCLUDED_RENDERER_BACKEND_GL_FRAMEBUFFER
GLuint GetHandle() const
Definition: Framebuffer.h:52
AttachmentLoadOp
Load operation is set for each attachment, what should be done with its content on BeginFramebufferPa...
Definition: IFramebuffer.h:36
uint32_t m_Width
Definition: Framebuffer.h:79
const CColor & GetClearColor() const override
Returns a clear color for all color attachments of the framebuffer.
Definition: Framebuffer.h:47
CDevice * m_Device
Definition: Framebuffer.h:76
AttachmentLoadOp m_ColorAttachmentLoadOp
Definition: Framebuffer.h:84
AttachmentStoreOp m_ColorAttachmentStoreOp
Definition: Framebuffer.h:85
AttachmentStoreOp
Store operation is set for each attachment, what should be done with its content on EndFramebufferPas...
Definition: IFramebuffer.h:51
Definition: Color.h:42
Definition: Framebuffer.h:40
~CFramebuffer() override
Definition: Framebuffer.cpp:188
CColor m_ClearColor
Definition: Framebuffer.h:82
AttachmentLoadOp GetDepthStencilAttachmentLoadOp() const
Definition: Framebuffer.h:57
uint32_t GetWidth() const override
Definition: Framebuffer.h:49
static std::unique_ptr< CFramebuffer > CreateBackbuffer(CDevice *device, const int surfaceDrawableWidth, const int surfaceDrawableHeight, const AttachmentLoadOp colorAttachmentLoadOp, const AttachmentStoreOp colorAttachmentStoreOp, const AttachmentLoadOp depthStencilAttachmentLoadOp, const AttachmentStoreOp depthStencilAttachmentStoreOp)
Definition: Framebuffer.cpp:164
AttachmentStoreOp m_DepthStencilAttachmentStoreOp
Definition: Framebuffer.h:87
uint32_t GetHeight() const override
Definition: Framebuffer.h:50
AttachmentLoadOp GetColorAttachmentLoadOp() const
Definition: Framebuffer.h:55
Definition: IDevice.h:47
Represents a texture object.
Definition: TextureManager.h:256
GLuint m_Handle
Definition: Framebuffer.h:78
IDevice * GetDevice() override
Definition: Framebuffer.cpp:194
AttachmentStoreOp GetColorAttachmentStoreOp() const
Definition: Framebuffer.h:56
Definition: IFramebuffer.h:67
Backend
Definition: Backend.h:27
uint32_t m_Height
Definition: Framebuffer.h:79
static std::unique_ptr< CFramebuffer > Create(CDevice *device, const char *name, SColorAttachment *colorAttachment, SDepthStencilAttachment *depthStencilAttachment)
Definition: Framebuffer.cpp:38
unsigned int uint32_t
Definition: wposix_types.h:53
Definition: VideoMode.h:28
GLbitfield GetAttachmentMask() const
Definition: Framebuffer.h:53
Definition: IFramebuffer.h:59
IFramebuffer stores attachments which should be used by backend as rendering destinations.
Definition: IFramebuffer.h:84
GLbitfield m_AttachmentMask
Definition: Framebuffer.h:80
AttachmentStoreOp GetDepthStencilAttachmentStoreOp() const
Definition: Framebuffer.h:58
Definition: Device.h:50
AttachmentLoadOp m_DepthStencilAttachmentLoadOp
Definition: Framebuffer.h:86