I'm struggling with the FTGL library for fonts in opengl. For example, I still haven't figured out how to put the text somewhere on the screen other than the bottom left. I'm currently using a pixmap font, and I started experimenting with glRasterPos
.
The following code "works" in that it displays the text on the bottom left in white:
ftglRenderFont(ftgl_freesans, "HELLO WORLD!", FTGL_RENDER_ALL);
In the following example, the text does not show up at all:
float r[4];
glGetFloatv(GL_CURRENT_RASTER_POSITION, r);
glRasterPos4fv(r);
ftglRenderFont(ftgl_freesans, "HELLO WORLD!", FTGL_RENDER_ALL);
I'm confused! Nothing should be different, so why does the font not render?
glRasterPos is transformed by the current value of the matrix stack when you call it, it doesn't just 'set' the value.
Querying the value of current raster position returns the already transformed location. So that calling
glRasterPos(glGet(GL_CURRENT_RASTER_POSITION))
has the effect of putting the current window space position through the transformation matrix again, which is not what you want.If you set the modelview and projection matrix to identity, then your get/set operation should do what you expect.
A quote from MSDN: