medium sized dollop
[carveJwlIkooP6JGAAIwe30JlM.git] / player_model.h
index a2379fca6e3db158655a83e2bd53de5663afd2b5..e0693b16433aad19987cf4b81ade116c0d6269e4 100644 (file)
 
 vg_tex2d tex_characters = { .path = "textures/ch_gradient.qoi" };
 
-static void player_model_register(void)
+static int player_model_init(void)
 {
    shader_viewchar_register();
+
+   if( vg_acquire_thread_sync(1) )
+   {
+      vg_tex2d_init( (vg_tex2d *[]){ &tex_characters }, 1 );
+      vg_release_thread_sync(1);
+      return 1;
+   }
+   else
+      return 0;
 }
 
-static void player_model_init(void)
+static void player_model_free(void *_)
 {
-   vg_tex2d_init( (vg_tex2d *[]){ &tex_characters }, 1 );
+   vg_tex2d_free( (vg_tex2d *[]){ &tex_characters }, 1 );
 }
 
-
 /*
  * Load model from file (.mdl)
  */
@@ -37,7 +45,9 @@ static int player_load_model( const char *name )
 
    struct player_model *mdl = &player.mdl;
    
-   mdl_unpack_glmesh( src, &mdl->mesh );
+   if( !mdl_unpack_glmesh( src, &mdl->mesh ) )
+      goto il_free_err;
+
    skeleton_setup( &mdl->sk, src );
 
    /*