#### Archived

This topic is now archived and is closed to further replies.

# How to use DrawIndexedPrimitive to draw multiple surfaces?

This topic is 5341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi ive got a vertex list(9vertices) that is positioned like a grid eg: 0-3-6 1-4-7 2-5-8 and ive got an indice(16) list like so: 0-3-1-4 1-4-2-5 3-6-4-7 4-7-5-8 And i am trying to use the DrawIndexedPrimitive with 'triangle strip' to draw 4 squares onto the scene. But I keep getting vertices going wrong places etc, eg atleast one point going to origin(0,0,0). I know ive set up my vertices and indices right as i had called the drawindexprimitive 4 times before to draw the lot, but i want to draw the lot with only one call now. heres the code im using so far that doesnt draw it properly: DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP,0,0,9,0,18); ive tried looking at the help file but i got no idea, thanks [edited by - johnnyBravo on March 29, 2004 9:47:35 PM]

##### Share on other sites

1st tri:0,3,1
2nd tri:3,1,4
both good healthy triangles, but then
3rd:1,4,1
4th:4,1,4
Both of which have 0 area. Not good.

I would recommend you use Triangle Lists instead. They''re much easier to work with and on most modern hardware they''re faster than strips.

Stay Casual,

Ken
Drunken Hyena

##### Share on other sites
but how are you supposed to draw a small grid with one draw call by doing that,
its impossible, unless you call the draw for each row.

Is there any other way of using the drawindexed to know to check every four parts of the array:
eg for 12345678
1234,5678

123, 234, 345,456,567,678

thanks,

[edited by - johnnyBravo on March 29, 2004 11:26:47 PM]

##### Share on other sites
quote:
Original post by johnnyBravo
but how are you supposed to draw a small grid with one draw call by doing that,
its impossible, unless you call the draw for each row.

It's not impossible but sometimes requires degenerate triangles to stitch things together.

quote:

Is there any other way of using the drawindexed to know to check every four parts of the array:
eg for 12345678
1234,5678

Only with multiple calls. Strips are designed to build triangles from each new vertex and the previous 2. That's how they work.

Is there any reason you don't want to use Lists?

Stay Casual,

Ken
Drunken Hyena

[edited by - DrunkenHyena on March 31, 2004 8:14:51 PM]

##### Share on other sites
I think you might be misunderstanding tri lists. They''re separately indexed faces, don''t have to be adjacent:

(0,3,4)(0,4,1)(3,6,7)(3,7,4)...

Though, if you were insistent on using a tri strip, it can be done in one call:
  0-3-1-4-4-1-1-4-2-5-5-3-3-6-4-7-7-4-4-7-5-8

Look at the above list and see how the degenrates work to stitch the strip together. However, since your actual strips are so small (two faces per) you have a high percentage of degenrate triangles. You can compress things a bit:
  0-3-1-4-2-5-5-3-3-6-4-7-5-8

But like DH says, tri lists are preferred in general, even though the IB can be much bigger.

I like pie.

##### Share on other sites
yeah thanks, ive gone to trilists and it works

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011316
• ### Who's Online (See full list)

There are no registered users currently online

×