2 * Use something like this:
4 * gcc -shared -fPIC -o glcapture.so glcapture.c -ldl
5 * LD_PRELOAD=`pwd`/glcapture.so ./demo
6 * for FILE in *.ppm; do convert -flip $FILE ${FILE/ppm/tga}; echo $FILE; done
7 * 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
8 * 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
18 #define RTLD_NEXT ((void *) -1l)
21 static char buf[640 * 480 * 3];
22 static int frameno = 0;
24 void glXSwapBuffers( Display *dpy, GLXDrawable drawable )
26 void (*real_swap)(Display*, GLXDrawable);
27 real_swap = (void(*)(Display*, GLXDrawable))dlsym(RTLD_NEXT, "glXSwapBuffers");
31 glReadPixels(0, 0, 640, 480, GL_RGB, GL_UNSIGNED_BYTE, buf);
33 sprintf(filename, "frame%05u.ppm", frameno++);
34 ppm = fopen(filename, "w");
35 fprintf(ppm, "P6\n640 480\n255\n");
36 fwrite(buf, 640*480*3, 1, ppm);
39 real_swap(dpy, drawable);
42 int gettimeofday(struct timeval *tv, struct timezone *tz)
44 printf("gettimeofday frame %u\n", frameno);
45 tv->tv_sec = frameno / 50;
46 tv->tv_usec = ((double)(frameno % 50) / 50) * 1000000;