X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_sfd.h;h=18789c7e841320a235726cfecad66ae2deaa71d2;hb=b4a83d4fcab39bee5a8cd6e8e6eec06314864e5b;hp=98d34b2498ed1ccedf43b4f09b5528cf9ab9a2dd;hpb=89113e9bc9544336b5ac4f53696c3de2d30698a2;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_sfd.h b/world_sfd.h index 98d34b2..18789c7 100644 --- a/world_sfd.h +++ b/world_sfd.h @@ -9,9 +9,7 @@ #include "shaders/scene_scoretext.h" #include "shaders/scene_vertex_blend.h" -vg_tex2d tex_scoretext = { .path = "textures/scoretext.qoi", - .flags = VG_TEXTURE_CLAMP|VG_TEXTURE_NEAREST }; - +GLuint tex_scoretex; float sfd_encode_glyph( char c ) { int value = 0; @@ -101,7 +99,9 @@ VG_STATIC void sfd_render( world_instance *world, camera *cam, m4x3f transform ) _uniform_scene_scoretext_uLightsIndex, 4 ); bind_terrain_noise(); - vg_tex2d_bind( &tex_scoretext, 1 ); + + glActiveTexture( GL_TEXTURE1 ); + glBindTexture( GL_TEXTURE_2D, tex_scoretex ); m4x4f pvm_prev; m4x3_expand( transform, pvm_prev ); @@ -131,7 +131,8 @@ VG_STATIC void sfd_render( world_instance *world, camera *cam, m4x3f transform ) world_bind_light_index( world, _shader_scene_vertex_blend.id, _uniform_scene_vertex_blend_uLightsIndex, 4 ); bind_terrain_noise(); - vg_tex2d_bind( &tex_scoretext, 1 ); + glActiveTexture( GL_TEXTURE1 ); + glBindTexture( GL_TEXTURE_2D, tex_scoretex ); shader_scene_vertex_blend_uPv( cam->mtx.pv ); shader_scene_vertex_blend_uPvmPrev( pvm_prev ); @@ -163,9 +164,15 @@ VG_STATIC void world_sfd_init(void) mdl_context mscoreboard; mdl_open( &mscoreboard, "models/rs_scoretext.mdl", vg_mem.scratch ); mdl_load_metadata_block( &mscoreboard, vg_mem.scratch ); + mdl_async_load_glmesh( &mscoreboard, &world_global.sfd.mesh_base ); + mdl_load_mesh_block( &mscoreboard, vg_mem.scratch ); - scene *sc = scene_init( vg_mem.scratch, 3000, 8000 ); + scene_context *scene = &world_global.sfd.scene; + vg_async_item *call = scene_alloc_async( scene, + &world_global.sfd.mesh_display, + 3000, 8000 ); + mdl_mesh *m_backer = mdl_find_mesh( &mscoreboard, "backer" ), *m_card = mdl_find_mesh( &mscoreboard, "score_card" ); @@ -175,17 +182,15 @@ VG_STATIC void world_sfd_init(void) *sm_card = mdl_arritm( &mscoreboard.submeshs, m_card->submesh_start ); world_global.sfd.sm_base = *sm_backer; - mdl_close( &mscoreboard ); - m4x3f identity; m4x3_identity( identity ); for( int i=0;i<4;i++ ){ - u32 vert_start = sc->vertex_count; - scene_add_mdl_submesh( sc, &mscoreboard, sm_card, identity ); + u32 vert_start = scene->vertex_count; + scene_add_mdl_submesh( scene, &mscoreboard, sm_card, identity ); for( int j=0; jvertex_count; j++ ){ - scene_vert *vert = &sc->arrvertices[ vert_start+j ]; + scene_vert *vert = &scene->arrvertices[ vert_start+j ]; float const k_glyph_uvw = 1.0f/64.0f; vert->uv[0] -= k_glyph_uvw * (float)(i-1); @@ -193,13 +198,12 @@ VG_STATIC void world_sfd_init(void) } } - vg_acquire_thread_sync(); - { - scene_upload( sc, &world_global.sfd.mesh_display ); - mdl_unpack_glmesh( &mscoreboard, &world_global.sfd.mesh_base ); - vg_tex2d_init( (vg_tex2d *[]){ &tex_scoretext }, 1 ); - } - vg_release_thread_sync(); + vg_async_dispatch( call, async_scene_upload ); + vg_tex2d_load_qoi_async_file( "textures/scoretext.qoi", + VG_TEX2D_CLAMP|VG_TEX2D_NEAREST, + &tex_scoretex ); + + mdl_close( &mscoreboard ); int w = 27, h = 13;