/// <summary>
 /// Gets the OpenAL sound controller, constructs the sound buffer, and sets up the event delegates for
 /// the reserved and recycled events.
 /// </summary>
 internal void InitializeSound()
 {
     controller = OpenALSoundController.GetInstance;
     soundBuffer = new OALSoundBuffer();
     soundBuffer.Reserved += HandleSoundBufferReserved;
     soundBuffer.Recycled += HandleSoundBufferRecycled;
 }
Beispiel #2
0
 public OpenTKGamePlatform(Game game)
   : base(game)
 {
   this._view = new OpenTKGameWindow();
   this._view.Game = game;
   this.Window = (GameWindow) this._view;
   this.IsMouseVisible = true;
   this.soundControllerInstance = OpenALSoundController.Instance;
 }
Beispiel #3
0
 public OpenTKGamePlatform(Game game)
   : base(game)
 {
   this._view = new OpenTKGameWindow();
   this._view.Game = game;
   this.Window = (GameWindow) this._view;
   this.soundControllerInstance = OpenALSoundController.Instance;
   WindowsHelperAccessibilityKeys.AllowAccessibilityShortcutKeys(false);
 }
		private void InitializeSound ()
		{
			controller = OpenALSoundController.GetInstance;
			soundBuffer = new OALSoundBuffer ();
			soundBuffer.BindDataBuffer (soundEffect._data, soundEffect.Format, soundEffect.Size, (int)soundEffect.Rate);
			soundBuffer.Reserved += HandleSoundBufferReserved;
			soundBuffer.Recycled += HandleSoundBufferRecycled;

		}
Beispiel #5
0
        public AndroidGamePlatform(Game game)
            : base(game)
        {
            System.Diagnostics.Debug.Assert(Game.Activity != null, "Must set Game.Activity before creating the Game instance");
            Game.Activity.Game = Game;
            AndroidGameActivity.Paused += Activity_Paused;
            AndroidGameActivity.Resumed += Activity_Resumed;

            _gameWindow = new AndroidGameWindow(Game.Activity, game);
            Window = _gameWindow;

            MediaLibrary.Context = Game.Activity;
            try
            {
                soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
        private int isExiting; // int, so we can use Interlocked.Increment
        
		public OpenTKGamePlatform(Game game)
            : base(game)
        {
            toolkit = Toolkit.Init();
            _view = new OpenTKGameWindow(game);
            this.Window = _view;

			// Setup our OpenALSoundController to handle our SoundBuffer pools
            try
            {
                soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
Beispiel #7
0
 public void Dispose()
 {
   if (ALHelper.Efx.IsInitialized)
     ALHelper.Efx.DeleteFilter(this.filterId);
   while (this.freeSources.Count > 0)
     AL.DeleteSource(this.freeSources.Pop());
   while (this.freeBuffers.Count > 0)
     AL.DeleteBuffer(this.freeBuffers.Pop());
   this.context.Dispose();
   OpenALSoundController.instance = (OpenALSoundController) null;
 }
        public override void Exit()
        {
            //(SJ) Why is this called here when it's not in any other project
            //Net.NetworkSession.Exit();
            Interlocked.Increment(ref isExiting);

            // sound controller must be disposed here
            // so that it doesn't stop the game from disposing
            if (soundControllerInstance != null)
            {
                soundControllerInstance.Dispose();
                soundControllerInstance = null;
            }
            OpenTK.DisplayDevice.Default.RestoreResolution();
        }
		public OpenTKGamePlatform(Game game)
            : base(game)
        {
            _view = new OpenTKGameWindow();
            _view.Game = game;
            this.Window = _view;

            this.IsMouseVisible = true;
			
			// Setup our OpenALSoundController to handle our SoundBuffer pools
			soundControllerInstance = OpenALSoundController.GetInstance;
            
#if LINUX
            // also set up SdlMixer to play background music. If one of these functions fails, we will not get any background music (but that should rarely happen)
            Tao.Sdl.Sdl.SDL_InitSubSystem(Tao.Sdl.Sdl.SDL_INIT_AUDIO);
            Tao.Sdl.SdlMixer.Mix_OpenAudio(44100, (short)Tao.Sdl.Sdl.AUDIO_S16SYS, 2, 1024);			
#endif
        }
Beispiel #10
0
        public MacGamePlatform(Game game) :
            base(game)
        {
            _state = RunState.NotStarted;
            game.Services.AddService(typeof(MacGamePlatform), this);

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;

            InitializeMainWindow();

            var path = NSBundle.MainBundle.ResourcePath;
            if (Directory.Exists(path)) {
                // We set the current directory to the ResourcePath on Mac
                Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);
            }
        }
Beispiel #11
0
		public OpenTKGamePlatform(Game game)
            : base(game)
        {
            _view = new OpenTKGameWindow();
            _view.Game = game;
            this.Window = _view;
			
			// Setup our OpenALSoundController to handle our SoundBuffer pools
            try
            {
                soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
            
#if LINUX
            // also set up SdlMixer to play background music. If one of these functions fails, we will not get any background music (but that should rarely happen)
            Tao.Sdl.Sdl.SDL_InitSubSystem(Tao.Sdl.Sdl.SDL_INIT_AUDIO);
            Tao.Sdl.SdlMixer.Mix_OpenAudio(44100, (short)Tao.Sdl.Sdl.AUDIO_S16SYS, 2, 1024);			

            //even though this method is called whenever IsMouseVisible is changed it needs to be called during startup
            //so that the cursor can be put in the correct inital state (hidden)
            OnIsMouseVisibleChanged();
#endif
        }
Beispiel #12
0
        public iOSGamePlatform(Game game) :
            base(game)
        {
            game.Services.AddService(typeof(iOSGamePlatform), this);
			
			// Setup our OpenALSoundController to handle our SoundBuffer pools
			soundControllerInstance = OpenALSoundController.GetInstance;
			
            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);

            _applicationObservers = new List<NSObject>();

            UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade);

            // Create a full-screen window
            _mainWindow = new UIWindow (UIScreen.MainScreen.Bounds);
			//_mainWindow.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
			
            game.Services.AddService (typeof(UIWindow), _mainWindow);

            _viewController = new iOSGameViewController(this);
            game.Services.AddService (typeof(UIViewController), _viewController);
            Window = new iOSGameWindow (_viewController);

            _mainWindow.RootViewController = _viewController;
            _mainWindow.Add (_viewController.View);

            _viewController.InterfaceOrientationChanged += ViewController_InterfaceOrientationChanged;

            Guide.Initialise(game);
        }
Beispiel #13
0
		public WindowsGamePlatform(Game game)
            : base(game)
        {
            _view = new WindowsGameWindow();
            _view.Game = game;
            this.Window = _view;
			
			// Setup our OpenALSoundController to handle our SoundBuffer pools
			soundControllerInstance = OpenALSoundController.GetInstance;

            //Initialize cursor visibility based on default value
            OnIsMouseVisibleChanged();
        }
Beispiel #14
0
		public OpenTKGamePlatform(Game game)
            : base(game)
        {
            if (PlatformParameters.PreferredBackend != Backend.Default)
                Toolkit.Init(new ToolkitOptions { Backend = PlatformBackend.PreferNative });

            _view = new OpenTKGameWindow(game);
            this.Window = _view;

			// Setup our OpenALSoundController to handle our SoundBuffer pools
            try
            {
                soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
 public static void DestroyInstance()
 {
     if (_instance != null)
     {
         _instance.Dispose();
         _instance = null;
     }
 }
 /// <summary>
 /// Gets the OpenAL sound controller, constructs the sound buffer, and sets up the event delegates for
 /// the reserved and recycled events.
 /// </summary>
 internal void InitializeSound()
 {
     controller = OpenALSoundController.GetInstance;
 }
Beispiel #17
0
        public iOSGamePlatform(Game game) :
            base(game)
        {
            game.Services.AddService(typeof(iOSGamePlatform), this);
			
			// Setup our OpenALSoundController to handle our SoundBuffer pools
			soundControllerInstance = OpenALSoundController.GetInstance;

            //This also runs the TitleContainer static constructor, ensuring it is done on the main thread
            Directory.SetCurrentDirectory(TitleContainer.Location);

            _applicationObservers = new List<NSObject>();

            UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade);

            // Create a full-screen window
            _mainWindow = new UIWindow (UIScreen.MainScreen.Bounds);
			//_mainWindow.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
			
            game.Services.AddService (typeof(UIWindow), _mainWindow);

            _viewController = new iOSGameViewController(this);
            game.Services.AddService (typeof(UIViewController), _viewController);
            Window = new iOSGameWindow (_viewController);

            _mainWindow.RootViewController = _viewController;
            _mainWindow.Add (_viewController.View);

            _viewController.InterfaceOrientationChanged += ViewController_InterfaceOrientationChanged;

            //(SJ) Why is this called here when it's not in any other project
            //Guide.Initialise(game);
        }