Font management in OpenGL

Started by Fool Running, April 15, 2007, 22:44:36

Previous topic - Next topic

Fool Running

I know that the fastest way to render text is to put the characters in a texture and then adjust the texture coords to render the text onto quads.
I'm currently generating the texture by rendering the first 255 font characters to a BufferedImage and then turning the image into an OpenGL texture. My problem is what to do if the user doesn't support a texture size that is big enough to create an OpenGL texture with. Can I safely assume that modern day cards can support 1024 texture sizes?
Is there a better way to create a font, then by putting all the characters into one texture?

I'm also wondering about memory size since I will have multiple fonts.

Any suggestions would be welcome :D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

bobjob

I also use a 1 file font, but it isnt to hard to produce a font list from multiple files.
are you planing to use multiple fonts on the screen at the same time?

to give an illusion of different fonts you could always add an extra print function to take color input.

Fool Running

Quoteare you planing to use multiple fonts on the screen at the same time?
yes.
My current implementation allows to change the color of the text on the fly. I'm mostly concerned with bold/italics and size changes which, at least in my current implementation, require a new font texture.
QuoteI also use a 1 file font, but it isnt to hard to produce a font list from multiple files.
I'm trying to avoid that ;D. It would be annoying to have to change textures in the middle of drawing the text. Even if it was optimized to draw all the characters of a string that require one texture, then change and draw the rest. Thats still possibly hundreds of texture changes every frame. :-\
Right now I'm thinking of making the font textures smaller (maybe 512x512) and just using OpenGL to stretch them to the size I need. It won't look as nice, but it would work.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

bobjob

with fonts you use a display list (or rather i do) so its not like you load the picture each time, rather each character is loaded into a seperate display list, this way you can have any quality of text you want made up of any number of files, each character is still going to refer to a seperate display list.

if you were having trouble with text changing here are some ideas, else just ignore them ;)
as for italic text im sure you can see how the top left and top right corners of each character just need to move to the right, so no new next picture needs to be loaded. casting a shadow you could always use the same text with a different color indented 1px down and 1 px right. as for bold, you could re draw the text multiple times around the current character.


Fool Running

Quoteas for italic text im sure you can see how the top left and top right corners of each character just need to move to the right...as for bold, you could re draw the text multiple times around the current character
I never thought of that, that would help a lot of my problems :-[
Thanks ;D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D