Skip to content
Snippets Groups Projects
Commit da91ed91 authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

[#14] add event boilerplate for swapchain recreation

added event boilerplate for swapchain recreation
needed to change window in create and constructor to not const
parent 3dc17e38
Branches
Tags
1 merge request!25Resolve "EventPoll mit Lambdas"
...@@ -33,7 +33,7 @@ namespace vkcv ...@@ -33,7 +33,7 @@ namespace vkcv
* *
* @param context encapsulates various Vulkan objects * @param context encapsulates various Vulkan objects
*/ */
Core(Context &&context, const Window &window, SwapChain swapChain, std::vector<vk::ImageView> imageViews, Core(Context &&context, Window &window, SwapChain swapChain, std::vector<vk::ImageView> imageViews,
const CommandResources& commandResources, const SyncResources& syncResources) noexcept; const CommandResources& commandResources, const SyncResources& syncResources) noexcept;
// explicit destruction of default constructor // explicit destruction of default constructor
Core() = delete; Core() = delete;
...@@ -53,6 +53,14 @@ namespace vkcv ...@@ -53,6 +53,14 @@ namespace vkcv
SyncResources m_SyncResources; SyncResources m_SyncResources;
uint32_t m_currentSwapchainImageIndex; uint32_t m_currentSwapchainImageIndex;
std::vector<vk::Framebuffer> m_TemporaryFramebuffers; std::vector<vk::Framebuffer> m_TemporaryFramebuffers;
/**
* recreates the swapchain
* @param[in] width new window width
* @param[in] height new window hight
*/
static void recreateSwapchain(int width, int height);
public: public:
/** /**
* Destructor of #Core destroys the Vulkan objects contained in the core's context. * Destructor of #Core destroys the Vulkan objects contained in the core's context.
...@@ -107,7 +115,7 @@ namespace vkcv ...@@ -107,7 +115,7 @@ namespace vkcv
* @param[in] deviceExtensions (optional) Requested device extensions * @param[in] deviceExtensions (optional) Requested device extensions
* @return New instance of #Context * @return New instance of #Context
*/ */
static Core create(const Window &window, static Core create(Window &window,
const char *applicationName, const char *applicationName,
uint32_t applicationVersion, uint32_t applicationVersion,
std::vector<vk::QueueFlagBits> queueFlags = {}, std::vector<vk::QueueFlagBits> queueFlags = {},
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace vkcv namespace vkcv
{ {
Core Core::create(const Window &window, Core Core::create(Window &window,
const char *applicationName, const char *applicationName,
uint32_t applicationVersion, uint32_t applicationVersion,
std::vector<vk::QueueFlagBits> queueFlags, std::vector<vk::QueueFlagBits> queueFlags,
...@@ -70,6 +70,10 @@ namespace vkcv ...@@ -70,6 +70,10 @@ namespace vkcv
const auto defaultCommandResources = createDefaultCommandResources(context.getDevice(), graphicQueueFamilyIndex); const auto defaultCommandResources = createDefaultCommandResources(context.getDevice(), graphicQueueFamilyIndex);
const auto defaultSyncResources = createDefaultSyncResources(context.getDevice()); const auto defaultSyncResources = createDefaultSyncResources(context.getDevice());
window.e_resize.add([&](int width, int height){
recreateSwapchain(width,height);
});
return Core(std::move(context) , window, swapChain, imageViews, defaultCommandResources, defaultSyncResources); return Core(std::move(context) , window, swapChain, imageViews, defaultCommandResources, defaultSyncResources);
} }
...@@ -78,7 +82,7 @@ namespace vkcv ...@@ -78,7 +82,7 @@ namespace vkcv
return m_Context; return m_Context;
} }
Core::Core(Context &&context, const Window &window , SwapChain swapChain, std::vector<vk::ImageView> imageViews, Core::Core(Context &&context, Window &window , SwapChain swapChain, std::vector<vk::ImageView> imageViews,
const CommandResources& commandResources, const SyncResources& syncResources) noexcept : const CommandResources& commandResources, const SyncResources& syncResources) noexcept :
m_Context(std::move(context)), m_Context(std::move(context)),
m_window(window), m_window(window),
...@@ -213,4 +217,9 @@ namespace vkcv ...@@ -213,4 +217,9 @@ namespace vkcv
vk::Format Core::getSwapchainImageFormat() { vk::Format Core::getSwapchainImageFormat() {
return m_swapchain.getSurfaceFormat().format; return m_swapchain.getSurfaceFormat().format;
} }
void Core::recreateSwapchain(int width, int height) {
/* boilerplate for #34 */
std::cout << "Resized to : " << width << " , " << height << std::endl;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment