WindowContext¶
Vulkan Window context implementation.
Overview¶
Typical use cases:
Defining Vulkan-specific window context implementations
Header¶
<RaeptorCogs/GAPI/Vulkan/Core/Internal/WindowContext.hpp>
Metadata¶
- Author
Estorc
- Version
v1.0
- Copyright
Copyright (c) 2025 Estorc MIT License.
Classes¶
Class |
Description |
|---|---|
|
Vulkan Window context implementation. |
-
class WindowContext : public RaeptorCogs::GAPI::Common::WindowContext¶
Vulkan Window context implementation.
Provides Vulkan-specific implementations for the window context interface.
Public Functions
-
inline WindowContext(Common::RendererBackend *renderer)¶
Default constructor for Vulkan WindowContext.
-
virtual ~WindowContext() override¶
Destructor for Vulkan WindowContext.
-
virtual void bind() override¶
Bind the window context for rendering.
-
void recreateSwapchain(Window *window = nullptr)¶
Recreate the swapchain and related resources.
Note
Called when the window is resized or the swapchain becomes invalid.
- Parameters:
window – Pointer to the window (optional).
-
inline const VkExtent2D &getSwapExtent() const¶
Get the swapchain extent.
Note
Contains width and height of the swapchain images.
- Returns:
Reference to the VkExtent2D representing the swapchain extent.
-
inline const VkSwapchainKHR &getSwapchain() const¶
Get the Vulkan surface.
- Returns:
Reference to the VkSurfaceKHR representing the Vulkan surface.
-
inline const std::vector<VkFramebuffer> &getFramebuffers() const¶
Get the depth image.
- Returns:
Reference to the VkImage representing the depth image.
-
inline const std::vector<VkCommandBuffer> &getCommandBuffers() const¶
Get the command buffers.
- Returns:
Reference to the vector of VkCommandBuffer representing the command buffers.
-
inline VkSemaphore getImageAvailableSemaphore(size_t index) const¶
Get synchronization objects for the current frame.
- Parameters:
index – Index of the frame.
- Returns:
References to the semaphores and fences for the specified frame.
-
inline VkSemaphore getRenderFinishedSemaphore(size_t index) const¶
Get render finished semaphore for the current frame.
- Parameters:
index – Index of the frame.
- Returns:
Render finished semaphore for the specified frame.
-
inline const VkFence &getInFlightFence(size_t index) const¶
Get in-flight fence for the current frame.
- Parameters:
index – Index of the frame.
- Returns:
In-flight fence for the specified frame.
-
inline VkFence &getImageInFlight(size_t index)¶
Get image in-flight fence for the specified image index.
- Parameters:
index – Index of the swapchain image.
- Returns:
Image in-flight fence for the specified image.
-
inline const size_t &getCurrentFrame() const¶
Get the current frame index.
- Returns:
Current frame index.
-
inline void advanceFrame()¶
Advance to the next frame.
Updates the current frame index in a circular manner.
Private Functions
Private Members
-
Window *window¶
Pointer to the associated window.
Holds a pointer to the Window instance this context is associated with.
-
VkExtent2D swapExtent¶
Swapchain extent (width and height).
Holds the dimensions of the swapchain images.
-
VkSwapchainKHR swapchain¶
Vulkan swapchain.
Holds the Vulkan swapchain used for presenting images to the window.
-
VkImage depthImage¶
Depth image resources.
Holds the depth image, its memory, and image view.
-
VkDeviceMemory depthImageMemory¶
Depth image memory.
Holds the memory allocated for the depth image.
-
VkImageView depthImageView¶
Depth image view.
Holds the image view for the depth image.
-
std::vector<VkFramebuffer> framebuffers¶
Framebuffers for the swapchain images.
Holds the framebuffers used for rendering to the swapchain images.
-
std::vector<VkCommandBuffer> commandBuffers¶
Command buffers for rendering.
Holds the command buffers used for rendering operations.
-
const unsigned int MAX_FRAMES_IN_FLIGHT = 2¶
Maximum number of frames that can be processed concurrently.
Holds the maximum number of frames in flight.
-
std::vector<VkSemaphore> imageAvailableSemaphores¶
Synchronization objects for image availability.
Holds semaphores for signaling when an image is available for rendering.
-
std::vector<VkSemaphore> renderFinishedSemaphores¶
Synchronization objects for render completion.
Holds semaphores for signaling when rendering is finished.
-
std::vector<VkFence> inFlightFences¶
Fences for frame synchronization.
Holds fences to ensure that frames are rendered in order.
-
inline WindowContext(Common::RendererBackend *renderer)¶