test19.c
上传用户:xk288cn
上传日期:2007-05-28
资源大小:4876k
文件大小:1k
- /* Copyright (c) Mark J. Kilgard, 1994. */
- /* This program is freely distributable without licensing fees
- and is provided without guarantee or warrantee expressed or
- implied. This program is -not- in the public domain. */
- /* This test makes sure damaged gets set when a window is
- resized smaller. */
- #include <stdlib.h>
- #include <stdio.h>
- #include <GL/glut.h>
- int width = -1, height = -1;
- int displayCount = 0;
- /* ARGSUSED */
- void
- done(int value)
- {
- if (displayCount != 2) {
- fprintf(stderr, "FAIL: test19, damage expectedn");
- exit(1);
- }
- fprintf(stderr, "PASS: test19n");
- exit(0);
- }
- void
- reshape(int w, int h)
- {
- printf("window reshaped: w=%d, h=%dn", w, h);
- width = w;
- height = h;
- }
- void
- display(void)
- {
- if (glutLayerGet(GLUT_NORMAL_DAMAGED) == 0) {
- fprintf(stderr, "FAIL: test19, damage expectedn");
- exit(1);
- }
- displayCount++;
- if (width == -1 || height == -1) {
- fprintf(stderr, "FAIL: test19, reshape not calledn");
- exit(1);
- }
- glClear(GL_COLOR_BUFFER_BIT);
- glFlush();
- if (displayCount == 1) {
- glutReshapeWindow(width / 2, height / 2);
- glutTimerFunc(1000, done, 0);
- }
- }
- int
- main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutCreateWindow("test19");
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- glutMainLoop();
- return 0; /* ANSI C requires main to return int. */
- }