Jump to content
  • Advertisement


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


The joys of Index Buffers with dx 8.1

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I know this question has been asked thousands of times, but I can''t find any articles about it, since the search tools are disabled. I want to render a list of quads, defining a terrain, with an Index buffer. My vertices look like that 0---1----2----3 | | | | 4---5----6----7 <-- this is the terrain, viewed from above | | | | 8---9---10---11 for a 2 by 3 quads terrain. Suppose I have one vertex buffer, filled with vertex data in the order given above, and I want to render the complete thing with 2 triangle strips. Here is the index buffer I used: { 4 0 5 1 6 2 7 3 8 4 9 5 10 6 11 7 } I have tried many DrawIndexedPrimitive() parameters combinations, but I still can''t render more than the first strip. I think I didn''t get the trick with those StartIndex, and FirstVertex parameters. Can someone show me the few lines of code which correctly do that ? (with the SetStreamSource, SetIndex, and DrawIndexedPrimitive calls) Thanks

Share this post

Link to post
Share on other sites
C# syntax, but it could be applicable. I use:
(a) a large vertex buffer with enough space for lets say 300 patches.
(b) a SMALL index buffer, after all - the indices are the same for every patch.

My drawing call looks like this:

_Device.DrawIndexedPrimitives (
baseVertex, 0, TerrainPatch.VERTICES_PER_PATCH,

Should help you :-).


Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post

Link to post
Share on other sites
Are you using ONE DrawPrimitives() for the whole Index Buffer you listed? or two? If you''re using just one, the Index Buffer doesn''t contain the correct information to draw both rows. Since it connects the first row to the second, the triangle created by 7 - 3 - 8 has the order reversed, resulting in it facing away from you, and not towards you.

A simple solution was featured in a recent article: Concatenating Triangle Strips by Marc Reilly

The method he uses should be quite efficient for your needs.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!