/*usr/bin/env cat >/tmp/r.c < #include #define GL_GLEXT_PROTOTYPES #include #define T(c) ({fprintf(stderr, "before %s\n", #c); c; fprintf(stderr, "after %s\n", #c);}) int main(int argc, char *argv[]) { int i, n, width = 1024, height = 512; Display *dpy = XOpenDisplay(NULL); int ncfg, attrs[] = {GLX_DOUBLEBUFFER, GL_TRUE, None}; GLXFBConfig *dconfigs = glXChooseFBConfig(dpy, 0, attrs, &ncfg); GLXContext ctx = glXCreateNewContext(dpy, dconfigs[0], GLX_RGBA_TYPE, NULL, True); Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, width, height, 0, 0, 0); XMapWindow(dpy, w); glXMakeCurrent(dpy, w, ctx); GLuint pbo; glGenBuffers(1, &pbo); glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, pbo); int size = width*height*4; T(glBufferData(GL_PIXEL_UNPACK_BUFFER_EXT, size, NULL, GL_STREAM_DRAW)); int *pixeldata = malloc(size); for (i = 0; i < size / 4; i++) pixeldata[i] = i | (i << 8); n = argc == 2 ? atoi(argv[1]) : 0; for (i = 0; i < n; i++) { T(glBufferSubData(GL_PIXEL_UNPACK_BUFFER_EXT, 0, size - i * 4, pixeldata + i)); T(glDrawPixels(width, height, GL_BGRA, GL_UNSIGNED_BYTE, NULL)); T(glXSwapBuffers(dpy, w)); } return 0; } #define ZZZ ZZZ