Dynamic window resizing
This commit is contained in:
@@ -13,6 +13,18 @@ namespace cve {
|
||||
|
||||
CveSwapChain::CveSwapChain(CveDevice &deviceRef, VkExtent2D extent)
|
||||
: device{deviceRef}, windowExtent{extent} {
|
||||
init();
|
||||
}
|
||||
|
||||
CveSwapChain::CveSwapChain(CveDevice &deviceRef, VkExtent2D extent, std::shared_ptr<CveSwapChain> previous)
|
||||
: device{deviceRef}, windowExtent{extent}, oldSwapChain{previous} {
|
||||
init();
|
||||
|
||||
// Clean up old swap chain
|
||||
oldSwapChain = nullptr;
|
||||
}
|
||||
|
||||
void CveSwapChain::init() {
|
||||
createSwapChain();
|
||||
createImageViews();
|
||||
createRenderPass();
|
||||
@@ -162,7 +174,7 @@ void CveSwapChain::createSwapChain() {
|
||||
createInfo.presentMode = presentMode;
|
||||
createInfo.clipped = VK_TRUE;
|
||||
|
||||
createInfo.oldSwapchain = VK_NULL_HANDLE;
|
||||
createInfo.oldSwapchain = oldSwapChain ? oldSwapChain->swapChain : VK_NULL_HANDLE;
|
||||
|
||||
if (vkCreateSwapchainKHR(device.device(), &createInfo, nullptr, &swapChain) != VK_SUCCESS) {
|
||||
throw std::runtime_error("failed to create swap chain!");
|
||||
|
||||
Reference in New Issue
Block a user