View Full Version : 2D?

10-14-2000, 01:09 PM
I was wondering, how can I make OpenGL draw in 2D instead of 3D?
Everywhere on the net, it says that OpenGL is great for 2D/3D, but the examples are only for 3D!!
Does anyone have any links or anything to help me???

Thanks in advance...

Mitchell Hayenga
10-14-2000, 01:21 PM
You could simply ignore teh 3d aspect of the code... such as rather than specifying the z portion of all commands, simply use ones that don't include it, or always set it to zero...

Like "glVertex2f(0.0, 0.0)". Here ut just uses the x and y values... I believe that it sets the z value to 0.0 for you..

And finally, you should usually try to do things in 3d rather than 2d these days. I know that this isn't an issue in this case, because either way you'll be using opengl, which always is 3d(or has the capability)...
Doing things in 3d gives you a better chance to being able to take advantage of 3d accelerator cards, making your app run faster..

10-14-2000, 01:45 PM
But, I need real examples of this, 'cause as you can see, I am posting this in the beginners section....
I am making a strategy game, and all I want to do is to be able to draw bitmaps on the screen really fast.
I didn't want to use DirectDraw, since I am thinking of porting the game to Linux later.

As I said, I need examples...

10-14-2000, 07:58 PM
ive made a couple of 2d games here http://members.xoom.com/myBollux (planetoids + tetris) though planetoids does use 3d models anyways they might be of use for you

10-14-2000, 11:25 PM
Sorry for not providing examples, just thought I'd provide a bit of general advice.

You should use gluOrtho2D to set up a simple flat orthographic projection, as opposed to a standard 3D perspective projection. You can find more info about this in Chapter 3 of The Red Book.


10-16-2000, 07:08 AM
I havn't looked into the specs of it, but I think for mere bit blasting to a buffer, DirectDraw may be a bit faster. However, portability is enough of a concern that I don't blame you for opting for OpenGL instead. But as stated earlier, be sure to use an Orthographic projection so your coordinates directly correspond to screen pixels. Otherwise, you'll get some funky results.