LWJGL
May 21, 2012, 00:34:25 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Font management in OpenGL  (Read 2433 times)
Fool Running
Nerdus Imperius
*****
Posts: 647


« on: April 15, 2007, 15:44:36 »

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 Cheesy
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
bobjob
Prolific Timewaster
****
Posts: 335


LWJGL: WOW SO GOOD


« Reply #1 on: April 15, 2007, 16:27:39 »

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.
Logged

LWJGL Benchmark online test:
http://have2chat.net/benchmark/
http://have2chat.net/benchmark/fullpage.html (run full OpenGL webpage)
Fool Running
Nerdus Imperius
*****
Posts: 647


« Reply #2 on: April 16, 2007, 06:34:32 »

Quote
are 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.
Quote
I 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 Grin. 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. Undecided
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.
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
bobjob
Prolific Timewaster
****
Posts: 335


LWJGL: WOW SO GOOD


« Reply #3 on: April 16, 2007, 12:29:57 »

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 Wink
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.

Logged

LWJGL Benchmark online test:
http://have2chat.net/benchmark/
http://have2chat.net/benchmark/fullpage.html (run full OpenGL webpage)
Fool Running
Nerdus Imperius
*****
Posts: 647


« Reply #4 on: April 19, 2007, 11:36:59 »

Quote
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...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 Embarrassed
Thanks Grin
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!