Direct3D index buffers and triangle strips

impc

New member
Last night i was trying something with indexed triangle strips.

I wanted to get something like here (ascii art :))

1--3- 5 (numbers are vertex indexes in vertex buffer)
| \| \ |
0-2 -4
| \ | \|
6 7 8

index buffer:
i[0]=0
i[1]=1
i[2]=2
i[3]=3
i[4]=4
i[5]=5
i[6]=6
i[7]=0
i[8]=7
i[9]=2
i[10]=8
i[11]=4

now i tried to render it with
dev->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP,0,9,0,8);
but all triangles are NOT drawn, if i change 8 to 10 in
DrawIndexedPrimitive then i get all triangles.
WHY TWO EXTRA primitives?

thanx
impc
 
Re: Direct3D index buffers and triangle strips

I can't get your indexbuffer to match the wanted triangles?
Do you really want a triangle out of 4-5-6?

i[4]=4
i[5]=5
i[6]=6
 
>I can't get your indexbuffer to match the wanted triangles?
>Do you really want a triangle out of 4-5-6?

no.

I want to draw triangle strips made of

0-1-2-3-4-5 and 6-0-7-2-8-4 like referenced in index buffer

err, can i do it in that way? (but why it works when using 10 in primitivecount parameter in DrawIndexedPrimitive() )

impc
 
Last edited:
Try this:

i[0]=0
i[1]=1
i[2]=2
i[3]=3
i[4]=4
i[5]=5

i[6]=4 // zero area triangle ... but lets us continue
i[7]=8 // zero area again
i[8]=2 // on track again ...
i[9]=7
i[10]=0
i[11]=6
 
Humus said:
Try this:

i[0]=0
i[1]=1
i[2]=2
i[3]=3
i[4]=4
i[5]=5

i[6]=4 // zero area triangle ... but lets us continue
i[7]=8 // zero area again
i[8]=2 // on track again ...
i[9]=7
i[10]=0
i[11]=6

yes that way it works.
in first version (first post), visually everything looks ok, does direct3d or display driver removes these (4-5-6 and 5-6-0) triangles?

impc
 
No it doesn't, but if they are coplanar it'll be drawing the exact same thing twice. Just a waste of fillrate, but will look OK.
 
But what about triangles like 4-4-5, 4-5-5, 5-5-4, which are used in swaps. Do driver/direct3d skips these triangles?
 
They will be skipped in hardware most likely. I think all API's clearly define that zero area triangles must render zero pixels. At least it was clearly stated in the Glide documentation back then, but I think the same is true for both D3D and OpenGL too.
 
For that particular shape you might just want to go with a triangle fan. That way you can get each and every triangle drawn at once.

1--2--3
| \|/ |
8--0--4
| /|\ |
7--6--5
 
Back
Top