From e08a26481cb47ede1c27b0d2c5c697e8c859c1a6 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 20 Mar 2024 07:02:31 +1100 Subject: [PATCH] Haiku: Fix crash when exiting game Also use legacy render mode when running under llvmpipe to reduce disappearing water/bedrock outside map into fog --- src/Graphics_GL1.c | 26 +++++++++++++++----------- src/interop_BeOS.cpp | 11 +++++++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index 3b71bdfa1..602d375df 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -590,23 +590,27 @@ static void Gfx_RestoreState(void) { cc_bool Gfx_WarnIfNecessary(void) { cc_string renderer = String_FromReadonly((const char*)glGetString(GL_RENDERER)); - - if (String_ContainsConst(&renderer, "llvmpipe")) { - Chat_AddRaw("&cSoftware rendering is being used, performance will greatly suffer."); - } + #ifdef CC_BUILD_GL11 Chat_AddRaw("&cYou are using the very outdated OpenGL backend."); Chat_AddRaw("&cAs such you may experience poor performance."); Chat_AddRaw("&cIt is likely you need to install video card drivers."); #endif - if (!String_ContainsConst(&renderer, "Intel")) return false; - Chat_AddRaw("&cIntel graphics cards are known to have issues with the OpenGL build."); - Chat_AddRaw("&cVSync may not work, and you may see disappearing clouds and map edges."); -#ifdef CC_BUILD_WIN - Chat_AddRaw("&cTry downloading the Direct3D 9 build instead."); -#endif - return true; + if (String_ContainsConst(&renderer, "llvmpipe")) { + Chat_AddRaw("&cSoftware rendering is being used, performance will greatly suffer."); + Chat_AddRaw("&cVSync may not work, and you may see disappearing clouds and map edges."); + return true; + } + if (String_ContainsConst(&renderer, "Intel")) { + Chat_AddRaw("&cIntel graphics cards are known to have issues with the OpenGL build."); + Chat_AddRaw("&cVSync may not work, and you may see disappearing clouds and map edges."); + #ifdef CC_BUILD_WIN + Chat_AddRaw("&cTry downloading the Direct3D 9 build instead."); + #endif + return true; + } + return false; } diff --git a/src/interop_BeOS.cpp b/src/interop_BeOS.cpp index 07bd665d7..c9a50ab50 100644 --- a/src/interop_BeOS.cpp +++ b/src/interop_BeOS.cpp @@ -243,6 +243,17 @@ class CC_BWindow : public BWindow public: CC_BWindow(BRect frame) : BWindow(frame, "", B_TITLED_WINDOW, 0) { } void DispatchMessage(BMessage* msg, BHandler* handler); + + virtual ~CC_BWindow() { + if (!view_3D) return; + + // Fixes OpenGL related crashes on exit since Mesa 21 + // Calling RemoveChild seems to fix the crash as per https://dev.haiku-os.org/ticket/16840 + // "Some OpenGL applications like GLInfo crash on exit under Mesa 21" + this->Lock(); + this->RemoveChild(view_3D); + this->Unlock(); + } }; static void ProcessKeyInput(BMessage* msg) {