Group key config symbols together
[neverball] / share / state.c
index 7af4bc0..db4a845 100644 (file)
 #include "glext.h"
 #include "state.h"
 #include "config.h"
+#include "video.h"
 
 /*---------------------------------------------------------------------------*/
 
-static float  state_time;
+static float         state_time;
+static int           state_drawn;
 static struct state *state;
 
 struct state *curr_state(void)
@@ -41,8 +43,9 @@ int goto_state(struct state *st)
     if (state && state->leave)
         state->leave(state->gui_id);
 
-    state      = st;
-    state_time =  0;
+    state       = st;
+    state_time  = 0;
+    state_drawn = 0;
 
     if (state && state->enter)
         state->gui_id = state->enter();
@@ -52,32 +55,37 @@ int goto_state(struct state *st)
 
 /*---------------------------------------------------------------------------*/
 
-void st_paint(void)
+void st_paint(float t)
 {
-    int stereo  = config_get_d(CONFIG_STEREO);
+    int stereo = config_get_d(CONFIG_STEREO);
+
+    state_drawn = 1;
 
     if (state && state->paint)
     {
         if (stereo)
         {
             glDrawBuffer(GL_BACK_LEFT);
-            config_clear();
-            state->paint(state->gui_id, (float) (+stereo));
+            video_clear();
+            state->paint(state->gui_id, t);
 
             glDrawBuffer(GL_BACK_RIGHT);
-            config_clear();
-            state->paint(state->gui_id, (float) (-stereo));
+            video_clear();
+            state->paint(state->gui_id, t);
         }
         else
         {
-            config_clear();
-            state->paint(state->gui_id, 0.0f);
+            video_clear();
+            state->paint(state->gui_id, t);
         }
     }
 }
 
 void st_timer(float dt)
 {
+    if (!state_drawn)
+        return;
+
     state_time += dt;
 
     if (state && state->timer)
@@ -96,6 +104,12 @@ void st_stick(int a, int k)
         state->stick(state->gui_id, a, k);
 }
 
+void st_angle(int x, int z)
+{
+    if (state && state->angle)
+        state->angle(state->gui_id, x, z);
+}
+
 /*---------------------------------------------------------------------------*/
 
 int st_click(int b, int d)