Hello,
I have a framework that is portable between Mac, Windows and Linux, potentially to OpenGL ES platforms as well, based on SDL. I’m interested in making high speed fonts available in full 3d. I have used FTGL, a very cool library that (somewhat inefficiently, with virtual calls letter by letter) would draw letters as either flat polygons, extruded 3d shapes, and other options. I want to build in a set of convenience functions for a higher speed version.
Let’s just consider one case, generating polygons out of freetype fonts, and rendering them as text in 3d space.
If a glyph were just a single polygon, then I could do a simple array draw primitive in OpenGL, and use VBO so that the polygons could be pre-loaded on the card. But glyphs can have a variable number of polygons.
If I upload a buffer of polygons, and a buffer of indices into those polygons, can I pass a string to a GLSL routine, and have it render the appropriate polygons? Excuse my ignorance, but the little shader code I’ve seen looks nothing like that.
in pseudo code, it would look like this:
void drawText(string text) {
for (each letter of string) {
int starti = glyphindex[string[i]];
int endi = glyphindex[string[i]+1];
drawPolygons(glypharray, starti, endi)
glTranslatef(glyphwwidth[string[i]], 0, 0);
}
}
Needless to say, in order to support platforms without GLSL, the object library will do this in ordinary OpenGL as well, slower.