/// <summary>Runs the game.</summary> public void Run() { string[] commandLineArguments = Environment.GetCommandLineArgs(); _sys = new OpenTKSys(commandLineArguments); DisplayDevice displayDevice = DisplayDevice.Default; bool windowed = _sys.GameConfig.VideoWindowed; int width, height; if(windowed) { width = _sys.GameConfig.VideoWindowWidth(displayDevice.Width); height = _sys.GameConfig.VideoWindowHeight(displayDevice.Height); } else { width = displayDevice.Width; height = displayDevice.Height; } GameWindowFlags gameWindowFlags = (windowed ? GameWindowFlags.FixedWindow : GameWindowFlags.Fullscreen); using(_gameWindow = new GameWindow(width, height, GraphicsMode.Default, "Hovertank3DdotNet (OpenTK)", gameWindowFlags)) { _gameWindow.VSync = (_sys.GameConfig.VideoVSync ? VSyncMode.On : VSyncMode.Off); if(windowed) { int left, top; if(_sys.GameConfig.VideoWindowCenter) { left = (displayDevice.Width - _gameWindow.Width) / 2; top = (displayDevice.Height - _gameWindow.Height) / 2; } else { left = _sys.GameConfig.VideoWindowLeft(displayDevice.Width); top = _sys.GameConfig.VideoWindowTop(displayDevice.Height); } _gameWindow.Location = new Point(left, top); } _viewportSize = new Size(_gameWindow.Width, _gameWindow.Height); _gameWindow.Load += gameWindow_Load; _gameWindow.Resize += gameWindow_Resize; _gameWindow.UpdateFrame += gameWindow_UpdateFrame; _gameWindow.RenderFrame += gameWindow_RenderFrame; _gameWindow.Unload += gameWindow_Unload; // This can fail if OpenAL isn't installed SoundSystem soundSystem = new OpenTKSoundSystem(); _sys.InitialiseSound(soundSystem); _input = new OpenTKInputSystem(_gameWindow); _disposableObjects.Add(_input); _sys.InitialiseInput(_input); _hovertank = new Hovertank(_sys); _hovertank.StateInitialise(); // Dispose sound system after sounds _disposableObjects.Add(soundSystem); _gameWindow.Run(70.0); } }
/// <summary>Creates a new OpenTK sound.</summary> /// <param name="soundSystem">The sound system.</param> /// <param name="bufferID">The buffer ID.</param> public OpenTKSound(OpenTKSoundSystem soundSystem, int bufferID) { _soundSystem = soundSystem; _bufferID = bufferID; }