Hello Guest

Displaying Text in OpenGL

  • 33 Replies
  • 63400 Views
*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
Re: Displaying Text in OpenGL
« Reply #30 on: March 23, 2008, 19:16:13 »
:D lol, well im out of ideas   :-\

Re: Displaying Text in OpenGL
« Reply #31 on: March 25, 2008, 21:20:01 »
Any other ideas?^^

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
Re: Displaying Text in OpenGL
« Reply #32 on: March 26, 2008, 22:20:22 »
if your desperate to get that ttf workn in the mean time, bofore the call to print text,

reverse it:

GL11.glPushMatrix();
use GL11.glScalef(-1, 1, 1);
or GL11.glScalef(1, -1, 1); //depending on which way you want it to print -x, or -y

and after the call to print text:
GL11.glPopMatrix();

this should work until you find out what is wrong.

anyway sry cant be anymore help, that works as a dodgy bandaid.

Re: Displaying Text in OpenGL
« Reply #33 on: June 24, 2008, 21:32:06 »
I always wanted to do it myself - so, do you know any tutorial to use ttf-fonts in lwjgl-applications?
If you like real ttf fonts,  not rasterized to a texture, its a quite complex matter. You can do it this way:

-Loading of a font via AWT:   font=Font.createFont(Font.TRUETYPE_FONT, inputStream)
-font.createGlyphVector can be used to obtain a "GlyphVector" for a String
-glyphVector.getOutline() returns an  "Shape" of the String...
-shape.getPathIterator() returns an  "PathIterator"...
-the PathIterator allows you to step the contour of the text as splines.
-build a FlatteningPathIterator(pathIterator)
-the FlatteningPathIterator allows you to step the contour as straight line segments (linearizing the splines)
-the countour needs to be fed to an triangulation algorithm (several sources out there.)
-resulting triangles can by drawn as GL_TRIANGLES

Quite complex.. For sorry I have no complete code, but sucessfully used this way to build particle text objects some time ago.