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 5 of 5

Thread: 2D text in a 3D environment

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    6

    2D text in a 3D environment

    This may seem very simple, but I can't figure it out.
    I'm using wglUseFontBitmaps to draw 2D text in a 2D overlay, kinda like a HUD in a 3D game.
    Now I want to use the 2D text in the 3D environment. An object with a 3D coordinate should have a flat text with info about it straight above it.

    Right now I use glRasterPos2f to position the text. I've messed with glRasterPos3f, gluPerspective, glOrtho, switched the matrix mode between GL_PROJECTION and GL_MODELVIEW, etc; either it shows nothing or it ignores the depth and just draws it like it does the HUD text.

    Any ideas on how to tackle this?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,097

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    6
    Sorry, that's not what I meant. That tutorial draws the text on top of the 3D environment, so the text itself is still in its 2D overlay environment. That's what I was doing already. I want to draw the text straight above an object in the 3D space. I basically just need the 2D screen coordinates (x, y) of the 3D object (not the (x, y) coordinates of the object in the 3D space).
    How do I get those screen coordinates from a 3D space?

  4. #4

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,097
    The samples on this site are for DirectX but a very easy to translate to OpenGL
    http://www.angelcode.com/products/bmfont/

Posting Permissions

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