menu stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / main.c
diff --git a/main.c b/main.c
index bbb4c321f310f8e297409801e3c3605c1874b2ae..61bd6dfcd15f94ad2dfbb8d6b672b11baa798eb0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -29,8 +29,7 @@
 #include "network.h"
 #include "menu.h"
 
-static int cl_ui     = 1,
-           cl_menu   = 0;
+static int cl_ui     = 1;
 
 int main( int argc, char *argv[] )
 {
@@ -93,7 +92,7 @@ void vg_load(void)
 
 static void vg_start(void)
 {
-   player_load_model( "ch_jordan" );
+   player_load_model( "ch_jordan", 0 );
    reset_player( 1, (const char *[]){ "start" } );
 }
 
@@ -110,27 +109,17 @@ void vg_update( int loaded )
 
    if( loaded )
    {
-      if( vg_get_button_down( "menu" ) )
-      {
-         cl_menu = !cl_menu;
-      }
-
       draw_origin_axis();
       network_update();
 
-      if( !cl_menu )
-      {
-         player_update_pre();
-         world_update( player.phys.rb.co );
-      }
-
-      menu_update( cl_menu );
+      player_update_pre();
+      world_update( player.phys.rb.co );
    }
 }
 
 static void vg_update_fixed( int loaded )
 {
-   if( loaded && !cl_menu )
+   if( loaded )
    {
       player_update_fixed();
    }
@@ -138,9 +127,10 @@ static void vg_update_fixed( int loaded )
 
 static void vg_update_post( int loaded )
 {
-   if( loaded && !cl_menu )
+   if( loaded )
    {
       player_update_post();
+      menu_update();
    }
 }
 
@@ -153,27 +143,19 @@ static void vg_framebuffer_resize( int w, int h )
 
 static void render_main_game(void)
 {
-   v3f *active_cam_inv = NULL,
-       *active_cam     = NULL;
-
    m4x4f world_4x4;
+   m4x3_expand( camera_mtx_inverse, world_4x4 );
 
-   if( cl_menu )
-   {
-      active_cam = menu_cam;
-      active_cam_inv = menu_cam_inv;
-   }
-   else
-   {
-      active_cam_inv = player.camera_inverse;
-      active_cam = player.camera;
-   }
+   static float fov = 97.0f;
 
-   m4x3_expand( active_cam_inv, world_4x4 );
+   float fov_target = 108.0f;
+   if( player.phys.on_board )
+      fov_target = 125.0f;
 
-   static float fov = 97.0f;
-   float fov_target = (player.phys.on_board&&!cl_menu)? 125.0f: 108.0f;
-   fov = vg_lerpf( fov, fov_target, vg.time_delta * 2.0f );
+   if( cl_menu )
+      fov_target = menu_fov_target;
+
+   fov = vg_lerpf( fov, fov_target, vg.frame_delta * 2.0f );
 
    gpipeline.fov = freecam? 60.0f: fov; /* 120 */
    m4x4_projection( vg.pv, gpipeline.fov, 
@@ -189,18 +171,21 @@ static void render_main_game(void)
 
    int draw_solid = player.is_dead | freecam;
    
-   render_world( vg.pv, active_cam );
+   render_world( vg.pv, camera_mtx );
    if( draw_solid )
-      draw_player( active_cam );
+      draw_player( camera_mtx );
 
-   render_water_texture( active_cam );
+   render_water_texture( camera_mtx );
 
    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
-   render_water_surface( vg.pv, active_cam );
-   render_world_gates( vg.pv, player.phys.rb.co, active_cam );
+   render_water_surface( vg.pv, camera_mtx );
+   render_world_gates( vg.pv, player.phys.rb.co, camera_mtx );
 
    if( cl_menu )
+   {
+      glClear( GL_DEPTH_BUFFER_BIT );
       menu_render( vg.pv );
+   }
    
    /* Copy the RGB of what we have into the background buffer */
    glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
@@ -223,9 +208,9 @@ static void render_main_game(void)
    {
       m4x4_projection( vg.pv, gpipeline.fov, 
             (float)vg.window_x / (float)vg.window_y, 
-            0.01f, 600.0f );
+            0.05f, 60.0f );
       m4x4_mul( vg.pv, world_4x4, vg.pv );
-      draw_player( active_cam );
+      draw_player( camera_mtx );
    }
 
    /* Draw back in the background