PDA

View Full Version : 2D with OpenGL



joeyTR
03-14-2003, 07:01 AM
Hi http://www.opengl.org/discussion_boards/ubb/smile.gif

Is there any way to write a traditional 2D game in OpenGL? I'm trying to find an Image function that does not have to do with textures and it seems this doesn't exist.

Can old fashioned animation be implemented in OpenGL (reading from image strips etc) with non 3D scrolling backgrounds (which are images, no primitives involved)?

If I've got something wrong in this whole concept, please correct me. Any answer would do.

Thanks.

PS: In case you're wondering, I'm planning to use 3D models but I would like to keep some of my old graphics.

shinpaughp
03-14-2003, 07:09 AM
You should be able to use glBitmap.

Deiussum
03-14-2003, 08:40 AM
There's also glDrawPixels. glBitmap will only work for single bit-per-pixel images.

You can also just use textured quads, which in many cases may be faster for you.

For instance, if you have a texture with multiple frames of 2D animation, you can choose which frame by picking the appropriate texture coordinates.

nexusone
03-14-2003, 08:57 AM
The best way under openGL to create a 2D game is to use texture mapping qauds, this will also make programming a 2D game easy.

You can do direct pixel drawing in openGl but it is slower and really don't want to use it much or at all if it can be help.

The texture quads can used like 2D sprites, which out having to write extra code for that function if it was done in pixel operations.
Also can make shadow masks, for the sprites to mask the ground areas with a shadow the object. Lot's of posiable things you can do.

Since your working in 3D, you easly create layers for backgound images, to forground images.

Easy to make Transparent to simi-transparent objects. Great for sprites or layered objects.

Some of the openGL features can really make it easy to create a 2D game, since you can have openGL take care of a lot of functions normally you may have to write yourself.

nehe.gamedev.net has a tutor on creating sprite type objects.


[This message has been edited by nexusone (edited 03-14-2003).]

joeyTR
03-14-2003, 12:12 PM
Thanks so much! http://www.opengl.org/discussion_boards/ubb/smile.gif

nexusone (or anyone else), I don't want to sound lazy or anything , but I can't seem to find any good resources on 2D sprites with textured quads. (I can't even find that sprite tutorial at nehe's!)

Would be so kind as to post any links on the subject that you might know of ?

Thanks again http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by joeyTR (edited 03-14-2003).]

nexusone
03-14-2003, 12:34 PM
Sorry I did not remember at the time of my post what tutor number was.

But the tutor I was thinking of is tutor number 32 on alpha testing and blending.
In this tutor 32 he creates a game using texture quads as a sprite like object, using the alpha channel.

This can be a little advanced to do without any basic knowlege of openGL. If you are going to use openGL, it would be wise to learn how it works.
Start will nehe's tutor 1 and work your way up.
This will help you understand how to use openGL's features to create a 2D game.

http://www.opengl.org/discussion_boards/ubb/smile.gif

also found this like to a 2D tile type game under opengl http://www.gamedev.net/community/gds/projects/default.asp?projectID=732



Originally posted by joeyTR:
Thanks so much! http://www.opengl.org/discussion_boards/ubb/smile.gif

nexusone (or anyone else), I don't want to sound lazy or anything , but I can't seem to find any good resources on 2D sprites with textured quads. (I can't even find that sprite tutorial at nehe's!)

Would be so kind as to post any links on the subject that you might know of ?

Thanks again http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by joeyTR (edited 03-14-2003).]



[This message has been edited by nexusone (edited 03-14-2003).]