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
));
21 static void Reshape(int width
, int height
)
26 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
28 glMatrixMode(GL_PROJECTION
);
30 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
31 glMatrixMode(GL_MODELVIEW
);
34 static void Key(unsigned char key
, int x
, int y
)
45 static void Draw(void)
47 glEnable(GL_SCISSOR_TEST
);
49 glClearColor(1, 0, 0, 0);
50 glScissor(0, 0, Width
/ 2, Height
/ 2);
51 glClear(GL_COLOR_BUFFER_BIT
);
53 glClearColor(0, 1, 0, 0);
54 glScissor(Width
/ 2, 0, Width
- Width
/ 2, Height
/ 2);
55 glClear(GL_COLOR_BUFFER_BIT
);
57 glClearColor(0, 0, 1, 0);
58 glScissor(0, Height
/ 2, Width
/ 2, Height
- Height
/ 2);
59 glClear(GL_COLOR_BUFFER_BIT
);
61 glClearColor(1, 1, 1, 0);
62 glScissor(Width
/ 2, Height
/ 2, Width
- Width
/ 2, Height
- Height
/ 2);
63 glClear(GL_COLOR_BUFFER_BIT
);
72 static GLenum
Args(int argc
, char **argv
)
76 doubleBuffer
= GL_FALSE
;
78 for (i
= 1; i
< argc
; i
++) {
79 if (strcmp(argv
[i
], "-sb") == 0) {
80 doubleBuffer
= GL_FALSE
;
81 } else if (strcmp(argv
[i
], "-db") == 0) {
82 doubleBuffer
= GL_TRUE
;
84 fprintf(stderr
, "%s (Bad option).\n", argv
[i
]);
91 int main(int argc
, char **argv
)
95 glutInit(&argc
, argv
);
97 if (Args(argc
, argv
) == GL_FALSE
) {
101 glutInitWindowPosition(0, 0); glutInitWindowSize( Width
, Height
);
103 type
= GLUT_RGB
| GLUT_ALPHA
;
104 type
|= (doubleBuffer
) ? GLUT_DOUBLE
: GLUT_SINGLE
;
105 glutInitDisplayMode(type
);
107 if (glutCreateWindow(argv
[0]) == GL_FALSE
) {
113 glutReshapeFunc(Reshape
);
114 glutKeyboardFunc(Key
);
115 glutDisplayFunc(Draw
);