fex
fex

Reputation: 3558

Opengl - Display List vs OOP

I am reading Nehe OpenGL tutorial and there is a tutorial about Display Lists. Are there any reasons to use it instead of "classes and objects" way? For example creating class of cube and then just simply write cube.render(x, y, z); ?

Upvotes: 0

Views: 298

Answers (3)

detale
detale

Reputation: 12912

Display lists are pre-compiled at GPU level. Your own rendering functions are compiled at CPU level, whose individual commands still need to go through the GPU at run time.

This is like comparing "stored procedures" to custom functions calling inline SQL. Stored procedures are compiled and execution plans are generated on the server side, while custom functions are only compiled in client side assemblies.

Upvotes: 1

SigTerm
SigTerm

Reputation: 26429

I am reading Nehe OpenGL tutorial and there is a tutorial about Display Lists.

I'd advise to stop reading Nehe. I've never seen anything decent related to Nehe to be mentioned on stackoverflow, and tutorials I saw use too much of platform-specific API.

Instead of NEHE, go to OpenGL.org and check "books" section. Alternatively, first version of "OpenGL red book" is available at glprogramming.com. While it doesn't cover most recent API present in OpenGL 4, all available methods are still available even in the most recent version of OpenGL via "compatibility profile".

Are there any reasons to use it instead of "classes and objects" way?

You're confusing two different concepts. Display list is OpenGL way to save sequence of OpenGL calls so you can "recall" them later quickly. Depending on OpenGL implementation, it might improve application performance. Usage of display lists has nothing to do with internal organization with your program (OOP). You can use OOP and still use display lists within cube.render(). Or you could use vertex buffer objects or whatever you want. Or you could work in "non-OOP" style and still use display lists.

Upvotes: 1

Jerry Coffin
Jerry Coffin

Reputation: 490198

The idea was to take advantage of hardware with on-board display-list processing. Basically, you'd build the display list in the memory of the graphics processor, then you could display the whole list by sending it a single command instead of re-sending all the coordinates and such every time you want to display the object. This can reduce the bandwidth requirement between the CPU and GPU substantially.

In reality, it depends heavily on the hardware and OpenGL implementation you're using though. With some implementations, a display list gets you major performance improvement -- but in others, it does essentially no good at all.

Upvotes: 3

Related Questions