Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: 2D Sprites?

  1. #1
    Guest

    2D Sprites?

    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. ^^

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    570

    Re: 2D Sprites?

    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:

    Code :
    //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.

  3. #3
    Guest

    Re: 2D Sprites?

    thanks, it helped a lot. I've come across a few solutions as well and it pointed in the same direction. ^^

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •