Displaying Simple 2D Text?

Hello I’m making a small project and i need a simple/fast way to print text in my opengl window.

In directX there is something like D3DXCreateFont, OpenGL equivalent?

I have now a method to draw a Quad with a (text texture). I think this way is wrong… isn’t it? I better have to use the Raster to draw the fonts ?

Thank you :slight_smile:

P.D. And PLEASE don’t tell me that i have to use GLUT >_<, i hate it.

Few methods of displaying text in OpenGL program:

http://www.opengl.org/resources/features/fontsurvey/

I can’t understand why we don’t have a ARB implementation for 2D fonts…

Fonts are used in many 3D apps, including games and other stuff.

Thank you kowal but for me these are not an easy/fast way… Why the ARB group did not disscused this? Incredible…

I can’t understand why we don’t have a ARB implementation for 2D fonts…

OpenGL exposes functionality of the hardware, not arbitrary conveniences for the user. Fonts are a purely software construct. They belong in user code, not in an OpenGL driver.

And I would point out that the more serious your language needs, the less likely a simple solution will work for you.

Thank you kowal but for me these are not an easy/fast way.

Using FreeType to get glyph images and putting them on the screen is reasonably easy. No, it isn’t simply giving an API call a string that magically appears on the screen, using unknown resources and performance. But it is reasonably easy. It’s simply a matter of rasterizing the glyphs, uploading them to a texture, and rendering them as needed. It shouldn’t take you more than a day or so to write such code, less if you’re not too particular about the structure of that code.

Not to mention that several of those libraries are very simple to use, no more complex than any reasonably OpenGL font rendering API might be.

Try this, if it works for you, if not find and try something else:

http://www.angelcode.com/products/bmfont/

I used the FTGL the textured fonts and it looks like this:

Uploaded with ImageShack.us

Ugly! Yeah… >_< I need help to improve how it looks :S. I think that i’m not doing it wrong but…

Thanks!

Here is the direct link to image

http://img32.imageshack.us/img32/4313/testkxq.jpg

I can’t see the “edit” post button :S ^^U

It looks like you only need a larger texture resolution.

(Editing a post can only be done during a few hours, to prevent confusion)

Uhmm Sorry Zbuffer but, how can I achieve a larger texture resolution? Considering of course that FTGL is what is making the texture.

Considering of course that FTGL is what is making the texture.

Doesn’t it take a size parameter when you create a texture? That should be either the pixel size or the point size of the font.

https://collab01a.scr.siemens.com/xipwiki/xip-doxygen/d1/d8e/classFTGLTextureFont.html

The constructor only takes the filename, but i think that the FaceSize method is what I need to touch.

bool FTGLTextureFont::FaceSize ( const unsigned int size,
const unsigned int res = 72
)

The “res” parameter :stuck_out_tongue: nice thank you i will try it!