Merge branch 'gles'
[neverball] / putt / main.c
index 1e0cda7..1c173da 100644 (file)
@@ -41,19 +41,30 @@ const char ICON[] = "icon/neverputt.png";
 
 /*---------------------------------------------------------------------------*/
 
-static int shot(void)
+static int shot_pending;
+
+static void shot_prep(void)
 {
-    static char filename[MAXSTR];
+    shot_pending = 1;
+}
 
-    sprintf(filename, "Screenshots/screen%05d.png", config_screenshot());
-    image_snap(filename);
+static void shot_take(void)
+{
+    static char filename[MAXSTR];
 
-    return 1;
+    if (shot_pending)
+    {
+        sprintf(filename, "Screenshots/screen%05d.png", config_screenshot());
+        image_snap(filename);
+        shot_pending = 0;
+    }
 }
+
 /*---------------------------------------------------------------------------*/
 
 static void toggle_wire(void)
 {
+#if !ENABLE_OPENGLES
     static int wire = 0;
 
     if (wire)
@@ -70,6 +81,7 @@ static void toggle_wire(void)
         glDisable(GL_LIGHTING);
         wire = 1;
     }
+#endif
 }
 /*---------------------------------------------------------------------------*/
 
@@ -119,7 +131,7 @@ static int loop(void)
 
             else switch (c)
             {
-            case SDLK_F10: d = shot();                break;
+            case SDLK_F10: shot_prep();               break;
             case SDLK_F9:  config_tgl_d(CONFIG_FPS);  break;
             case SDLK_F8:  config_tgl_d(CONFIG_NICE); break;
             case SDLK_F7:  toggle_wire();             break;
@@ -164,6 +176,7 @@ static int loop(void)
             default:
                 d = st_keybd(e.key.keysym.sym, 0);
             }
+            break;
 
         case SDL_ACTIVEEVENT:
             if (e.active.state == SDL_APPINPUTFOCUS)
@@ -246,6 +259,7 @@ int main(int argc, char *argv[])
                 {
                     st_timer((t1 - t0) / 1000.f);
                     st_paint(0.001f * t1);
+                    shot_take();
                     SDL_GL_SwapBuffers();
 
                     t0 = t1;