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 CI_RED COLOR_RED
32 #define CI_ANTI_ALIAS_GREEN 16
33 #define CI_ANTI_ALIAS_YELLOW 32
34 #define CI_ANTI_ALIAS_RED 48
37 GLenum rgb
, doubleBuffer
, windType
;
49 static void Init(void)
53 glClearColor(0.0, 0.0, 0.0, 0.0);
55 glBlendFunc(GL_SRC_ALPHA
, GL_ZERO
);
58 for (i
= 0; i
< 16; i
++) {
59 glutSetColor(i
+CI_ANTI_ALIAS_RED
, i
/15.0, 0.0, 0.0);
60 glutSetColor(i
+CI_ANTI_ALIAS_YELLOW
, i
/15.0, i
/15.0, 0.0);
61 glutSetColor(i
+CI_ANTI_ALIAS_GREEN
, 0.0, i
/15.0, 0.0);
69 static void Reshape(int width
, int height
)
73 windH
= (GLint
)height
;
75 glViewport(0, 0, width
, height
);
77 glMatrixMode(GL_PROJECTION
);
79 gluOrtho2D(-windW
/2, windW
/2, -windH
/2, windH
/2);
80 glMatrixMode(GL_MODELVIEW
);
83 static void Key2(int key
, int x
, int y
)
106 static void Key(unsigned char key
, int x
, int y
)
131 static void Draw(void)
134 glClear(GL_COLOR_BUFFER_BIT
);
136 SetColor(COLOR_YELLOW
);
137 glBegin(GL_LINE_STRIP
);
138 glVertex2f(-windW
/2, 0);
139 glVertex2f(windW
/2, 0);
141 glBegin(GL_LINE_STRIP
);
142 glVertex2f(0, -windH
/2);
143 glVertex2f(0, windH
/2);
148 glEnable(GL_POINT_SMOOTH
);
151 glDisable(GL_POINT_SMOOTH
);
156 (rgb
) ? glColor3f(1.0, 0.0, 0.0) : glIndexf(CI_ANTI_ALIAS_RED
);
158 (rgb
) ? glColor3f(1.0, 0.0, 0.0) : glIndexf(CI_RED
);
164 glDisable(GL_POINT_SMOOTH
);
168 SetColor(COLOR_GREEN
);
180 static GLenum
Args(int argc
, char **argv
)
185 doubleBuffer
= GL_FALSE
;
187 for (i
= 1; i
< argc
; i
++) {
188 if (strcmp(argv
[i
], "-ci") == 0) {
190 } else if (strcmp(argv
[i
], "-rgb") == 0) {
192 } else if (strcmp(argv
[i
], "-sb") == 0) {
193 doubleBuffer
= GL_FALSE
;
194 } else if (strcmp(argv
[i
], "-db") == 0) {
195 doubleBuffer
= GL_TRUE
;
197 printf("%s (Bad option).\n", argv
[i
]);
204 int main(int argc
, char **argv
)
206 glutInit(&argc
, argv
);
208 if (Args(argc
, argv
) == GL_FALSE
) {
214 glutInitWindowPosition(0, 0); glutInitWindowSize( windW
, windH
);
216 windType
= (rgb
) ? GLUT_RGB
: GLUT_INDEX
;
217 windType
|= (doubleBuffer
) ? GLUT_DOUBLE
: GLUT_SINGLE
;
218 glutInitDisplayMode(windType
);
220 if (glutCreateWindow("Point Test") == GL_FALSE
) {
228 glutReshapeFunc(Reshape
);
229 glutKeyboardFunc(Key
);
230 glutSpecialFunc(Key2
);
231 glutDisplayFunc(Draw
);