simplify
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
index c3dec8c87d9a749cbb6a0b68173794abb8fd9694..6246be38d722a9b4651cdbddc578bdb1195713e4 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #define SR_NETWORKED
-//#define VG_DEVWINDOW
+#define VG_DEVWINDOW
 #include "common.h"
 #include "conf.h"
 #include "steam.h"
@@ -23,8 +23,9 @@
 #include "player.h"
 
 VG_STATIC struct player_avatar localplayer_avatar;
-VG_STATIC glmesh localplayer_meshes[3];
-vg_tex2d localplayer_texture = { .path = "textures/ch_gradient.qoi" };
+VG_STATIC struct player_model  localplayer_models[3];
+VG_STATIC struct player_board  localplayer_boards[1];
+VG_STATIC int skaterift_status = 0;
 
 #include "network.h"
 #include "menu.h"
@@ -88,50 +89,27 @@ vg_info("            '        ' '--' [] '----- '----- '     ' '---'  "
 
 VG_STATIC void load_playermodels(void)
 {
-   vg_linear_clear( vg_mem.scratch );
-
-   /* 
-    * load in other player models. This may need to be more sophisticated in
-    * the futre if we have more of these guys
-    */
-   mdl_context ctx_default,
-               ctx_outlaw,
-               ctx_jordan;
-
-   mdl_open( &ctx_default, "models/ch_new.mdl", vg_mem.scratch );
-   mdl_load_metadata_block( &ctx_default, vg_mem.scratch );
-   mdl_load_mesh_block( &ctx_default, vg_mem.scratch );
-   mdl_close( &ctx_default );
-
-   mdl_open( &ctx_outlaw, "models/ch_outlaw.mdl", vg_mem.scratch );
-   mdl_load_metadata_block( &ctx_outlaw, vg_mem.scratch );
-   mdl_load_mesh_block( &ctx_outlaw, vg_mem.scratch );
-   mdl_close( &ctx_outlaw );
-
-   mdl_open( &ctx_jordan, "models/ch_jordan.mdl", vg_mem.scratch );
-   mdl_load_metadata_block( &ctx_jordan, vg_mem.scratch );
-   mdl_load_mesh_block( &ctx_jordan, vg_mem.scratch );
-   mdl_close( &ctx_jordan );
+   player_model_load( &localplayer_models[0], "models/ch_new.mdl" );
+   player_model_load( &localplayer_models[1], "models/ch_outlaw.mdl" );
+   player_model_load( &localplayer_models[2], "models/ch_jordan.mdl" );
    
-   vg_acquire_thread_sync();
-   {
-      mdl_unpack_glmesh( &ctx_default, &localplayer_meshes[0] );
-      mdl_unpack_glmesh( &ctx_outlaw,  &localplayer_meshes[1] );
-      mdl_unpack_glmesh( &ctx_jordan,  &localplayer_meshes[2] );
-   }
-   vg_release_thread_sync();
+   player_board_load( &localplayer_boards[0], "models/board_fish.mdl" );
 
    /* FIXME: hack */
    shader_model_character_view_register();
-   vg_acquire_thread_sync();
-   {
-      vg_tex2d_init( (vg_tex2d *[]){ &localplayer_texture }, 1 );
-   }
-   vg_release_thread_sync();
+   shader_model_board_view_register();
 }
 
 void temp_update_playermodel(void){
-   player__use_mesh( &localplayer, &localplayer_meshes[cl_playermdl_id] );
+   player__use_model( &localplayer, &localplayer_models[cl_playermdl_id] );
+}
+
+VG_STATIC void async_skaterift_complete( void *payload, u32 size )
+{
+   skaterift_status = 1;
+
+   localplayer.viewable_world = get_active_world();
+   localplayer_cmd_respawn( 1, (const char *[]){ "start" } );
 }
 
 VG_STATIC void vg_load(void)
@@ -154,8 +132,8 @@ VG_STATIC void vg_load(void)
    player__create( &localplayer );
    player_avatar_load( &localplayer_avatar, "models/ch_new.mdl" );
    player__use_avatar( &localplayer, &localplayer_avatar );
-   player__use_mesh( &localplayer, &localplayer_meshes[cl_playermdl_id] );
-   player__use_texture( &localplayer, &localplayer_texture );
+   player__use_model( &localplayer, &localplayer_models[cl_playermdl_id] );
+   player__use_board( &localplayer, &localplayer_boards[0] );
    player__bind( &localplayer );
 
    /* --------------------- */
@@ -166,11 +144,12 @@ VG_STATIC void vg_load(void)
    /* 'systems' are completely loaded now */
 
    /* load home world */
-#if 0
-   world_load( 0, "maps/mp_spawn.mdl" );
-#endif
 
+#if 1
+   world_load( 0, "maps/mp_spawn.mdl" );
+#else
    world_load( 0, "maps/mp_mtzero.mdl" );
+#endif
 
 #if 0
    world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" );
@@ -180,12 +159,8 @@ VG_STATIC void vg_load(void)
 #endif
 
    vg_console_load_autos();
-}
 
-VG_STATIC void vg_start(void)
-{
-   localplayer.viewable_world = get_active_world();
-   localplayer_cmd_respawn( 1, (const char *[]){ "start" } );
+   vg_async_call( async_skaterift_complete, NULL, 0 );
 }
 
 VG_STATIC void draw_origin_axis(void)
@@ -199,7 +174,7 @@ VG_STATIC void vg_update(void)
 {
    steam_update();
 
-   if( vg.is_loaded ){
+   if( skaterift_status == 1 ){
       draw_origin_axis();
       network_update();
       
@@ -212,7 +187,7 @@ VG_STATIC void vg_update(void)
 
 VG_STATIC void vg_update_fixed(void)
 {
-   if( vg.is_loaded ){
+   if( skaterift_status == 1 ){
       world_routes_fixedupdate( get_active_world() );
 
       player__update( &localplayer );
@@ -245,7 +220,7 @@ VG_STATIC void vg_update_fixed(void)
 
 VG_STATIC void vg_update_post(void)
 {
-   if( vg.is_loaded ){
+   if( skaterift_status == 1 ){
       player__post_update( &localplayer );
 
       float dist;
@@ -458,6 +433,11 @@ VG_STATIC void render_main_game(void)
 
 VG_STATIC void vg_render(void)
 {
+   if( skaterift_status == 0 ){
+      _vg_loader_render();
+      return;
+   }
+
    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
 
    glViewport( 0,0, vg.window_x, vg.window_y );
@@ -479,6 +459,10 @@ VG_STATIC void vg_render(void)
 
 VG_STATIC void vg_ui(void)
 {
+   if( skaterift_status == 0 ){
+      return;
+   }
+
 #if 0
    player__im_gui( &localplayer );
 #endif