This tests the faker's ability to handle the 2000 Flushes issue
| 1075 | |
| 1076 | // This tests the faker's ability to handle the 2000 Flushes issue |
| 1077 | int flushTest(void) |
| 1078 | { |
| 1079 | TestColor clr(0); |
| 1080 | Display *dpy = NULL; Window win = 0; |
| 1081 | int dpyw, dpyh, lastFrame = 0, retval = 1; |
| 1082 | int glxattribs[] = { GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE, 8, |
| 1083 | GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, None }; |
| 1084 | XVisualInfo *vis = NULL; |
| 1085 | GLXContext ctx = 0; |
| 1086 | XSetWindowAttributes swa; |
| 1087 | |
| 1088 | putenv((char *)"VGL_SPOIL=1"); |
| 1089 | printf("10000 flushes test:\n"); |
| 1090 | |
| 1091 | try |
| 1092 | { |
| 1093 | if(!(dpy = XOpenDisplay(0))) THROW("Could not open display"); |
| 1094 | dpyw = DisplayWidth(dpy, DefaultScreen(dpy)); |
| 1095 | dpyh = DisplayHeight(dpy, DefaultScreen(dpy)); |
| 1096 | |
| 1097 | if((vis = glXChooseVisual(dpy, DefaultScreen(dpy), glxattribs)) == NULL) |
| 1098 | THROW("Could not find a suitable visual"); |
| 1099 | |
| 1100 | Window root = RootWindow(dpy, DefaultScreen(dpy)); |
| 1101 | swa.colormap = XCreateColormap(dpy, root, vis->visual, AllocNone); |
| 1102 | swa.border_pixel = 0; |
| 1103 | swa.event_mask = 0; |
| 1104 | if((win = XCreateWindow(dpy, root, 0, 0, dpyw / 2, dpyh / 2, 0, vis->depth, |
| 1105 | InputOutput, vis->visual, CWBorderPixel | CWColormap | CWEventMask, |
| 1106 | &swa)) == 0) |
| 1107 | THROW("Could not create window"); |
| 1108 | |
| 1109 | if((ctx = glXCreateContext(dpy, vis, 0, True)) == NULL) |
| 1110 | THROW("Could not establish GLX context"); |
| 1111 | XFree(vis); vis = NULL; |
| 1112 | if(!glXMakeCurrent(dpy, win, ctx)) |
| 1113 | THROW("Could not make context current"); |
| 1114 | checkCurrent(dpy, win, win, ctx, dpyw / 2, dpyh / 2); |
| 1115 | if(!doubleBufferTest()) |
| 1116 | THROW("This test requires double buffering, which appears to be broken."); |
| 1117 | glReadBuffer(GL_FRONT); |
| 1118 | XMapWindow(dpy, win); |
| 1119 | |
| 1120 | clr.clear(GL_BACK); |
| 1121 | clr.clear(GL_FRONT); |
| 1122 | for(int i = 0; i < 10000; i++) |
| 1123 | { |
| 1124 | printf("%.4d\b\b\b\b", i); glFlush(); |
| 1125 | } |
| 1126 | checkFrame(dpy, win, -1, lastFrame); |
| 1127 | printf("Read back %d of 10000 frames\n", lastFrame); |
| 1128 | checkBufferState(GL_FRONT, GL_FRONT, dpy, win, win, ctx); |
| 1129 | checkWindowColor(dpy, win, clr.bits(-1), 0); |
| 1130 | printf("SUCCESS\n"); |
| 1131 | } |
| 1132 | catch(std::exception &e) |
| 1133 | { |
| 1134 | printf("Failed! (%s)\n", e.what()); retval = 0; |
no test coverage detected