diff --git a/4J.Render/4J_Render.cpp b/4J.Render/4J_Render.cpp index 879a27695..65b408e1e 100644 --- a/4J.Render/4J_Render.cpp +++ b/4J.Render/4J_Render.cpp @@ -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) diff --git a/4J.Render/4J_Render.h b/4J.Render/4J_Render.h index 657edaf99..d16df4112 100644 --- a/4J.Render/4J_Render.h +++ b/4J.Render/4J_Render.h @@ -210,6 +210,7 @@ public: // Linux window management bool ShouldClose(); + void Shutdown(); }; diff --git a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp index 748b0da8d..8fdb60aca 100644 --- a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp @@ -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(); diff --git a/Minecraft.Client/Rendering/Tesselator.cpp b/Minecraft.Client/Rendering/Tesselator.cpp index 921175e2a..d16746a23 100644 --- a/Minecraft.Client/Rendering/Tesselator.cpp +++ b/Minecraft.Client/Rendering/Tesselator.cpp @@ -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__