devkaiser at January 23rd, 2003 07:47 — #1
I'm newbie with OpenGL
How do you draw bitmap sprites in
dk2 at January 23rd, 2003 10:51 — #2
If I understand your question correctly, you are trying to draw 2D images. Right?
Well, you will have to use ortho mode like this:
glLoadIdentity(); // Reset The Current Modelview Matrix
// Now you are in 2D...
// Draw something....
// Ending ortho mode...
glMatrixMode( GL_PROJECTION );
glMatrixMode( GL_MODELVIEW );
I hope that helps.
woz1010 at January 24th, 2003 16:43 — #3
After going into ortho mode, you may want to display a texture on say a quad, to represent your sprite.
No code handy to show, as I am at work, but I am sure someone can show you if needed.
luke at January 24th, 2003 17:11 — #4
BTW Ortho mode has no Z axis so theres no point trying to do translations on it.
void at January 24th, 2003 18:56 — #5
If your an OpenGL newbie, check out nehe.gamedev.net it has probably the best introductory and intermediate OpenGL tutorials on the net.
woz1010 at January 25th, 2003 11:21 — #6
Also check out Game Tutorials
godecho at January 25th, 2003 14:59 — #7
Rendering a 2d sprite is as simple (or not simple depending on how you look at it as rendering a quad with some texture coordinates. I'd suggest looking into getting the OpenGL Programming Guide (3rd ed), usually refered to as "the open red book". I find nehe's tutorials a really awful way to learn opengl.
Its also occured to me you might be asking about a technique called "billboarding." Billboarding is where a 2d sprite is rendered so its always facing the player. That topic is a little more involved, so I wont bother unless thats what you were asking about.
morgoth at January 31st, 2003 06:08 — #8
glOrtho is just a projection mode. z axis is specified (otherwise why specify near and far cliping planes with glOrtho?) but of course z translations are not visible for one single object. If you depth-test your objects, you'll see that far objects are occluded by near ones.
Besides using textured quads with glOrtho for sprites, and IFF it's only 2d images you want, there is also glDrawPixels, but it's too rigid to do anything fancy with it. Just puts a rectangular pixel area on screen...
woz1010 at January 31st, 2003 11:21 — #9
If you depth-test your objects, you'll see that far objects are occluded by near ones.
Here is a compiled, and source code version of a OpenGL ortho mode project I was doing to see how fast I could get OpenGL on low end graphics cards, as well as learn OpenGL vertex arrays.
The demo also shows the far objects occluded by the card that zooms to and away from the screen as well you can see the mipmap (level of detail) effects on the cards as the zooming card goes back to its farthest point.