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