Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most efficient way to manage a large set of lines in OpenGL?

I am working on a simple CAD program which uses OpenGL to handle on-screen rendering. Every shape drawn on the screen is constructed entirely out of simple line segments, so even a simple drawing ends up processing thousands of individual lines.

What is the best way to communicate changes in this collection of lines between my application and OpenGL? Is there a way to update only a certain subset of the lines in the OpenGL buffers?

I'm looking for a conceptual answer here. No need to get into the actual source code, just some recommendations on data structure and communication.

like image 236
e.James Avatar asked Dec 01 '08 21:12

e.James


1 Answers

You can use a simple approach such as using a display list (glNewList/glEndList)

The other option, which is slightly more complicated, is to use Vertex Buffer Objects (VBOs - GL_ARB_vertex_buffer_object). They have the advantage that they can be changed dynamically whereas a display list can not.

These basically batch all your data/transformations up and them execute on the GPU (assuming you are using hardware acceleration) resulting in higher performance.

like image 64
grepsedawk Avatar answered Sep 27 '22 19:09

grepsedawk