This topic is now archived and is closed to further replies.


OpenGL Text

Recommended Posts

Running_Wolf    122
I am trying to use the tutorial about bitmapped fonts to put the FPS of my application at the bottom of the screen. But the text won''t stay at the bottom. As you move around the world the text moves also. Sometimes you can''t even see it. When the text moves it moves somewhere betweent the center of the screen and the side. Or you just can''t see it.

Share this post

Link to post
Share on other sites
Bleakcabal    122
You are not obligated to set the projection matrix like this. I was faced with the same problem with my 3d engine which uses code based on NeHe's tuts for printing text.

I will post my code here so you may see your error and point to you what my error was.

unsigned int fps = frame_counter.GetFrameCount();
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glRasterPos3f(-0.2665f, 0.195f, -0.5f);
gl.Print("FPS : %7i", fps);

At first I had the very same problem as you did, but after I added a glLoadIdentity everything was fixed. Another error you can make with this is not to use the glTranslate3f command but rather glRasterPos3f. The thing most likely to happen is that there is glTranslatef somewhere that interferes with your position, your text is positioned right, but maybe you specify that the your view should be adjusted on the y axis, to compensate for camera direction. This throws off the text. There must not be a glTranslate command between the glLoadIdentity and the print command. But there must be a glRasterpos. One more thing maybe you need to set the projections matrix like this or something because I have some trouble rendering text above -0.5f on the z axis. But maybe this has something to do with view frustrum culling.

If you need any more help reply to this message. If you suceed with the change of projection matrix could you post some pseudo-code or code, im not familiar with changing the projection matrix.

*** EDIT : In case somebody's wondering you must disable the gl_texture2d to render things like text, lines, etc. accuratly. But you must put it back on again to have access to texture mapping.


GARAL website

Edited by - Bleakcabal on January 26, 2001 1:06:53 PM

Share this post

Link to post
Share on other sites
RealityMonster    122
position your text first before any transformations
eg :if u use my camera class..

// trnslate scale n position text
cglFont.print("Hello World!");
// do all other transformations

Share this post

Link to post
Share on other sites
Wavarian    850
RealityMonster: I had been doing that for quite a while, but have recently run into a problem when disabling Depth testing for a skybox after. Im currently looking for a better way to position text on the screen.

- Wav

Share this post

Link to post
Share on other sites