Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ISwapChain.h
Go to the documentation of this file.
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_ISWAPCHAIN
19#define INCLUDED_RENDERER_BACKEND_ISWAPCHAIN
20
23
24#include <cstdint>
25
26namespace Renderer
27{
28
29namespace Backend
30{
31
32class ISwapChain : public IDeviceObject<ISwapChain>
33{
34public:
35 /**
36 * @return True if we still can use the swapchain to present. A swapchain
37 * can become invalid on window resize or some other system event.
38 */
39 virtual bool IsValid() const = 0;
40
41 /**
42 * Acquires a backbuffer for rendering a frame.
43 *
44 * @return True if it was successfully acquired and we can render to it.
45 */
46 virtual bool AcquireNextBackbuffer() = 0;
47
48 /**
49 * Returns a framebuffer for the current backbuffer with the required
50 * attachment operations. It should not be called if the last
51 * AcquireNextBackbuffer call returned false.
52 *
53 * It's guaranteed that for the same acquired backbuffer this function returns
54 * a framebuffer with the same attachments and properties except load and
55 * store operations.
56 *
57 * @return The last successfully acquired framebuffer that wasn't
58 * presented.
59 */
61 const AttachmentLoadOp colorAttachmentLoadOp,
62 const AttachmentStoreOp colorAttachmentStoreOp,
63 const AttachmentLoadOp depthStencilAttachmentLoadOp,
64 const AttachmentStoreOp depthStencilAttachmentStoreOp) = 0;
65
66 /**
67 * Presents the backbuffer to the swapchain queue to be flipped on a
68 * screen. Should be called only if the last AcquireNextBackbuffer call
69 * returned true.
70 */
71 virtual void Present() = 0;
72};
73
74} // namespace Backend
75
76} // namespace Renderer
77
78#endif // INCLUDED_RENDERER_BACKEND_ISWAPCHAIN
Definition: IDeviceObject.h:33
IFramebuffer stores attachments which should be used by backend as rendering destinations.
Definition: IFramebuffer.h:87
Definition: ISwapChain.h:33
virtual void Present()=0
Presents the backbuffer to the swapchain queue to be flipped on a screen.
virtual IFramebuffer * GetCurrentBackbuffer(const AttachmentLoadOp colorAttachmentLoadOp, const AttachmentStoreOp colorAttachmentStoreOp, const AttachmentLoadOp depthStencilAttachmentLoadOp, const AttachmentStoreOp depthStencilAttachmentStoreOp)=0
Returns a framebuffer for the current backbuffer with the required attachment operations.
virtual bool AcquireNextBackbuffer()=0
Acquires a backbuffer for rendering a frame.
virtual bool IsValid() const =0
AttachmentStoreOp
Store operation is set for each attachment, what should be done with its content on EndFramebufferPas...
Definition: IFramebuffer.h:54
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:39
Definition: Canvas2D.h:30