PDA

View Full Version : how to draw text on the screen



AeroSujan
10-09-2011, 09:36 AM
Dear Friends
how can I draw text on the screen in openGL...Please give me some suggestion how can I write 'Hello World' on the screen.
Not using any glut feature....Using openGL in VC++. Please give me some suggestions. Thanks Sujan

BionicBytes
10-09-2011, 11:24 AM
Have you Googled this subject?
There are tutorials on using a font texture ( see HeNe website ) and many free 3rd party font rendering libraries.

Mctittles
10-10-2011, 09:35 AM
I've found drawing text in a graphics environment can be kind of a pain when you start. Once you create an openGL context the OS pretty much gives up and says your own your own here.

A common way is to use an atlas texture for your fonts. Here is one of many programs that can generate such a texture:
http://www.lmnopc.com/bitmapfontbuilder/

If you need multiple languages, I've heard good things about FreeType:
http://www.freetype.org/freetype2/index.html
It can generate font textures on the fly in your code so you don't need megabytes of font maps.

If you just need something quick and dirty you can use wglUseFontBitmaps (Windows only). The downside for this is it's pretty slow to render, and the fonts are very aliased. A good option if you just need to throw FPS on the screen or something:
http://msdn.microsoft.com/en-us/library/dd374392(v=vs.85).aspx

V-man
10-11-2011, 01:43 AM
There is an app for that
http://www.opengl.org/resources/faq/technical/#indx0170