2 * Use something like this:
4 * gcc -shared -fPIC -o glcapture.so glcapture.c -ldl
5 * LD_PRELOAD=`pwd`/glcapture.so ./demo
6 * mencoder -noskip -endpos 76.920 -ovc x264 -x264encopts bitrate=3000:pass=1 -audiofile data/Juledemo.ogg -o tufs.avi mf://\*.tga -mf fps=50 -oac mp3lame -lameopts cbr:br=128
7 * mencoder -noskip -endpos 76.920 -ovc x264 -x264encopts bitrate=3000:pass=2 -audiofile data/Juledemo.ogg -o tufs.avi mf://\*.tga -mf fps=50 -oac mp3lame -lameopts cbr:br=128
17 #define RTLD_NEXT ((void *) -1l)
23 static char buf[WIDTH * HEIGHT * 3];
24 static int frameno = 0;
26 void glXSwapBuffers( Display *dpy, GLXDrawable drawable )
28 void (*real_swap)(Display*, GLXDrawable);
29 real_swap = (void(*)(Display*, GLXDrawable))dlsym(RTLD_NEXT, "glXSwapBuffers");
33 glReadPixels(0, 0, WIDTH, HEIGHT, GL_BGR, GL_UNSIGNED_BYTE, buf);
35 sprintf(filename, "frame%05u.tga", frameno++);
36 ppm = fopen(filename, "w");
37 fwrite("\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00", 12, 1, ppm);
39 unsigned short w = WIDTH;
40 fwrite(&w, 2, 1, ppm);
43 unsigned short h = HEIGHT;
44 fwrite(&h, 2, 1, ppm);
46 fwrite("\x18\x00", 2, 1, ppm);
47 fwrite(buf, WIDTH*HEIGHT*3, 1, ppm);
50 real_swap(dpy, drawable);
53 int gettimeofday(struct timeval *tv, struct timezone *tz)
55 printf("gettimeofday frame %u\n", frameno);
56 tv->tv_sec = frameno / 50;
57 tv->tv_usec = ((double)(frameno % 50) / 50) * 1000000;