evan 2026.1.4
Evan
Loading...
Searching...
No Matches
DesktopSwapchainContext.hpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** DesktopSwapchainContext
6*/
7
8#pragma once
9
10#include "evan/ASwapchainContext.hpp"
11
12#include "evan/glfw/DesktopSwapchainImage.hpp"
13
14#include <memory>
15#include <unordered_map>
16
17namespace evan
18{
19 class DeviceContext;
20
41 {
42 public:
65 DesktopSwapchainContext(const DeviceContext &deviceContext,
66 GLFWwindow *window);
67
69
90 void destroy(VkDevice device) override;
91
109 void recreateSwapchain(const DeviceContext &deviceContext,
110 VkRenderPass renderpass) override;
111
147 VkResult aquireImage(uint32_t index, VkDevice device,
148 VkSemaphore imageAvailableSemaphore,
149 VkFence inFlightFence,
150 uint32_t &imageIndex) override;
151
173 void waitForImage(uint32_t index) override
174 {
175 }
176
182 ViewSet &getViewSet() override;
183
189 const ViewSet &getViewSet() const override;
190
197 VkSampleCountFlagBits getMsaaSamples() const override;
198
205 bool usesImageAvailableSemaphore() const override;
206
214 bool needsSwapchainRecreation() const override;
215
216 private:
220 ViewSet _viewSet;
221
225 GLFWwindow *_referenceWindow;
226
230 VkSampleCountFlagBits _msaaSamples = VK_SAMPLE_COUNT_1_BIT;
231
236 bool _framebufferResized = false;
237
243 static std::unordered_map<GLFWwindow *, DesktopSwapchainContext *>
244 _contexts;
245
255 static void framebufferSizeCallback(GLFWwindow *window, int width,
256 int height);
257 };
258} // namespace evan
Represents the context for managing the swapchain in the rendering system.
Swapchain context for desktop platforms using GLFW.
void recreateSwapchain(const DeviceContext &deviceContext, VkRenderPass renderpass) override
Recreates the swapchain and associated resources.
void destroy(VkDevice device) override
Destroys the swapchain and releases associated resources.
ViewSet & getViewSet() override
Retrieves the set of views to render (mutable).
VkSampleCountFlagBits getMsaaSamples() const override
Retrieves the MSAA sample count used by this swapchain context.
VkResult aquireImage(uint32_t index, VkDevice device, VkSemaphore imageAvailableSemaphore, VkFence inFlightFence, uint32_t &imageIndex) override
Acquires the next available image from the swapchain for rendering.
void waitForImage(uint32_t index) override
Waits for the specified image to be available for rendering.
bool needsSwapchainRecreation() const override
Desktop swapchains must be recreated when the GLFW window is resized.
bool usesImageAvailableSemaphore() const override
Desktop swapchains signal the image-available semaphore through vkAcquireNextImageKHR.
Represents the device context for the engine, managing Vulkan-related resources and operations.
Describes a set of views to render, independent of the swapchain image sets.
Definition ViewSet.hpp:37