Jump to content
  • Advertisement
Sign in to follow this  
floyd3

Heightmaps, Vertex Buffer & TRIANGLE_STRIP

This topic is 4834 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

Hello, Let me cut to the chase... Currently I am using an index array to draw the heightmap with TRIANGLE_STRIP in the old fashion way (Display list). That works fine. Now, I want to load my heightmap's vertex data to the GPU (using vertex buffer). I know how to do that, but I just realized that my vertex array isn't set in the right order. Since I am loading the heightmap's raw data as-is, and I am relying on the vertex index array to draw, then my raw vertex array is a mess (its not even in triangles order) and the Vertex Buffer will not draw it correctly (I've tried). What can I do? I try to sit and think, but I just can't find a method to set it in the proper order. If there was some sort of way to upload and link an index array to the vertex buffer ? Should I just use an expanded vertex array and set it in the right order? that means a lot of duplicated vertex data... Isn't there more "Elegant" way? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You can upload all your vertex data in ANY order you want. Its only the index buffer that needs to specify the correct order of the vertices.

So just fill your vertex buffer with all your values, then generate the correct ordered indices in a separate index buffer.

Share this post


Link to post
Share on other sites
Ok, I saw "glDrawElements", but that isn't the problem.
the problem is that I can't find a mathematical way to sort the indices according to a TRIANGLE_STRIP mode...

Share this post


Link to post
Share on other sites
Ok, I saw "glDrawElements", but that isn't the problem.
the problem is that I can't find a mathematical way to sort the indices according to a TRIANGLE_STRIP mode...

Share this post


Link to post
Share on other sites
If you were using immediate mode and display lists:
You just put the vertices in the same order you called glVertex for your display list and not use indices at all (stick to glDrawArrays)?

If you were using vertex arrays and display lists:
just copy all the vertex data into one VBO and the indices into another VBO and use glDrawElements. Bind both buffers and use the same DrawElements call.


If you're wondering, the triangles TRIANGLE_STIRP creates go:

012, 123, 234, 345, 456, 567, 678, ...

where 0 is the first vertex specified.

Share this post


Link to post
Share on other sites
I still can't find a way to draw all the map at a single strip.
What I do now, is draw the map strip by strip...

I can't tell OGL to do that...

What is the method?

Share this post


Link to post
Share on other sites
you need to merge your strips by inserting degenerated triangles which will be culled

e.g. add the last vertex of the first strip and the first vertex of the second strip twice

strip 1
0123455
strip 2
66789....

the triangles 455 and 556 will be discarded because the space is zero

thats the common way to merge triangle strips

Share this post


Link to post
Share on other sites
I got you!

Ok, what you actually say is, I should make "dummy" triangles, who actually wont have any dimention, and will only serve as a starting position for the next strip , and so forth.

right?

Thanks alot!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!