PDA

View Full Version : glutBitmapCharacter()



screwtape
04-25-2001, 06:23 AM
okay I want to use glutBitmapCharacter to print some text on the screen, but I want to do it relative to the window lay out, for example, 10 pixels up from the bottom and 10 to the right of the left most side.

However I've already got all my main objects in the background with their own translations, and given the fact that the camera can optionally be moved I don't want to get into any complicated translations for the bitmapped fonts. Is there anyway to just render everything, and then tell glut or gl to print the fonts relative to the window positions so that they appear straight forward and aren't affected by my other translations?

Relic
04-26-2001, 04:44 AM
I think I've seen this before on the forum.

Pretty simple. Put this in your function which prints the text and your current camera transformations are not affected by the text position.

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, width, 0, height); // window size
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glListBase(yourFontBitmapsListBase);
glRasterPos2i(10, 10); // where the text starts printing, origin lower left
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

Relic
04-26-2001, 04:46 AM
Oops, posted twice.
Don't press refresh if "Back" doesn't work.

[This message has been edited by Relic (edited 04-26-2001).]