summaryrefslogtreecommitdiffstats
path: root/src/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/game.c b/src/game.c
index c3c617a..4b0ea22 100644
--- a/src/game.c
+++ b/src/game.c
@@ -88,6 +88,14 @@ const uint16_t indices[] = {
};
const int INDICES_SIZE = VK_ARRAY_LEN(indices);
+static int resizing_event_watcher(void* data, SDL_Event* event) {
+ if (event->type == SDL_WINDOWEVENT &&
+ event->window.event == SDL_WINDOWEVENT_RESIZED) {
+ s.sdl_window_resized = 1;
+ }
+ return 0;
+}
+
bool
init()
{
@@ -107,6 +115,8 @@ init()
return false;
}
+ SDL_AddEventWatch(resizing_event_watcher,NULL);
+
return true;
}
@@ -552,7 +562,7 @@ void
vulkan_create_surface()
{
if (SDL_Vulkan_CreateSurface(s.sdl_window, s.vk_instance, &s.vk_surface) == SDL_FALSE) {
- vk_log(VK_INFO, "Failed to create surface\n");
+ vk_log(VK_ERROR, "Failed to create surface\n");
} else {
vk_log(VK_INFO, "Vulkan surface created\n");
}
@@ -1599,7 +1609,8 @@ draw_frame() {
result = vkQueuePresentKHR(s.vk_present_queue, &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 || s.sdl_window_resized) {
+ s.sdl_window_resized = 0;
recreateSwapChain();
} else if (result != VK_SUCCESS) {
vk_log(VK_ERROR, "failed to present swap chain image!\n");
@@ -1647,7 +1658,7 @@ main(int argc, char* args[])
while (!quit) {
handle_input(&quit);
draw_frame();
- SDL_Delay(16);
+ //SDL_Delay(16);
}
close_vulkan();