public D3DRenderSystem() { LogManager.Instance.Write("D3D9 : {0} created.", Name); // update singleton access pointer. _D3D9RenderSystem = this; // set pointers to NULL _pD3D = null; _driverList = null; _activeD3DDriver = null; textureManager = null; _hardwareBufferManager = null; _gpuProgramManager = null; _useNVPerfHUD = false; _hlslProgramFactory = null; _deviceManager = null; //_perStageConstantSupport = false; // Create the resource manager. _resourceManager = new D3D9ResourceManager(); // init lights for (var i = 0; i < MaxLights; i++) lights[i] = null; // Create our Direct3D object _pD3D = new Direct3D(); if (_pD3D == null) throw new AxiomException( "Failed to create Direct3D9 object" ); InitConfigOptions(); // fsaa options _fsaaHint = ""; _fsaaSamples = 0; // init the texture stage descriptions for ( var i = 0; i < Config.MaxTextureLayers; i++ ) { _texStageDesc[ i ].autoTexCoordType = TexCoordCalcMethod.None; _texStageDesc[ i ].coordIndex = 0; _texStageDesc[ i ].texType = D3DTextureType.Normal; _texStageDesc[ i ].tex = null; _texStageDesc[ i ].vertexTex = null; } }
protected override void dispose(bool disposeManagedResources) { // this causes infinite recursions in axiom //Shutdown(); // Deleting the HLSL program factory if ( _hlslProgramFactory != null ) { // Remove from manager safely if ( HighLevelGpuProgramManager.Instance != null ) HighLevelGpuProgramManager.Instance.RemoveFactory( _hlslProgramFactory ); _hlslProgramFactory.Dispose(); _hlslProgramFactory = null; } if ( _pD3D != null ) { _pD3D.Dispose(); _pD3D = null; } if ( _resourceManager != null ) { _resourceManager.Dispose(); _resourceManager = null; } LogManager.Instance.Write( "D3D9 : {0} destroyed.", Name ); _D3D9RenderSystem = null; base.dispose( disposeManagedResources ); }
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 _activeD3DDriver = D3DHelper.GetDriverInfo(_pD3D)[ConfigOptions["Rendering Device"].Value]; if (_activeD3DDriver == null) throw new ArgumentException("Problems finding requested Direct3D driver!"); driverVersion.Major = _activeD3DDriver.AdapterIdentifier.DriverVersion.Major; driverVersion.Minor = _activeD3DDriver.AdapterIdentifier.DriverVersion.Minor; driverVersion.Release = _activeD3DDriver.AdapterIdentifier.DriverVersion.MajorRevision; driverVersion.Build = _activeD3DDriver.AdapterIdentifier.DriverVersion.MinorRevision; // Create the device manager. _deviceManager = new D3D9DeviceManager(); // Create the texture manager for use by others textureManager = new D3DTextureManager(); // Also create hardware buffer manager _hardwareBufferManager = new D3DHardwareBufferManager(); // Create the GPU program manager _gpuProgramManager = new D3DGpuProgramManager(); _hlslProgramFactory = new HLSLProgramFactory(); RenderWindow renderWindow = null; if (autoCreateWindow) { var fullScreen = (ConfigOptions["Full Screen"].Value == "Yes"); var optVm = ConfigOptions["Video Mode"]; var vm = optVm.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))); // sRGB window option ConfigOption opt; var hwGamma = ConfigOptions.TryGetValue("sRGB Gamma Conversion", out opt) && (opt.Value == "Yes"); var miscParams = new NamedParameterList(); miscParams.Add("title", windowTitle); // Axiom only? miscParams.Add("colorDepth", bpp); miscParams.Add("FSAA", _fsaaSamples); miscParams.Add("FSAAHint", _fsaaHint); miscParams.Add("vsync", vSync); miscParams.Add("vsyncInterval", vSyncInterval); miscParams.Add("useNVPerfHUD", _useNVPerfHUD); miscParams.Add("gamma", hwGamma); miscParams.Add("monitorIndex", _activeD3DDriver.AdapterNumber); // create the render window renderWindow = CreateRenderWindow("Main Window", width, height, fullScreen, miscParams); // If we have 16bit depth buffer enable w-buffering. Debug.Assert(renderWindow != null); wBuffer = (renderWindow.ColorDepth == 16); } LogManager.Instance.Write("***************************************"); LogManager.Instance.Write("*** D3D9 : Subsystem Initialized OK ***"); LogManager.Instance.Write("***************************************"); // call superclass method base.Initialize( autoCreateWindow, windowTitle ); // Configure SlimDX SlimDX.Configuration.ThrowOnError = true; SlimDX.Configuration.AddResultWatch(ResultCode.DeviceLost, ResultWatchFlags.AlwaysIgnore); SlimDX.Configuration.AddResultWatch(ResultCode.WasStillDrawing, ResultWatchFlags.AlwaysIgnore); #if DEBUG SlimDX.Configuration.DetectDoubleDispose = false; SlimDX.Configuration.EnableObjectTracking = true; #else SlimDX.Configuration.DetectDoubleDispose = false; SlimDX.Configuration.EnableObjectTracking = false; #endif return renderWindow; }