I am trying to create a font that displays text. So far I am using glTranslatef for my camera arrangements and gluPerspective for camera Perspective. Anyway, when I create my font it will not display on screen, but if I change to glOrtho2D the text will display and my screen looks distorted. Simply, I want to be able to display my text and display everyting else. Please help.
Are you using bitmap fonts? You should be aware that glRasterPos is modified by the same things that glVertex is. Here’s an exceprt from MSDN’s documentation on glRasterPos:
The object coordinates presented by glRasterPos are treated just like those of a glVertex command. They are transformed by the current modelview and projection matrices and passed to the clipping stage. If the vertex is not culled, then it is projected and scaled to window coordinates, which become the new current raster position, and the GL_CURRENT_RASTER_POSITION_VALID flag is set. If the vertex is culled, then the valid bit is cleared and the current raster position and associated color and texture coordinates are undefined.
gluPerspective/gluLookAt/glLoadMatrix etc.
setup your states
...
draw scene here
...
glOrtho
...
draw text here
...
EDIT: glOrtho will create an orthographic projection matrix that will be multiplied with the current matrix. Don’t forget to reset the projection matrix to the identity matrix before calling glOrtho.
[This message has been edited by kehziah (edited 01-13-2003).]
//2D OVERLAY STUFF
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,1,0,1); //0,0 to 1,1 2D
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glColor3d(255,255,255); //color for text
glRasterPos2f(0.02f,0.95f); //text position
glPrint("type your text in here.);
works great for text Though I noticed if I use textures then the texture can cover the text but normal colored polygons won’t.
Anyone know how to make it so the text stays on top without being affected by textures? I tried a glDisable(GL_TEXTURE_2D); to no avail. Guess I’ll do some more reading
eh??? You want to display the text on an actual polygon? The example i gave is for showing text on top of your scene like a frame rate counter. If you want to display text on the side of a polygon why not just use a bitmap texture?