2D Graphics!

Hi! I’m a beginner in OpenGL, and I want to know how do I write 2D graphics?

I have tried to search some topics about this, but all that I found were documents telling about 3D graphics, like “creating squares and triangles…”

Is it possible to write 2D graphics in Open GL?? or only 3D graphics are valid?

yes. this has been done before, btw.

3D graphic:
 /    /|
+----+ |
|    | |
|    |/

2D graphic:
|    | 
|    |

moral? don’t draw the third dimension.


Yes, but i think when we draw a rectangle in Open GL, it automaticaly Loaded a Z buffer… it should not appear, but it is loadded and taking memory…

Am I right?

Hi !

OpenGL uses a pipeline architecture, this means that your graphics don’t use any memory (except of course for the frame buffer) and you can disable the Z-buffer.

So you can just use the 2D version of the glVertex calls (glVertex2xxx).


At last, someone who wants to program Streetfighter !!

Why disable the Z-buffer when you don’t even have to enable it in the first place, it’s disable by default. And if you don’t want a Z-buffer at all, then don’t ask for one when creating the context.

After all, 2D is just a special case of 3D. It’s 3D where all coordinates has the same Z-value.