How do I draw text with GLUT / OpenGL in C++?


Question

How do I draw a text string onto the screen using GLUT / OpenGL drawing functions?

1
23
12/21/2017 8:11:27 PM

Accepted Answer

There are two ways to draw strings with GLUT

glutStrokeString will draw text in 3D

alt text
(source: uwa.edu.au)

and glutBitmapString will draw text facing the user

alt text
(source: sourceforge.net)

25
7/13/2019 7:40:44 PM

If you don't like the built-in stroke font or bitmap font that comes with GLUT as per epatel's answer, you'll have to roll your own solution.

NeHe has some good tutorials (along with fully-working sample code) on this:


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon