DrawIndexedPrimitive help understanding
Hello, I am new here. I have a few books that cover
DrawIndexedPrimitive
and one says the parameters are for vertex buffer the other says index buffer?
My problem is I am trying to render my terrain in patches. Right now I have a 65x65 size terrain
and want to render 4 patches 33x33 each one. So my call to
DrawIndexedPrimitive
is
dxApp.d3dDevice->DrawIndexedPrimitive(type, 0, 0, NUM_VERTICES, indicesSum, NUM_POLYGONS);
indicesSum += NUM_INDICES;
and my mesh is all messed up when rendered? Any ideas would be great. Thanks
[557 byte] By [
Mars_999] at [2007-12-23]
You did not say if you remembered to set the vertex stream and indexes..?
tell the device where to get the vertices
device.SetStreamSource(0, vertexBuffer, 0);
tell it where to find the indexes
device.Indices = indexBuffer;
tell it to render, starting with vertex 0 and index 0 and how many vertices and primities you want.
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numVert, 0, numTri);
I was only calling it once per frame....
dxApp.d3dDevice->SetStreamSource(0, vertexBuffer, 0, sizeof(Vertex));
dxApp.d3dDevice->SetIndices(indexBuffer);
dxApp.d3dDevice->SetVertexDeclaration(vertexDeclaration);
and then
dxApp.d3dDevice->DrawIndexedPrimitive(type, 0, 0, NUM_VERTICES, indicesSum, NUM_POLYGONS);
indicesSum += NUM_INDICES;
for the DrawIndexePrimitive