mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-04-17 04:21:50 +00:00
[SDL] Do not attempt to use versions < 2.0.0
Versions prior to 2.0.0 are not ABI-compatible with 2.0.x and attempting to use those will result in random instability. We now explicitly check the SDL2 version before enabling the SDL2 backend.
This commit is contained in:
parent
0fcd47132c
commit
7153a69466
|
@ -201,31 +201,55 @@ 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 {0}. Version is {1}.{2}.{3}",
|
||||
supported ? "supported" : "not supported",
|
||||
version.Major, version.Minor, version.Patch);
|
||||
}
|
||||
|
||||
return supported;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue