2
/* Copyright (c) Mark J. Kilgard, 1994. */
5
* (c) Copyright 1993, Silicon Graphics, Inc.
7
* Permission to use, copy, modify, and distribute this software for
8
* any purpose and without fee is hereby granted, provided that the above
9
* copyright notice appear in all copies and that both the copyright notice
10
* and this permission notice appear in supporting documentation, and that
11
* the name of Silicon Graphics, Inc. not be used in advertising
12
* or publicity pertaining to distribution of the software without specific,
13
* written prior permission.
15
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
16
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
17
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
18
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
20
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
21
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
22
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
23
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
24
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
25
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
26
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
28
* US Government Users Restricted Rights
29
* Use, duplication, or disclosure by the Government is subject to
30
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
31
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
32
* clause at DFARS 252.227-7013 and/or in similar or successor
33
* clauses in the FAR or the DOD or NASA FAR Supplement.
34
* Unpublished-- rights reserved under the copyright laws of the
35
* United States. Contractor/manufacturer is Silicon Graphics,
36
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
38
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
42
* This program demonstrates some characters of a
43
* stroke (vector) font. The characters are represented
44
* by display lists, which are given numbers which
45
* correspond to the ASCII values of the characters.
46
* Use of glCallLists() is demonstrated.
56
typedef struct charpoint {
62
{ 0, 0, PT}, {0, 9, PT}, {1, 10, PT}, {4, 10, PT},
63
{5, 9, PT}, {5, 0, STROKE}, {0, 5, PT}, {5, 5, END}
67
{5, 0, PT}, {0, 0, PT}, {0, 10, PT}, {5, 10, STROKE},
68
{0, 5, PT}, {4, 5, END}
72
{0, 0, PT}, {0, 10, PT}, {4, 10, PT}, {5, 9, PT}, {5, 6, PT},
73
{4, 5, PT}, {0, 5, END}
77
{0, 0, PT}, {0, 10, PT}, {4, 10, PT}, {5, 9, PT}, {5, 6, PT},
78
{4, 5, PT}, {0, 5, STROKE}, {3, 5, PT}, {5, 0, END}
82
{0, 1, PT}, {1, 0, PT}, {4, 0, PT}, {5, 1, PT}, {5, 4, PT},
83
{4, 5, PT}, {1, 5, PT}, {0, 6, PT}, {0, 9, PT}, {1, 10, PT},
84
{4, 10, PT}, {5, 9, END}
87
/* drawLetter() interprets the instructions from the array
88
* for that letter and renders the letter with line segments.
90
static void drawLetter(CP *l)
92
glBegin(GL_LINE_STRIP);
101
glBegin(GL_LINE_STRIP);
106
glTranslatef(8.0, 0.0, 0.0);
113
/* Create a display list for each of 6 characters */
114
static void myinit (void)
118
glShadeModel (GL_FLAT);
120
base = glGenLists (128);
122
glNewList(base+'A', GL_COMPILE); drawLetter(Adata); glEndList();
123
glNewList(base+'E', GL_COMPILE); drawLetter(Edata); glEndList();
124
glNewList(base+'P', GL_COMPILE); drawLetter(Pdata); glEndList();
125
glNewList(base+'R', GL_COMPILE); drawLetter(Rdata); glEndList();
126
glNewList(base+'S', GL_COMPILE); drawLetter(Sdata); glEndList();
127
glNewList(base+' ', GL_COMPILE); glTranslatef(8.0, 0.0, 0.0); glEndList();
130
char *test1 = "A SPARE SERAPE APPEARS AS";
131
char *test2 = "APES PREPARE RARE PEPPERS";
133
static void printStrokedString(char *s)
135
GLsizei len = (GLsizei) strlen(s);
136
glCallLists(len, GL_BYTE, (GLbyte *)s);
139
static void display(void)
141
glClear(GL_COLOR_BUFFER_BIT);
142
glColor3f(1.0, 1.0, 1.0);
144
glScalef(2.0, 2.0, 2.0);
145
glTranslatef(10.0, 30.0, 0.0);
146
printStrokedString(test1);
149
glScalef(2.0, 2.0, 2.0);
150
glTranslatef(10.0, 13.0, 0.0);
151
printStrokedString(test2);
156
static void reshape(GLsizei w, GLsizei h)
158
glViewport(0, 0, w, h);
159
glMatrixMode(GL_PROJECTION);
161
glOrtho(0.0, (GLdouble)w, 0.0, (GLdouble)h, -1.0, 1.0);
162
glMatrixMode(GL_MODELVIEW);
167
key(unsigned char k, int x, int y)
170
case 27: /* Escape */
180
* Open window with initial window size, title bar,
181
* RGBA display mode, and handle input events.
183
int main(int argc, char** argv)
185
glutInit(&argc, argv);
186
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
187
glutInitWindowSize (440, 120);
188
glutCreateWindow (argv[0]);
190
glutDisplayFunc(display);
191
glutReshapeFunc(reshape);
192
glutKeyboardFunc(key);
194
return 0; /* ANSI C requires main to return int. */