public SDLGamePlatform(Game game) : base(game)
        {
            _game = game;

            SDL.GetVersion(out SDL.Version version);

            if (version.Major < 2 || version.Minor < 0 || version.Patch < 5)
            {
                Debug.WriteLine("Please use SDL 2.0.5 or higher.");
            }

            // Needed so VS can debug the project on Windows
            if (version.Major >= 2 && version.Minor >= 0 && version.Patch >= 5 &&
                Debugger.IsAttached &&
                PlatformInfo.CurrentOS == PlatformInfo.OS.Windows)
            {
                SDL.SetHint("SDL_WINDOWS_DISABLE_THREAD_NAMING", "1");
            }

            SDL.Init(
                SDL.InitFlags.Video |
                SDL.InitFlags.Joystick |
                SDL.InitFlags.GameController |
                SDL.InitFlags.Haptic);

            SDL.DisableScreenSaver();

            GamePad.InitDatabase();
            _window = new SDLGameWindow(_game);
        }
Example #2
0
        public Sdl2NativeWindow(int x, int y, int width, int height,
                                string title, GameWindowFlags options, DisplayDevice device)
        {
            lock (sync)
            {
                SDL.DisableScreenSaver();

                var bounds = device.Bounds;
                var flags  = TranslateFlags(options);
                flags |= WindowFlags.OPENGL;
                flags |= WindowFlags.HIDDEN;
                if (Toolkit.Options.EnableHighResolution)
                {
                    flags |= WindowFlags.ALLOW_HIGHDPI;
                }

                if ((flags & WindowFlags.FULLSCREEN_DESKTOP) != 0 ||
                    (flags & WindowFlags.FULLSCREEN) != 0)
                {
                    window_state = WindowState.Fullscreen;
                }

                if ((flags & WindowFlags.RESIZABLE) == 0)
                {
                    window_border = WindowBorder.Fixed;
                }

                IntPtr handle;
                lock (SDL.Sync)
                {
                    handle = SDL.CreateWindow(title, bounds.Left + x, bounds.Top + y, width, height, flags);
                    exists = true;
                }
                ProcessEvents();
                window    = new Sdl2WindowInfo(handle, null);
                window_id = SDL.GetWindowID(handle);
                windows.Add(window_id, this);
            }
        }