Font rendering in GLUT using bitmap fonts with Sample example.

GLUT supports two types 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 flexible 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.
For example,
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 glRasterPos2f(float x, float y);
void glRasterPos3f(float x, float y, float z);

Source code of Sample Example



SHARE Font rendering in GLUT using bitmap fonts with Sample example.

You may also like...

4 Responses

  1. Maria says:

    Thank you for bitmap fonts guide! Really helped a lot!

  2. Peter says:

    Thank you, this was the only example, that I could use! Very helpful!!!

  3. can we add new font in GLUT because i need bigger size font for this GLUT_BITMAP_TIMES_ROMAN_24 font

Leave a Reply

Your email address will not be published. Required fields are marked *