LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Qu0ll on February 15, 2010, 10:38:01

Title: Rendering of text with LWJGL
Post by: Qu0ll on February 15, 2010, 10:38:01
What are the options for displaying "reasonable" quality text within a LWJGL game?  Of course it would be nice if subpixel antialiasing were possible but is there a way to display fairly crisp text anyway?
Title: Re: Rendering of text with LWJGL
Post by: princec on February 15, 2010, 10:57:20
I use large bitmap fonts rendered out beforehand, mipmapped, and then scaled down to size.

Cas :)
Title: Re: Rendering of text with LWJGL
Post by: kappa on February 15, 2010, 11:43:07
I'd go for bitmap fonts too as they are so easy to do, just write a parser to support a tool like http://www.angelcode.com/products/bmfont/ and you should be ready to go.

Alternatively you could use AWT fonts see following post for some example code http://lwjgl.org/forum/index.php/topic,1258.0.html
Title: Re: Rendering of text with LWJGL
Post by: ryanm on February 15, 2010, 12:23:35
Also check out distance field rendering (http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf). It allows high quality output even with very low-resolution font textures. Requires a fragment shader though. There's code in the Slick library.

edit: Also code and test webstart linked from this post (http://www.javagaming.org/index.php/topic,21989.msg181279.html#msg181279).
Title: Re: Rendering of text with LWJGL
Post by: princec on February 21, 2010, 10:34:25
You don't need frag shaders for distance rendering; the simple algorithm works with just the alpha test.

Cas :)
Title: Re: Rendering of text with LWJGL
Post by: ryanm on February 22, 2010, 10:38:26
That's true - you only need the shader if you want anti-aliasing or transparency or the spiffy border/glow/shadow effects.