Line data Source code
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"
23 : #include "renderer/backend/IFramebuffer.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 0 : class CFramebuffer final : public IFramebuffer
41 : {
42 : public:
43 : ~CFramebuffer() override;
44 :
45 : IDevice* GetDevice() override;
46 :
47 0 : const CColor& GetClearColor() const override { return m_ClearColor; }
48 :
49 0 : uint32_t GetWidth() const override { return m_Width; }
50 0 : uint32_t GetHeight() const override { return m_Height; }
51 :
52 0 : GLuint GetHandle() const { return m_Handle; }
53 0 : GLbitfield GetAttachmentMask() const { return m_AttachmentMask; }
54 :
55 0 : AttachmentLoadOp GetColorAttachmentLoadOp() const { return m_ColorAttachmentLoadOp; }
56 0 : AttachmentStoreOp GetColorAttachmentStoreOp() const { return m_ColorAttachmentStoreOp; }
57 0 : AttachmentLoadOp GetDepthStencilAttachmentLoadOp() const { return m_DepthStencilAttachmentLoadOp; }
58 0 : AttachmentStoreOp GetDepthStencilAttachmentStoreOp() const { return m_DepthStencilAttachmentStoreOp; }
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;
79 : uint32_t m_Width = 0, m_Height = 0;
80 : GLbitfield m_AttachmentMask = 0;
81 :
82 : CColor m_ClearColor;
83 :
84 : AttachmentLoadOp m_ColorAttachmentLoadOp = AttachmentLoadOp::DONT_CARE;
85 : AttachmentStoreOp m_ColorAttachmentStoreOp = AttachmentStoreOp::DONT_CARE;
86 : AttachmentLoadOp m_DepthStencilAttachmentLoadOp = AttachmentLoadOp::DONT_CARE;
87 : AttachmentStoreOp m_DepthStencilAttachmentStoreOp = AttachmentStoreOp::DONT_CARE;
88 : };
89 :
90 : } // namespace GL
91 :
92 : } // namespace Backend
93 :
94 : } // namespace Renderer
95 :
96 : #endif // INCLUDED_RENDERER_BACKEND_GL_FRAMEBUFFER
|