X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=skaterift.c;h=7b1d1d15dbcc723067562329187f0bff4676e56f;hb=01e2535f8daaab0e3d46dcc61a08a9268babd47c;hp=00dbb110fa1a78279df0b2ff463c20c6afb5fd45;hpb=49f76c732d2c4ba2f7f772656831f1855521417c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/skaterift.c b/skaterift.c index 00dbb11..7b1d1d1 100644 --- a/skaterift.c +++ b/skaterift.c @@ -12,13 +12,14 @@ */ #define SR_NETWORKED +#define VG_DEVWINDOW #include "common.h" #include "conf.h" #include "steam.h" #include "render.h" #include "audio.h" #include "world.h" - +#include "font.h" #include "player.h" @@ -37,15 +38,21 @@ player_instance *tmp_localplayer(void) #include "vehicle.h" static int cl_ui = 1, - cl_view_id = 0, cl_light_edit = 0; +#define DEV_AARON +#ifdef DEV_AARON +static rb_object aaron={ + .type=k_rb_shape_box, + .rb.bbx = {{ -2.0f, -1.0f, -1.0f }, { 2.0f, 1.0f, 1.0f }} +}; +#endif + int main( int argc, char *argv[] ) { vg_mem.use_libc_malloc = 0; vg_set_mem_quota( 160*1024*1024 ); vg_enter( argc, argv, "Voyager Game Engine" ); - return 0; } @@ -126,14 +133,6 @@ VG_STATIC void vg_preload(void) .persistent = 0 }); - vg_var_push( (struct vg_var){ - .name = "cl_view_id", - .data = &cl_view_id, - .data_type = k_var_dtype_i32, - .opt_i32 = { .min=0, .max=1, .clamp=1 }, - .persistent = 0 - }); - vg_var_push( (struct vg_var){ .name = "ledit", .data = &cl_light_edit, @@ -171,6 +170,14 @@ vg_info(" ' ' '--' [] '----- '----- ' ' '---' " steam_init(); vg_loader_step( NULL, steam_end ); vg_loader_step( network_init, network_end ); + +#ifdef DEV_AARON + q_identity( aaron.rb.q ); + v3_zero( aaron.rb.w ); + v3_zero( aaron.rb.co ); + v3_zero( aaron.rb.v ); + rb_init_object( &aaron ); +#endif } VG_STATIC void load_playermodels(void) @@ -226,8 +233,12 @@ VG_STATIC void vg_load(void) vg_loader_step( render_init, NULL ); vg_loader_step( menu_init, NULL ); vg_loader_step( world_init, NULL ); + vg_loader_step( font3d_init, NULL ); + + font3d_load( &world_global.font, "models/rs_font.mdl", vg_mem.rtmemory ); + //vg_loader_step( player_init, NULL ); - //vg_loader_step( vehicle_init, NULL ); + vg_loader_step( vehicle_init, NULL ); // //vg_loader_step( player_model_init, NULL ); @@ -250,8 +261,8 @@ VG_STATIC void vg_load(void) /* 'systems' are completely loaded now */ /* load home world */ - //world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" ); - world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" ); + world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" ); + //world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" ); #if 0 world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" ); @@ -279,55 +290,54 @@ VG_STATIC void vg_update(void) { steam_update(); - if( vg.is_loaded ) - { + if( vg.is_loaded ){ draw_origin_axis(); network_update(); -#if 0 - if( !gzoomer.inside ) - player_update_pre(); -#endif - player__pre_update( &localplayer ); - world_update( get_active_world(), localplayer.rb.co ); - audio_update(); + world_update( get_active_world(), localplayer.rb.co ); + audio_ambient_sprites_update( get_active_world(), localplayer.rb.co ); } } VG_STATIC void vg_update_fixed(void) { - if( vg.is_loaded ) - { -#if 0 - if( !gzoomer.inside ) - player_update_fixed(); + if( vg.is_loaded ){ + world_routes_fixedupdate( get_active_world() ); + player__update( &localplayer ); vehicle_update_fixed(); + +#ifdef DEV_AARON + world_instance *world = get_active_world(); + rb_solver_reset(); + rb_ct *buf = rb_global_buffer(); + + int l = rb_box__scene( aaron.rb.to_world, aaron.rb.bbx, + NULL, &world->rb_geo.inf.scene, buf ); + for( int j=0; jrb_geo.rb; + } + rb_contact_count += l; + rb_presolve_contacts( rb_contact_buffer, rb_contact_count ); + + for( int j=0; j<8; j++ ){ + rb_solve_contacts( rb_contact_buffer, rb_contact_count ); + } + + rb_iter( &aaron.rb ); + rb_update_transform( &aaron.rb ); #endif - player__update( &localplayer ); } } VG_STATIC void vg_update_post(void) { - if( vg.is_loaded ) - { -#if 0 - if( gzoomer.inside ) - { - vehicle_camera(); - } - else - { - player_update_post(); - } -#endif - + if( vg.is_loaded ){ player__post_update( &localplayer ); - float inr3 = 0.57735027, inr2 = 0.70710678118; @@ -394,7 +404,6 @@ VG_STATIC void vg_update_post(void) if( si >= 14 ) si = 0; - /* FIXME: TEMP */ audio_lock(); vg_dsp.echo_distances[si] = dist; @@ -415,8 +424,20 @@ VG_STATIC void vg_update_post(void) audio_unlock(); menu_update(); -#if 0 vehicle_update_post(); + +#ifdef DEV_AARON + SDL_Scancode sc = SDL_GetScancodeFromKey( SDLK_q ); + if( vg_input.sdl_keys[sc] ){ + m4x3_mulv( main_camera.transform, (v3f){0.0f,0.0f,-3.0f}, + aaron.rb.co ); + + v3_zero( aaron.rb.v ); + v3_zero( aaron.rb.w ); + rb_update_transform( &aaron.rb ); + } + + rb_object_debug( &aaron, VG__PINK ); #endif } } @@ -429,34 +450,34 @@ VG_STATIC void vg_framebuffer_resize( int w, int h ) VG_STATIC void present_view_with_post_processing(void) { glBindFramebuffer( GL_FRAMEBUFFER, 0 ); + glViewport( 0,0, vg.window_x, vg.window_y ); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); glBlendEquation(GL_FUNC_ADD); + v2f inverse; + render_fb_inverse_ratio( gpipeline.fb_main, inverse ); + 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)); + shader_blitblur_uInverseRatio( inverse ); 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, 0, 0 ); render_fb_bind_texture( gpipeline.fb_main, 1, 1 ); } else{ shader_blit_use(); shader_blit_uTexMain( 0 ); + shader_blit_uInverseRatio( inverse ); render_fb_bind_texture( gpipeline.fb_main, 0, 0 ); } @@ -480,13 +501,13 @@ VG_STATIC void render_player_transparent(void) /* Draw player to window buffer and blend background ontop */ glBindFramebuffer( GL_FRAMEBUFFER, 0 ); + glViewport( 0,0, vg.window_x, vg.window_y ); player__render( &small_cam, &localplayer ); } VG_STATIC void render_scene(void) { - render_fb_bind( gpipeline.fb_main ); - glViewport( 0,0, g_render_x, g_render_y ); + render_fb_bind( gpipeline.fb_main, 1 ); glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT ); @@ -503,10 +524,8 @@ VG_STATIC void render_scene(void) render_world( view_world, &main_camera, 0 ); - render_water_texture( view_world, &main_camera, 0 ); - render_fb_bind( gpipeline.fb_main ); - glViewport( 0,0, g_render_x, g_render_y ); + render_fb_bind( gpipeline.fb_main, 1 ); render_water_surface( view_world, &main_camera ); int depth = 1; @@ -588,11 +607,7 @@ VG_STATIC void vg_render(void) { glBindFramebuffer( GL_FRAMEBUFFER, 0 ); - float scale = (sin(vg.time)*0.5f+0.5f)*0.75f+0.25f; - g_render_x = VG_MAX((float)vg.window_x * scale,64), - g_render_y = VG_MAX((float)vg.window_y * scale,64); - - glViewport( 0,0, g_render_x, g_render_y ); + glViewport( 0,0, vg.window_x, vg.window_y ); glDisable( GL_DEPTH_TEST ); glClearColor( 1.0f, 0.0f, 0.0f, 0.0f ); @@ -609,7 +624,6 @@ 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) { #if 0 @@ -617,98 +631,6 @@ VG_STATIC void vg_ui(void) #endif world_instance *world = get_active_world(); menu_crap_ui(); - -#if 0 - if( cl_light_edit ) - { - 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 - s5 = { .min=0.0f, .max=2.0f, .len=3, .data=wl->g_ambient_colour }; - - struct ui_slider - s8 = { .min=0.0f, .max=2.0f, .data = &gpipeline.shadow_spread }, - s9 = { .min=0.0f, .max=25.0f, .data = &gpipeline.shadow_length }; - - for( int i=0; i<3; i++ ) - run_light_widget( &gpipeline.widgets[i] ); - - 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( &c1 ); - - render_update_lighting_ub(); - } -#endif - audio_debug_soundscapes(); render_view_framebuffer_ui(); - -#if 0 - player_physics_gui(); -#endif -} - -VG_STATIC void run_light_widget( struct light_widget *lw ) -{ - struct ui_checkbox c1 = { .data=&lw->enabled }; - - ui_checkbox( &c1 ); - - if( lw->enabled ) - { - struct ui_slider_vector - 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( &colour ); - vg_uictx.cursor[1] += 4; - ui_slider_vector( &dir ); - } -} - -VG_STATIC void run_debug_info(void) -{ -#if 0 - char buf[40]; - - snprintf( buf, 40, "%.2fm/s", v3_length( player.rb.v ) ); - ui_text( (ui_px [2]){ 0, 0 }, buf, 1, k_text_align_left ); - - snprintf( buf, 40, "%.2f %.2f %.2f m/s", - player.phys.a[0], player.phys.a[1], player.phys.a[2] ); - ui_text( (ui_px [2]){ 0, 20 }, buf, 1, k_text_align_left ); - - snprintf( buf, 40, "pos %.2f %.2f %.2f", - player.phys.rb.co[0], player.phys.rb.co[1], player.phys.rb.co[2] ); - ui_text( (ui_px [2]){ 0, 40 }, buf, 1, k_text_align_left ); - - if( vg_input.controller_handle ) - { - for( int i=0; i