Graphics Reference
In-Depth Information
2.
After retrieving the device and device context from the device manager,
the first action should be ensuring that any previous references to buffers
have been released.
// Retrieve references to device and context
var device = DeviceManager.Direct3DDevice;
var context = DeviceManager.Direct3DContext;
// Before swapchain can resize, buffers must be released
RemoveAndDispose(ref _backBuffer);
RemoveAndDispose(ref _renderTargetView);
RemoveAndDispose(ref _depthStencilView);
RemoveAndDispose(ref _depthBuffer);
RemoveAndDispose(ref _bitmapTarget);
3.
If we are resizing an existing swap chain, then we will resize it using the
ResizeBuffers method.
// If the swap chain already exists, resize it.
if (_swapChain != null)
{
_swapChain.ResizeBuffers(
_swapChain.Description1.BufferCount,
Width, Height,
SharpDX.DXGI.Format.B8G8R8A8_UNorm,
SharpDX.DXGI.SwapChainFlags.None);
}
// Otherwise, create a new one.
else
{
... create swap chain
}
4.
If the swap chain has not already been initialized (or the device was reset), we need
to create a new swap chain. This is done almost exactly as described in the Initializing
a Direct3D 11.1/11.2 device and swap chain recipe in Chapter 1 , Getting Started
with Direct3D .
// SwapChain description
var desc = CreateSwapChainDescription();
// Rather than create a new DXGI Factory we reuse the one
// that has been used internally to create the device.
 
Search WWH ::




Custom Search