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
34 static void Init(void)
37 glClearColor(0.0, 0.0, 0.0, 0.0);
38 glClearAccum(0.0, 0.0, 0.0, 0.0);
40 thing1
= glGenLists(1);
41 glNewList(thing1
, GL_COMPILE
);
42 glColor3f(1.0, 0.0, 0.0);
43 glRectf(-1.0, -1.0, 1.0, 0.0);
46 thing2
= glGenLists(1);
47 glNewList(thing2
, GL_COMPILE
);
48 glColor3f(0.0, 1.0, 0.0);
49 glRectf(0.0, -1.0, 1.0, 1.0);
53 static void Reshape(int width
, int height
)
56 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
58 glMatrixMode(GL_PROJECTION
);
60 glMatrixMode(GL_MODELVIEW
);
64 static void Key(unsigned char key
, int x
, int y
)
72 glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
75 glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
84 static void Draw(void)
89 glScalef(0.8, 0.8, 1.0);
91 glClear(GL_COLOR_BUFFER_BIT
);
93 glAccum(GL_LOAD
, 0.5);
95 glClear(GL_COLOR_BUFFER_BIT
);
97 glAccum(GL_ACCUM
, 0.5);
99 glAccum(GL_RETURN
, 1.0);
110 static GLenum
Args(int argc
, char **argv
)
114 doubleBuffer
= GL_FALSE
;
116 for (i
= 1; i
< argc
; i
++) {
117 if (strcmp(argv
[i
], "-sb") == 0) {
118 doubleBuffer
= GL_FALSE
;
119 } else if (strcmp(argv
[i
], "-db") == 0) {
120 doubleBuffer
= GL_TRUE
;
122 printf("%s (Bad option).\n", argv
[i
]);
129 int main(int argc
, char **argv
)
133 glutInit(&argc
, argv
);
135 if (Args(argc
, argv
) == GL_FALSE
) {
139 glutInitWindowPosition(0, 0);
140 glutInitWindowSize( 300, 300);
142 type
= GLUT_RGB
| GLUT_ACCUM
;
143 type
|= (doubleBuffer
) ? GLUT_DOUBLE
: GLUT_SINGLE
;
144 glutInitDisplayMode(type
);
146 if (glutCreateWindow("Accum Test") == GL_FALSE
) {
152 glutReshapeFunc(Reshape
);
153 glutKeyboardFunc(Key
);
154 glutDisplayFunc(Draw
);