correctly destroy stuff

This commit is contained in:
Till Wübbers
2025-04-29 09:52:19 +02:00
parent 91e9566747
commit 234a9b1732
4 changed files with 42 additions and 18 deletions

View File

@@ -6,6 +6,7 @@
#include "../Tools.h"
#include "Rendering.h"
#include "Dither.h"
#include "SDL3/SDL_events.h" // IWYU pragma: keep
#include "backends/imgui_impl_sdl3.h"
#include "bgfx/defines.h"
@@ -326,9 +327,10 @@ namespace Game
bgfx::Init init;
init.type = bgfx::RendererType::Direct3D12;
#ifdef _DEBUG
// init.debug = true;
#else
init.debug = true;
// init.debug = false;
#else
init.debug = false;
#endif
init.platformData.nwh = shared.Window.Handle;
init.platformData.ndt = nullptr;
@@ -558,6 +560,22 @@ namespace Game
ZoneScopedN("Shutdown");
LOG("--- RENDERING_SHUTDOWN ---");
for (int32_t i = 0; i < BX_COUNTOF(Textures); ++i)
{
if (isValid(Textures[i].RenderHandle))
{
bgfx::destroy(Textures[i].RenderHandle);
Textures[i].RenderHandle = {bgfx::kInvalidHandle};
}
}
for (int32_t i = 0; i < ModelCount; ++i)
{
bgfx::destroy(Models[i].VertexBuffer);
bgfx::destroy(Models[i].IndexBuffer);
}
ModelCount = 0;
CleanupDitherData(DitherTextures);
if (SetupData.UseImgui)
{
ImGui::SaveIniSettingsToDisk("imgui.ini");