JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Ugly hack for making a screencast screencaster
authorJason Woofenden <jason@jasonwoof.com>
Sun, 31 Jan 2010 12:29:01 +0000 (07:29 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Sun, 31 Jan 2010 12:29:01 +0000 (07:29 -0500)
Here's the command to convert the resulting (huge pile of) .bmp files to 1 .avi:

mencoder "mf://*.bmp" -mf fps=27.9 -o test.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=8000

main.c

diff --git a/main.c b/main.c
index 1d4ce85..f4cf4aa 100644 (file)
--- a/main.c
+++ b/main.c
@@ -666,6 +666,10 @@ gameloop() {
                if(ms_frame > 50) {
                        ms_frame = 50;
                }
+               if(ms_frame < 35) {
+                       SDL_Delay(35 - ms_frame);
+                       ms_frame = 35;
+               }
                t_frame = gamespeed * ms_frame / 50;
                frames++;
 
@@ -804,6 +808,21 @@ gameloop() {
 
 
                        draw();
+                                                               {
+                                                                       FILE *screenshot_fp;
+                                                                       char tmp[30];
+                                                                       char *screenshot_filename = &(tmp[0]);
+                                                                       for(;;) {
+                                                                               snprintf(screenshot_filename, 30, "vor-screenshot-%04i.bmp", screenshot_number++);
+                                                                               screenshot_fp = fopen(screenshot_filename, "r");
+                                                                               if(screenshot_fp) {
+                                                                                       fclose(screenshot_fp);
+                                                                               } else {
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                                       SDL_SaveBMP(surf_screen, screenshot_filename);
+                                                               }
 
                        // new game
                        if((keystate[SDLK_SPACE] || keystate[SDLK_1] || keystate[SDLK_2])
@@ -867,7 +886,7 @@ main(int argc, char **argv) {
        frames = 0;
        gameloop();
        end = SDL_GetTicks();
-       // printf("%ld frames in %ld ms, %.2f fps.\n", frames, end-start, frames * 1000.0 / (end-start));
+       printf("%ld frames in %ld ms, %.2f fps.\n", frames, end-start, frames * 1000.0 / (end-start));
 
        return 0;
 }