jdidjjjjjjjjjjjjjjjjjjjjjj
[vg.git] / src / vg / vg.h
index e125f26a3c4111c3fa6c10c23f4d15ee2a5bee71..299c9b0112d1e5a83510e7d32d4c3b3fe6df3868 100644 (file)
@@ -75,8 +75,11 @@ struct vg
 
    /* Runtime */
    double time,
-          time_last,
           time_delta,
+          frame_delta,
+          time_real,
+          time_real_last,
+          time_rate,
           accumulator;
 
    int fixed_iterations;
@@ -100,7 +103,7 @@ struct vg
    const char       *gamepad_name;
    int                               gamepad_id;
 }
-static vg;
+static vg = { .time_rate = 1.0 };
 
 struct vg_thread_info
 {
@@ -503,14 +506,20 @@ static void vg_enter( int argc, char *argv[], const char *window_name )
       v2_copy( (v2f){ 0.0f, 0.0f }, vg.mouse_wheel );
       glfwPollEvents();
 
-      vg.time_last = vg.time;
-      vg.time = glfwGetTime();
-      vg.time_delta = vg.time-vg.time_last;
+      vg.time_real_last = vg.time_real;
+      vg.time_real = glfwGetTime();
+      vg.frame_delta = vg.time_real-vg.time_real_last;
+      
+      /* scaled time */
+      vg.time_delta = vg.frame_delta * vg.time_rate;
+      vg.time += vg.time_delta;
       
       if( vg.is_loaded )
       {
+#if 0
          glClearColor( 0.0f,sinf(vg.time*20.0)*0.5f+0.5f,0.0f,1.0f );
          glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
+#endif
          
          if( !loaded )
          {