, Visual C#


- 9


{

Device myDev = (Device)sender;

// CullMode,

// :

myDev.RenderState.CullMode = Cull.None;

// Direct3D,

// :

myDev.RenderState.Lighting = false;

}

// :

public void OnCreateVertexBuffer(object sender, EventArgs e)

{

// 4- :

VertexBuffer myVB = (VertexBuffer)sender;

CustomVertex.PositionColored[] Vertex = (

CustomVertex.PositionColored[])myVB.Lock(0, 0);

// 0:

Vertex[0].X = -1.0f; Vertex[0].Y = -1.0f;

Vertex[0].Z = 0.0f;

Vertex[0].Color = System.Drawing.Color.Black.ToArgb();

// 1:

Vertex[1].X = -1.0f; Vertex[1].Y = 1.0f;

Vertex[1].Z = 0.0f;

Vertex[1].Color =

System.Drawing.Color.MediumOrchid.ToArgb();

// 2:

Vertex[2].X = 1.0f; Vertex[2].Y = -1.0f;

Vertex[2].Z = 0.0f;

Vertex[2].Color = System.Drawing.Color.Black.ToArgb();

// 3:

Vertex[3].X = 1.0f; Vertex[3].Y = 1.0f;

Vertex[3].Z = 0.0f;

Vertex[3].Color = System.Drawing.Color.Cornsilk.ToArgb();

 

myVB.Unlock();

}

// :

public void myRendering()

{

if (myDevice == null) return;

if (myPause) return;

// Form1 :

myDevice.Clear(ClearFlags.Target,

System.Drawing.Color.White, 1.0f, 0);

// :

myDevice.BeginScene();

// :

SetupMatrices();

myDevice.SetStreamSource(0, myVertexBuffer, 0);

myDevice.VertexFormat =

CustomVertex.PositionColored.Format;

// :

myDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);

// :

myDevice.EndScene();

myDevice.Present();

}

// :