About GL text drawing on the Mac OS X platform

GL text drawing has been recently implemented in 3 steps on Mac OS:
1) draw text to a bitmap using standard OS text drawing routines
2) convert this bitmap into a GL texture
3) map this texture to the GL scene
Benefits:
- the only 64-bit compatible solution (the previous implementation
was not compilable in 64-bit)
- any utf8 text in any font can be drawn
Drawback:
- significantly slower than before

After experiencing with Christophe Geuzaine huge OpenGL app, we
have learnt about the slowlyness mentionned above and a solution
for that: pre-compute textures once and re-use them as often
as needed.

I have thus committed a new algorithm for Mac GL text drawing:
1) Allocate a pile of pre-computed textures of default size 100.
2) To draw a text string do
   - if the corresponding texture is in the pile, map it to the GL scene
   - if not, pre-compute the corresponding texture and map it
      + if the pile is not full, put the texture in the pile
      + if not, remove the most ancient pile element, and put
        the new texture in the pile.

Christophe's app with a pile as high as 5000 becomes "very correct"
with this change.

Because the pile height has no obvious universal adequate value,
I have added 2 mac-specific functions:
void gl_texture_pile_height(int max);
int gl_texture_pile_height();
to set and get the texture pile height.

Please, let me know if you see problems with these (committed) changes.

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to