various
authorhgn <hgodden00@gmail.com>
Wed, 23 Aug 2023 16:21:41 +0000 (17:21 +0100)
committerhgn <hgodden00@gmail.com>
Wed, 23 Aug 2023 16:21:41 +0000 (17:21 +0100)
vg.h
vg_audio.h
vg_build_utils_shader.h
vg_m.h

diff --git a/vg.h b/vg.h
index f839f02e60e1848573d68c6a52df6467cd64ad36..2acdfc529053caef494352933b74530a909fcb0c 100644 (file)
--- a/vg.h
+++ b/vg.h
@@ -141,6 +141,7 @@ struct vg{
 
    /* Runtime */
    double time,
+          time_real,
           time_delta,
           time_rate,
 
@@ -466,7 +467,7 @@ VG_STATIC void _vg_gameloop_render(void)
                vg.samples, 
                vg.fixed_iterations, 
                (vg.time_fixed_accumulator/VG_TIMESTEP_FIXED)*100.0f,
-               vg.time, vg.time_delta, vg.time_rate,
+               vg.time_real, vg.time_delta, vg.time_rate,
                vg.time_fixed_extrapolate, vg.time_frame_delta,
                vg.time_spinning );
 
@@ -557,7 +558,7 @@ VG_STATIC int _vg_crashscreen(void)
    glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
    glBlendEquation(GL_FUNC_ADD);
 
-   glClearColor( 0.15f + sinf(vg.time)*0.1f, 0.0f, 0.0f,1.0f );
+   glClearColor( 0.15f + sinf(vg.time_real)*0.1f, 0.0f, 0.0f,1.0f );
    glClear( GL_COLOR_BUFFER_BIT );
    glViewport( 0,0, vg.window_x, vg.window_y );
 
@@ -592,6 +593,7 @@ VG_STATIC void _vg_gameloop(void){
 
       enum engine_status status = _vg_engine_status();
 
+      vg.time_real += vg.time_frame_delta;
       vg.time_delta = vg.time_frame_delta * vg.time_rate;
       vg.time += vg.time_delta;
 
index f27c8592dac436d1844287671f4e939620e0c2b4..b0c4823d21c7ed79295fec80dfc78c4b359a4cec 100644 (file)
@@ -1246,9 +1246,11 @@ VG_STATIC void audio_clip_load( audio_clip *clip, void *lin_alloc )
       if( read_samples != length_samples )
          vg_fatal_error( "Decode error" );
 
+#if 0
       float mb = (float)(data_size) / (1024.0f*1024.0f);
       vg_info( "Loaded audio clip '%s' (%.1fmb) %u samples\n", clip->path, mb,
                length_samples );
+#endif
    }
 }
 
index 39c0db9a53705da100a8c0b9909c1867a7c5cdd5..642e7fc4003ec4d734bc0db12820602a4df0a261 100644 (file)
@@ -197,7 +197,7 @@ int vg_build_shader( char *src_vert, /* path/to/vert.vs    */
    types[] =
    {
       { "float", "float f", "glUniform1f(%s,f);" },
-      { "bool", "int b", "glUniform1f(%s,b);" },
+      { "bool", "int b", "glUniform1i(%s,b);" },
 
       { "vec2", "v2f v", "glUniform2fv(%s,1,v);" },
       { "vec3", "v3f v", "glUniform3fv(%s,1,v);" },
diff --git a/vg_m.h b/vg_m.h
index 91282f0f3d25e90249e97ac8cd052c83e52f3938..090c4873ed723ad90244e8786842d047fa808a32 100644 (file)
--- a/vg_m.h
+++ b/vg_m.h
@@ -710,6 +710,16 @@ static inline void m2x2_create_rotation( m2x2f a, f32 theta )
    a[1][1] =  c;
 }
 
+static inline void m2x2_mulv( m2x2f m, v2f v, v2f d )
+{
+   v2f res;
+   
+   res[0] = m[0][0]*v[0] + m[1][0]*v[1];
+   res[1] = m[0][1]*v[0] + m[1][1]*v[1];
+   
+   v2_copy( res, d );
+}
+
 /*
  * -----------------------------------------------------------------------------
  * Section 4.b                  3x3 matrices
@@ -1536,7 +1546,7 @@ int plane_intersect2( v4f a, v4f b, v3f p, v3f n )
 static int plane_segment( v4f plane, v3f a, v3f b, v3f co )
 {
    f32 d0 = v3_dot( a, plane ) - plane[3],
-         d1 = v3_dot( b, plane ) - plane[3];
+       d1 = v3_dot( b, plane ) - plane[3];
 
    if( d0*d1 < 0.0f )
    {
@@ -1558,6 +1568,17 @@ static inline f64 plane_polarity( f64 p[4], f64 a[3] )
    ;
 }
 
+static f32 ray_plane( v4f plane, v3f co, v3f dir ){
+   f32 d = v3_dot( plane, dir );
+   if( fabsf(d) > 1e-6f ){
+      v3f v0;
+      v3_muls( plane, plane[3], v0 );
+      v3_sub( v0, co, v0 );
+      return v3_dot( v0, plane ) / d;
+   }
+   else return INFINITY;
+}
+
 /*
  * -----------------------------------------------------------------------------
  * Section 5.c            Closest point functions