Game Development Reference
In-Depth Information
The last method in our manager handles the device reset event. The purpose of this
method is to re-create the swap chains with the recalculated render target size, and
then re-create the resources that are shared across all swap chains. The ready flag is
also flipped to true so that the application can begin rendering the scenes once again.
private void DeviceReset(object sender, EventArgs e)
{
foreach (SwapChainInstance instance in _swapChainList)
ResetSwapChain(instance);
_teapotMesh = Mesh.Teapot(_device);
_sphereMesh = Mesh.Sphere(_device, 1.0f, 30, 30);
_device.Lights[0].Type = LightType.Directional;
_device.Lights[0].Diffuse = System.Drawing.Color.White;
_device.Lights[0].Enabled = true;
_device.RenderState.Lighting = true;
_device.RenderState.Ambient = Color.White;
_device.RenderState.CullMode = Cull.CounterClockwise;
_device.RenderState.ShadeMode = ShadeMode.Gouraud;
Material material = new Material();
material.Ambient = Color.ForestGreen;
material.Diffuse = Color.Olive;
_device.Material = material;
_ready = true;
}
}
The implementation of the swap chain manager is complete, so the discussion will
now focus on using the manager. The following code insertions are methods and
properties extracted directly from the example on the Companion Web site that
should offer insight into using the solution if the interfaces alone are not enough.
The code snippets are from the single context window that uses the entire window
as a display context.
The first property is a unique identifier that references a SwapChainInstance object
within the swap chain manager. It is initialized in the DeviceReset() method that is
described later in this chapter.
private int _swapChain;
Search Nedrilad ::




Custom Search