Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualNercury

Posted 20 February 2013 - 06:34 AM

My approach is to lazy-render each separate glyph into opengl texture and update it if more glyphs are needed. Store information about every glyph and it's position on the texture. Rendering is amazingly fast, it is just mapping the right texture coordinates for each glyph. And it opens very nice possibilities for text effects.

 

Implementation consists of:

- Glyph object, which has glyph measurements and it's cached position of surface, as well as reference to opengl texture.

- A Factory object used to get glyph or return existing one based on char code. It manages unlimited surfaces for a specificly - sized font.

- A Surface to keep rendered glyphs on. I am always keeping SDL surface in memory, and refreshing opengl surface only on change or if opengl context is lost (resize).

 

Then I can have various text objects to render these glyphs in various interesting ways.

Color: I pre-render glyphs as white and use blending for color, as you said.

 

This is a crappy version of this approach written quite a long time ago: http://code.google.com/p/glstext/

Since I have rewrote all of it last week, I may share the code if anyone is interested. I even managed to get the kerning working, which is oh-so-amazing smile.png


#1Nercury

Posted 20 February 2013 - 05:58 AM

My approach is to lazy-render each separate glyph into opengl texture and update it if more glyphs are needed. Store information about every glyph and it's position on the texture. Rendering is amazingly fast, it is just mapping the right texture coordinates for each glyph. And it opens very nice possibilities for text effects.

 

Implementation consists of:

- Glyph object, which has glyph measurements and it's cached position of surface, as well as reference to opengl texture.

- A Factory object used to get glyph or return existing one based on char code. It manages unlimited surfaces for a specificly - sized font.

- A Surface to keep rendered glyphs on. I am always keeping SDL surface in memory, and refreshing opengl surface only on change or if opengl context is lost (resize).

 

Then I can have various text objects to render these glyphs in various interesting ways.

 

This is a crappy version of this approach written quite a long time ago: http://code.google.com/p/glstext/

Since I have rewrote all of it last week, I may share the code if anyone is interested. I even managed to get the kerning working, which is oh-so-amazing :)


PARTNERS