Fix some stuff

This commit is contained in:
2026-06-21 18:00:22 +02:00
parent b1dad89214
commit d534e57ad2
14 changed files with 518 additions and 238 deletions
+32 -8
View File
@@ -1,4 +1,5 @@
#include <chrono>
#include <SDL_vulkan.h>
#include <thread>
#include <destrum/App.h>
@@ -66,6 +67,8 @@ void App::run() {
InputManager::GetInstance().BeginFrame();
camera.Update(dt);
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
@@ -76,8 +79,11 @@ void App::run() {
switch (event.window.event) {
case SDL_WINDOWEVENT_SIZE_CHANGED:
case SDL_WINDOWEVENT_RESIZED:
m_params.windowSize = { event.window.data1, event.window.data2 };
{
resizePending = true;
lastResizeTime = std::chrono::steady_clock::now();
break;
}
}
}
if (InputManager::GetInstance().ProcessEvent(event)) {
@@ -104,15 +110,33 @@ void App::run() {
const float alpha = accumulator / fixedDt;
if (!gfxDevice.needsSwapchainRecreate()) {
customDraw();
if (gfxDevice.needsSwapchainRecreate() || resizePending) {
auto now = std::chrono::steady_clock::now();
if (resizePending &&
now - lastResizeTime < std::chrono::milliseconds(100)) {
continue;
}
int w = 0;
int h = 0;
SDL_Vulkan_GetDrawableSize(window, &w, &h);
if (w == 0 || h == 0) {
continue;
}
spdlog::info("Recreating swapchain to size: {}x{}", w, h);
gfxDevice.recreateSwapchain(w, h);
onWindowResize(w, h);
resizePending = false;
continue;
}
if (gfxDevice.needsSwapchainRecreate()) {
spdlog::info("Recreating swapchain to size: {}x{}", m_params.windowSize.x, m_params.windowSize.y);
gfxDevice.recreateSwapchain(m_params.windowSize.x, m_params.windowSize.y);
onWindowResize(m_params.windowSize.x, m_params.windowSize.y);
}
customDraw();
if (frameLimit) {
auto sleepTime = Time::GetInstance().SleepDuration();