Lagrange [release]

macOS: 10.13 should use OpenGL renderer

=> 6857abd51afdb08bc7f9955d9367d155c6bf1a80

diff --git a/src/macos.h b/src/macos.h
index 07990090..700d50f8 100644
--- a/src/macos.h
+++ b/src/macos.h
@@ -26,6 +26,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 
 /* Platform-specific functionality for macOS */
 
+iBool   shouldDefaultToMetalRenderer_MacOS  (void);
+
 void    setupApplication_MacOS  (void);
 void    insertMenuItems_MacOS   (const char *menuLabel, int atIndex, const iMenuItem *items, size_t count);
 void    handleCommand_MacOS     (const char *cmd);
diff --git a/src/macos.m b/src/macos.m
index 975ba928..1d972ebd 100644
--- a/src/macos.m
+++ b/src/macos.m
@@ -38,14 +38,25 @@ enum iTouchBarVariant {
     default_TouchBarVariant,
 };
 
+static iInt2 macVer_(void) {
+    if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
+        const NSOperatingSystemVersion ver = [[NSProcessInfo processInfo] operatingSystemVersion];
+        return init_I2(ver.majorVersion, ver.minorVersion);
+    }
+    return init_I2(10, 10);
+}
+
 static NSString *currentSystemAppearance_(void) {
     /* This API does not exist on 10.13. */
-    @try {
+    if ([NSApp respondsToSelector:@selector(effectiveAppearance)]) {
         return [[NSApp effectiveAppearance] name];
     }
-    @catch (NSException *) {
-        return @"NSAppearanceNameAqua";
-    }
+    return @"NSAppearanceNameAqua";
+}
+
+iBool shouldDefaultToMetalRenderer_MacOS(void) {
+    const iInt2 ver = macVer_();
+    return ver.x > 10 || ver.y > 13;
 }
 
 /*----------------------------------------------------------------------------------------------*/
diff --git a/src/ui/window.c b/src/ui/window.c
index b1fd3a07..97d56ec5 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -522,7 +522,7 @@ void init_Window(iWindow *d, iRect rect) {
     d->isDrawFrozen = iTrue;
     uint32_t flags = 0;
 #if defined (iPlatformApple)
-    SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
+    SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl");
 #else
     flags |= SDL_WINDOW_OPENGL;
 #endif
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/release/cdiff/6857abd51afdb08bc7f9955d9367d155c6bf1a80
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
28.610441 milliseconds
Gemini-to-HTML Time
0.226386 milliseconds

This content has been proxied by September (ba2dc).