int adapterOrdinal=Manager.Adapters.Default.Adapter;
//Get our device capabilities so we can check them to set up the CreatedFlags
Caps caps=Manager.GetDeviceCaps(adapterOrdinal, DeviceType.Hardware);
CreateFlags createFlags;
//Check the capabilities of the graphics card
//if able to perform the vertex processing operation
//The HardwareVertexProcessing choice is best
if(caps.DeviceCaps.SupportsHardwareTransformAndLight)
{
createFlags=CreateFlags.HardwareVertexProcessing;
}
else
{
creatFlags=CreateFlags.SoftwareVertexProcessing;
}
//If the graphics card supports vertex processing check if the devive
//can do rasterization, matrix transformations, lighting and shading operations
//This combination provides the fastest game experience
if(caps.DeviceCaps.SupportsPureDevice && createFlags==CreateFlags.HardwareVertexProcessing)
{
createFlags!=CreateFlags.PureDevice;
}
//Set up the PresentParameters which determine how the device behaves
PresentParameters presentParams=new PresentParameters();
presentParams.SwapEffect=SwapEffect.Discard;
//Make sure we are windowed mode when we debug
#if DEBUG
presentParams.Windowed=true;
#endif
//Create the Device
device= new Device(adapterOrdinal,
DeviceType.Hardware,
this,
createFlags,
presentParams);