GLUT supports two type of font rendering: stroke fonts, meaning each character is rendered as a set of line segments; and bitmap fonts, where each character is a bitmap generated with glBitmap. Stroke fonts have the advantage that because they are geometry, they can be arbitrarily scale and rendered. Bitmap fonts are less ﬂexible since they are rendered as bitmaps but are usually faster than stroke fonts. In this tutorial I will explain about Bitmap fonts. The function that renders bitmap character using OpenGL is glutBitmapCharacter. The syntax is
glutBitmapCharacter (void *font, int character);
font –> bitmap font to use and character –> Character to render.
outputs a single character ‘a’ at the current raster position.
There are 7 bitmap fonts available in GLUT. They are
You can render the character in any raster position of the window. The raster position can be set using family of functions glRasterPos from OpenGL library. The syntax of the functions are:
void glRasterPos3f(float x, float y, float z);