   octree render optimization
  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 nodesglEnd();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 nodeglEnd();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);
  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.   ;Quote:Original post by Lord_EvilMost 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 =)