2 * glClear + glScissor + Undefined content of framebuffer
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
));
19 fprintf(stderr
, "Top right corner should be red\n");
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
)
47 static void Draw(void)
49 glColor4f(1.0, 0.0, 0.0, 1.0);
59 glVertex2d(0.0, -1.0);
60 glVertex2d(1.0, -1.0);
64 glEnable(GL_SCISSOR_TEST
);
65 glClearColor(1, 1, 0, 0);
66 glScissor(Width
/ 2, 0, Width
- Width
/ 2, Height
/ 2);
67 glClear(GL_COLOR_BUFFER_BIT
);
69 glClearColor(0, 0, 1, 0);
70 glScissor(0, Height
/ 2, Width
/ 2, Height
- Height
/ 2);
71 glClear(GL_COLOR_BUFFER_BIT
);
72 glDisable(GL_SCISSOR_TEST
);
74 glColor4f(0.0, 1.0, 0.0, 1.0);
76 glVertex2d( 0.0, 0.0);
77 glVertex2d( 0.0, -1.0);
78 glVertex2d(-1.0, -1.0);
79 glVertex2d(-1.0, 0.0);
89 static GLenum
Args(int argc
, char **argv
)
93 doubleBuffer
= GL_TRUE
;
95 for (i
= 1; i
< argc
; i
++) {
96 if (strcmp(argv
[i
], "-sb") == 0) {
97 doubleBuffer
= GL_FALSE
;
98 } else if (strcmp(argv
[i
], "-db") == 0) {
99 doubleBuffer
= GL_TRUE
;
101 fprintf(stderr
, "%s (Bad option).\n", argv
[i
]);
108 int main(int argc
, char **argv
)
112 glutInit(&argc
, argv
);
114 if (Args(argc
, argv
) == GL_FALSE
) {
118 glutInitWindowPosition(0, 0); glutInitWindowSize( Width
, Height
);
121 type
= GLUT_RGB
| GLUT_ALPHA
;
122 type
|= (doubleBuffer
) ? GLUT_DOUBLE
: GLUT_SINGLE
;
123 glutInitDisplayMode(type
);
125 if (glutCreateWindow(argv
[0]) == GL_FALSE
) {
130 Reshape(Width
, Height
);
132 glutReshapeFunc(Reshape
);
133 glutKeyboardFunc(Key
);
134 glutDisplayFunc(Draw
);