/// <summary> /// Enumerates driver information and their supported display modes. /// </summary> public static DriverCollection GetDriverInfo() { DriverCollection driverList = new DriverCollection(); foreach ( XFG.GraphicsAdapter adapterInfo in XFG.GraphicsAdapter.Adapters ) { Driver driver = new Driver( adapterInfo ); int lastWidth = 0, lastHeight = 0; XFG.SurfaceFormat lastFormat = 0; foreach ( XFG.DisplayMode mode in adapterInfo.SupportedDisplayModes ) { // filter out lower resolutions, and make sure this isnt a dupe (ignore variations on refresh rate) if ( ( mode.Width >= 640 && mode.Height >= 480 ) && ( ( mode.Width != lastWidth ) || mode.Height != lastHeight || mode.Format != lastFormat ) ) { // add the video mode to the list driver.VideoModes.Add( new VideoMode( mode ) ); // save current mode settings for comparison on the next iteraion lastWidth = mode.Width; lastHeight = mode.Height; lastFormat = mode.Format; } } driverList.Add( driver ); } return driverList; }
/// <summary> /// /// </summary> /// <param name="driver">The root driver</param> /// <param name="deviceIfSwapChain"></param> public XnaRenderWindow( Driver driver, XFG.GraphicsDevice deviceIfSwapChain ) : this( driver ) { _isSwapChain = ( deviceIfSwapChain != null ); }
/// <summary> /// /// </summary> /// <param name="driver">The root driver</param> public XnaRenderWindow( Driver driver ) : base() { _driver = driver; }
/// <summary> /// Initialize the rendering engine. /// </summary> /// <param name="autoCreateWindow">If true, a default window is created to serve as a rendering target.</param> /// <param name="windowTitle">Text to display on the window caption if not fullscreen.</param> /// <returns>A RenderWindow implementation specific to this RenderSystem.</returns> /// <remarks>All subclasses should call this method from within thier own intialize methods.</remarks> public override RenderWindow Initialize(bool autoCreateWindow, string windowTitle) { LogManager.Instance.Write("[XNA] : Subsystem Initializing"); #if !( XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE ) WindowEventMonitor.Instance.MessagePump = Win32MessageHandling.MessagePump; #endif _activeDriver = XnaHelper.GetDriverInfo()[ConfigOptions["Rendering Device"].Value]; if (_activeDriver == null) { throw new ArgumentException("Problems finding requested Xna driver!"); } RenderWindow renderWindow = null; // register the HLSL program manager //HighLevelGpuProgramManager.Instance.AddFactory(new HLSLProgramFactory()); StateManager = new StateManagement(); if (autoCreateWindow) { #if SILVERLIGHT var width = (int)XnaRenderWindow.DrawingSurface.ActualWidth; var height = (int)XnaRenderWindow.DrawingSurface.ActualHeight; #else var width = 800; var height = 600; #endif var bpp = 32; var fullScreen = false; var optVM = ConfigOptions["Video Mode"]; var vm = optVM.Value; width = int.Parse(vm.Substring(0, vm.IndexOf("x"))); height = int.Parse(vm.Substring(vm.IndexOf("x") + 1, vm.IndexOf("@") - (vm.IndexOf("x") + 1))); bpp = int.Parse(vm.Substring(vm.IndexOf("@") + 1, vm.IndexOf("-") - (vm.IndexOf("@") + 1))); #if !(XBOX || XBOX360) fullScreen = (ConfigOptions["Full Screen"].Value == "Yes"); #endif var miscParams = new NamedParameterList(); miscParams.Add("title", windowTitle); miscParams.Add("colorDepth", bpp); //miscParams.Add( "FSAA", this._fsaaType ); miscParams.Add("FSAAQuality", _fsaaQuality); miscParams.Add("vsync", _vSync); miscParams.Add("useNVPerfHUD", _useNVPerfHUD); // create the render window renderWindow = CreateRenderWindow("Main Window", width, height, fullScreen, miscParams); } new XnaMaterialManager(); LogManager.Instance.Write("[XNA] : Subsystem Initialized successfully."); return renderWindow; }
/// <summary> /// Shuts down the RenderSystem. /// </summary> public override void Shutdown() { _activeDriver = null; // dispose of the device if (_device != null) { _device = null; } if (gpuProgramMgr != null) { if (!gpuProgramMgr.IsDisposed) gpuProgramMgr.Dispose(); gpuProgramMgr = null; } if ( _hardwareBufferManager != null ) { if ( !_hardwareBufferManager.IsDisposed ) _hardwareBufferManager.Dispose(); _hardwareBufferManager = null; } if (textureManager != null) { if (!textureManager.IsDisposed) textureManager.Dispose(); textureManager = null; } base.Shutdown(); LogManager.Instance.Write("[XNA] : " + Name + " shutdown."); }
/// <summary> /// Enumerates driver information and their supported display modes. /// </summary> public static DriverCollection GetDriverInfo() { var driverList = new DriverCollection(); #if SILVERLIGHT switch (GraphicsDeviceManager.Current.RenderModeReason) { case RenderModeReason.GPUAccelerationDisabled: MessageBox.Show("GPU hardware acceleration is disabled. Set 'EnableGPUAcceleration' to true in the hosting HTML page and 'Use GPU Acceleration' in Out-of-Browser settings", "GPUAccelerationDisabled", MessageBoxButton.OK); break; case RenderModeReason.Not3DCapable: MessageBox.Show("The graphics card is not 3D capable.", "Not3DCapable", MessageBoxButton.OK); break; case RenderModeReason.SecurityBlocked: MessageBox.Show("Right-click menu, open Silverlight Configuration, go to the Permissions panel and allow 3D Graphics", "SecurityBlocked", MessageBoxButton.OK); break; case RenderModeReason.TemporarilyUnavailable: MessageBox.Show("Device is temporarily unavailable.", "TemporarilyUnavailable", MessageBoxButton.OK); break; case RenderModeReason.Normal: driverList.Add(new Driver(GraphicsDeviceManager.Current.GraphicsDevice.Adapter)); break; } #else foreach (var adapterInfo in GraphicsAdapter.Adapters) { var driver = new Driver( adapterInfo ); int lastWidth = 0, lastHeight = 0; SurfaceFormat lastFormat = 0; foreach ( var mode in adapterInfo.SupportedDisplayModes ) { // filter out lower resolutions, and make sure this isnt a dupe (ignore variations on refresh rate) if ( ( mode.Width >= 640 && mode.Height >= 480 ) && ( ( mode.Width != lastWidth ) || mode.Height != lastHeight || mode.Format != lastFormat ) ) { // add the video mode to the list driver.VideoModes.Add( new VideoMode( mode ) ); // save current mode settings for comparison on the next iteraion lastWidth = mode.Width; lastHeight = mode.Height; lastFormat = mode.Format; } } driverList.Add( driver ); } #endif return driverList; }