more than 1 trianglestrip at a time

Started by
5 comments, last by muskad202 20 years, 1 month ago
hi ! i've got 30 vertices, and i want to draw 3 triangle strips (10 vertices in each trianglestrip). can some one show me how to do this? at present, i'm creating 3 vertexbuffers, each with 10 vertices, and then calling the drawprimitive function 3 times .. is there any way to do this by creating only one vertex buffer and/or calling drawprimitive only once? thanks muskad202 [edited by - muskad202 on March 21, 2004 3:27:33 AM]
Advertisement
*Scratches head*
How do you want the trianglestrips rendered? In a row? On top of eachother? (in that case you need an index buffer)
An overview of options:

You can do this by creating one vertex buffer containing all your vertices, and one index buffer containing indices looking up the correct vertices to make your triangles. Then, you can issue 3 DrawIndexedPrimitive() calls with appropriate offsets to render these.
Result: 1 VB, 1 IB, 3 DIP calls.

Alternatively, you can create your vertex buffer as above, but in the index buffer, stitch the strips together with degenerate triangles, this way you can render all three strips in one DIP call because the geometry is connected correctly (the degenerate triangles have no visual effect on the final image).
Result: 1 VB, 1 IB, 1 DIP call.

I''m not going to detail the VB only option because you should almost always use indexed primitives.

Finally, you could just leave strips alone and go with indexed triangle lists.

-Mezz
hi !!
actually, i''m trying to create a 8x8 board (the number 30 in my earlier post was just an example)
so, what i thought of doing is, creating one trianglestrip for each row .., so i have 8 trianglestrips, with each strip having 16 triangles .. (2 triangles for each square).

muskad202
"indexed triangle lists" .. i don''t know what those are .. any link to page that explains it ?
thanks
muskad202
OK, if you''re doing an 8x8 board type thing you might be better off with triangle strips, also, you can probably manage to render the board with a single big triangle strip, without even needing to stitch strips together (if you get the indexing right).

Indexed triangle lists are just, as the name implies, a list of triangle vertices that you reference by indexing them, like an array.
For example, for one board square you only need four vertices (lets number them 0 to 4), and with triangle lists you could index them with 6 indices e.g.
0,1,2 -- first triangle
3,0,2 -- second triangle

You see how with indexing, you only need to store the vertex in the vertex buffer *once* but you can reference it in the index buffer multiple times.

Er, I don''t really have handy links to a lot of DirectX information, you could try various tutorials on NeXe
(http://nexe.gamedev.net) or searching the net for something like "direct3d vertex buffer" or "direct3d index buffer".

-Mezz
thanks for your help

This topic is closed to new replies.

Advertisement