コード例 #1
0
        public SdlGamePlatform(Game game)
            : base(game)
        {
            // if we're on Windows, we need to detect the CPU arch and load the correct dlls
            // on other system, the MonoGame.Framework.dll.config handles this
            if (PlatformParameters.DetectWindowsArchitecture)
            {
                NativeHelper.InitDllDirectory();
            }

            _game = game;
            _keys = new List <Keys>();
            Keyboard.SetKeys(_keys);

            Sdl.Version sversion;
            Sdl.GetVersion(out sversion);

            Sdl.Major = sversion.Major;
            Sdl.Minor = sversion.Minor;
            Sdl.Patch = sversion.Patch;

            try
            {
                // HACK: The current development version of SDL
                // returns 2.0.4, to check SDL version we simply
                // need to try and execute a function that's only
                // available in the newer version of it.
                Sdl.Window.SetResizable(IntPtr.Zero, false);
                Sdl.Patch = 5;
            }
            catch { }

            var version = 100 * Sdl.Major + 10 * Sdl.Minor + Sdl.Patch;

            if (version <= 204)
            {
                Debug.WriteLine("Please use SDL 2.0.5 or higher.");
            }

            Sdl.Init((int)(
                         Sdl.InitFlags.Video |
                         Sdl.InitFlags.Joystick |
                         Sdl.InitFlags.GameController |
                         Sdl.InitFlags.Haptic
                         ));

            Sdl.DisableScreenSaver();

            Window = _view = new SdlGameWindow(_game);

            try
            {
                _soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
コード例 #2
0
        public SdlGamePlatform(Game game)
            : base(game)
        {
            // if we're on Windows, we need to detect the CPU arch and load the correct dlls
            // on other system, the MonoGame.Framework.dll.config handles this
            if (PlatformParameters.DetectWindowsArchitecture)
            {
                NativeHelper.InitDllDirectory();
            }

            _game = game;
            _keys = new List <Keys>();
            Keyboard.SetKeys(_keys);

            Sdl.Version sversion;
            Sdl.GetVersion(out sversion);

            Sdl.Major = sversion.Major;
            Sdl.Minor = sversion.Minor;
            Sdl.Patch = sversion.Patch;

            var version = 100 * Sdl.Major + 10 * Sdl.Minor + Sdl.Patch;

            if (version <= 204)
            {
                Debug.WriteLine("Please use SDL 2.0.5 or higher.");
            }

            // Needed so VS can debug the project on Windows
            if (version >= 205 && CurrentPlatform.OS == OS.Windows && Debugger.IsAttached)
            {
                Sdl.SetHint("SDL_WINDOWS_DISABLE_THREAD_NAMING", "1");
            }

            Sdl.Init((int)(
                         Sdl.InitFlags.Video |
                         Sdl.InitFlags.Joystick |
                         Sdl.InitFlags.GameController |
                         Sdl.InitFlags.Haptic
                         ));

            Sdl.DisableScreenSaver();

            GamePad.InitDatabase();
            Window = _view = new SdlGameWindow(_game);

            try
            {
                _soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
コード例 #3
0
ファイル: SdlGameHost.cs プロジェクト: sergios1234/monoxna
		public void EnsureHost()
		{
			int result = Sdl.SDL_Init(Sdl.SDL_INIT_TIMER | Sdl.SDL_INIT_VIDEO | Sdl.SDL_INIT_JOYSTICK);
			if (result == 0)
				System.Diagnostics.Debug.WriteLine("SDL initialized");
			else
				System.Diagnostics.Debug.WriteLine("Couldn't initialize SDL");
			
			Il.ilInit();
			
			window = new SdlGameWindow(game);
		}
コード例 #4
0
        protected override void Dispose(bool disposing)
        {
            if (_view != null)
            {
                _view.Dispose();
                _view = null;

                Joystick.CloseDevices();

                Sdl.Quit();
            }

            base.Dispose(disposing);
        }
コード例 #5
0
ファイル: Game.cs プロジェクト: dakk/OpenXNA
        public Game()
        {
            Content = new ContentManager();
            GraphicsDevice = new GraphicsDevice(new GraphicsAdapter(),
                                                new GraphicsProfile(),
                                                new PresentationParameters());
            Window = new SdlGameWindow();

            IsMouseVisible = false;
            IsFixedTimeStep = true;
            IsActive = true;

            InactiveSleepTime = new TimeSpan(0);
            TargetElapsedTime = new TimeSpan(0);
        }
コード例 #6
0
        public SdlGamePlatform(Game game)
            : base(game)
        {
            _game = game;
            _keys = new List <Keys>();
            Keyboard.SetKeys(_keys);

            Sdl.Version sversion;
            Sdl.GetVersion(out sversion);

            Sdl.Major = sversion.Major;
            Sdl.Minor = sversion.Minor;
            Sdl.Patch = sversion.Patch;

            var version = 100 * Sdl.Major + 10 * Sdl.Minor + Sdl.Patch;

            if (version <= 204)
            {
                Debug.WriteLine("Please use SDL 2.0.5 or higher.");
            }

            // Needed so VS can debug the project on Windows
            if (version >= 205 && CurrentPlatform.OS == OS.Windows && Debugger.IsAttached)
            {
                Sdl.SetHint("SDL_WINDOWS_DISABLE_THREAD_NAMING", "1");
            }

            Sdl.Init((int)(
                         Sdl.InitFlags.Video |
                         Sdl.InitFlags.Joystick |
                         Sdl.InitFlags.GameController |
                         Sdl.InitFlags.Haptic
                         ));

            Sdl.DisableScreenSaver();

            GamePad.InitDatabase();
            Window = _view = new SdlGameWindow(_game);

            try
            {
                _soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
コード例 #7
0
ファイル: SdlGameHost.cs プロジェクト: leha-bot/Mono.XNA
        public void EnsureHost()
        {
            int result = Sdl.SDL_Init(Sdl.SDL_INIT_TIMER | Sdl.SDL_INIT_VIDEO | Sdl.SDL_INIT_JOYSTICK);

            if (result == 0)
            {
                System.Diagnostics.Debug.WriteLine("SDL initialized");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Couldn't initialize SDL");
            }

            Il.ilInit();

            window = new SdlGameWindow(game);
        }