chaos caused by async
[carveJwlIkooP6JGAAIwe30JlM.git] / font.h
diff --git a/font.h b/font.h
index eaba149b68d06bd7514fd9fc0b4d250ca06e3b2b..9b5a13b8b354aa18f8a4972f86749e86784a9192 100644 (file)
--- a/font.h
+++ b/font.h
@@ -31,32 +31,18 @@ VG_STATIC void font3d_load( font3d *font, const char *mdl_path, void *alloc )
    mdl_load_array( &font->mdl, &font->glyphs, "ent_glyph", alloc );
 
    vg_linear_clear( vg_mem.scratch );
-   mdl_load_mesh_block( &font->mdl, vg_mem.scratch );
 
    if( !mdl_arrcount( &font->mdl.textures ) )
-      vg_fatal_exit_loop( "No texture in font file" );
+      vg_fatal_error( "No texture in font file" );
 
    mdl_texture *tex0 = mdl_arritm( &font->mdl.textures, 0 );
    void *data = vg_linear_alloc( vg_mem.scratch, tex0->file.pack_size );
    mdl_fread_pack_file( &font->mdl, &tex0->file, data );
 
-   vg_acquire_thread_sync();
-   {
-      /* upload mesh */
-      mesh_upload( &font->mesh, 
-                     font->mdl.verts.data, font->mdl.verts.count,
-                     font->mdl.indices.data, font->mdl.indices.count );
-
-      /* upload first texture */
-      font->texture = vg_tex2d_new();
-
-      vg_tex2d_set_error();
-      vg_tex2d_qoi( data, tex0->file.pack_size,
-                    mdl_pstr( &font->mdl, tex0->file.pstr_path ));
-      vg_tex2d_nearest();
-      vg_tex2d_repeat();
-   }
-   vg_release_thread_sync();
+   mdl_async_load_glmesh( &font->mdl, &font->mesh );
+   vg_tex2d_load_qoi_async( data, tex0->file.pack_size, 
+                            VG_TEX2D_NEAREST|VG_TEX2D_REPEAT|VG_TEX2D_NOMIP,
+                            &font->texture );
 
    mdl_close( &font->mdl );
 }