, Visual C#


         


myPresentParameters1.Windowed = true;
myPresentParameters1.SwapEffect = SwapEffect.Discard;
myDevice = new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProcessing,
myPresentParameters1);
this.OnCreateDevice(myDevice, null);
// :
PresentParameters myPresentParameters2 =
new PresentParameters();
myPresentParameters2.Windowed = true;
myPresentParameters2.SwapEffect = SwapEffect.Discard;
myDevice = new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProcessing,
myPresentParameters2);
this.OnCreateDevice(myDevice, null);
return true;
}
catch (DirectXException)
{
return false;
}
}
//
// :
public void myRendering()
{
if (myDevice == null)
return;
myDevice.Clear(ClearFlags.Target,
System.Drawing.Color.White, 1.0f, 0);
myDevice.VertexFormat =
CustomVertex.TransformedColored.Format;
// :
myDevice.BeginScene();
// :
myDevice.SetStreamSource(0, myVertexBuffer1, 0);
myDevice.DrawPrimitives(PrimitiveType.TriangleList,0, 1);
// :
myDevice.SetStreamSource(0, myVertexBuffer2, 0);
myDevice.DrawPrimitives(PrimitiveType.TriangleStrip,0,2);
// :
myDevice.EndScene();
myDevice.Present();
}
// :
public void OnCreateDevice(object sender, EventArgs e)
{
Device myDev = (Device)sender;
// :
myVertexBuffer1 = new VertexBuffer(
typeof(CustomVertex.TransformedColored), 3,
myDev, 0, CustomVertex.TransformedColored.Format,
Pool.Default);
myVertexBuffer1.Created +=
new System.EventHandler(this.OnCreateVertexBuffer1);