From ebc3490243ef4a70ae019977ce376e99a2847d73 Mon Sep 17 00:00:00 2001 From: kanato Date: Mon, 2 Mar 2009 01:49:23 +0000 Subject: [PATCH] Add MacOS code to call gestalt to detect OS version. --- Source/OpenTK/Platform/MacOS/Application.cs | 9 ++++++++- .../Platform/MacOS/CarbonBindings/CarbonAPI.cs | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Platform/MacOS/Application.cs b/Source/OpenTK/Platform/MacOS/Application.cs index 3a9dc8ac..d905902b 100644 --- a/Source/OpenTK/Platform/MacOS/Application.cs +++ b/Source/OpenTK/Platform/MacOS/Application.cs @@ -20,6 +20,7 @@ namespace OpenTK.Platform.MacOS.Carbon static bool mInitialized = false; static IntPtr uppHandler; static CarbonGLNative eventHandler; + static int osMajor, osMinor, osBugfix; static Application() { @@ -32,7 +33,13 @@ namespace OpenTK.Platform.MacOS.Carbon API.AcquireRootMenu(); - ConnectEvents(); + ConnectEvents(); + + API.Gestalt(GestaltSelector.SystemVersionMajor, out osMajor); + API.Gestalt(GestaltSelector.SystemVersionMinor, out osMinor); + API.Gestalt(GestaltSelector.SystemVersionBugFix, out osBugfix); + + Debug.Print("Running on Mac OS X {0}.{1}.{2}.", osMajor, osMinor, osBugfix); } internal static CarbonGLNative WindowEventHandler diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs index 6ef33b48..849eba68 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs @@ -370,6 +370,17 @@ namespace OpenTK.Platform.MacOS.Carbon inStructure = 15, } + #endregion + #region --- Enums from gestalt.h --- + + internal enum GestaltSelector + { + SystemVersion = 0x73797376, // FOUR_CHAR_CODE("sysv"), /* system version*/ + SystemVersionMajor = 0x73797331, // FOUR_CHAR_CODE("sys1"), /* The major system version number; in 10.4.17 this would be the decimal value 10 */ + SystemVersionMinor = 0x73797332, // FOUR_CHAR_CODE("sys2"), /* The minor system version number; in 10.4.17 this would be the decimal value 4 */ + SystemVersionBugFix = 0x73797333, // FOUR_CHAR_CODE("sys3") /* The bug fix system version number; in 10.4.17 this would be the decimal value 17 */ + }; + #endregion #region --- Carbon API Methods --- @@ -873,6 +884,12 @@ namespace OpenTK.Platform.MacOS.Carbon IntPtr displayID, out IntPtr displayDevice, Boolean failToMain); + const string gestaltlib = "/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon"; + + + [DllImport(gestaltlib)] + internal static extern OSStatus Gestalt(GestaltSelector selector, out int response); + } #endregion