/* Runtime */
double time,
- time_last,
time_delta,
+ frame_delta,
+ time_real,
+ time_real_last,
+ time_rate,
accumulator;
int fixed_iterations;
const char *gamepad_name;
int gamepad_id;
}
-static vg;
+static vg = { .time_rate = 1.0 };
struct vg_thread_info
{
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 )
{
#define AUDIO_FLAG_LOOP 0x1
#define AUDIO_FLAG_ONESHOT 0x2
#define AUDIO_FLAG_SPACIAL_3D 0x4
+#define AUDIO_FLAG_AUTO_START 0x8
#define FADEOUT_LENGTH 1100
#define FADEOUT_DIVISOR (1.0f/(float)FADEOUT_LENGTH)
return a + t*(b-a);
}
+static inline double vg_lerp( double a, double b, double t )
+{
+ return a + t*(b-a);
+}
+
+/* correctly lerp around circular period -pi -> pi */
+static float vg_alerpf( float a, float b, float t )
+{
+ float d = fmodf( b-a, VG_TAUf ),
+ s = fmodf( 2.0f*d, VG_TAUf ) - d;
+ return a + s*t;
+}
+
static inline void v3_lerp( v3f a, v3f b, float t, v3f d )
{
d[0] = a[0] + t*(b[0]-a[0]);
static inline void q_nlerp( v4f a, v4f b, float t, v4f d )
{
- v4_lerp( a, b, t, d );
+ if( v4_dot(a,b) < 0.0f )
+ {
+ v4_muls( b, -1.0f, d );
+ v4_lerp( a, d, t, d );
+ }
+ else
+ v4_lerp( a, b, t, d );
+
q_normalize( d );
}