PDA

View Full Version : Using OpenGL to draw in 2D



sonicbhoc
05-26-2008, 11:26 AM
Hey, I'm trying to learn how to program using SDL and OpenGL as the graphics backend. However, I want to start simple on my first attempt at this, so I want to make a sprite-based game. I'm no good at modelling at this point in time, and I know more people that can lend me a hand spriting than people that can help me model.

However, I have absolutely no clue where to begin. I have just made the transition from Python to C, and I picked up a pretty good amount of C++'s basics, and used Pygame in Python (which will make learning SDL easier, if even just a little) for a little over a year and almost made a game with it (due to circumstances beyond my control, I never finished). But now I'm on summer break at school and I want to try my hand at this. Problem is, most of the tutorials I've found don't really deal with how to render in 2D using sprites and all that fun stuff. I could just use SDL alone, but I really want to use OpenGL. Can you guys help me?

Zengar
05-26-2008, 12:59 PM
The best would be using textured rectangles for sprites. Basically, OpenGL is "3d only"(yes, this is not exactly true, but close to truth). The hardware can draw textured triangles with great efficiency, so by "tricking" it into believing it draws 3D objects you get simple-to-use, powerful 2D engine with free image scaling, interpolation etc. --- and most important, resolution independence (as you set up virtual coordinates) --- at least in theory. Still, you will have to learn how to use 3D first. I suggest you work your way through the NeHe tutorials (google) until you learn how to use texture mapping.

Have fun and don't be shy asking questions!

sonicbhoc
05-26-2008, 03:58 PM
Thank you. I've looked at the NeHe tutorials before, and I have a basic understanding of what's going on. I had figured as much, I just didn't know how to go about doing this stuff. So, just texture a rectangle? I don't know why I didn't think of that before.