This commit is contained in:
Asuro
2025-02-21 22:44:57 +01:00
parent edde743542
commit 833d78c142
8 changed files with 118 additions and 44 deletions

View File

@@ -301,41 +301,14 @@ namespace Game
}
}
// Start Rendering
imguiBeginFrame(20);
ImGui_ImplSDL3_NewFrame();
// TODO: why does this break stuff??
ImGui::DockSpaceOverViewport(0, 0, ImGuiDockNodeFlags_PassthruCentralNode);
ImGui::ShowDemoWindow();
auto& IO = ImGui::GetIO();
GetInstance().GameLevel.Update();
// TODO: Move player stuff to level
{
float proj[16];
bx::mtxProj(proj,
75.0f,
float(shared.Window.WindowWidth) / float(shared.Window.WindowHeight),
0.1f,
1000.0f,
bgfx::getCaps()->homogeneousDepth);
auto& player = GetInstance().Player;
if (player.Mode == PlayerMode::Freefly)
{
player.FreeflyCamTransform.UpdateMatrix();
bgfx::setViewTransform(MainViewID, player.FreeflyCamTransform.M.M, proj);
}
else
{
player.PlayerCamTransform.UpdateMatrix();
bgfx::setViewTransform(MainViewID, player.PlayerCamTransform.M.M, proj);
}
}
GetInstance().GameLevel.Cubes.Render(Models, Materials);
GetInstance().GameLevel.Tests.Render(Models, Materials);
GetInstance().GameLevel.Render(MainViewID, Models, Materials);
bgfx::dbgTextPrintf(1, 1, 0x0F, "Time: %.1fs", GetInstance().Time.Now);
for (int32_t i = 0; i < (int32_t)PerfCounterType::COUNT; ++i)
@@ -343,6 +316,8 @@ namespace Game
bgfx::dbgTextPrintf(
1, 2 + i, 0x0F, "%s Max: %.3fs", PerfCounterNames[i], shared.Window.PerfCounters[i].GetMax());
}
// Finish Frame
imguiEndFrame();
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
@@ -364,7 +339,7 @@ namespace Game
}
Material Material::LoadFromShader(
const char* vertPath, const char* fragPath, uint32_t view, bgfx::TextureHandle tex, bgfx::UniformHandle sampler)
const char* vertPath, const char* fragPath, uint16_t view, bgfx::TextureHandle tex, bgfx::UniformHandle sampler)
{
BX_ASSERT(vertPath != nullptr && fragPath != nullptr, "Invalid shader path!");
bgfx::ShaderHandle vertexShader = loadShader(vertPath);

View File

@@ -49,7 +49,7 @@ namespace Game
uint32_t ViewID = 0;
static Material LoadFromShader(const char* vertPath,
const char* fragPath,
uint32_t view = 0,
uint16_t view,
bgfx::TextureHandle = BGFX_INVALID_HANDLE,
bgfx::UniformHandle sampler = BGFX_INVALID_HANDLE);
};
@@ -64,7 +64,7 @@ namespace Game
int32_t LastWidth = 0;
int32_t LastHeight = 0;
uint32_t ResetFlags = BGFX_RESET_VSYNC;
uint32_t MainViewID = 10;
uint16_t MainViewID = 10;
public:
void Setup();