PDA

View Full Version : 2D Sprites?



11-30-2004, 05:12 AM
I don't know if it's possible with OpenGL but is it?

What I want to do is, create bitmaps in the front and have 3D objects in the background. The bitmaps must not zoom and change angle with the 3D objects of course...

So I'm asking where do I begin to study in order to create this effect.. Thanks in advance. ^^

Aeluned
11-30-2004, 06:40 AM
first render all of your 3D geometry using a standard perspective projection matrix.

after that switch over to an orthographic (screen aligned) projection and draw your sprites on top (texture mapped quads for example)

pseudocode:



//assumes the perspective matrix has been set up
//already
DrawScene()
{
glMatrixMode(GL_MODELVIEW);
Draw3DStuff();
glMatrixMode(GL_PROJECTION);
glPushMatrix(); //save perspective matrix
//setup an ortho projection with dimensions
//800x600
glOrtho(0,800,0,600,1,-1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); //clear any transformations
Draw2DStuff(); //draw sprites on top
glMatrixMode(GL_PROJECTION);
glPopMatrix(); //restore perspective matrix
}
that's more or less it.

11-30-2004, 06:45 AM
thanks, it helped a lot. I've come across a few solutions as well and it pointed in the same direction. ^^