public D3DRenderWindow(Driver driver, bool isSwapChain) { this.driver = driver; this.isSwapChain = isSwapChain; fsaaType = MultiSampleType.None; fsaaQuality = 0; isFullScreen = false; isSwapChain = false; isExternal = false; windowHandle = null; isActive = false; displayFrequency = 0; }
public override void Shutdown() { base.Shutdown(); _activeD3DDriver = null; if (_deviceManager != null) { _deviceManager.Dispose(); _deviceManager = null; } if (_driverList != null) { _driverList.Dispose(); _driverList = null; } _activeD3DDriver = null; LogManager.Instance.Write( "D3D9 : Shutting down cleanly." ); if (textureManager != null) { textureManager.Dispose(); textureManager = null; } if (_hardwareBufferManager != null) { _hardwareBufferManager.Dispose(); _hardwareBufferManager = null; } if ( _gpuProgramManager == null ) return; _gpuProgramManager.Dispose(); _gpuProgramManager = null; }
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; } }
/// <summary> /// Enumerates driver information and their supported display modes. /// </summary> public static DriverCollection GetDriverInfo( D3D.Direct3D manager ) { DriverCollection driverList = new DriverCollection(); foreach ( D3D.AdapterInformation adapterInfo in manager.Adapters ) { List<D3D.DisplayMode> displaymodeList = new List<D3D.DisplayMode>(); Driver driver = new Driver( adapterInfo.Adapter, adapterInfo.GetCaps(DeviceType.Hardware), adapterInfo.Details, adapterInfo.CurrentDisplayMode); int lastWidth = 0, lastHeight = 0; D3D.Format lastFormat = 0; // 32bit Modes foreach ( D3D.DisplayMode mode in adapterInfo.GetDisplayModes( D3D.Format.X8R8G8B8 ) ) { displaymodeList.Add( mode ); } // 16Bit modes foreach ( D3D.DisplayMode mode in adapterInfo.GetDisplayModes( D3D.Format.R5G6B5 ) ) { displaymodeList.Add( mode ); } foreach ( D3D.DisplayMode mode in displaymodeList ) { // 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.VideoModeList.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; }
public override RenderWindow Initialize(bool autoCreateWindow, string windowTitle, string initialLoadBitmap) { RenderWindow renderWindow = null; activeD3DDriver = D3DHelper.GetDriverInfo(); if (autoCreateWindow) { Axiom.Configuration.DisplayMode mode = displayConfig.SelectedMode; if (mode == null) { throw new Exception("No video mode is selected"); } // create a default form window // DefaultForm newWindow = CreateDefaultForm(windowTitle, 0, 0, mode.Width, mode.Height, mode.FullScreen); // create the render window renderWindow = CreateRenderWindow("Main Window", (int)mode.Width, (int)mode.Height, mode.Fullscreen, "colorDepth", mode.Depth, "FSAA", fsaa, "FSAAQuality", fsaaQuality, "vsync", vsync, "title", windowTitle, "useNVPerfHUD", useNVPerfHUD, "multiThreaded", multiThreaded, "initialLoadBitmap", initialLoadBitmap); // use W buffer when in 16 bit color mode useWBuffer = (renderWindow.ColorDepth == 16); } base.Initialize(autoCreateWindow, windowTitle); return renderWindow; }
public override void Shutdown() { base.Shutdown(); activeD3DDriver = null; // dispose of the device if (device != null) { device.Dispose(); } if (gpuProgramMgr != null) { gpuProgramMgr.Dispose(); } if (hardwareBufferManager != null) { hardwareBufferManager.Dispose(); } if (textureManager != null) { textureManager.Dispose(); } }
/// <summary> /// /// </summary> /// <param name="driver">The root driver</param> /// <param name="deviceIfSwapChain">The existing D3D device to create an additional swap chain from, if this is not the first window.</param> public D3DRenderWindow( Driver driver, D3D.Device deviceIfSwapChain ) : this( driver ) { _isSwapChain = ( deviceIfSwapChain != null ); }
/// <summary> /// /// </summary> /// <param name="driver">The root driver</param> public D3DRenderWindow( Driver driver ) : base() { _driver = driver; }
/// <summary> /// Enumerates driver information and their supported display modes. /// </summary> public static Driver GetDriverInfo() { ArrayList driverList = new ArrayList(); // get the information for the default adapter (not checking secondaries) AdapterInformation adapterInfo = D3D.Manager.Adapters[0]; Driver driver = new Driver(adapterInfo); int lastWidth = 0, lastHeight = 0; D3D.Format lastFormat = 0; foreach(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; } } return driver; }