PDA

View Full Version : Adding text to a scene



gurkama
02-22-2005, 12:24 PM
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):



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

H.Stony
02-22-2005, 01:36 PM
glRasterPos2f

but transformations should work too

gurkama
02-22-2005, 10:54 PM
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 :)

mikael_aronsson
02-23-2005, 05:00 AM
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

gurkama
02-24-2005, 09:45 AM
Thanks, it worked :)