Пример #1
0
        static bool DetectSdl2()
        {
            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
            {
                version = Platform.SDL2.SDL.Version;
                if (version.Number >= 2000)
                {
                    if (Platform.SDL2.SDL.WasInit(0))
                    {
                        supported = true;
                    }
                    else
                    {
                        // 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());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Print("SDL2 init failed with exception: {0}", e);
            }

            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);
        }
Пример #2
0
        static bool DetectSdl2()
        {
            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
            {
                version = Platform.SDL2.SDL.Version;
                    if (version.Number >= 2000)
                {
                    if (Platform.SDL2.SDL.WasInit(0))
                    {
                        supported = true;
                    }
                    else
                    {
                        // 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());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Print("SDL2 init failed with exception: {0}", e);
            }

            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;
        }