DrawIndexedPrimitives bugged?
Hi everybody!
Does anyone know if DrawIndexedPrimitives is bugged?
I read about people having freezing problems or getting blank screens. I have something completely different: I am trying to draw two triangles with just one shared vertex and the DX function displays just the first triangles!!!
Here is the code for the VertexBuffer:
private
void VertexDeclaration(){
vb =newVertexBuffer(typeof(CustomVertex.PositionColored),5, device,Usage.Dynamic |Usage.WriteOnly,CustomVertex.PositionColored.Format,Pool.Default);
vertices =newCustomVertex.PositionColored[5];
vertices[0].Position =newVector3(0f, 0f, 0f);
vertices[0].Color =Color.White.ToArgb();
vertices[1].Position =newVector3(5f, 0f, 0f);
vertices[1].Color =Color.White.ToArgb();
vertices[2].Position =newVector3(10f, 0f, 0f);
vertices[2].Color =Color.White.ToArgb();
vertices[3].Position =newVector3(5f, 5f, 0f);
vertices[3].Color =Color.White.ToArgb();
vertices[4].Position =newVector3(10f, 5f, 0f);
vertices[4].Color =Color.White.ToArgb();
vb.SetData(vertices, 0,LockFlags.None);
}
Here is the code for the IndecesDeclaration:
private
void IndicesDeclaration(){
ib =
newIndexBuffer(typeof(short), 6, device,Usage.WriteOnly,Pool.Default);indices =
newintindices[0] = 3;
indices[1] = 1;
indices[2] = 0;
indices[3] = 4;
indices[4] = 2;
indices[5] = 1;
ib.SetData(indices, 0,
LockFlags.None);}
and this one is the DrawIndexedPrimitives call:
[...]
device.Indices = ib;
device.SetStreamSource(0, vb, 0);
device.DrawIndexedPrimitives(
PrimitiveType.TriangleStrip, 0, 0, 5, 0, 2);[...]
I also tried to set DeviceType to Reference but nothing has changed...
Any idea?
Thanks!
Gianluca.

