I've just finished writing a few useful functions for displaying allegro fonts in AllegroGL. (AllegroGL's font drawing routines are not working for displaying textured allegro fonts in anything other than monochrome).
If anyone else is having the same problem, you may find this very useful.
Here are the function prototypes:
JFONT *create_jfont(FONT *fnt);This generates a font from an allegro font. FONT *fnt must be an allegro font.
void destroy_jfont(JFONT *jfont);Destroys the generated font, deleting OpenGL textures.
void jprintf(JFONT *f, float x, float y, float z,float scale, char *format, ...);Draws the text as a series of quads (printf style). OpenGL's matrix transformations must be set appropriately before the text is drawn.
There , nice and simple.
(note: the blurring around the edges is 'cause this is a .jpg screenshot.)
JFONT *create_jfont(FONT *fnt) is actually quite complicated. It uses a packing algorithm to fit the glyphs into an appropriately sized texture:
Allegro font: (before packing)
OpenGL (2^n,2^m) texture after packing:
I won't post the code now, but if anyone wants it, I'll neaten it up a bit. (I can't be bothered at the moment 'cause, no doubt, Bob'll fix the problem tomorrow and all this will be a waste of time )
Gnatinator: Thanks for your code, I found it useful for writing my own functions.