X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=main.c;h=6e61fa25cbf6b5f259f08c116270b84f2bed491c;hb=4fe5ceb89da36e746227675b8928e9d74cc18f95;hp=81584dd5b0b97800e2ca20f9f6459428e776620f;hpb=d13f2700b1773551307685cc7c34c804ccd6d664;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/main.c b/main.c index 81584dd..6e61fa2 100644 --- a/main.c +++ b/main.c @@ -26,11 +26,13 @@ #include "audio.h" #include "world.h" #include "player.h" +#include "network.h" -static int cl_ui = 1; +static int cl_ui = 1, + cl_menu = 0; int main( int argc, char *argv[] ) -{ +{ vg_enter( argc, argv, "Voyager Game Engine" ); } @@ -50,13 +52,13 @@ void vg_preload(void) .persistent = 1 }); -vg_info(" Copyright . . . -----, ,----- ,---. .---. " ); -vg_info(" 2021-2022 |\\ /| | / | | | | /| " ); -vg_info(" | \\ / | +-- / +----- +---' | / | " ); -vg_info(" | \\ / | | / | | \\ | / | " ); -vg_info(" | \\/ | | / | | \\ | / | " ); +vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" ); +vg_info(" 2021-2022 |\\ /| | / | | | | /| \n" ); +vg_info(" | \\ / | +-- / +----- +---' | / | \n" ); +vg_info(" | \\ / | | / | | \\ | / | \n" ); +vg_info(" | \\/ | | / | | \\ | / | \n" ); vg_info(" ' ' '--' [] '----- '----- ' ' '---' " - "SOFTWARE" ); + "SOFTWARE\n" ); highscores_init( 2000, 50 ); vg_loader_highwater( NULL, highscores_save_at_exit, NULL ); @@ -106,9 +108,30 @@ void vg_update( int loaded ) { draw_origin_axis(); network_update(); - player_update(); + player_update_pre(); world_update( player.phys.rb.co ); } + + if( vg_get_button_down( "menu" ) ) + { + cl_menu = !cl_menu; + } +} + +static void vg_update_fixed( int loaded ) +{ + if( loaded ) + { + player_update_fixed(); + } +} + +static void vg_update_post( int loaded ) +{ + if( loaded ) + { + player_update_post(); + } } static void vg_framebuffer_resize( int w, int h ) @@ -120,23 +143,19 @@ static void vg_framebuffer_resize( int w, int h ) static void render_main_game(void) { - /* TODO Breakup this & Gen */ -#if 0 - float speed = freecam? 0.0f: v3_length( player.phys.rb.v ); - v3f shake = { vg_randf()-0.5f, vg_randf()-0.5f, vg_randf()-0.5f }; - v3_muls( shake, speed*0.01f, shake ); -#endif - m4x4f world_4x4; m4x3_expand( player.camera_inverse, world_4x4 ); - gpipeline.fov = freecam? 60.0f: 125.0f; /* 120 */ - m4x4_projection( vg_pv, gpipeline.fov, - (float)vg_window_x / (float)vg_window_y, - 0.02f, 2100.0f ); + static float fov = 97.0f; + float fov_target = player.phys.on_board? 125.0f: 108.0f; + fov = vg_lerpf( fov, fov_target, vg.time_delta * 2.0f ); - m4x4_mul( vg_pv, world_4x4, vg_pv ); + gpipeline.fov = freecam? 60.0f: fov; /* 120 */ + m4x4_projection( vg.pv, gpipeline.fov, + (float)vg.window_x / (float)vg.window_y, + 0.02f, 2100.0f ); + m4x4_mul( vg.pv, world_4x4, vg.pv ); glEnable( GL_DEPTH_TEST ); /* @@ -145,21 +164,21 @@ static void render_main_game(void) int draw_solid = player.is_dead | freecam; - render_world( vg_pv, player.camera ); + render_world( vg.pv, player.camera ); if( draw_solid ) draw_player(); render_water_texture( player.camera ); glBindFramebuffer( GL_FRAMEBUFFER, 0 ); - render_water_surface( vg_pv, player.camera ); + render_water_surface( vg.pv, player.camera ); - render_world_gates( vg_pv, player.phys.rb.co, player.camera ); + render_world_gates( vg.pv, player.phys.rb.co, player.camera ); /* Copy the RGB of what we have into the background buffer */ glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 ); glBindFramebuffer( GL_DRAW_FRAMEBUFFER, gpipeline.fb_background ); - glBlitFramebuffer( 0,0, vg_window_x, vg_window_y, - 0,0, vg_window_x, vg_window_y, + glBlitFramebuffer( 0,0, vg.window_x, vg.window_y, + 0,0, vg.window_x, vg.window_y, GL_COLOR_BUFFER_BIT, GL_LINEAR ); @@ -174,10 +193,10 @@ static void render_main_game(void) if( !draw_solid ) { - m4x4_projection( vg_pv, gpipeline.fov, - (float)vg_window_x / (float)vg_window_y, + m4x4_projection( vg.pv, gpipeline.fov, + (float)vg.window_x / (float)vg.window_y, 0.01f, 600.0f ); - m4x4_mul( vg_pv, world_4x4, vg_pv ); + m4x4_mul( vg.pv, world_4x4, vg.pv ); draw_player(); } @@ -202,7 +221,7 @@ static void render_main_game(void) void vg_render(void) { glBindFramebuffer( GL_FRAMEBUFFER, 0 ); - glViewport( 0,0, vg_window_x, vg_window_y ); + glViewport( 0,0, vg.window_x, vg.window_y ); glDisable( GL_DEPTH_TEST ); glClearColor( 0.11f, 0.35f, 0.37f, 1.0f ); @@ -214,12 +233,45 @@ void vg_render(void) /* Other shite */ glDisable(GL_BLEND); glDisable( GL_DEPTH_TEST ); - vg_lines_drawall( (float *)vg_pv ); - glViewport( 0,0, vg_window_x, vg_window_y ); + vg_lines_drawall( (float *)vg.pv ); + glViewport( 0,0, vg.window_x, vg.window_y ); } void vg_ui(void) { + if( cl_menu ) + { + ui_rect menu = + { + vg.window_x / 2 - 150, + vg.window_y / 2 - 50, + 300, + 130 + }; + + ui_fill_rect( &ui_global_ctx, menu, 0xa0000000 ); + + ui_text( &ui_global_ctx, (ui_rect){ menu[0]+menu[2]/2,menu[1]+6, 0, 0 }, + steam_username_at_startup, + 1, k_text_align_center ); + menu[1] += 24; + menu[3] -= 30; + + ui_rect_pad( menu, 8 ); + ui_fill_rect( &ui_global_ctx, menu, 0x90ffffff ); + ui_rect_pad( menu, 2 ); + ui_fill_rect( &ui_global_ctx, menu, 0xa0000000 ); + + menu[1] += 32; + ui_text( &ui_global_ctx, (ui_rect){ menu[0]+menu[2]/2,menu[1], 0, 0 }, + "Exit", 2, k_text_align_center ); + + if( vg_get_button_down( "jump" ) ) + { + glfwSetWindowShouldClose( vg.window, 1 ); + } + } + #if 0 if( lightedit ) {