public override RenderWindow Initialize( bool autoCreateWindow, string windowTitle ) { LogManager.Instance.Write( "[D3D9] : Subsystem Initializing" ); // Axiom specific WindowEventMonitor.Instance.MessagePump = Win32MessageHandling.MessagePump; // Init using current settings this._activeD3DDriver = this._driverList[ ConfigOptions[ "Rendering Device" ].Value ]; if ( this._activeD3DDriver == null ) { throw new ArgumentException( "Problems finding requested Direct3D driver!" ); } driverVersion.Major = this._activeD3DDriver.AdapterIdentifier.DriverVersion.Major; driverVersion.Minor = this._activeD3DDriver.AdapterIdentifier.DriverVersion.Minor; driverVersion.Release = this._activeD3DDriver.AdapterIdentifier.DriverVersion.MajorRevision; driverVersion.Build = this._activeD3DDriver.AdapterIdentifier.DriverVersion.MinorRevision; // Create the device manager. this._deviceManager = new D3D9DeviceManager(); // Create the texture manager for use by others textureManager = new D3D9TextureManager(); // Also create hardware buffer manager this._hardwareBufferManager = new D3D9HardwareBufferManager(); // Create the GPU program manager this._gpuProgramManager = new D3D9GpuProgramManager(); // Create & register HLSL factory this._hlslProgramFactory = new D3D9HLSLProgramFactory(); RenderWindow autoWindow = null; if ( autoCreateWindow ) { var fullScreen = ( ConfigOptions[ "Full Screen" ].Value == "Yes" ); D3D9VideoMode videoMode = null; var vm = ConfigOptions[ "Video Mode" ].Value; var width = int.Parse( vm.Substring( 0, vm.IndexOf( "x" ) ) ); var height = int.Parse( vm.Substring( vm.IndexOf( "x" ) + 1, vm.IndexOf( "@" ) - ( vm.IndexOf( "x" ) + 1 ) ) ); var bpp = int.Parse( vm.Substring( vm.IndexOf( "@" ) + 1, vm.IndexOf( "-" ) - ( vm.IndexOf( "@" ) + 1 ) ) ); foreach ( var currVideoMode in this._activeD3DDriver.VideoModeList ) { var temp = currVideoMode.Description; var colorDepth = int.Parse( temp.Substring( temp.IndexOf( "@" ) + 1, temp.IndexOf( "-" ) - ( temp.IndexOf( "@" ) + 1 ) ) ); // In full screen we only want to allow supported resolutions, so temp and opt->second.currentValue need to // match exactly, but in windowed mode we can allow for arbitrary window sized, so we only need // to match the colour values if ( fullScreen && ( temp == vm ) || !fullScreen && ( colorDepth == bpp ) ) { videoMode = currVideoMode; break; } } if ( videoMode == null ) { throw new AxiomException( "Can't find requested video mode." ); } // sRGB window option ConfigOption opt; if ( !ConfigOptions.TryGetValue( "sRGB Gamma Conversion", out opt ) ) { throw new AxiomException( "Can't find sRGB option!" ); } var hwGamma = opt.Value == "Yes"; var miscParams = new NamedParameterList(); miscParams.Add( "title", windowTitle ); // Axiom only? miscParams.Add( "colorDepth", bpp ); miscParams.Add( "FSAA", this._fsaaSamples ); miscParams.Add( "FSAAHint", this._fsaaHint ); miscParams.Add( "vsync", vSync ); miscParams.Add( "vsyncInterval", vSyncInterval ); miscParams.Add( "useNVPerfHUD", this._useNVPerfHUD ); miscParams.Add( "gamma", hwGamma ); miscParams.Add( "monitorIndex", this._activeD3DDriver.AdapterNumber ); // create the render window autoWindow = CreateRenderWindow( windowTitle, width, height, fullScreen, miscParams ); // If we have 16bit depth buffer enable w-buffering. Contract.Requires( autoWindow != null ); wBuffer = ( autoWindow.ColorDepth == 16 ); } LogManager.Instance.Write( "***************************************" ); LogManager.Instance.Write( "*** D3D9 : Subsystem Initialized OK ***" ); LogManager.Instance.Write( "***************************************" ); // call superclass method base.Initialize( autoCreateWindow, windowTitle ); // Configure SharpDX DX.Configuration.ThrowOnShaderCompileError = true; #if DEBUG DX.Configuration.EnableObjectTracking = true; #endif return autoWindow; }
public override RenderWindow Initialize(bool autoCreateWindow, string windowTitle) { LogManager.Instance.Write("[D3D9] : Subsystem Initializing"); // Axiom specific WindowEventMonitor.Instance.MessagePump = Win32MessageHandling.MessagePump; // Init using current settings this._activeD3DDriver = this._driverList[ConfigOptions["Rendering Device"].Value]; if (this._activeD3DDriver == null) { throw new ArgumentException("Problems finding requested Direct3D driver!"); } driverVersion.Major = this._activeD3DDriver.AdapterIdentifier.DriverVersion.Major; driverVersion.Minor = this._activeD3DDriver.AdapterIdentifier.DriverVersion.Minor; driverVersion.Release = this._activeD3DDriver.AdapterIdentifier.DriverVersion.MajorRevision; driverVersion.Build = this._activeD3DDriver.AdapterIdentifier.DriverVersion.MinorRevision; // Create the device manager. this._deviceManager = new D3D9DeviceManager(); // Create the texture manager for use by others textureManager = new D3D9TextureManager(); // Also create hardware buffer manager this._hardwareBufferManager = new D3D9HardwareBufferManager(); // Create the GPU program manager this._gpuProgramManager = new D3D9GpuProgramManager(); // Create & register HLSL factory this._hlslProgramFactory = new D3D9HLSLProgramFactory(); RenderWindow autoWindow = null; if (autoCreateWindow) { var fullScreen = (ConfigOptions["Full Screen"].Value == "Yes"); D3D9VideoMode videoMode = null; var vm = ConfigOptions["Video Mode"].Value; var width = int.Parse(vm.Substring(0, vm.IndexOf("x"))); var height = int.Parse(vm.Substring(vm.IndexOf("x") + 1, vm.IndexOf("@") - (vm.IndexOf("x") + 1))); var bpp = int.Parse(vm.Substring(vm.IndexOf("@") + 1, vm.IndexOf("-") - (vm.IndexOf("@") + 1))); foreach (var currVideoMode in this._activeD3DDriver.VideoModeList) { var temp = currVideoMode.Description; var colorDepth = int.Parse(temp.Substring(temp.IndexOf("@") + 1, temp.IndexOf("-") - (temp.IndexOf("@") + 1))); // In full screen we only want to allow supported resolutions, so temp and opt->second.currentValue need to // match exactly, but in windowed mode we can allow for arbitrary window sized, so we only need // to match the colour values if (fullScreen && (temp == vm) || !fullScreen && (colorDepth == bpp)) { videoMode = currVideoMode; break; } } if (videoMode == null) { throw new AxiomException("Can't find requested video mode."); } // sRGB window option ConfigOption opt; if (!ConfigOptions.TryGetValue("sRGB Gamma Conversion", out opt)) { throw new AxiomException("Can't find sRGB option!"); } var hwGamma = opt.Value == "Yes"; var miscParams = new NamedParameterList(); miscParams.Add("title", windowTitle); // Axiom only? miscParams.Add("colorDepth", bpp); miscParams.Add("FSAA", this._fsaaSamples); miscParams.Add("FSAAHint", this._fsaaHint); miscParams.Add("vsync", vSync); miscParams.Add("vsyncInterval", vSyncInterval); miscParams.Add("useNVPerfHUD", this._useNVPerfHUD); miscParams.Add("gamma", hwGamma); miscParams.Add("monitorIndex", this._activeD3DDriver.AdapterNumber); // create the render window autoWindow = CreateRenderWindow(windowTitle, width, height, fullScreen, miscParams); // If we have 16bit depth buffer enable w-buffering. Contract.Requires(autoWindow != null); wBuffer = (autoWindow.ColorDepth == 16); } LogManager.Instance.Write("***************************************"); LogManager.Instance.Write("*** D3D9 : Subsystem Initialized OK ***"); LogManager.Instance.Write("***************************************"); // call superclass method base.Initialize(autoCreateWindow, windowTitle); // Configure SharpDX DX.Configuration.ThrowOnShaderCompileError = true; #if DEBUG DX.Configuration.EnableObjectTracking = true; #endif return(autoWindow); }