+VG_STATIC void world_process_resources(void)
+{
+ vg_info( "Loading textures\n" );
+ world.texture_count = world.meta->info.texture_count;
+ world.textures =
+ vg_linear_alloc( world.dynamic_vgl, sizeof(GLuint)*world.texture_count );
+
+ vg_acquire_thread_sync();
+ {
+ /* error texture */
+ world.textures[0] = vg_tex2d_new();
+ vg_tex2d_set_error();
+ vg_tex2d_nearest();
+ vg_tex2d_repeat();
+
+ for( int i=1; i<world.texture_count; i++ )
+ {
+ mdl_texture *tex = &world.meta->texture_buffer[i];
+
+ if( !tex->pack_offset )
+ {
+ vg_release_thread_sync();
+ vg_fatal_exit_loop( "World models must have packed textures!" );
+ }
+
+ vg_linear_clear( vg_mem.scratch );
+ world.textures[i] = vg_tex2d_new();
+ vg_tex2d_set_error();
+ vg_tex2d_qoi( world.meta->pack + tex->pack_offset, tex->pack_length,
+ mdl_pstr( world.meta, tex->pstr_name ));
+ vg_tex2d_nearest();
+ vg_tex2d_repeat();
+ }
+ }
+ vg_release_thread_sync();
+
+ vg_info( "Loading materials\n" );
+
+ u32 size = sizeof(struct world_material) * world.meta->info.material_count;
+ world.materials = vg_linear_alloc( world.dynamic_vgl, size );
+
+ world.material_count = world.meta->info.material_count;
+ memset( world.materials, 0, size );
+
+ for( int i=1; i<world.material_count; i++ )
+ world.materials[i].info = world.meta->material_buffer[i];
+
+ /* error material */
+ struct world_material *errmat = &world.materials[0];
+ v4_copy( (v4f){ 1.0f,0.0f,0.0f,1.0f }, errmat->info.colour );
+ v4_copy( (v4f){ 1.0f,0.0f,0.0f,1.0f }, errmat->info.colour1 );
+ errmat->info.flags = 0x00;
+ errmat->info.pstr_name = 0; /* useless? */
+ errmat->info.shader = -1;
+ errmat->info.tex_decal = 0;
+ errmat->info.tex_diffuse = 0;
+ errmat->info.tex_normal = 0;
+}