Text in OpenGL

Moderator
Posts: 613
Joined: 2004.09
Post: #1
Through some research I have learned that aglUseFont() isnt the way to go for built in text support. I was wondering what some of you have been using for text output and what advice you have on OpenGL text. Any sample code would be much appeciated as always.

I took a look at FreeType and it looks like it may be a bit too powerful for the simple things im working with right now.

Thanks as always.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
I used this:
http://www.geocities.com/ed72678954/GlyphTool.zip

for my OMG entry among other things, Nick has turned it into a framework also which and made several improvments, but I think the link for that is dead atm.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 144
Joined: 2004.07
Post: #3
I've been using FTGL for the past, say, 4-5 months and I love it.

It uses freetype2 to render a font to a texture at whatever fontsize I need it at for beatifully sized fonts. I can't think of something I'd want for it to do that it doesn't already do just great.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
If you don't care about portability, you can use Cocoa to render text into a bitmap, and texture from that. It's easy to do on 10.4: http://onesadcookie.com/svn/repos/NSViewTexture , and possible on previous versions of the OS.

If you do care about portability, but don't care about complex languages (eg. Arabic, Thai) you can use FTGL ( http://homepages.paradise.net.nz/henryj/code/index.html ) or just use FreeType raw ( eg. http://onesadcookie.com/svn/repos/RubyGa...rce/font.c ).

If you do care about portability and do care about complex languages, the best solution I've found is to use Pango + FreeType to render into a bitmap, and texture from that. It works easily on Mac OS X and Linux, but the port to Windows is rather harder.
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #5
unknown Wrote:I used this:
http://www.geocities.com/ed72678954/GlyphTool.zip

for my OMG entry among other things, Nick has turned it into a framework also which and made several improvments, but I think the link for that is dead atm.
could you give me the command to create something like this:
[Image: Font2.png]

the font doesn't matter. It's just whenever I seem to feed it a string, or anything else, it turns up all screwy.
size of the texture is 512x512
Quote this message in a reply
Member
Posts: 131
Joined: 2004.10
Post: #6
Not the best but an alternative to look into, polyfonts at http://gameprogrammer.com/programming.html uses polygons and polylines for drawing out a character. There are pros and cons with vector fonts vs bitmap fonts.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #7
unknown Wrote:I used this:
http://www.geocities.com/ed72678954/GlyphTool.zip

for my OMG entry among other things, Nick has turned it into a framework also which and made several improvments, but I think the link for that is dead atm.
Here's the framework.
http://www.simrealitystudios.com/GlyphTo...mework.zip

skyhawk Wrote:could you give me the command to create something like this:
(image here)
the font doesn't matter. It's just whenever I seem to feed it a string, or anything else, it turns up all screwy.
size of the texture is 512x512
This will give you a 512x512 image where the text is white and background is transparent, that way you use glColor3f() to set the font color.
Code:
./GlyphTool Impact -square 512 -pt 50 -color FFFFFF -ts -o Impact.png

I'll also hint at the fact that I'm working on a Cocoa-ized version of the GlyphTool, so I'll definitely post about it when I get it working. Then you won't need to remember the commands. It'll be as easy as checking boxes and filling in text fields.
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #8
Nick Wrote:I'll also hint at the fact that I'm working on a Cocoa-ized version of the GlyphTool, so I'll definitely post about it when I get it working. Then you won't need to remember the commands. It'll be as easy as checking boxes and filling in text fields.
I'd love you forever if you did that! Love
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #9
skyhawk Wrote:I'd love you forever if you did that! Love
Not ready yet, but here's a teaser screenshot.
[Image: screen1.png]
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #10
Here is the v0.0.1 alpha release thread over at iDA:
http://www.idevapps.com/forum/showthread...#post48299
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #11
#1 feature request:
automate it.
I pick a squaresize and font, and you make it all fit to use up all the space appropriately
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #12
skyhawk Wrote:#1 feature request:
automate it.
I pick a squaresize and font, and you make it all fit to use up all the space appropriately
I'll check in to doing that. I've always been thinking that'd be nice. Does that mean you want to be rid of the kerning option or have that option AND an "automatically fill the whole square" option?

I put a new version up (same link as above) so you can check it out.

One note, I released an updated framework with the new GlyphTool which will only work with files produced by the new GlyphTool. Not a HUGE difference, but enough that you won't get anything written to the screen with the other framework. I also took out some unnecessary UI options.
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #13
I personally don't use kerning =)
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #14
skyhawk Wrote:I personally don't use kerning =)
I've never found real need for it, either, except trying to fill up the whole texture. Hopefully I'll be able to figure out the auto-fill feature in a reasonable amount of time. I'll post updates over at the iDA thread I posted above and on my website (see signature).
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #15
Kerning can be useful: for instance, if you want to apply a filter in Photoshop/GIMP to the resulting font texture, an extra margin around each char prevents "bleeding" of pixels from other chars nearby.
In my fontmaker app (that I need to fix someday), I have kerning per char, but it is mostly used for the opposite reason (bringing chars closer together) as well as correcting any unnatural spacing caused by weird-shaped letters.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Opengl/Cocoa text rendering tesil 15 17,405 Mar 20, 2012 11:16 AM
Last Post: OneSadCookie
  SDL/OpenGL fullscreen text rendering StealthyCoin 2 6,523 Mar 26, 2009 09:47 AM
Last Post: StealthyCoin
  OpenGL Text Rendering (in Cocoa) daveh84 5 7,893 Feb 19, 2009 12:44 PM
Last Post: TomorrowPlusX
  opengl text/font drawing from CGContext fretmunky 11 13,049 Dec 7, 2008 11:29 AM
Last Post: fretmunky
  OpenGL text and other things. Talyn 7 4,766 Jul 22, 2008 02:09 AM
Last Post: OneSadCookie