PDA

View Full Version : 2D Graphics with OpenGL



donev
06-22-2003, 04:05 PM
Hello,

Please cc adonev@princeton.edu on replies.

I have a scientific animation that uses OpenGL and that is both in 2 and in 3D. My assumption was that 2D would be much faster, because the objects that need to be rendered are much simpler (say disks versus spheres).

In 2D, I set up the perspective using gluOrtho2D, and then I render the disks using a glList which has a glu quadric Disk stored in it. I change the color using glColor. Lighting is disabled. In opposition, in 3D I use a true gluPerspective and use glu quadric Sphere object with lighting enabled and change color via glMaterial. So I assumed everything would run much faster in 2D.

Although this is true, the screen flickers in the 2D animations. But it does *not* in the 3D ones. I use double buffering in GLUT and glutSwapBuffers, so I cannot understand where the flickering comes from.

Any clues on what it is that GL does not like about 2D graphics would be helpful.

Thank you,
Aleksandar

jpummill
06-22-2003, 05:12 PM
My understanding is that gluOrtho2D is really just 3D with a near and far clipping plane of -1, and 1.

Could the flickering be a result of Z buffer issues?

Not sure but I sometimes see the same result.
jpummill

mikael_aronsson
06-22-2003, 11:02 PM
Hi !

perspective or orthographic view makes no difference for the depth buffer so the flickering is caused by something else.

Mikael

donev
06-23-2003, 06:01 AM
Hello,

Thanks for the clues, I found the problem--it was my programming that was an error. I had by mistake turned double-buffering off in 2D, probably thinking at some point that it would be fast enough not to require it.

Sorry for the junk,
Aleksandar

nexusone
06-23-2003, 10:30 AM
Just a note on 2D, most 2D games use a double buffer, to reduce the flicker when the screen data is changing like in a game or animation.


Originally posted by donev:
Hello,

Thanks for the clues, I found the problem--it was my programming that was an error. I had by mistake turned double-buffering off in 2D, probably thinking at some point that it would be fast enough not to require it.

Sorry for the junk,
Aleksandar