9cd46e0e69ea8f0606769e5a7f753b7e6475b8cf
[xscreensaver] / hacks / glx / glut_stroke.c
1
2 /* Copyright (c) Mark J. Kilgard, 1994. */
3
4 /* This program is freely distributable without licensing fees
5    and is provided without guarantee or warrantee expressed or
6    implied. This program is -not- in the public domain. */
7
8 #if 0   /* for Mesa */
9 # include "glutint.h"
10 #else   /* for xscreensaver */
11 # include "config.h"
12 # include <GL/gl.h>
13 # define APIENTRY /**/
14 #endif
15
16 #include "glutstroke.h"
17
18 void APIENTRY 
19 glutStrokeCharacter(GLUTstrokeFont font, int c)
20 {
21   const StrokeCharRec *ch;
22   const StrokeRec *stroke;
23   const CoordRec *coord;
24   StrokeFontPtr fontinfo;
25   int i, j;
26
27
28 #if defined(_WIN32)
29   fontinfo = (StrokeFontPtr) __glutFont(font);
30 #else
31   fontinfo = (StrokeFontPtr) font;
32 #endif
33
34   if (c < 0 || c >= fontinfo->num_chars)
35     return;
36   ch = &(fontinfo->ch[c]);
37   if (ch) {
38     for (i = ch->num_strokes, stroke = ch->stroke;
39       i > 0; i--, stroke++) {
40       glBegin(GL_LINE_STRIP);
41       for (j = stroke->num_coords, coord = stroke->coord;
42         j > 0; j--, coord++) {
43         glVertex2f(coord->x, coord->y);
44       }
45       glEnd();
46     }
47     glTranslatef(ch->right, 0.0, 0.0);
48   }
49 }