/// <summary> /// Disposes of object resources. /// </summary> /// <param name="disposeManagedResources">If true, managed resources should be /// disposed of in addition to unmanaged resources.</param> protected virtual void Dispose(bool disposeManagedResources) { if (disposeManagedResources) { _d3d11Device.Dispose(); _dxgiDevice.Dispose(); _backBuffer.Dispose(); _targetBitmap.Dispose(); _backBuffer2.Dispose(); _targetBitmap2.Dispose(); _d2dDevice.Dispose(); swapChain.Dispose(); swapChain2.Dispose(); d2dContext.Dispose(); d2dContext2.Dispose(); dw_Factory.Dispose(); } _d3d11Device = null; _dxgiDevice = null; _backBuffer = null; _targetBitmap = null; _backBuffer2 = null; _targetBitmap2 = null; _d2dDevice = null; swapChain = null; swapChain2 = null; d2dContext = null; d2dContext2 = null; dw_Factory = null; }
internal void ReleaseDevices() { IsRendererSuppressed = true; RenderTarget.Dispose(); Backbuffer.Dispose(); RenderTargetSurface.Dispose(); RenderTargetView.Dispose(); D2DDeviceContext.Dispose(); D2DDevice.Dispose(); D2DFactory.Dispose(); DXGIDevice.Dispose(); D3DDevice.Dispose(); D3DDefaultDevice.Dispose(); SwapChain.Dispose(); SwapChain = null; RenderTarget = null; RenderTargetSurface = null; Backbuffer = null; RenderTargetView = null; D2DDeviceContext = null; D2DFactory = null; D2DDevice = null; DXGIDevice = null; D3DDevice = null; D3DDefaultDevice = null; }
public void Shutdown() { if (_deviceContext != null) { _deviceContext.Dispose(); _deviceContext = null; } if (_device2D != null) { _device2D.Dispose(); _device2D = null; } if (_dxgiDevice != null) { _dxgiDevice.Dispose(); _dxgiDevice = null; } if (_default3DDevice1 != null) { _default3DDevice1.Dispose(); _default3DDevice1 = null; } if (_default3DDevice != null) { _default3DDevice.Dispose(); _default3DDevice = null; } }
public void Dispose() { d2dContext.Target = null; bitmap.Dispose(); d2dContext.Dispose(); d2dDevice.Dispose(); d2dFactory.Dispose(); dxgiSurface.Dispose(); swapChain.Dispose(); dxgiFactory.Dispose(); dxgiDevice.Dispose(); d3dDevice.Dispose(); form.Dispose(); }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { d2dContext.Dispose(); dwFactory.Dispose(); imagingFactory.Dispose(); d2dDevice.Dispose(); dxgiDevice.Dispose(); d3dDevice.Dispose(); defaultDevice.Dispose(); textBrush.Dispose(); textFormat.Dispose(); } disposedValue = true; } }
public void Init(IntPtr hWnd, ApplicationInfo appInfo) { if (m_ApplicationInfo != null) { throw new InvalidOperationException("context already initialized"); } m_ApplicationInfo = appInfo; var swapChainDesc = new DXGI.SwapChainDescription { ModeDescription = new DXGI.ModeDescription { Width = m_ApplicationInfo.Width, Height = m_ApplicationInfo.Height, RefreshRate = new DXGI.Rational(60, 1), Format = DXGI.Format.R8G8B8A8_UNorm }, SampleDescription = new DXGI.SampleDescription { Count = 4 }, BufferCount = 1, Usage = DXGI.Usage.RenderTargetOutput, OutputHandle = hWnd, IsWindowed = !m_ApplicationInfo.FullScreen, SwapEffect = DXGI.SwapEffect.Discard, Flags = DXGI.SwapChainFlags.AllowModeSwitch }; D3D11.Device.CreateWithSwapChain(D3D.DriverType.Hardware, D3D11.DeviceCreationFlags.BgraSupport | D3D11.DeviceCreationFlags.Debug, new[] { m_FeatureLevel }, swapChainDesc, out D3D11.Device dev, out DXGI.SwapChain swapChain); Dev = dev; DevCon = Dev.ImmediateContext; SwapChain = swapChain; D2DFactory = new D2D1.Factory(D2D1.FactoryType.SingleThreaded, D2D1.DebugLevel.Information); DWriteFactory = new DirectWrite.Factory(DirectWrite.FactoryType.Shared); m_MSAAQuality = Dev.CheckMultisampleQualityLevels(DXGI.Format.R8G8B8A8_UNorm, 4); D3D11.DeviceDebug d3dDebug = dev.QueryInterface <D3D11.DeviceDebug>(); if (d3dDebug != null) { D3D11.InfoQueue infoQueue = dev.QueryInterface <D3D11.InfoQueue>(); if (infoQueue != null) { D3D11.MessageId[] hide = { D3D11.MessageId.MessageIdDeviceDrawSamplerNotSet }; infoQueue.AddStorageFilterEntries(new D3D11.InfoQueueFilter() { DenyList = new D3D11.InfoQueueFilterDescription { Ids = hide } }); } } Resize(); CreateBlendStates(); CreateDepthStencilStates(); CreateRasterizerStates(); SetBlend(false); SetDepthTesting(true); SetWireframe(false); SharpDX.DXGI.Device dxgiDev = Dev.QueryInterface <SharpDX.DXGI.Device>(); SharpDX.DXGI.AdapterDescription adapterDesc = dxgiDev.Adapter.Description; Console.WriteLine("----------------------------------"); Console.WriteLine(" Direct3D 11:"); Console.WriteLine(" " + adapterDesc.Description); Console.WriteLine(" VRAM: " + adapterDesc.DedicatedVideoMemory / 1024 / 1024 + " MB"); Console.WriteLine("----------------------------------"); dxgiDev.Dispose(); }