Game Development Reference
In-Depth Information
The next property is a reference to the swap chain manager instance that will typ-
ically be created in the parent form if the application uses an MDI windowing
mode. In an SDI application, the manager can be instantiated with a device bound
to the SDI window.
This example has the manager reference passed in through the child form con-
structor from the parent form.
private SwapChainManager _manager;
The next method is executed when the rendering device is lost or reset and the
swap chain(s) must be re-created. You will notice that the methods requiring a
control are passed a this keyword that references the entire Form . It is perfectly
acceptable to pass a reference to a Control residing on the form if you want to target
the rendering within a specific Control like a panel. The CreateSwapChain() method
creates a swap chain for the entire window and returns a unique identifier back to
the user. This unique identifier can be later used to return the swap chain object
from the manager.
private void DeviceReset()
{
_swapChain = _manager.CreateSwapChain(this);
}
Typically, a device is lost before it is reset, and the purpose of this method is to
destroy an existing swap chain before the reset method is executed and a new swap
chain is created.
private void DeviceLost()
{
_manager.DestroySwapChain(_swapChain);
}
The following event is fired when the window is first loaded, resulting in the cre-
ation of a swap chain.
private void ContextWindow_Load(object sender, System.EventArgs e)
{
DeviceReset();
}
Search Nedrilad ::




Custom Search