View Full Version : Draw some text in figure

Yuriy Rusinov
05-20-2005, 02:37 AM
Hello !

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

glMatrixMode( GL_MODELVIEW );
glRasterPos2i( 20, 10 );
glBitmap(0, 0, 0, 0, 0, 0, NULL);
glCallLists( pout.length(), GL_UNSIGNED_BYTE, pout.c_str() );
where pout is a string, but nothing draws, what I do wrong ?

05-20-2005, 03:45 AM
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.