Skip to main content
gamedev.net
🔒 Locked

DrawIndexPrimitive Problem

Started by robertnc Feb 24, 2005 at 11:23 PM 1 replies 800+ views
Original Post
robertnc
robertnc
Hi! I am having a little problem with my program, and I have found something weird. When I execute my program on a computer with T&L, my program runs fine. But without it, everything gets messed up. So pretty much, my DrawIndexedPrimitive is not working properly when I have D3DCREATE_SOFTWARE_VERTEXPROCESSING on. The problem is coming from the fact that I am trying to only draw a couple triangles from my vertex and index buffer, which store all of the data I am trying to draw. It works fine when I draw all of the vertex and index buffer at once, but when I loop through it and try to draw subsets of the buffers, the output is a bunch of messed up triangles. So I guess my question is, why is it only failing on software vertex processing, and also how would I use DrawIndexedPrimitive to only draw a subset of the buffers? For the second question, heres what i have so far: device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, 4, indexOffset, 2); where 4 is the number of vertices I want to use and 2 is the number of triangle to draw. Anybody got any ideas on either of my questions? Thanks!
Muhammad Haggag
Muhammad Haggag
Quote:
But without it, everything gets messed up. So pretty much, my DrawIndexedPrimitive is not working properly when I have D3DCREATE_SOFTWARE_VERTEXPROCESSING on.

Hmmm...are you running on nVidia hardware?
nVidia drivers aren't really tight when it comes to bad DIP parameters, which could explain why it works in HARDWARE but not in SOFTWARE.

Quote:
device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, 4, indexOffset, 2);

This call says that you'll only be using vertices starting from index 0 to index 3 (i.e. the first 4 vertices starting from vertex 0). If the indices starting at indexOffset index vertices farther than the first 4 in the vertex buffer, this won't work.

robertnc
robertnc
Hooray! Thank you so much for your quick and very helpful reply!
Yes, both machines I tested it on when it was working on hardware vertex processing had nVidia cards.
And now I got it working, what I had to do was say this:

device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, numVerts, indexOffset, 2);

where numVerts is that max number of verts, indexOffset is where i want it to start reading, and 2 is how many triangle to render.

I am so happy, I've spent many hours on this single problem. Thanks for helping me understand it and helping me get it working!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.