Contents / Previous / Next


Fonts with GLUT

All that we discussed so far about bitmaps and fonts is also provided by the GLUT library:
  public void drawFontWithGLUT( GL gl, GLUT glut ) 
    {
      // Fomat numbers with Java.
      NumberFormat format = NumberFormat.getNumberInstance();
      format.setMinimumFractionDigits(2);
      format.setMaximumFractionDigits(2);
     
      // Printing fonts, letters and numbers is much simpler with GLUT.
      // We do not have to use our own bitmap for the font.

      gl.glWindowPos2i( 20, 20 );
      glut.glutBitmapString(
        GLUT.BITMAP_TIMES_ROMAN_24, 
        "OpenGL Text with GLUT - " 
        + format.format( 17.13 ) );
    }