From 572be48f3884742e41b4005efdccf25633697d3e Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 19 Apr 2021 20:55:25 -0400 Subject: [PATCH] Attempts to add an early exit for non-Metal Macs. This will be necessary only prior to 10.14. --- OSBindings/Mac/Clock Signal/AppDelegate.swift | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/AppDelegate.swift b/OSBindings/Mac/Clock Signal/AppDelegate.swift index f54ae5faf..4b202f4cf 100644 --- a/OSBindings/Mac/Clock Signal/AppDelegate.swift +++ b/OSBindings/Mac/Clock Signal/AppDelegate.swift @@ -11,12 +11,24 @@ import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { - func applicationDidFinishLaunching(_ aNotification: Notification) { + private var failedMetalCheck = false + func applicationDidFinishLaunching(_ notification: Notification) { // Insert code here to initialize your application. - } - func applicationWillTerminate(_ aNotification: Notification) { - // Insert code here to tear down your application. + // Check for at least one Metal-capable GPU; this check + // will become unnecessary if/when the minimum OS version + // that this project supports reascends to 10.14. + if (MTLCopyAllDevices().count == 0) { + self.failedMetalCheck = true + + let alert = NSAlert() + alert.messageText = "This application requires a Metal-capable GPU" + alert.addButton(withTitle: "Exit") + alert.runModal() + + let application = notification.object as! NSApplication + application.terminate(self) + } } private var hasShownOpenDocument = false