Concerning the rendering of line loops, line strips, and polygons: I assume using vertex arrays provides better performance than does drawing with glBegin() - glVertex3i - glEnd(). Can I drastically improve the performance of my opengl app using vertex arrays instead of glVertex3i?
Another issue is clearing the display before redrawing the next frame. The red book says that glClear is a very expensive operation. What should I do to ensure clearing the screen is as quick as possible?
newbie Thanks in advance
Yes arrays will drastically improve performance, but make sure your data is appropriately structured. Send many primitives per array for example.
Clear isn’t that slow these days, but clear as little as you can per frame, for example if you’re in a dungeon, you probably don’t need to clear the color buffer, just the depth buffer. Even if you’re outside you may have a skydome so no need to clear the color there either.
When you do clear clear everything at once using bitwise OR operatiosn on the tokens, rather than clearing different buffers in multiple calls, this is especially true for z and stencil (if you need stencil).
Also some implementations may optimize for certain clear values like 1.0 for depth.
It means that your arrays must be filled the right
for example if you were rendering triangles, the
first 3 entries of your array would define the
3 vertices for the first triangle, the next 3
indices would define the 3 vertices for the next
triangle and so on…
As far as what dorbie said regarding sending many
primitives per array:
Try and pack as many vertices as possible into a
vertex array in order to get as much a performance
boost as possible.
Communication across the bus can be an expensive
process, so the more vertices you can send to your
board in one shot, the better.
an alternative is VBOs, which need not be uploaded
each frame…the vertex data can reside
permanently on the video board.