|
evan 2026.1.4
Evan
|
Swapchain context for desktop platforms using GLFW. More...
#include <headers/evan/glfw/DesktopSwapchainContext.hpp>


Public Member Functions | |
| DesktopSwapchainContext (const DeviceContext &deviceContext, GLFWwindow *window) | |
| Constructs a DesktopSwapchainContext instance with the provided device context and GLFW window. | |
| void | destroy (VkDevice device) override |
| Destroys the swapchain and releases associated resources. | |
| void | recreateSwapchain (const DeviceContext &deviceContext, VkRenderPass renderpass) override |
| Recreates the swapchain and associated resources. | |
| 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. | |
| ViewSet & | getViewSet () override |
| Retrieves the set of views to render (mutable). | |
| const ViewSet & | getViewSet () const override |
| Retrieves the set of views to render (const). | |
| VkSampleCountFlagBits | getMsaaSamples () const override |
| Retrieves the MSAA sample count used by this swapchain context. | |
| bool | usesImageAvailableSemaphore () const override |
| Desktop swapchains signal the image-available semaphore through vkAcquireNextImageKHR. | |
| bool | needsSwapchainRecreation () const override |
| Desktop swapchains must be recreated when the GLFW window is resized. | |
Public Member Functions inherited from evan::ASwapchainContext | |
| VkRenderPass | getRenderPass () const |
| Retrieves the render pass associated with the swapchain context. | |
| std::size_t | getSwapchainCount () const |
| Retrieves the number of swapchain image sets in the context. | |
| virtual bool | usesMultiview () const |
| Indicates whether the frame renders every view in one pass. | |
| utility::graphic::ViewF | getView (std::size_t index) const |
| Retrieves the view matrix for the specified view index. | |
| virtual void | setView (std::size_t index, const utility::graphic::ViewF &view) |
| Sets the view state for the specified view index. | |
| const utility::graphic::PoseF & | getViewOffset (void) const |
| Retrieves the persistent world-space view offset. | |
| std::size_t | getViewCount (void) const |
| Retrieves the number of views in the swapchain context. | |
| glm::mat4 | getProjection (std::size_t index) const |
| Retrieves the projection matrix for the specified view index. | |
| utility::math::Vector2F | getViewportSize () const |
| Retrieves the current viewport size in pixels. | |
Additional Inherited Members | |
Static Public Member Functions inherited from evan::ASwapchainContext | |
| static void | updateViewForExtent (utility::graphic::ViewF &view, VkExtent2D extent) |
| Updates a view's viewport size and perspective for a new swapchain extent. | |
Public Attributes inherited from evan::ASwapchainContext | |
| std::vector< std::shared_ptr< ASwapchainImage > > | _swapchainImages |
Protected Member Functions inherited from evan::ASwapchainContext | |
| void | createRenderPass (const std::shared_ptr< ADeviceBackend > &deviceBackend, VkSampleCountFlagBits msaaSamples, ColorAttachmentMode mode, uint32_t viewMask=0) |
| Creates the Vulkan render pass for the swapchain context. | |
| VkFormat | selectSwapchainFormat (VkPhysicalDevice physicalDevice, const std::vector< int64_t > &swapchainFormats) |
| Selects the appropriate swapchain format from the available formats. | |
| VkFormat | findSupportedFormat (VkPhysicalDevice physicalDevice, const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features) |
| Finds a supported format from a list of candidates based on the specified tiling and feature requirements. | |
Protected Attributes inherited from evan::ASwapchainContext | |
| VkRenderPass | _renderPass |
| utility::graphic::PoseF | _viewOffset {} |
| Persistent world-space offset applied on top of the tracked poses. | |
Swapchain context for desktop platforms using GLFW.
This class manages the swapchain for desktop applications, providing functionality to acquire images, get projection and view matrices, and handle synchronization. It inherits from ASwapchainContext and implements the necessary virtual functions for desktop-specific behavior.
The constructor initializes the swapchain context with the given device context and GLFW window. The destructor ensures proper cleanup of resources. The aquireImage function allows acquiring an image from the swapchain, while getProjection and getView provide the necessary matrices for rendering.
Definition at line 40 of file DesktopSwapchainContext.hpp.
| evan::DesktopSwapchainContext::DesktopSwapchainContext | ( | const DeviceContext & | deviceContext, |
| GLFWwindow * | window | ||
| ) |
Constructs a DesktopSwapchainContext instance with the provided device context and GLFW window.
This constructor initializes the swapchain context for desktop platforms using GLFW. It takes a reference to a DeviceContext instance, which provides access to Vulkan resources and synchronization mechanisms, and a pointer to a GLFWwindow, which is used to create the swapchain and manage the rendering surface.
| deviceContext | A reference to the DeviceContext instance that provides access to Vulkan resources and synchronization mechanisms. |
| window | A pointer to the GLFWwindow that is used to create the swapchain and manage the rendering surface for desktop applications. |
Definition at line 16 of file DesktopSwapchainContext.cpp.

| evan::DesktopSwapchainContext::~DesktopSwapchainContext | ( | ) |
Definition at line 41 of file DesktopSwapchainContext.cpp.
|
overridevirtual |
Acquires the next available image from the swapchain for rendering.
This function overrides the pure virtual function from ASwapchainContext to handle the acquisition of the next available image from the swapchain for rendering. It takes several parameters, including the index of the image to acquire, the Vulkan device, a semaphore to signal when the image is available, a fence to signal when the image is in flight, and a reference to store the index of the acquired image. Implement this function to ensure that the rendering system can acquire images from the swapchain for rendering operations.
| index | The index of the image to acquire from the swapchain. |
| device | The Vulkan device used to perform the image acquisition. |
| imageAvailableSemaphore | A Vulkan semaphore that will be signaled when the image is available for rendering. |
| inFlightFence | A Vulkan fence that will be signaled when the image is in flight and ready for rendering operations. |
| imageIndex | A reference to a uint32_t variable where the index of the acquired image will be stored. |
Implements evan::ASwapchainContext.
Definition at line 119 of file DesktopSwapchainContext.cpp.
Destroys the swapchain and releases associated resources.
This function overrides the pure virtual function from ASwapchainContext to handle the destruction of the swapchain and the release of any resources associated with it. It takes a Vulkan device as a parameter, which is used to perform the necessary cleanup operations. Implement this function to ensure that all resources related to the swapchain are properly released when the swapchain is no longer needed.
| device | The Vulkan device used to perform cleanup operations for the swapchain. |
Implements evan::ASwapchainContext.
Definition at line 54 of file DesktopSwapchainContext.cpp.
|
overridevirtual |
Retrieves the MSAA sample count used by this swapchain context.
Implements evan::ASwapchainContext.
Definition at line 146 of file DesktopSwapchainContext.cpp.
|
overridevirtual |
Retrieves the set of views to render (const).
Implements evan::ASwapchainContext.
Definition at line 141 of file DesktopSwapchainContext.cpp.
|
overridevirtual |
Retrieves the set of views to render (mutable).
Implements evan::ASwapchainContext.
Definition at line 136 of file DesktopSwapchainContext.cpp.
|
overridevirtual |
Desktop swapchains must be recreated when the GLFW window is resized.
Reimplemented from evan::ASwapchainContext.
Definition at line 156 of file DesktopSwapchainContext.cpp.
|
overridevirtual |
Recreates the swapchain and associated resources.
This function is responsible for recreating the swapchain and any associated resources when the swapchain becomes out of date or needs to be recreated due to changes in the window size or other factors. It takes a reference to the DeviceContext instance, which provides access to Vulkan resources and synchronization mechanisms. Implement this function to ensure that the swapchain is properly recreated and that all necessary resources are reinitialized for rendering operations.
| deviceContext | A reference to the DeviceContext instance that provides access to Vulkan resources and synchronization mechanisms. |
| renderpass | The Vulkan render pass that will be used with the swapchain images during rendering operations. |
Implements evan::ASwapchainContext.
Definition at line 72 of file DesktopSwapchainContext.cpp.

|
overridevirtual |
Desktop swapchains signal the image-available semaphore through vkAcquireNextImageKHR.
Reimplemented from evan::ASwapchainContext.
Definition at line 151 of file DesktopSwapchainContext.cpp.
Waits for the specified image to be available for rendering.
This function overrides the pure virtual function from ASwapchainContext to handle waiting for a specific image to be available for rendering. In the context of desktop applications using GLFW, this function may not require any specific implementation, as synchronization is typically handled through Vulkan semaphores and fences. However, it is essential to provide an implementation to satisfy the interface requirements of ASwapchainContext.
| index | The index of the image to wait for. |
Implements evan::ASwapchainContext.
Definition at line 173 of file DesktopSwapchainContext.hpp.