, Visual C#


         


this.OnCreateVertexBuffer1(myVertexBuffer1, null);
// :
myVertexBuffer2 = new VertexBuffer(
typeof(CustomVertex.TransformedColored), 4,
myDev, 0, CustomVertex.TransformedColored.Format,
Pool.Default);
myVertexBuffer2.Created += new System.EventHandler(
this.OnCreateVertexBuffer2);
this.OnCreateVertexBuffer2(myVertexBuffer2, null);
}
// :
public void OnCreateVertexBuffer1(object sender, EventArgs e)
{
VertexBuffer myVB1 = (VertexBuffer)sender;
GraphicsStream myGraphicsStream1 = myVB1.Lock(0, 0, 0);
CustomVertex.TransformedColored[] Vertex1 =
new CustomVertex.TransformedColored[3];
// 0:
Vertex1[0].X = 150; Vertex1[0].Y = 50; Vertex1[0].Z=0.5f;
Vertex1[0].Rhw = 1;
Vertex1[0].Color = System.Drawing.Color.Aqua.ToArgb();
// 1:
Vertex1[1].X = 250; Vertex1[1].Y =300; Vertex1[1].Z=0.5f;
Vertex1[1].Rhw = 1;
Vertex1[1].Color = System.Drawing.Color.Black.ToArgb();
// 2:
Vertex1[2].X = 50; Vertex1[2].Y = 300; Vertex1[2].Z=0.5f;
Vertex1[2].Rhw = 1;
Vertex1[2].Color =
System.Drawing.Color.LightPink.ToArgb();
myGraphicsStream1.Write(Vertex1);
myVB1.Unlock();
}
// :
public void OnCreateVertexBuffer2(object sender, EventArgs EvArgs)
{
VertexBuffer myVB2 = (VertexBuffer)sender;
GraphicsStream myGraphicsStream2 = myVB2.Lock(0, 0, 0);
CustomVertex.TransformedColored[] Vertex2 =
new CustomVertex.TransformedColored[4];
// 0:
Vertex2[0].X = 300.0f; Vertex2[0].Y = 300.0f;
Vertex2[0].Z = 0.5f; Vertex2[0].Rhw = 1;
Vertex2[0].Color = System.Drawing.Color.Black.ToArgb();
// 1:
Vertex2[1].X = 300.0f; Vertex2[1].Y = 50.0f;
Vertex2[1].Z = 0.5f; Vertex2[1].Rhw = 1;
Vertex2[1].Color = System.Drawing.Color.White.ToArgb();