handle resizes

feature/softbody-runtime-control
Benjamin Kraft 4 months ago
parent 9f533d91c3
commit 4309dae5a0
  1. 2
      include/vulkan/instance.hpp
  2. 4
      src/vulkan/application.cpp
  3. 3
      src/vulkan/instance.cpp

@ -22,6 +22,8 @@ public:
VkQueue presentQueue = VK_NULL_HANDLE;
VkQueue computeQueue = VK_NULL_HANDLE;
bool windowResized = false;
CommandPool* commandPool = nullptr;
struct QueueFamilyIndices {

@ -154,9 +154,9 @@ void Application::drawFrame() {
presentInfo.pImageIndices = &imageIndex;
result = vkQueuePresentKHR(Instance::instance->presentQueue, &presentInfo);
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR){
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || Instance::instance->windowResized){
Instance::instance->windowResized = false;
swapchain->recreateSwapchain();
return;
}
}

@ -67,6 +67,9 @@ void Instance::initWindow() {
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
window = glfwCreateWindow(800, 600, "Vulkan Simulation", nullptr, nullptr);
glfwSetFramebufferSizeCallback(window, [](GLFWwindow* window, int width, int height) {
instance->windowResized = true;
});
}
void Instance::createInstance() {

Loading…
Cancel
Save