GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
Swapchain.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Ivar Härnqvist
2// SPDX-License-Identifier: MIT
3
4#ifndef GREM_GRAPHICS_SWAPCHAIN_HPP
5#define GREM_GRAPHICS_SWAPCHAIN_HPP
6
8
11
12namespace grem::graphics {
13
14class Device; // Forward declaration, to avoid a circular include of Device.hpp.
15class Window; // Forward declaration, to avoid including Window.hpp.
16
34
49#ifdef __EMSCRIPTEN__
50 true
51#else
52 false
53#endif
54 ;
55};
56
61class Swapchain : public Texture {
62public:
72 GREM_API(graphics) Swapchain(Device& device, Window& window, const SwapchainOptions& options = {});
73
75 ~Swapchain() = default;
76
78 Swapchain(const Swapchain&) = delete;
79
81 Swapchain(Swapchain&&) = delete;
82
84 Swapchain& operator=(const Swapchain&) = delete;
85
88
90 void pasteImage(Extent3D imageSize, const void* pixels, Offset3D destinationOffset, Region3D sourceRegion) = delete;
91
93 void pasteImage(Extent3D imageSize, const void* pixels, Offset3D destinationOffset = {.x = 0, .y = 0, .z = 0}, Offset3D sourceOffset = {.x = 0, .y = 0, .z = 0}) = delete;
94
96 void pasteTexture(const Texture& texture, Offset3D destinationOffset, Region3D sourceRegion) = delete;
97
99 void pasteTexture(const Texture& texture, Offset3D destinationOffset = {.x = 0, .y = 0, .z = 0}, Offset3D sourceOffset = {.x = 0, .y = 0, .z = 0}) = delete;
100
102 void fill(const ClearValues& values = {}) = delete;
103
105 void generateMipmap() = delete;
106
108 [[nodiscard]] Texture copy() const = delete;
109
111 [[nodiscard]] Texture copyWithSamplerOptions(Optional<TextureSamplerOptions> newSamplerOptions) const = delete;
112
121 GREM_API(graphics) void setVerticalSynchronizationEnabled(bool useVerticalSynchronization);
122
133 GREM_API(graphics) void setMaxBufferedFrameCount(uint32_t maxBufferedFrameCount);
134
143 [[nodiscard]] GREM_API(graphics) bool isVerticalSynchronizationEnabled() const;
144
155 [[nodiscard]] GREM_API(graphics) uint32_t getMaxBufferedFrameCount() const;
156};
157
158} // namespace grem::graphics
159
160#endif
Optional value type that holds either a value or no value.
Definition Optional.hpp:58
Persistent system managing the rendering context of a Window.
Definition Device.hpp:68
Swapchain & operator=(const Swapchain &)=delete
Copying a swapchain is not allowed.
void generateMipmap()=delete
Directly modifying a swapchain is not allowed.
void setMaxBufferedFrameCount(uint32_t maxBufferedFrameCount)
Set the maximum buffered frame count.
bool isVerticalSynchronizationEnabled() const
Check if vertical synchronization is enabled.
void pasteImage(Extent3D imageSize, const void *pixels, Offset3D destinationOffset, Region3D sourceRegion)=delete
Directly modifying a swapchain is not allowed.
Swapchain(const Swapchain &)=delete
Copying a swapchain is not allowed.
void fill(const ClearValues &values={})=delete
Directly modifying a swapchain is not allowed.
~Swapchain()=default
Destructor.
void setVerticalSynchronizationEnabled(bool useVerticalSynchronization)
Enable or disable vertical synchronization.
void pasteImage(Extent3D imageSize, const void *pixels, Offset3D destinationOffset={.x=0,.y=0,.z=0}, Offset3D sourceOffset={.x=0,.y=0,.z=0})=delete
Directly modifying a swapchain is not allowed.
Texture copy() const =delete
Copying a swapchain is not allowed.
uint32_t getMaxBufferedFrameCount() const
Get the maximum buffered frame count.
Swapchain(Swapchain &&)=delete
Moving a swapchain is not allowed.
Swapchain & operator=(Swapchain &&)=delete
Moving a swapchain is not allowed.
Texture copyWithSamplerOptions(Optional< TextureSamplerOptions > newSamplerOptions) const =delete
Copying a swapchain is not allowed.
void pasteTexture(const Texture &texture, Offset3D destinationOffset={.x=0,.y=0,.z=0}, Offset3D sourceOffset={.x=0,.y=0,.z=0})=delete
Directly modifying a swapchain is not allowed.
void pasteTexture(const Texture &texture, Offset3D destinationOffset, Region3D sourceRegion)=delete
Directly modifying a swapchain is not allowed.
Swapchain(Device &device, Window &window, const SwapchainOptions &options={})
Construct a swapchain.
Texture() noexcept=default
Construct an empty texture without a value.
Graphical window that can be rendered to.
Definition Window.hpp:131
Definition buffer_layouts.hpp:20
Region< 3 > Region3D
Rectangular region of 3D data.
Definition extents.hpp:820
Offset< 3 > Offset3D
Offset in a 3D data region.
Definition extents.hpp:22
Extent< 3 > Extent3D
Size of a 3D data region.
Definition extents.hpp:32
Specification of values that a texture should be cleared to.
Definition Texture.hpp:426
Configuration options for a Swapchain.
Definition Swapchain.hpp:20
uint32_t maxBufferedFrameCount
Maximum number of additional swapchain frames to buffer and render while waiting for the oldest submi...
Definition Swapchain.hpp:33
bool useVerticalSynchronization
Whether the swapchain should use vertical synchronization (VSync) or not.
Definition Swapchain.hpp:48