+ int c;
+ int numchar = strlen ( string ) ;
+
+ /*
+ * First of all we'll need a font to use
+ */
+ SFG_Font* font = fghFontByID( fontID );
+
+ float raster_position[4] ;
+ glGetFloatv ( GL_CURRENT_RASTER_POSITION, raster_position ) ;
+
+ /*
+ * Save the old pixel store settings
+ */
+ glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
+
+ /*
+ * Set up the pixel unpacking ways
+ */
+ glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
+ glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE );
+ glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
+ glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
+ glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
+ glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+ /*
+ * Step through the string, drawing each character.
+ * A carriage return will simply translate the next character's insertion point back to the
+ * start of the line and down one line.
+ */
+ for( c = 0; c < numchar; c++ )
+ {
+ if ( ( string[ c ] >= 0 ) && ( string[ c ] < 256 ) )
+ {
+ if ( string[c] == '\n' )
+ {
+ raster_position[1] -= (float)font->Height ;
+ glRasterPos4fv ( raster_position ) ;
+ }
+ else /* Not a carriage return, draw the bitmap character */
+ {
+ const GLubyte* face = font->Characters[ string[ c ] - 1 ] ;
+
+ /*
+ * We'll use a glBitmap call to draw the font.
+ */
+ glBitmap(
+ face[ 0 ], font->Height, /* The bitmap's width and height */
+ font->xorig, font->yorig, /* The origin -- what on earth? */
+ (float)(face[ 0 ]), 0.0, /* The raster advance -- inc. x */
+ (face + 1) /* The packed bitmap data... */
+ ) ;
+ }
+ }
+ }