2
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
4
* Permission to use, copy, modify, distribute, and sell this software and
5
* its documentation for any purpose is hereby granted without fee, provided
6
* that (i) the above copyright notices and this permission notice appear in
7
* all copies of the software and related documentation, and (ii) the name of
8
* Silicon Graphics may not be used in any advertising or
9
* publicity relating to the software without the specific, prior written
10
* permission of Silicon Graphics.
12
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
14
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
18
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31
#define OPENGL_WIDTH 24
32
#define OPENGL_HEIGHT 13
35
char string[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz";
36
GLenum rgb, doubleBuffer, windType;
37
float angleX = 0.0, angleY = 0.0, angleZ = 0.0;
38
float scaleX = 1.0, scaleY = 1.0, scaleZ = 1.0;
39
float shiftX = 0.0, shiftY = 0.0, shiftZ = 0.0;
45
static void DrawBitmapString(void *font, const char *string)
49
for (i = 0; string[i]; i++)
50
glutBitmapCharacter(font, string[i]);
53
static void DrawStrokeString(void *font, const char *string)
57
for (i = 0; string[i]; i++)
58
glutStrokeCharacter(font, string[i]);
61
static void Init(void)
64
glClearColor(0.0, 0.0, 0.0, 0.0);
68
static void Reshape(int width, int height)
71
glViewport(0, 0, (GLint)width, (GLint)height);
73
glMatrixMode(GL_PROJECTION);
75
glOrtho(-400.0, 400.0, -200.0, 200.0, -400.0, 400.0);
76
glMatrixMode(GL_MODELVIEW);
79
static void Key2(int key, int x, int y)
102
static void Key(unsigned char key, int x, int y)
147
angleX = 360.0 + angleX;
152
if (angleX > 360.0) {
153
angleX = angleX - 360.0;
159
angleY = 360.0 + angleY;
164
if (angleY > 360.0) {
165
angleY = angleY - 360.0;
171
angleZ = 360.0 + angleZ;
176
if (angleZ > 360.0) {
177
angleZ = angleZ - 360.0;
187
static void Draw(void)
190
glClear(GL_COLOR_BUFFER_BIT);
192
SetColor(COLOR_WHITE);
196
glTranslatef(shiftX, shiftY, shiftZ);
197
glRotatef(angleX, 1.0, 0.0, 0.0);
198
glRotatef(angleY, 0.0, 1.0, 0.0);
199
glRotatef(angleZ, 0.0, 0.0, 1.0);
200
glScalef(scaleX, scaleY, scaleZ);
203
glRasterPos2f(-390.5, 0.5);
204
DrawBitmapString(GLUT_BITMAP_9_BY_15, string);
208
glTranslatef(-390.5, -30.5, 0.0);
209
DrawStrokeString(GLUT_STROKE_ROMAN, string);
221
static GLenum Args(int argc, char **argv)
226
doubleBuffer = GL_FALSE;
228
for (i = 1; i < argc; i++) {
229
if (strcmp(argv[i], "-ci") == 0) {
231
} else if (strcmp(argv[i], "-rgb") == 0) {
233
} else if (strcmp(argv[i], "-sb") == 0) {
234
doubleBuffer = GL_FALSE;
235
} else if (strcmp(argv[i], "-db") == 0) {
236
doubleBuffer = GL_TRUE;
238
printf("%s (Bad option).\n", argv[i]);
245
int main(int argc, char **argv)
247
glutInit(&argc, argv);
249
if (Args(argc, argv) == GL_FALSE) {
253
glutInitWindowPosition(0, 0); glutInitWindowSize( 800, 400);
255
windType = (rgb) ? GLUT_RGB : GLUT_INDEX;
256
windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
257
glutInitDisplayMode(windType);
259
if (glutCreateWindow("Font Test") == GL_FALSE) {
267
glutReshapeFunc(Reshape);
268
glutKeyboardFunc(Key);
269
glutSpecialFunc(Key2);
270
glutDisplayFunc(Draw);