This commit is contained in:
JuiceyDev 2026-03-06 00:19:13 +01:00
parent 65a9c99215
commit 2f7962cbb2
4 changed files with 22 additions and 2 deletions

View file

@ -176,6 +176,18 @@ bool C4JRender::ShouldClose()
return !s_window || glfwWindowShouldClose(s_window);
}
void C4JRender::Shutdown()
{
// Destroy the main window and terminate GLFW cleanly so that
// destructors running after the game loop don't touch a dead context.
if (s_window)
{
glfwDestroyWindow(s_window);
s_window = nullptr;
}
glfwTerminate();
}
void C4JRender::DoScreenGrabOnNextPresent() {}
void C4JRender::Clear(int flags)

View file

@ -210,6 +210,7 @@ public:
// Linux window management
bool ShouldClose();
void Shutdown();
};

View file

@ -955,7 +955,12 @@ else
// A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset
Vec3::resetPool();
} // end game loop
}
// Graceful shutdown: destroy GL context and GLFW before any C++ dtors run.
// Without this, static/global destructors that touch GL objects cause SIGSEGV.
RenderManager.Shutdown();
_exit(0);
} // end main
// Free resources, unregister custom classes, and exit.
// app.Uninit();

View file

@ -109,11 +109,13 @@ void Tesselator::end()
if (!hasColor)
{
// 4J - TEMP put in fixed vertex colors if we don't have any, until we have a shader that can cope without them
// Use 0x00000000 (not 0xffffffff) so DrawVertices skips glColor for these vertices,
// letting any caller-set GL colour (e.g. sky colour) pass through unmodified.
unsigned int *pColData = (unsigned int *)_array->data;
pColData += 5;
for( int i = 0; i < vertices; i++ )
{
*pColData = 0xffffffff;
*pColData = 0x00000000;
pColData += 8;
}
#ifdef __PSVITA__