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.
each frame :
setup your states
draw scene here
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
gluOrtho2D(0,1,0,1); //0,0 to 1,1 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
I tried your example eXor, it displays the text you gave, but I have created a polygon on my screen that looks like this:
glColor3f( 1.0, 1.0, 1.0 );
glBegin( GL_POLYGON );
glVertex3f( -2.5f, -0.8f, 0.5f );
glVertex3f( 2.5f, -0.8f, 0.5f );
glVertex3f( 2.5f, 0.8f, 0.5f );
glVertex3f( -2.5f, 0.8f, 0.5f );
And when I enter your code you gave me, it clears the screen and only shows your text. Why?
It’s working, but only on the black part of my screen which is the main background. How do I display my text on a GL_POLYGON?
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?
Check this link: http://nehe.gamedev.net/tutorials/lesson.asp?l=14
shows how to make text that can move around like an object
Thanks for all the help!!!