VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
SwapchainManager.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
9#include <volk.h>
10#include <vk_mem_alloc.h>
11#include <SDL3/SDL.h>
12#include <SDL3/SDL_vulkan.h>
13#include <vector>
14#include <memory>
15
16#include "context.hpp"
17#include "components/ErrorUtils.hpp"
18
19namespace vex {
22 public:
26 VulkanSwapchainManager(VulkanContext& context, SDL_Window* window);
27
30
33 void createSwapchain();
34
37 void cleanupSwapchain();
38
41 void cleanupSyncObjects();
42
45 void recreateSwapchain();
46
50 void setVSync(bool enabled);
51 private:
53 void createImageViews();
54
56 void createCommandPool();
57
60
62 void createSyncObjects();
63
66
69
73
77 VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
78
82 VkPresentModeKHR chooseSwapPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes);
83
87 VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
88
91 VkFormat findDepthFormat();
92
93 VulkanContext& m_r_context;
94 SDL_Window *m_p_window;
95 bool m_vsyncEnabled = false;
96 };
97}
void cleanupSwapchain()
Cleans up swapchain resources.
void createDepthResources()
Helper function to create depth resources for swapchain creation.
~VulkanSwapchainManager()
Simple destructor.
void setVSync(bool enabled)
Sets the vsync enabled state.
void cleanupSyncObjects()
Cleans up synchronization objects.
VulkanSwapchainManager(VulkanContext &context, SDL_Window *window)
Constructor for VulkanSwapchainManager.
VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector< VkSurfaceFormatKHR > &availableFormats)
Helper function choosing SwapSurfaceFormat based on hardware capabilities.
VkPresentModeKHR chooseSwapPresentMode(const std::vector< VkPresentModeKHR > &availablePresentModes)
Helper function choosing SwapPresentMode based on hardware capabilities.
void cleanupLowResResources()
Helper function to cleanup low resolution resources, since low res resources can be changed without c...
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities)
Helper function choosing SwapExtent based on hardware capabilities.
void createImageViews()
Helper function to create image views for swapchain images.
void recreateSwapchain()
Recreates the swapchain.
void createSyncObjects()
Helper function to create synchronization objects for swapchain creation.
void createCommandPool()
Helper function to create command pool for swapchain creation.
void createLowResResources()
Helper function to create low resolution resources for low res rendering.
VkFormat findDepthFormat()
Helper function to find depth format based on hardware capabilities.
void createCommandBuffers()
Helper function to create command buffers for swapchain creation.
void createSwapchain()
Creates or recreates the swapchain.
This file defines struct holding all vulkan data, like device, surface, swapchain,...
Struct holding all vulkan data, like device, surface, swapchain, images, views, and more.
Definition context.hpp:26