Pyrogenesis  trunk
IFramebuffer.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_IFRAMEBUFFER
19 #define INCLUDED_RENDERER_BACKEND_IFRAMEBUFFER
20 
21 #include "graphics/Color.h"
23 
24 namespace Renderer
25 {
26 
27 namespace Backend
28 {
29 
30 class ITexture;
31 
32 /**
33  * Load operation is set for each attachment, what should be done with its
34  * content on BeginFramebufferPass.
35  */
36 enum class AttachmentLoadOp
37 {
38  // Loads the attachment content.
39  LOAD,
40  // Clears the attachment content without loading. Prefer to use that
41  // operation over manual ClearFramebuffer.
42  CLEAR,
43  // After BeginFramebufferPass the attachment content is undefined.
44  DONT_CARE
45 };
46 
47 /**
48  * Store operation is set for each attachment, what should be done with its
49  * content on EndFramebufferPass.
50  */
52 {
53  // Stores the attachment content.
54  STORE,
55  // After EndFramebufferPass the attachment content is undefined.
56  DONT_CARE
57 };
58 
60 {
61  ITexture* texture = nullptr;
65 };
66 
68 {
69  ITexture* texture = nullptr;
72 };
73 
74 /**
75  * IFramebuffer stores attachments which should be used by backend as rendering
76  * destinations. That combining allows to set these destinations at once.
77  * IFramebuffer doesn't own its attachments so clients must keep them alive.
78  * The number of framebuffers ever created for a device during its lifetime
79  * should be as small as possible.
80  *
81  * Framebuffer is a term from OpenGL/Vulkan worlds (D3D synonym is a render
82  * target).
83  */
84 class IFramebuffer : public IDeviceObject<IFramebuffer>
85 {
86 public:
87  /**
88  * Returns a clear color for all color attachments of the framebuffer.
89  * @see IDevice::CreateFramebuffer()
90  */
91  virtual const CColor& GetClearColor() const = 0;
92 
93  virtual uint32_t GetWidth() const = 0;
94  virtual uint32_t GetHeight() const = 0;
95 };
96 
97 } // namespace Backend
98 
99 } // namespace Renderer
100 
101 #endif // INCLUDED_RENDERER_BACKEND_IFRAMEBUFFER
AttachmentLoadOp
Load operation is set for each attachment, what should be done with its content on BeginFramebufferPa...
Definition: IFramebuffer.h:36
Definition: ITexture.h:33
AttachmentStoreOp
Store operation is set for each attachment, what should be done with its content on EndFramebufferPas...
Definition: IFramebuffer.h:51
CColor clearColor
Definition: IFramebuffer.h:64
Definition: Color.h:42
Definition: IFramebuffer.h:67
Backend
Definition: Backend.h:27
unsigned int uint32_t
Definition: wposix_types.h:53
Definition: VideoMode.h:28
Definition: IDeviceObject.h:32
Definition: IFramebuffer.h:59
IFramebuffer stores attachments which should be used by backend as rendering destinations.
Definition: IFramebuffer.h:84