X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_glide.c;fp=player_glide.c;h=dd820fb7b1c8d58421c2d17d3813ce8321ce075b;hb=ad9ece78cdcf550c34d28af276567d7d18b67668;hp=06070dea88000fdd65aa12cf56bd148099218faf;hpb=4eccfd7252f8ff165670842df537441afae5458b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_glide.c b/player_glide.c index 06070de..dd820fb 100644 --- a/player_glide.c +++ b/player_glide.c @@ -453,32 +453,15 @@ void player_glide_bind(void) mdl_open( mdl, "models/glider.mdl", alloc ); mdl_load_metadata_block( mdl, alloc ); - - vg_linear_clear( vg_mem.scratch ); - - u32 count = mdl_arrcount( &mdl->textures ); - player_glide.glider_textures = - vg_linear_alloc( alloc, vg_align8(sizeof(GLuint)*(count+1))); - player_glide.glider_textures[0] = vg.tex_missing; - mdl_async_load_glmesh( mdl, &player_glide.glider_mesh, NULL ); - - for( u32 i=0; itextures, i ); - void *data = vg_linear_alloc( vg_mem.scratch, tex->file.pack_size ); - mdl_fread_pack_file( mdl, &tex->file, data ); - vg_tex2d_load_qoi_async( data, tex->file.pack_size, - VG_TEX2D_LINEAR|VG_TEX2D_CLAMP, - &player_glide.glider_textures[i+1] ); - } + mdl_async_full_load_std( mdl ); /* load trail positions */ mdl_array_ptr markers; MDL_LOAD_ARRAY( mdl, &markers, ent_marker, vg_mem.scratch ); + mdl_close( mdl ); - for( u32 i=0; itransform.co, player_glide.trail_positions[ player_glide.trail_count ++ ] ); @@ -487,10 +470,9 @@ void player_glide_bind(void) break; } - mdl_close( mdl ); - /* allocate effects */ - for( u32 i=0; imeshs); i ++ ){ + for( u32 i=0; imeshs); i ++ ) + { mdl_mesh *mesh = mdl_arritm( &mdl->meshs, i ); m4x3f mmmdl; @@ -548,7 +531,8 @@ void render_glider_model( vg_camera *cam, world_instance *world, if( shader == k_board_shader_player ) shader_model_board_view_uMdl( mmmdl ); - else if( shader == k_board_shader_entity ){ + else if( shader == k_board_shader_entity ) + { m4x4f m4mmmdl; m4x3_expand( mmmdl, m4mmmdl ); m4x4_mul( cam->mtx_prev.pv, m4mmmdl, m4mmmdl ); @@ -557,17 +541,28 @@ void render_glider_model( vg_camera *cam, world_instance *world, shader_model_entity_uPvmPrev( m4mmmdl ); } - for( u32 j=0; jsubmesh_count; j ++ ){ + for( u32 j=0; jsubmesh_count; j ++ ) + { mdl_submesh *sm = mdl_arritm( &mdl->submeshs, mesh->submesh_start+j ); - if( !sm->material_id ) { + if( !sm->material_id ) + { vg_error( "Invalid material ID 0\n" ); continue; } mdl_material *mat = mdl_arritm( &mdl->materials, sm->material_id-1 ); - if( mat->tex_diffuse != current_tex ){ - glBindTexture( GL_TEXTURE_2D, - player_glide.glider_textures[ mat->tex_diffuse ] ); + if( mat->tex_diffuse != current_tex ) + { + GLuint tex = vg.tex_missing; + + if( mat->tex_diffuse ) + { + u32 index = mat->tex_diffuse-1; + mdl_texture *ptex = mdl_arritm( &mdl->textures, index ); + tex = ptex->glname; + } + + glBindTexture( GL_TEXTURE_2D, tex ); current_tex = mat->tex_diffuse; }