Draw some text in figure

Hello !

I try to draw some text on my OpenGL figure. I write

            glMatrixMode( GL_MODELVIEW );
            glPushMatrix();
            glLoadIdentity();
            glRasterPos2i( 20, 10 );
            glBitmap(0, 0, 0, 0, 0, 0, NULL);
            glCallLists( pout.length(), GL_UNSIGNED_BYTE, pout.c_str() );
            glFlush();
  

where pout is a string, but nothing draws, what I do wrong ?

you have to call glXUseXFont (in linux) or wglUseFont (in windows) once after you’ve made your gl context current. this creates bitmaps for the font characters.

to display text you don’t need glBitmap(), it’s just:

 char c[64];
sprintf(c, "pi = %3.1f", M_PI);
glRasterPos(x, y);
glCallLists(strlen(c), GL_UNSIGNED_BYTE, c); 

be sure that the raster position is within the window. if it is only one pixel outside, no text is drawn, even if the rest would be within the window.