This commit is contained in:
Asuro
2025-03-14 22:07:44 +01:00
parent a3e22b7b05
commit a5e32c414e
5 changed files with 236 additions and 185 deletions

View File

@@ -3,9 +3,12 @@
#include "Instance.h"
#include "Log.h"
#include "Setup.h"
#include "rendering/Rendering.h"
#include "bx/bx.h"
#include "bx/timer.h"
#include "rendering/Rendering.h"
#include <client/TracyProfiler.hpp>
#include <tracy/tracy.hpp>
namespace Game
{
@@ -23,6 +26,7 @@ namespace Game
void Setup(SharedData& shared)
{
LOG("Game Setup Start!");
tracy::StartupProfiler();
if (shared.Game.PermanentStorage == nullptr)
{
@@ -56,33 +60,35 @@ namespace Game
void Update()
{
auto& inst = GetInstance();
int64_t newNowHP = bx::getHPCounter() - inst.Time.StartTime;
inst.Time.DeltaHP = newNowHP - inst.Time.NowHP;
inst.Time.NowHP = newNowHP;
inst.Time.Now = (double)inst.Time.NowHP / bx::getHPFrequency();
inst.Time.Delta = (double)inst.Time.DeltaHP / bx::getHPFrequency();
GetShared().Window.PerfCounters[(int32_t)PerfCounterType::GameDelta].Write(inst.Time.DeltaHP,
GetShared().Window.FrameCounter);
if (GetKeyPressedNow(ScanCode::R))
{
GetInstance().Size = 0;
Shutdown();
Setup(GetShared());
ZoneScopedN("TimeUpdate");
auto& inst = GetInstance();
int64_t newNowHP = bx::getHPCounter() - inst.Time.StartTime;
inst.Time.DeltaHP = newNowHP - inst.Time.NowHP;
inst.Time.NowHP = newNowHP;
inst.Time.Now = (double)inst.Time.NowHP / bx::getHPFrequency();
inst.Time.Delta = (double)inst.Time.DeltaHP / bx::getHPFrequency();
GetShared().Window.PerfCounters[(int32_t)PerfCounterType::GameDelta].Write(inst.Time.DeltaHP,
GetShared().Window.FrameCounter);
}
SetupInstance.Rendering.Update();
auto& win = GetShared().Window;
win.MouseDeltaX = 0.0f;
win.MouseDeltaY = 0.0f;
bx::memCopy(win.LastHeldScanCodes, win.HeldScanCodes, sizeof(win.HeldScanCodes));
bx::memCopy(win.LastHeldMouseButtons, win.HeldMouseButtons, sizeof(win.HeldMouseButtons));
{
ZoneScopedN("MouseDeltaUpdate");
auto& win = GetShared().Window;
win.MouseDeltaX = 0.0f;
win.MouseDeltaY = 0.0f;
bx::memCopy(win.LastHeldScanCodes, win.HeldScanCodes, sizeof(win.HeldScanCodes));
bx::memCopy(win.LastHeldMouseButtons, win.HeldMouseButtons, sizeof(win.HeldMouseButtons));
}
FrameMark;
}
void Shutdown()
{
LOG("Shutdown");
SetupInstance.Rendering.Shutdown();
tracy::ShutdownProfiler();
}
} // namespace Game