Yet another glFont

Started by ndhb, November 12, 2006, 23:13:03

Previous topic - Next topic

ndhb

Hi all. There are several libs around but if someone hasn't found them and wants to draw some bitmap fonts in OpenGL:

* I've made a few classes that renders text in orthographic (2D) and perspective (3D).
* It currently only supports loading fonts created with Codehead's Bitmap Font Generator (http://www.codehead.co.uk/cbfg).
* It's implemented with display lists and at least it's fast enough for my own purposes (creating new text, results in display lists created which can occur a temporary stall).
* There's no support for unicode. To support unicode I'm considering writing a loader for BMFont (http://www.angelcode.com/products/bmfont).
* You're free to use it for whatever purpose if you include me (ndhb) in the credit.
* There's some generated javadoc that explains how it works (or look at TestFont.java).

Looks like this:


Please post if you try it and find any bugs or issues!

Download:
http://85.235.22.202:8080/dk.nesos.font.01a.zip


numberR

looks pretty cool!

i was doing dynamic font generation using BufferedImage and Graphics2D so it can generate whatever the text in any languages as long as Java supports them, but of cource, it has some speed issue...

appel

That's awesome work ndhb :)

But one thing though! If you zoom in on the characters that overlay the big blue text you'll notice a black border. This is most likely due to the anti-aliasing. It wouldn't look good on a colored background, like in-game.

You could try to change the clearColor, see what happens.


Isn't there a way around this?

ndhb

The border is due to the blending function I used. Changing the blending "solves" the issue. There are a lot of options and parameters to adjust (BlendFunc, AlphaTest, AlphaFunc, Texture mode, etc.) that can change the appearance of the text. I havn't had much time to experiment but it should be possible to achieve almost any effect (even stencilfun). Here's another screenshot with a different blending function.



from the code http://85.235.22.202:8080/dk.nesos.font.01b.zip

One of the nice thing about bitmap fonts is the versability, then again it can be hard to achieve the effect you have in mind without a lot of experience with all the different knobs and switches (which I don't really have).

kieselsteini

Hiho. Your font library is pretty cool. But there are at least two things I'll glad to see. First of all your BitmapFileFont loader is only capable of loading fonts from files not from URL oder File objects, so putting font files into a jar is very hard.
Also some setScale(float)/getScale() method for the Font class would be nice. Sure you can do this with glScale() for your own, but only when doing this via drawText3D().

Keep on working man!! After I found you lib, I'm the happiest man here  ;D

ndhb

Some changes to my router config caused the posted links to break. The zip package is now at: http://85.235.22.202:8080/dk.nesos.font.01b.zip

- Nicolai de Haan Brøgger