Results 1 to 5 of 5

Thread: Adding text to a scene

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2005
    Posts
    10

    Adding text to a scene

    Hi

    I have a 3D scene which I want to add text to. I try to use something like this (after I finish with the scene):

    Code :
    glPushMatrix();
        	glLoadIdentity();
          char* p = (char*) string;
    	while (*p != '\0')
    		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *p++);
    glPopMatrix();
    I see the string small and white, at the bottom-left corner of the screen. Changing the color, translating or scaling using
    glColor3f, glTranslate3f and glScale3f simply did not change a thing.

    Does anyone have a clue?

    Thanks

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2004
    Posts
    150

    Re: Adding text to a scene

    glRasterPos2f

    but transformations should work too

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2005
    Posts
    10

    Re: Adding text to a scene

    Thanks

    But this does not work, and I have several thoughts about it:
    Can glRasterPos2f (or glRasterPos2d) work with gluPerspective? Doesn't it need an orthogonal projection?

    I still didn't fully understand what the parameters for glRasterPos2f should be - What do they represent? If my camera is positioned at distance 500, and my scene is about 350x350 pixles in size - what values should I use with glRasterPos2f ?

    Thanks a lot

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: Adding text to a scene

    The easiest thing is to swith to orthographic projection just before you want to render your text, glRasterPos coordinates are transformed just like a glVertex coordinate so if you use orthographic projection it is much easier to figure out the coordinates, if you setup the projection to match the pixel coordinates of your window it is even easier.

    Mikael

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2005
    Posts
    10

    Re: Adding text to a scene

    Thanks, it worked

Similar Threads

  1. The order of adding lights and vertices to a scene
    By panicz in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-14-2013, 04:30 AM
  2. Adding text
    By Sniipe in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 01-23-2006, 07:30 AM
  3. How to write Text on in the scene?
    By jesse79 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-05-2004, 09:46 AM
  4. Replies: 0
    Last Post: 11-15-2002, 02:58 AM
  5. Dynamically Adding Shapes/Objects to a Scene
    By dhin in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 04-22-2002, 10:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean