notes from the bigfug

programming light and other strange tales

Skip to: Content | Sidebar | Footer

Adding FreeType2 support to PatchBox

5 June, 2009 (16:50) | PatchBox, Programming | By: Alex May

It?s well overdue, but am finally getting around to adding font support to PatchBox.  Rather than using bitmap based fonts, I thought it would be fun to use the font outlines and create proper 3D models.  Here?s how it went:

2009-06-05 - 0002 

Having extracted the glyph outline using FreeType2, let?s draw it with GL_LINES? ah?

2009-06-05 - 0006

GL_LINE_STRIP isn?t correct either?

2009-06-05 - 0007

Ah, good old GL_LINE_LOOP?

2009-06-05 - 0005 

Initially, adding conic and cubic curves didn?t go quite as planned?

2009-06-05 - 0008

Better, but FreeType2 uses long?s to position data, resulting in the rather wobbly lines.

2009-06-05 - 0009

Converting to double?s does the trick nicely?

2009-06-05 - 0010

Now, lets? fill the outlines using gluTesselate() ? oh, FreeType2 uses NONZERO winding by default, whereas GLU uses ODD?

2009-06-05 - 0013

That?s looking better, but there?s still a problem?

2009-06-05 - 0014

Some characters are being drawn weirdly!  Turns out to be a problem with my GLU_TESS_COMBINE_DATA routine.  I?m using a custom vertex format, which I thought was what you returned from your combine callback, but no, you have to return an allocated GLdouble[ 3 ] and remember it so it can be freed later.

2009-06-05 - 0015

The finished result!  All nice and smooth and stored away in vertex array ready for dumping to a VBO?

Next up will be creating a whole string, then multiple lines, then adding depth, colours, textures, etc!

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Slashdot
  • Technorati
  • Twitter

Write a comment





Page optimized by WP Minify WordPress Plugin