Merge pull request #126 from thefiddler/sdlversion

[SDL] Do not attempt to use versions < 2.0.0
This commit is contained in:
thefiddler 2014-05-31 15:54:20 +02:00
commit 08829c4feb

View file

@ -201,31 +201,54 @@ namespace OpenTK
bool supported = false;
// Detect whether SDL2 is supported
// We require:
// - SDL2 version 2.0.0 or higher (previous beta
// versions are not ABI-compatible)
// - Successful SDL2 initialization (sometimes the
// binary exists but fails to initialize correctly)
var version = new Platform.SDL2.Version();
try
{
if (!OpenTK.Platform.SDL2.SDL.WasInit(0))
version = Platform.SDL2.SDL.Version;
if (version.Number >= 2000)
{
var flags =
OpenTK.Platform.SDL2.SystemFlags.VIDEO | Platform.SDL2.SystemFlags.TIMER;
if (OpenTK.Platform.SDL2.SDL.Init(flags) == 0)
if (Platform.SDL2.SDL.WasInit(0))
{
supported = true;
}
else
{
Debug.Print("SDL2 init failed with error: {0}", OpenTK.Platform.SDL2.SDL.GetError());
// Attempt to initialize SDL2.
var flags =
Platform.SDL2.SystemFlags.VIDEO |
Platform.SDL2.SystemFlags.TIMER;
if (Platform.SDL2.SDL.Init(flags) == 0)
{
supported = true;
}
else
{
Debug.Print("SDL2 init failed with error: {0}",
Platform.SDL2.SDL.GetError());
}
}
}
else
{
supported = true;
}
}
catch (Exception e)
{
Debug.Print("SDL2 init failed with exception: {0}", e);
}
Debug.Print("SDL2 is {0}", supported ? "supported" : "not supported");
if (!supported)
{
Debug.Print("SDL2 is not supported");
}
else
{
Debug.Print("SDL2 is supported. Version is {0}.{1}.{2}",
version.Major, version.Minor, version.Patch);
}
return supported;
}