How would you go about printing text in OpenGL? I would like to use real fonts instead of bitmap fonts. And is there any way I can render it to a texture so I can place it on a quad?
Any links or libraries would be appreciated. Thanks.
How would you go about printing text in OpenGL? I would like to use real fonts instead of bitmap fonts. And is there any way I can render it to a texture so I can place it on a quad?
Any links or libraries would be appreciated. Thanks.
http://nehe.gamedev.net
or more accurately:
http://nehe.gamedev.net/data/lessons....asp?lesson=13
If using windows then there's wglUseFontOutlines. As far as I know there's no corresponding X-server function so you're probably stuck with bitmap fonts.
I think nehe's site will probably have an example on the use of wglUseFontOutlines.
edit: beaten by jverkoey
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
If you feel like being creative you can create your own bitmap based fonts with a little work. Basicly create a bitmap file that has your characters in them (use a graphic program's text tool).
The step goes a little like this:
Say your font bitmap file has 10 characters per line and 4 linesCode:// psuedo for every character in a string { select the bitmap texture file get a texture rectangle to the character you want to display display a quad offset x pos by current char * char width }
a b c d e f g h i j
k l m n o p q r s t
u v w x y z - - - -
- - - - - - - - - -
in order to get the correct texture rectangle you take the character you want to display
subtract 67 from it. This will get you the nth character in your bitmap . Convert the 1d character number (1-40) into a 2d position (row column). Then multiply 0.10 times row and col position to find out the x, y tex coordinate.
I've given very vague - but workible example. I hope it can help you out.
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)
wglUseFontBitmaps will generate a bitmapped font from a font file. You have to use drawl lists to draw the text, but it's not that complicated.
Last edited by skorman00; 06-24-2004 at 12:33 PM.