What Is OpenGL® Text?

Eugene P.

OpenGL® text describes any computer font that, through a number of different methods, appears as an element inside an OpenGL® scene. There is no innate ability for OpenGL® to display text inside a three-dimensional (3D) scene, and there are really no intrinsic ways to overlay system text inside a framebuffer. This has led to the creation of different independent libraries to try to make using OpenGL® text as easy as possible. There are three basic methods of creating OpenGL® text: texture mapping, geometry and bitmap. Each has advantages and disadvantages, with the largest disadvantage for almost all OpenGL® text being a reduction in the rendering speed.

OpenGL is a programming interface that allows software applications to create three-dimensional (3D) scenes quickly and efficiently.
OpenGL is a programming interface that allows software applications to create three-dimensional (3D) scenes quickly and efficiently.

There is no mechanism for displaying text in OpenGL®, mainly because the purpose of the library is to provide hardware-accelerated 3D graphics. The display of fonts or other text is not considered a necessary part of the OpenGL® library of functions. Instead, the developers of software and operating systems have provided independent libraries in an attempt to make it easier to use text inside a 3D environment.

Using bitmap OpenGL® text can be done in a few ways, but it is by far one of the easiest methods to implement. This process begins with a single bitmapped image of the entire font set that is going to be used. When a word needs to be displayed on the screen, the individual letters are copied from the bitmap and arranged on an OpenGL® texture. This texture, which now contains a complete string, is then mapped onto a quadrilateral and placed in front of the scene so it overlays the rest of the 3D objects.

It also is possible to use geometry to actually construct OpenGL® text. This involves using a font that has two-dimensional (2D) vector-based information about how to draw each letter. These vectors are translated into vertices and triangles, making each letter its own model. To display a string of text with geometric fonts, the models just need to be lined up in the correct order in the scene. One advantage to this method is that the text models can be easily extruded to form block-like 3D letters.

The final common method that can be used to show OpenGL® text is to use a simple pre-made texture map. This is an image in which the desired text string is already drawn in the way it should appear within the scene. The image can then be applied to any object, showing the text when the object is rendered. Texture maps are mostly effective for static text, such as words on the side of a 3D cardboard box model. It is one of the simplest ways to show text that has proper spacing and kerning.

You might also Like

Discuss this Article

Post your comments
Forgot password?