From dc12510fcb2e631929e3951e51abd703d6aa3598 Mon Sep 17 00:00:00 2001 From: Asuro Date: Fri, 21 Feb 2025 00:09:24 +0100 Subject: [PATCH] some fixes --- src/game/rendering/Rendering.cpp | 16 +++++++++++++--- src/game/rendering/Rendering.h | 4 ++++ src/game/rendering/imgui-helper.cpp | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/game/rendering/Rendering.cpp b/src/game/rendering/Rendering.cpp index 3c3fed9..2c2a1da 100644 --- a/src/game/rendering/Rendering.cpp +++ b/src/game/rendering/Rendering.cpp @@ -205,8 +205,10 @@ namespace Game init.platformData.type = bgfx::NativeWindowHandleType::Default; init.resolution.width = shared.Window.WindowWidth; init.resolution.height = shared.Window.WindowHeight; - init.resolution.reset = BGFX_RESET_VSYNC; + init.resolution.reset = ResetFlags; + LastWidth = shared.Window.WindowWidth; + LastHeight = shared.Window.WindowHeight; Log("%i by %i", init.resolution.width, init.resolution.height); if (!bgfx::init(init)) @@ -217,7 +219,7 @@ namespace Game { Log("BGFX setup succeded!"); } - bgfx::setDebug(BGFX_DEBUG_TEXT); + // bgfx::setDebug(BGFX_DEBUG_TEXT); bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x303030ff, 1.0f, 0); DefaultSampler = bgfx::createUniform("s_texColor", bgfx::UniformType::Sampler); @@ -263,7 +265,8 @@ namespace Game ImGui_ImplSDL3_NewFrame(); imguiBeginFrame(0, 0, 0, 0, shared.Window.WindowWidth, shared.Window.WindowHeight); - ImGui::DockSpaceOverViewport(); + // TODO: why does this break stuff?? + // ImGui::DockSpaceOverViewport(); ImGui::ShowDemoWindow(); // Reload shaders if necessary @@ -289,6 +292,13 @@ namespace Game } } } + if (shared.Window.WindowWidth != LastWidth || shared.Window.WindowHeight != LastHeight) + { + bgfx::reset(shared.Window.WindowWidth, shared.Window.WindowHeight, ResetFlags); + + LastWidth = shared.Window.WindowWidth; + LastHeight = shared.Window.WindowHeight; + } { GetInstance().GameLevel.Update(); diff --git a/src/game/rendering/Rendering.h b/src/game/rendering/Rendering.h index 4237ad1..b064d66 100644 --- a/src/game/rendering/Rendering.h +++ b/src/game/rendering/Rendering.h @@ -1,4 +1,5 @@ #pragma once +#include "bgfx/defines.h" #include #include #include @@ -58,6 +59,9 @@ namespace Game Texture Textures[8]; Material Materials[8]; Model Models[8]; + int32_t LastWidth = 0; + int32_t LastHeight = 0; + uint32_t ResetFlags = BGFX_RESET_VSYNC; public: void Setup(); diff --git a/src/game/rendering/imgui-helper.cpp b/src/game/rendering/imgui-helper.cpp index ba57594..5ae0b36 100644 --- a/src/game/rendering/imgui-helper.cpp +++ b/src/game/rendering/imgui-helper.cpp @@ -322,8 +322,8 @@ struct OcornutImguiContext { m_viewId = _viewId; - // ImGuiIO& io = ImGui::GetIO(); - // io.DisplaySize = ImVec2((float)_width, (float)_height); + ImGuiIO& io = ImGui::GetIO(); + io.DisplaySize = ImVec2((float)_width, (float)_height); const int64_t now = bx::getHPCounter(); const int64_t frameTime = now - m_last;