Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
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
28namespace Renderer
29{
30
31namespace Backend
32{
33
34namespace GL
35{
36
37class CDevice;
38class CTexture;
39
40class CFramebuffer final : public IFramebuffer
41{
42public:
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
60private:
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
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
Represents a texture object.
Definition: TextureManager.h:262
Definition: Device.h:51
Definition: Framebuffer.h:41
AttachmentLoadOp GetColorAttachmentLoadOp() const
Definition: Framebuffer.h:55
AttachmentLoadOp m_ColorAttachmentLoadOp
Definition: Framebuffer.h:84
CColor m_ClearColor
Definition: Framebuffer.h:82
uint32_t m_Width
Definition: Framebuffer.h:79
AttachmentStoreOp GetDepthStencilAttachmentStoreOp() const
Definition: Framebuffer.h:58
AttachmentLoadOp GetDepthStencilAttachmentLoadOp() const
Definition: Framebuffer.h:57
~CFramebuffer() override
Definition: Framebuffer.cpp:188
GLbitfield GetAttachmentMask() const
Definition: Framebuffer.h:53
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
GLuint GetHandle() const
Definition: Framebuffer.h:52
AttachmentStoreOp m_DepthStencilAttachmentStoreOp
Definition: Framebuffer.h:87
const CColor & GetClearColor() const override
Returns a clear color for all color attachments of the framebuffer.
Definition: Framebuffer.h:47
IDevice * GetDevice() override
Definition: Framebuffer.cpp:194
uint32_t GetHeight() const override
Definition: Framebuffer.h:50
AttachmentLoadOp m_DepthStencilAttachmentLoadOp
Definition: Framebuffer.h:86
static std::unique_ptr< CFramebuffer > Create(CDevice *device, const char *name, SColorAttachment *colorAttachment, SDepthStencilAttachment *depthStencilAttachment)
Definition: Framebuffer.cpp:38
AttachmentStoreOp m_ColorAttachmentStoreOp
Definition: Framebuffer.h:85
uint32_t GetWidth() const override
Definition: Framebuffer.h:49
GLuint m_Handle
Definition: Framebuffer.h:78
AttachmentStoreOp GetColorAttachmentStoreOp() const
Definition: Framebuffer.h:56
uint32_t m_Height
Definition: Framebuffer.h:79
CDevice * m_Device
Definition: Framebuffer.h:76
GLbitfield m_AttachmentMask
Definition: Framebuffer.h:80
Definition: IDevice.h:48
IFramebuffer stores attachments which should be used by backend as rendering destinations.
Definition: IFramebuffer.h:85
AttachmentStoreOp
Store operation is set for each attachment, what should be done with its content on EndFramebufferPas...
Definition: IFramebuffer.h:52
Backend
Definition: Backend.h:28
AttachmentLoadOp
Load operation is set for each attachment, what should be done with its content on BeginFramebufferPa...
Definition: IFramebuffer.h:37
Definition: VideoMode.h:29
Definition: Color.h:43
Definition: IFramebuffer.h:60
Definition: IFramebuffer.h:68
unsigned int uint32_t
Definition: wposix_types.h:53