# 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.

## 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 on other sites
Quote:
 Original post by Pipo DeClownEDIT: 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 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 on other sites
Thanks for the tips.

##### Share on other sites
I'm a cut it in pieces and let the user pick a part to edit. That's gonna be much easier :)

##### 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 on other sites
Quote:
 Original post by benjamin bunnyI 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 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

1. 1
2. 2
Rutin
23
3. 3
JoeJ
20
4. 4
5. 5

• 28
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631737
• Total Posts
3001949
×