12 GLint Width
= 200, Height
= 150;
14 static void Init(void)
16 fprintf(stderr
, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
17 fprintf(stderr
, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION
));
18 fprintf(stderr
, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR
));
22 static void Reshape(int width
, int height
)
27 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
29 glMatrixMode(GL_PROJECTION
);
31 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
32 glMatrixMode(GL_MODELVIEW
);
35 static void Key(unsigned char key
, int x
, int y
)
46 static void Draw(void)
48 glEnable(GL_SCISSOR_TEST
);
50 glClearColor(1, 0, 0, 0);
51 glScissor(0, 0, Width
/ 2, Height
/ 2);
52 glClear(GL_COLOR_BUFFER_BIT
);
54 glClearColor(0, 1, 0, 0);
55 glScissor(Width
/ 2, 0, Width
- Width
/ 2, Height
/ 2);
56 glClear(GL_COLOR_BUFFER_BIT
);
58 glClearColor(0, 0, 1, 0);
59 glScissor(0, Height
/ 2, Width
/ 2, Height
- Height
/ 2);
60 glClear(GL_COLOR_BUFFER_BIT
);
62 glClearColor(1, 1, 1, 0);
63 glScissor(Width
/ 2, Height
/ 2, Width
- Width
/ 2, Height
- Height
/ 2);
64 glClear(GL_COLOR_BUFFER_BIT
);
73 static GLenum
Args(int argc
, char **argv
)
77 doubleBuffer
= GL_FALSE
;
79 for (i
= 1; i
< argc
; i
++) {
80 if (strcmp(argv
[i
], "-sb") == 0) {
81 doubleBuffer
= GL_FALSE
;
82 } else if (strcmp(argv
[i
], "-db") == 0) {
83 doubleBuffer
= GL_TRUE
;
85 fprintf(stderr
, "%s (Bad option).\n", argv
[i
]);
92 int main(int argc
, char **argv
)
96 glutInit(&argc
, argv
);
98 if (Args(argc
, argv
) == GL_FALSE
) {
102 glutInitWindowPosition(0, 0); glutInitWindowSize( Width
, Height
);
104 type
= GLUT_RGB
| GLUT_ALPHA
;
105 type
|= (doubleBuffer
) ? GLUT_DOUBLE
: GLUT_SINGLE
;
106 glutInitDisplayMode(type
);
108 if (glutCreateWindow(argv
[0]) == GL_FALSE
) {
114 glutReshapeFunc(Reshape
);
115 glutKeyboardFunc(Key
);
116 glutDisplayFunc(Draw
);