Adding FreeType2 support to PatchBox
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:
Having extracted the glyph outline using FreeType2, let?s draw it with GL_LINES? ah?
GL_LINE_STRIP isn?t correct either?
Ah, good old GL_LINE_LOOP?
Initially, adding conic and cubic curves didn?t go quite as planned?
![]()
Better, but FreeType2 uses long?s to position data, resulting in the rather wobbly lines.
Converting to double?s does the trick nicely?
![]()
Now, lets? fill the outlines using gluTesselate() ? oh, FreeType2 uses NONZERO winding by default, whereas GLU uses ODD?
That?s looking better, but there?s still a problem?
![]()
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.
![]()
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!