• Advertisement
Sign in to follow this  

octree render optimization

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

I finished octree recursive render function, now it looks something like:
glBegin(GL_TRIANGLES);
  octree_rec_render(); // <- this is were immediate glVertex, glNormal called recursively for octree nodes
glEnd();

will it be faster if I collect just indices of the visible triangles in octree_rec_render(), and render afterwards? just like:
glBegin(GL_TRIANGLES);
  octree_rec_render(); // <- collect triangle indices in visible node
glEnd();

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, visible_vertices);
glDrawElements(GL_TRIANGLES, visible_triangle_num*3, GL_UNSIGNED_INT, visible_triangles);
glDisableClientState(GL_VERTEX_ARRAY);

Share this post


Link to post
Share on other sites
Advertisement
Most certainly, yes it will be more efficient. The reason is that immediate mode will result in more API calls than using vertex and index buffers.

Also, if the vertices are static you only transfer that data over the bus once and only transfer index data each frame (if necessary). With immediate mode you'd transfer all the vertex data every frame.

And btw, immediate mode is already deprecated in OpenGL 3.1 so you might want to drop that altogether.

Note though that the code you posted misses the normals array [smile].
Ans you should check if you can use unsigned short indices (i.e. 16-bit) for even better performance.

Another note: as with every algorithm/optimization you should profile first and compare the solutions. However in this case there's almost always a performance benefit.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lord_Evil
Most certainly, yes it will be more efficient. The reason is that immediate mode will result in more API calls than using vertex and index buffers.

Also, if the vertices are static you only transfer that data over the bus once and only transfer index data each frame (if necessary). With immediate mode you'd transfer all the vertex data every frame.

And btw, immediate mode is already deprecated in OpenGL 3.1 so you might want to drop that altogether.

So as I thought, thank you.

Quote:

Note though that the code you posted misses the normals array [smile].
Ans you should check if you can use unsigned short indices (i.e. 16-bit) for even better performance.

Yeah, I was just simplifying the question, in the real code it is all there =)

Share this post


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

  • Advertisement