Adding text to a scene


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):

      char* p = (char*) string;
	while (*p != '\0')
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *p++);


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?



but transformations should work too


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 :slight_smile:

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.


Thanks, it worked :slight_smile: