Jump to content
  • Advertisement
Sign in to follow this  
Pipo DeClown

OpenGL 512x512 of dynamic data

This topic is 4963 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'm making a OpenGL heightmap editor. I'm trying to render 512x512 indexed triangles. I'm using this render function:
GLvoid cHeightMap::Render()
{
    glEnableClientState(GL_COLOR_ARRAY);
    glColorPointer(4, GL_FLOAT, 0, Colors);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_FLOAT, 0, Verts);

    glDrawElements(GL_TRIANGLES, (mapRows-1)*(mapCols-1)*6, GL_UNSIGNED_INT, Indices);

    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
}


It runs like crap right now. Is it that I need to do multiple counts according to the vertex cache, or is it because I use 4-byte indices (511x511x6 of them)? I'm kind of new in OpenGL, don't know the right functions yet. Thanks! EDIT: 522.242 primitives.. [Edited by - Pipo DeClown on December 15, 2004 9:45:32 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Pipo DeClown
EDIT: 522.242 primitives..


Yeah, that's your problem. You need to reduce the number of polys you are rendering. You'll need to do 2 things:
1) Slice the terrain into blocks. Don't render blocks which aren't visible.
2) Perform some sort of LoD calculation on the scape to reduce the number of rendered polygons.

Share this post


Link to post
Share on other sites
Using an indexed triangle strip should give you a fairly significant increase in performance.

You could also try the ARB_vertex_buffer_object extension to upload the data into video memory. You'll lose some of the benefit of VBO because your data is dynamic, but if you only update the VBO every few frames you should get a decent increase in frame rate.

You should also consider breaking the vertex data into smaller chunks, especially if you plan on using VBO (which tends to choke on too much or too little data). That way you could get away with unsigned shorts for your indices.

Share this post


Link to post
Share on other sites
I only meant break into chunks from a rendering point of view. You could still treat it as one big heightmap for the purposes of editing if that's what you want to do. Otherwise you may have problems with seams etc.

Share this post


Link to post
Share on other sites
Quote:
Original post by benjamin bunny
I only meant break into chunks from a rendering point of view. You could still treat it as one big heightmap for the purposes of editing if that's what you want to do. Otherwise you may have problems with seams etc.

It doesn't matter that much, the editor doesn't have to be bug proof. I'll see in the future if it may need rendering optimizing, I'll remember your advice.

Share this post


Link to post
Share on other sites
not only is it good to break the mesh into chucks thus u draw fewer verts (cause fewer are onscreen)
but also drawelements has got an optimal number of index/elements (normally about 2000-4000) to draw in one call.
ie drawelements 100 x 2000 verts is likely to be quicker than
drawelements 1 x 200000 verts

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!