PDA

View Full Version : Displaying Simple 2D Text?



RoiiG
07-02-2010, 09:11 AM
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 :)

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

kowal
07-02-2010, 09:35 AM
Few methods of displaying text in OpenGL program:

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

RoiiG
07-02-2010, 03:10 PM
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..

Alfonse Reinheart
07-02-2010, 07:26 PM
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.

ugluk
07-03-2010, 01:31 PM
Try this, if it works for you, if not find and try something else:

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

RoiiG
07-03-2010, 04:07 PM
I used the FTGL the textured fonts and it looks like this:


http://img32.imageshack.us/img32/4313/testkxq.jpg (http://img32.imageshack.us/i/testkxq.jpg/)

Uploaded with ImageShack.us (http://imageshack.us)

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

Thanks!

RoiiG
07-04-2010, 04:27 AM
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

ZbuffeR
07-04-2010, 04:41 AM
It looks like you only need a larger texture resolution.

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

RoiiG
07-04-2010, 05:00 AM
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.

Alfonse Reinheart
07-04-2010, 05:07 AM
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.

RoiiG
07-04-2010, 05:20 AM
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 :P nice thank you i will try it!