Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / glut / dos / stroke.c
1 /*
2 * FxGLUT version 0.12 - GLUT for Voodoo 1 and 2 under Linux
3 * Copyright (C) 1999 Christopher John Purnell
4 * cjp@lost.org.uk
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include "internal.h"
22
23
24 void
25 glutStrokeCharacter (void *font, int c)
26 {
27 const GLUTStrokeFont *sfp = _glut_font(font);
28 const GLUTStrokeChar *scp;
29 const GLUTStrokeStrip *ssp;
30 const GLUTStrokeVertex *svp;
31 unsigned i, j;
32
33 if (((unsigned)c) >= sfp->num || !(scp = sfp->table[c]))
34 return;
35
36 ssp = scp->strip;
37
38 for (i = 0; i < scp->num; i++, ssp++) {
39 svp = ssp->vertex;
40
41 glBegin(GL_LINE_STRIP);
42 for (j = 0; j < ssp->num; j++, svp++) {
43 glVertex2f(svp->x, svp->y);
44 }
45 glEnd();
46 }
47
48 glTranslatef(scp->right, 0.0, 0.0);
49 }
50
51
52 void
53 glutStrokeString (void *font, const unsigned char *string)
54 {
55 const GLUTStrokeFont *sfp = _glut_font(font);
56 const GLUTStrokeChar *scp;
57 const GLUTStrokeStrip *ssp;
58 const GLUTStrokeVertex *svp;
59 unsigned char c;
60 unsigned i, j;
61
62 while ((c = *(string++))) {
63 if (c < sfp->num && (scp = sfp->table[c])) {
64 ssp = scp->strip;
65
66 for (i = 0; i < scp->num; i++, ssp++) {
67 svp = ssp->vertex;
68
69 glBegin(GL_LINE_STRIP);
70 for (j = 0; j < ssp->num; j++, svp++) {
71 glVertex2f(svp->x, svp->y);
72 }
73 glEnd();
74 }
75
76 glTranslatef(scp->right, 0.0, 0.0);
77 }
78 }
79 }
80
81
82 int
83 glutStrokeWidth (void *font, int c)
84 {
85 const GLUTStrokeFont *sfp = _glut_font(font);
86 const GLUTStrokeChar *scp;
87
88 if (((unsigned)c) >= sfp->num || !(scp = sfp->table[c]))
89 return 0;
90
91 return scp->right;
92 }
93
94
95 int
96 glutStrokeLength (void *font, const unsigned char *string)
97 {
98 const GLUTStrokeFont *sfp = _glut_font(font);
99 const GLUTStrokeChar *scp;
100 unsigned char c;
101 int length = 0;
102
103 while ((c = *(string++))) {
104 if (c < sfp->num && (scp = sfp->table[c]))
105 length += scp->right;
106 }
107
108 return length;
109 }
110
111
112 GLfloat
113 glutStrokeHeight (void *font)
114 {
115 const GLUTStrokeFont *sfp = _glut_font(font);
116
117 return sfp->height;
118 }