tags:

views:

254

answers:

5

What's the quickest, easiest way to draw text in standard OGL ??

A: 

Depends on what framework you are using. One common method is to render text to an offscreen buffer and use that as a texture.

Otto Allmendinger
A: 

OpenGL does not support drawing text. You need to use some library to render text to bitmap and then you can use OpenGL to render the bitmap. Freetype2 and Pango are good cross-platform low level solutions. Game programming libraries such as ClanLib and GUI libraries such as Qt may also have their own ways for rendering text.

Tronic
A: 

It depends on the framework you are working on like the one above me said. for example, SDL is multi-platform and one can draw text using a special lib inside SDL: http://gameprogrammingtutorials.blogspot.com/2010/02/sdl-tutorial-series-part-6-displaying.html

If you're using glut look at the following functions: glutStrokeString, glutBitmapString in glut documentation..

Protostome
+1  A: 

Text is surprisingly involved in OpenGl
Take a look at this example from NeHe

Martin Beckett
After OpenGL has been around so many years, and almost every OpenGL application needs to render text, you'd think it would be in GLU or something, but no, it has not really advanced at all. "surprisingly involved" is an excellent description, even when you use a library like FreeType.
Ricket
A: 

Use textures. Each character is a textured quad, and texture coordinates enclose the specific characters.

Then, you can affine using display lists, generating raster representing string at runtime, outlining, blending...

You can use a platform specific OpenGL API (i.e. wglUseFontOutlines), but I think it will be deprecated since OpenGL 3.2.

Luca