test23.c
上传用户:xk288cn
上传日期:2007-05-28
资源大小:4876k
文件大小:4k
- /* Copyright (c) Mark J. Kilgard, 1997. */
- /* 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 tests unexpected interactions between
- glutInitDisplayMode and glutInitDisplayString. */
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <GL/glut.h>
- int modes[] =
- {
- GLUT_RGB | GLUT_SINGLE,
- GLUT_RGB | GLUT_DOUBLE,
- GLUT_INDEX | GLUT_SINGLE,
- GLUT_INDEX | GLUT_DOUBLE
- };
- #define NUM_MODES (sizeof(modes)/sizeof(modes[0]))
- char *strings[] =
- {
- "rgb double",
- "rgba double",
- "rgba single",
- "index",
- "index double",
- "rgb samples=4",
- "stencil depth red green blue alpha conformant auxbufs buffer acc acca double rgb rgba",
- "stereo index samples slow",
- NULL
- };
- char *ostrings[] =
- {
- "index double",
- "index single",
- "index buffer=4",
- "index buffer=8",
- "index buffer~4",
- "index buffer=4 depth",
- NULL
- };
- int verbose;
- int
- main(int argc, char **argv)
- {
- int k, i, j, win;
- int num, exists;
- char mode[200];
- glutInit(&argc, argv);
- if (argc > 1) {
- if (!strcmp(argv[1], "-v")) {
- verbose = 1;
- }
- }
- glutInitWindowPosition(10, 10);
- glutInitWindowSize(200, 200);
- for (k = 0; k < NUM_MODES; k++) {
- glutInitDisplayMode(modes[k]);
- printf("Display Mode = %d (%s,%s)n", modes[k],
- modes[k] & GLUT_INDEX ? "index" : "rgba",
- modes[k] & GLUT_DOUBLE ? "double" : "single");
- for (i = 0; strings[i]; i++) {
- glutInitDisplayString(strings[i]);
- if (glutGet(GLUT_DISPLAY_MODE_POSSIBLE)) {
- if (verbose)
- printf(" Possible: %sn", strings[i]);
- win = glutCreateWindow("test23");
- if (verbose)
- printf(" Created: %sn", strings[i]);
- for (j = 0; ostrings[j]; j++) {
- glutInitDisplayString(ostrings[j]);
- if (glutLayerGet(GLUT_OVERLAY_POSSIBLE)) {
- if (verbose)
- printf(" Overlay possible: %sn", ostrings[j]);
- glutEstablishOverlay();
- if (verbose)
- printf(" Overlay establish: %sn", ostrings[j]);
- glutRemoveOverlay();
- if (verbose)
- printf(" Overlay remove: %sn", ostrings[j]);
- }
- }
- glutDestroyWindow(win);
- if (verbose)
- printf(" Destroyed: %sn", strings[i]);
- } else {
- if (verbose)
- printf("Not possible: %sn", strings[i]);
- }
- }
- }
- glutInitDisplayString(NULL);
- num = 1;
- do {
- sprintf(mode, "rgb num=%d", num);
- glutInitDisplayString(mode);
- exists = glutGet(GLUT_DISPLAY_MODE_POSSIBLE);
- if (exists) {
- if (verbose)
- printf(" Possible: %sn", mode);
- win = glutCreateWindow("test23");
- if (verbose)
- printf(" Created: %sn", mode);
- glutDestroyWindow(win);
- if (verbose)
- printf(" Destroyed: %sn", mode);
- sprintf(mode, "rgb num=0x%x", num);
- glutInitDisplayString(mode);
- exists = glutGet(GLUT_DISPLAY_MODE_POSSIBLE);
- if (!exists) {
- printf("FAIL: test23 (hex num= don't work)n");
- exit(1);
- }
- win = glutCreateWindow("test23");
- glutDestroyWindow(win);
- num++;
- } else {
- if (verbose)
- printf("Not possible: %sn", mode);
- }
- } while (exists);
- glutInitDisplayString(NULL);
- printf("PASS: test23n");
- return 0; /* ANSI C requires main to return int. */
- }