From 44eb8dfdb558f48ce4b78ad9c5f65be45aab5790 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Tue, 26 Sep 2023 04:24:18 -0600 Subject: [PATCH] Added hot swapping textures --- src/port/Engine.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 11ac557a..56937228 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -62,13 +62,32 @@ void GameEngine::Destroy(){ this->context = nullptr; } +bool ShouldClearTextureCacheAtEndOfFrame = false; + void GameEngine::StartFrame() const{ + using LUS::KbScancode; + int32_t dwScancode = this->context->GetWindow()->GetLastScancode(); + this->context->GetWindow()->SetLastScancode(-1); + + switch (dwScancode) { + case KbScancode::LUS_KB_TAB: { + // Toggle HD Assets + CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + ShouldClearTextureCacheAtEndOfFrame = true; + break; + } + } this->context->GetWindow()->StartFrame(); } void GameEngine::RunCommands(Gfx* Commands) { gfx_run(Commands, {}); gfx_end_frame(); + + if (ShouldClearTextureCacheAtEndOfFrame) { + gfx_texture_cache_clear(); + ShouldClearTextureCacheAtEndOfFrame = false; + } } void GameEngine::ProcessFrame(void (*run_one_game_iter)()) const {