some fixes

This commit is contained in:
Asuro
2025-02-21 00:09:24 +01:00
parent 43d7d2d012
commit dc12510fcb
3 changed files with 19 additions and 5 deletions

View File

@@ -205,8 +205,10 @@ namespace Game
init.platformData.type = bgfx::NativeWindowHandleType::Default; init.platformData.type = bgfx::NativeWindowHandleType::Default;
init.resolution.width = shared.Window.WindowWidth; init.resolution.width = shared.Window.WindowWidth;
init.resolution.height = shared.Window.WindowHeight; 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); Log("%i by %i", init.resolution.width, init.resolution.height);
if (!bgfx::init(init)) if (!bgfx::init(init))
@@ -217,7 +219,7 @@ namespace Game
{ {
Log("BGFX setup succeded!"); 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); bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x303030ff, 1.0f, 0);
DefaultSampler = bgfx::createUniform("s_texColor", bgfx::UniformType::Sampler); DefaultSampler = bgfx::createUniform("s_texColor", bgfx::UniformType::Sampler);
@@ -263,7 +265,8 @@ namespace Game
ImGui_ImplSDL3_NewFrame(); ImGui_ImplSDL3_NewFrame();
imguiBeginFrame(0, 0, 0, 0, shared.Window.WindowWidth, shared.Window.WindowHeight); imguiBeginFrame(0, 0, 0, 0, shared.Window.WindowWidth, shared.Window.WindowHeight);
ImGui::DockSpaceOverViewport(); // TODO: why does this break stuff??
// ImGui::DockSpaceOverViewport();
ImGui::ShowDemoWindow(); ImGui::ShowDemoWindow();
// Reload shaders if necessary // 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(); GetInstance().GameLevel.Update();

View File

@@ -1,4 +1,5 @@
#pragma once #pragma once
#include "bgfx/defines.h"
#include <bgfx/bgfx.h> #include <bgfx/bgfx.h>
#include <bx/string.h> #include <bx/string.h>
#include <cstdint> #include <cstdint>
@@ -58,6 +59,9 @@ namespace Game
Texture Textures[8]; Texture Textures[8];
Material Materials[8]; Material Materials[8];
Model Models[8]; Model Models[8];
int32_t LastWidth = 0;
int32_t LastHeight = 0;
uint32_t ResetFlags = BGFX_RESET_VSYNC;
public: public:
void Setup(); void Setup();

View File

@@ -322,8 +322,8 @@ struct OcornutImguiContext
{ {
m_viewId = _viewId; m_viewId = _viewId;
// ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
// io.DisplaySize = ImVec2((float)_width, (float)_height); io.DisplaySize = ImVec2((float)_width, (float)_height);
const int64_t now = bx::getHPCounter(); const int64_t now = bx::getHPCounter();
const int64_t frameTime = now - m_last; const int64_t frameTime = now - m_last;