From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[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 # ifdef HAVE_CONFIG_H
12 #  include "config.h"
13 # endif
14 # ifndef HAVE_COCOA
15 #  include <GL/gl.h>
16 # endif
17 # ifdef HAVE_JWZGLES
18 #  include "jwzgles.h"
19 # endif /* HAVE_JWZGLES */
20 # undef APIENTRY
21 # define APIENTRY /**/
22 #endif
23
24 #include "glutstroke.h"
25
26 void APIENTRY 
27 glutStrokeCharacter(GLUTstrokeFont font, int c)
28 {
29   const StrokeCharRec *ch;
30   const StrokeRec *stroke;
31   const CoordRec *coord;
32   StrokeFontPtr fontinfo;
33   int i, j;
34
35
36 #if defined(_WIN32)
37   fontinfo = (StrokeFontPtr) __glutFont(font);
38 #else
39   fontinfo = (StrokeFontPtr) font;
40 #endif
41
42   if (c < 0 || c >= fontinfo->num_chars)
43     return;
44   ch = &(fontinfo->ch[c]);
45   if (ch) {
46     for (i = ch->num_strokes, stroke = ch->stroke;
47       i > 0; i--, stroke++) {
48       glBegin(GL_LINE_STRIP);
49       for (j = stroke->num_coords, coord = stroke->coord;
50         j > 0; j--, coord++) {
51         glVertex2f(coord->x, coord->y);
52       }
53       glEnd();
54     }
55     glTranslatef(ch->right, 0.0, 0.0);
56   }
57 }