Do not call SDL.GetVersion unless requested
This commit is contained in:
parent
635bb85313
commit
32828ecd8a
1 changed files with 24 additions and 9 deletions
|
@ -29,6 +29,7 @@ using System.Runtime.InteropServices;
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Security;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
@ -46,17 +47,25 @@ namespace OpenTK.Platform.SDL2
|
|||
#endif
|
||||
|
||||
public readonly static object Sync = new object();
|
||||
public readonly static Version Version;
|
||||
|
||||
static SDL()
|
||||
static Nullable<Version> version;
|
||||
public static Version Version
|
||||
{
|
||||
try
|
||||
get
|
||||
{
|
||||
GetVersion(out Version);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// nom nom
|
||||
try
|
||||
{
|
||||
if (!version.HasValue)
|
||||
{
|
||||
version = GetVersion();
|
||||
}
|
||||
return version.Value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// nom nom
|
||||
Debug.Print("[SDL2] Failed to retrieve version");
|
||||
return new Version();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,6 +149,12 @@ namespace OpenTK.Platform.SDL2
|
|||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetVersion", ExactSpelling = true)]
|
||||
public static extern void GetVersion(out Version version);
|
||||
public static Version GetVersion()
|
||||
{
|
||||
Version v;
|
||||
GetVersion(out v);
|
||||
return v;
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetWindowID", ExactSpelling = true)]
|
||||
|
|
Loading…
Reference in a new issue