Game Development Reference
In-Depth Information
This method is used to re-create a swap chain after a device reset has occurred.
First, the old swap chain is destroyed, and then a new swap chain with the new ren-
der target size is created.
private void ResetSwapChain(SwapChainInstance instance)
{
if (instance != null)
{
DestroySwapChain(instance.SwapChain);
instance.PresentParameters.BackBufferWidth =
instance.RenderTarget.Width;
instance.PresentParameters.BackBufferHeight =
instance.RenderTarget.Height;
instance.SwapChain = new SwapChain(_device,
instance.PresentParameters);
}
}
This method is simply used to release the memory associated with a Direct3D
swap chain.
private void DestroySwapChain(SwapChain swapChain)
{
if (swapChain != null)
swapChain.Dispose();
}
This method is very important because it begins the rendering process for a spe-
cific swap chain that is referenced by a unique identifier. Notice the ready flag that
breaks out of rendering if its value is set to false . This flag is used to prevent errors
from occurring if the device is invalid.
public void BeginSwapChainRender(int id)
{
if (!_ready)
return;
SwapChainInstance instance = FindSwapChainInstance(id);
if (instance != null && instance.SwapChain != null)
{
_activeSwapChain = instance;
Search Nedrilad ::




Custom Search