博客转自:http://www.lighthouse3d.com/tutorials/glut-tutorial/stroke-fonts/
笔画是一种利用直线绘制的字体,对比位图字体,笔画字体更像3维物体。例如字体可以旋转、缩放和平移。这个小节内,我们将呈现GLUT 将笔画字体显示在屏幕上的函数。基本上只需要一个函数 glutStrokeCharacter。
void glutStrokeCharacter(void *font, int character) Parameters: font – the name of the font to use (see bellow for a list of what’s available character – what to render, a letter, symbol, number, etc…
The font options available are:
- GLUT_STROKE_ROMAN
- GLUT_STROKE_MONO_ROMAN (fixed width font: 104.76 units wide).
The following line of text exemplifies a call to the glutStrokeCharacter function to output a single character at the current local coordinates:
glutStrokeCharacter(GLUT_STROKE_ROMAN,'3');
As opposed to bitmap fonts, the render location for stroke fonts is specified in the same way as for any graphical primitive, i.e. using translations, rotations and scales.The following function renders a string starting at the specified position in local world coordinates:
void renderStrokeFontString( float x, float y, float z, void *font, char *string) { char *c; glPushMatrix(); glTranslatef(x, y,z); for (c=string; *c != '