a fairly major physics update
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
index de702d78b974a5c52a95b75be745b5e5d48dc0d8..9d72bec2aa030060fdd7009f465715e07026e195 100644 (file)
@@ -2,7 +2,7 @@
  * =============================================================================
  *
  * Copyright  .        . .       -----, ,----- ,---.   .---.
- * 2021-2022  |\      /| |           /  |      |    | |    /|
+ * 2021-2023  |\      /| |           /  |      |    | |    /|
  *            | \    / | +--        /   +----- +---'  |   / |
  *            |  \  /  | |         /    |      |   \  |  /  |
  *            |   \/   | |        /     |      |    \ | /   |
@@ -23,7 +23,8 @@
 #include "menu.h"
 
 static int cl_ui      = 1,
-           cl_view_id = 0;
+           cl_view_id = 0,
+           cl_light_edit = 0;
 
 int main( int argc, char *argv[] )
 {
@@ -64,6 +65,14 @@ VG_STATIC void vg_preload(void)
       .persistent = 0
    });
 
+   vg_convar_push( (struct vg_convar){
+      .name = "ledit",
+      .data = &cl_light_edit,
+      .data_type = k_convar_dtype_i32,
+      .opt_i32 = { .min=0, .max=1, .clamp=1 },
+      .persistent = 0
+   });
+
 vg_info(" Copyright  .        . .       -----, ,----- ,---.   .---.  \n" );
 vg_info(" 2021-2022  |\\      /| |           /  |      |    | |    /| \n" );
 vg_info("            | \\    / | +--        /   +----- +---'  |   / | \n" );
@@ -96,7 +105,7 @@ VG_STATIC void vg_load(void)
 
    /* 'systems' are completely loaded now */
    strcpy( world.world_name, "maps/mp_mtzero.mdl" );
-   //strcpy( world.world_name, "maps/mp_gridmap.mdl" );
+   strcpy( world.world_name, "maps/mp_gridmap.mdl" );
    world_load();
    vg_console_load_autos();
 }
@@ -158,29 +167,41 @@ VG_STATIC void present_view_with_post_processing(void)
    glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
    glBlendEquation(GL_FUNC_ADD);
 
-   shader_blitblur_use();
-   shader_blitblur_uTexMain( 0 );
-   shader_blitblur_uTexMotion( 1 );
-   shader_blitblur_uBlurStrength( cl_blur_strength / (vg.frame_delta*60.0f) );
-
-   v2f menu_blurring;
-   v2_muls( (v2f){ 0.04f, 0.001f }, menu_opacity, menu_blurring );
-   shader_blitblur_uOverrideDir( menu_blurring );
-
-   if( cl_view_id == 0 )
-      render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
-   else if( cl_view_id == 1 )
-      render_fb_bind_texture( gpipeline.fb_main, 1, 0 );
+   if( cl_blur )
+   {
+      shader_blitblur_use();
+      shader_blitblur_uTexMain( 0 );
+      shader_blitblur_uTexMotion( 1 );
+      shader_blitblur_uBlurStrength(cl_blur_strength / (vg.frame_delta*60.0f));
+
+      v2f menu_blurring;
+      v2_muls( (v2f){ 0.04f, 0.001f }, menu_opacity, menu_blurring );
+      shader_blitblur_uOverrideDir( menu_blurring );
+
+      if( cl_view_id == 0 )
+         render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
+      else if( cl_view_id == 1 )
+         render_fb_bind_texture( gpipeline.fb_main, 1, 0 );
+      else
+         render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
+
+      render_fb_bind_texture( gpipeline.fb_main, 1, 1 );
+   }
    else
+   {
+      shader_blit_use();
+      shader_blit_uTexMain( 0 );
       render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
+   }
 
-   render_fb_bind_texture( gpipeline.fb_main, 1, 1 );
    render_fsquad();
 }
 
 VG_STATIC void render_player_transparent(void)
 {
-   camera small_cam;
+   static camera small_cam;      /* DOES NOT NEED TO BE STATIC BUT MINGW 
+                                    SAIS OTHERWISE */
+
    m4x3_copy( main_camera.transform, small_cam.transform );
 
    small_cam.fov = main_camera.fov;
@@ -281,17 +302,17 @@ VG_STATIC void vg_render(void)
    glViewport( 0,0, vg.window_x, vg.window_y );
 }
 
+VG_STATIC void run_light_widget( struct light_widget *lw );
 VG_STATIC void vg_ui(void)
 {
    menu_crap_ui();
 
-#if 0
-   if( lightedit )
+   if( cl_light_edit )
    {
-      ui_global_ctx.cursor[0] = 10;
-      ui_global_ctx.cursor[1] = 10;
-      ui_global_ctx.cursor[2] = 200;
-      ui_global_ctx.cursor[3] = 20;
+      vg_uictx.cursor[0] = 10;
+      vg_uictx.cursor[1] = 10;
+      vg_uictx.cursor[2] = 200;
+      vg_uictx.cursor[3] = 20;
 
       struct ub_world_lighting *wl = &gpipeline.ub_world_lighting;
       struct ui_slider_vector 
@@ -303,24 +324,23 @@ VG_STATIC void vg_ui(void)
 
       for( int i=0; i<3; i++ )
          run_light_widget( &gpipeline.widgets[i] );
-
-      gui_text( ui_global_ctx.cursor, "Ambient", 1, 0 );
-      ui_global_ctx.cursor[1] += 16;
-      ui_slider_vector( &ui_global_ctx, &s5 );
-
-      gui_text( ui_global_ctx.cursor, "Shadows", 1, 0 );
-      ui_global_ctx.cursor[1] += 16;
-      ui_slider( &ui_global_ctx, &s8 );
-      ui_slider( &ui_global_ctx, &s9 );
-
-      gui_text( ui_global_ctx.cursor, "Misc", 1, 0 );
-      ui_global_ctx.cursor[1] += 16;
+      
+      ui_text( vg_uictx.cursor, "Ambient", 1, 0 );
+      vg_uictx.cursor[1] += 16;
+      ui_slider_vector( &s5 );
+
+      ui_text( vg_uictx.cursor, "Shadows", 1, 0 );
+      vg_uictx.cursor[1] += 16;
+      ui_slider( &s8 );
+      ui_slider( &s9 );
+
+      ui_text( vg_uictx.cursor, "Misc", 1, 0 );
+      vg_uictx.cursor[1] += 16;
       struct ui_checkbox c1 = {.data = &wl->g_light_preview};
-      ui_checkbox( &ui_global_ctx, &c1 );
+      ui_checkbox( &c1 );
 
       render_update_lighting_ub();
    }
-#endif
    
    //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
    if( cl_ui )
@@ -333,12 +353,11 @@ VG_STATIC void vg_ui(void)
    render_view_framebuffer_ui();
 }
 
-#if 0
 VG_STATIC void run_light_widget( struct light_widget *lw )
 {
    struct ui_checkbox c1 = { .data=&lw->enabled };
 
-   ui_checkbox( &ui_global_ctx, &c1 );
+   ui_checkbox( &c1 );
    
    if( lw->enabled )
    {
@@ -346,12 +365,11 @@ VG_STATIC void run_light_widget( struct light_widget *lw )
          colour = { .min=0.0f, .max=2.0f, .len=3, .data=lw->colour },
          dir    = { .min=-VG_PIf, .max=VG_PIf, .len=2, .data=lw->dir };
 
-      ui_slider_vector( &ui_global_ctx, &colour );
-      ui_global_ctx.cursor[1] += 4;
-      ui_slider_vector( &ui_global_ctx, &dir );
+      ui_slider_vector( &colour );
+      vg_uictx.cursor[1] += 4;
+      ui_slider_vector( &dir );
    }
 }
-#endif
 
 VG_STATIC void run_debug_info(void)
 {