Add MacOS code to call gestalt to detect OS version.

This commit is contained in:
kanato 2009-03-02 01:49:23 +00:00
parent 4ac210a991
commit ebc3490243
2 changed files with 25 additions and 1 deletions

View file

@ -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

View file

@ -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