RE: Materials for Mesh.Box

From: GAEL (
Date: 05/30/04

Date: Sun, 30 May 2004 16:11:02 -0700

I tried to read some of the messages posted before about this, and I wrote the following code.
The proble is that I can't see anything on the screen when I run the program;

box = Mesh.Box(dev, 2.0f, 2.0f, 2.0f);
box = box.Clone(MeshFlags.Managed, CustomVertex.PositionColored.Format, dev);
vertexBuffer = box.VertexBuffer;
vertexBuffer.Created += new System.EventHandler(this.OnCreateVertexBuffer);

public void OnCreateVertexBuffer(object sender, EventArgs e)
        VertexBuffer vb = (VertexBuffer)sender;
        CustomVertex.PositionColored[] verts = (CustomVertex.PositionColored[])vb.Lock( 0,typeof(CustomVertex.PositionColored),0,box.NumberVertices);
        numVerts=verts.Length; // I get 24 vertices when I set a breakpoint


This is my rendering code. I dont know if the problem comes from here

device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
device.SetStreamSource(0, vertexBuffer, 0);
device.VertexFormat = CustomVertex.PositionColored.Format;
device.DrawPrimitives((PrimitiveType)vertexBuffer.Type,0, 24); // I got 24 vertices

Thanks for your help