scoreboards
[carveJwlIkooP6JGAAIwe30JlM.git] / world_sfd.h
index 05f191d1d9b9cae9cb9b4aff1b0439cca68c6e4d..29244e8c843caf70dfcb3ad73b3e60323b3a6035 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
+ */
+
 #ifndef SFD_H
 #define SFD_H
 
@@ -72,7 +76,7 @@ static void sfd_new( struct sfd_instance *display, u32 w, u32 h )
 {
    display->w = w;
    display->h = h;
-   display->buffer = malloc( w*h*sizeof(float)*2 );
+   display->buffer = vg_alloc( w*h*sizeof(float)*2 );
 
    for( int i=0; i<w*h*2; i++ )
       display->buffer[i] = 0.0f;
@@ -85,7 +89,7 @@ static void sfd_update( struct sfd_instance *display )
       float *target = &display->buffer[i],
             *cur = target+display->w*display->h;
       
-      float const rate = ktimestep*15.2313131414f;
+      float const rate = vg.time_delta * 15.2313131414f;
       float d1 = *target-*cur;
       
       if( fabsf(d1) > rate )
@@ -153,7 +157,7 @@ static int world_sfd_test( int argc, const char *argv[] )
    return 0;
 }
 
-static int world_sfd_init(void)
+static void world_sfd_init(void)
 {
    vg_info( "world_sfd_init\n" );
    shader_scoretext_register();
@@ -176,7 +180,7 @@ static int world_sfd_init(void)
    m4x3f identity;
    m4x3_identity( identity );
 
-   for( int i=0;i<8;i++ )
+   for( int i=4;i<6;i++ )
    {
       u32 vert_start = sfd->mesh.vertex_count;
       scene_add_submesh( &sfd->mesh, mboard, card, identity );
@@ -192,33 +196,18 @@ static int world_sfd_init(void)
       }
    }
 
-   if( vg_acquire_thread_sync(1) )
+   vg_acquire_thread_sync();
    {
       vg_tex2d_init( (vg_tex2d *[]){ &tex_scoretext }, 1 );
-      if( !scene_upload( &sfd->mesh ) )
-      {
-         vg_release_thread_sync(1);
-         return 0;
-      }
-
-      if( !mdl_unpack_submesh( mboard, &sfd->temp, backer ) )
-      {
-         vg_release_thread_sync(1);
-         return 0;
-      }
 
-      vg_release_thread_sync(1);
-   }
-   else
-   {
-      free( mboard );
-      return 0;
+      scene_upload( &sfd->mesh );
+      mdl_unpack_submesh( mboard, &sfd->temp, backer );
    }
+   vg_release_thread_sync();
 
    scene_free_offline_buffers( &sfd->mesh );
    sfd_new( &sfd->tester, 27, 13 );
-   free( mboard );
-   return 1;
+   vg_free( mboard );
 }