!*.txt
!*.tga
!*.vdf
+!*.qoi
--- /dev/null
+#include "vg/vg_platform.h"
+#include "vg/vg_log.h"
+#include "vg/vg_opt.h"
+#include "vg/vg_build.h"
+
+/*
+ * c build.c --release --clang
+ * c build.c --clang -p
+ * c build.c --file=game -rc --clang --play
+ */
+
+int compiled_something = 0;
+
+void build_server( enum compiler compiler )
+{
+ vg_build_start( "skaterift_server", compiler );
+ vg_build_object( "server.c " );
+ vg_build_link( "-pthread -lm -lsdkencryptedappticket -lsteam_api " );
+ vg_build_library_dir( "-L./vg/dep/steam " );
+
+ vg_build_bin_dependency_file( "vg/dep/steam/steamclient.so" );
+ vg_build_bin_dependency_file( "vg/dep/steam/libsteam_api.so" );
+ vg_build_bin_dependency_file( "vg/dep/steam/libsdkencryptedappticket.so" );
+
+ vg_build();
+ compiled_something = 1;
+}
+
+void build_game( enum compiler compiler )
+{
+ vg_build_start( "skaterift", compiler );
+ vg_build_object( "skaterift.c " );
+ vg_build_add_link_for_graphics();
+ vg_build_add_link_for_game();
+
+ vg_build_copy_graphics_dependencies();
+ vg_build_copy_game_dependencies();
+
+ vg_build_symbolic_link( "textures_src", "textures" );
+ vg_build_symbolic_link( "models_src", "models" );
+ vg_build_symbolic_link( "sound_src", "sound" );
+ vg_build_syscall( "mkdir -p %s/cfg", vg_compiler.build_dir );
+
+ vg_build_miniaudio();
+ vg_build();
+ compiled_something = 1;
+}
+
+int main( int argc, char *argv[] )
+{
+ time_t uid = time(NULL);
+
+ char *arg;
+ while( vg_argp( argc, argv ) )
+ {
+ if( vg_long_opt( "debug" ) || vg_opt( 'd' ) )
+ vg_build_mode_debug();
+
+ if( vg_long_opt( "release" ) || vg_opt( 'r' ) )
+ vg_build_mode_release();
+
+ if( vg_long_opt( "clang-server" ) )
+ build_server( k_compiler_clang );
+
+ if( vg_long_opt( "clang" ) )
+ build_game( k_compiler_clang );
+
+ if( vg_long_opt( "gcc" ) )
+ build_game( k_compiler_gcc );
+
+ if( vg_long_opt( "mingw" ) )
+ build_game( k_compiler_mingw );
+
+ if( vg_long_opt( "tar" ) || vg_opt( 't' ) )
+ {
+ vg_build_syscall( "mkdir -p dist" );
+ if( compiled_something )
+ vg_build_syscall( "tar -chzvf dist/%s-%u.tar.gz %s",
+ vg_compiler.name, uid, vg_compiler.build_dir );
+ }
+
+ if( vg_long_opt( "zip" ) || vg_opt( 'z' ) )
+ {
+ vg_build_syscall( "mkdir -p dist" );
+ if( compiled_something )
+ vg_build_syscall( "zip -r9 dist/%s-%u.zip %s",
+ vg_compiler.name, uid, vg_compiler.build_dir );
+ }
+ }
+}
-#!/bin/bash
-#
-# Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
-#
-# Main cross-compiling build script for Skate Rift
-# Supports Linux and Windows building from a Linux Host
-#
-# vg must be "ln -s"'d into this src folder as the only dependency
-#
-# Compiler Presets
-# ==============================================================================
-
-_linux_compiler="clang -std=gnu99 -D_REENTRANT"
-_linux_linkgraphics="-lGL -lglfw3 -lX11 -lXxf86vm -lXrandr -lm -pthread -lXi -ldl"
-_linux_asan="-fsanitize=address"
-_linux_linksteam="-lsteam_api"
-_linux_folder="bin/linux"
-_linux_server_folder="bin/linux_server"
-
-_windows_compiler="i686-w64-mingw32-gcc"
-_windows_linkgraphics="-lglfw3dll -lopengl32 -lm -pthread -static -mwindows"
-_windows_asan=""
-_windows_linksteam="vg/dep/steam/steam_api.dll"
-_windows_folder="bin/win32"
-
-_options_debugmode="-O0 -ggdb3 -fno-omit-frame-pointer -rdynamic"
-_options_release="-O3 -DVG_RELEASE"
-
-# Compiler lines
-# ==============================================================================
-
-_warnings="-Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unused-but-set-variable"
-_include="-I. -I./vg/dep -I./vg/src"
-_library="-L. -L./vg/dep/glfw -L./vg/dep/steam"
-_epilogue="-Wl,-rpath=./"
-_ext=""
-
-# Compile scripts
-# ==============================================================================
-
-compile_miniaudio(){
-
- temp_options=$_options
- _options="-O3"
-
- _link="-lm"
- _folder="."
- _src="-c vg/dep/dr_soft/miniaudio_impl.c"
- _dst="vg/dep/dr_soft/miniaudio_$1"
- _ext=".o"
- compile_x
-
- _options=$temp_options
-}
-
-# Again, these are not cross platform currently
-# TODO
-run_game(){
- cd $_linux_folder
- ./skaterift --samples=4
- cd ./../
-}
-
-run_server(){
- cd $_linux_server_folder
- ./skaterift_server
- cd ./../
-}
-
-delay_run_game(){
- sleep 2
- run_game
-}
-
-link_content(){
- unlink $1/textures
- unlink $1/models
- unlink $1/sound
-
- ln -srf bin/content/textures $1/textures
- ln -srf bin/content/models $1/models
- ln -srf bin/content/sound $1/sound
-}
-
-TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S`
-
-vg_command(){
- case "$1" in
- release)
- _linux_options=$_options_release
- _windows_options=$_options_release
- ;;
- debug)
- _linux_options="$_linux_asan $_options_debugmode"
- _windows_options="$_windows_asan $_options_debugmode"
- ;;
- ltools)
- _compiler=$_linux_compiler
- _options=$_linux_options
- _folder=$_linux_folder
- _ext=""
- vg_compile_tools
-
- ;;
- game)
- titleit "Creating Linux build"
- mkdir -p $_linux_folder/cfg
-
- # Dependencies
- cp vg/dep/steam/libsteam_api.so $_linux_folder
- link_content $_linux_folder
-
- _compiler=$_linux_compiler
- _options=$_linux_options
-
- compile_miniaudio linux
-
- # Game tools
- _folder=$_linux_folder
- _ext=""
- vg_compile_tools
-
- # Main build
- _link="$_linux_linkgraphics $_linux_linksteam"
- _src="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_linux.o"
- _dst="skaterift"
- compile_x
- ;;
- game_win)
- titleit "Creating Windows build"
- mkdir -p $_windows_folder/cfg
-
- # Dependencies
- cp vg/dep/steam/steam_api.dll $_windows_folder
- link_content $_windows_folder
-
- _compiler=$_windows_compiler
- _options=$_windows_options
-
- compile_miniaudio windows
-
- # Game tools
- _ext=".exe"
- _folder=$_windows_folder
- vg_compile_tools
-
- # Main build
- _link="$_windows_linkgraphics $_windows_linksteam"
- _src="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_windows.o"
- _dst="skaterift"
- compile_x
- ;;
- server)
- titleit "Creating Server build"
- mkdir -p $_linux_server_folder/cfg
-
- # Dependencies
- cp vg/dep/steam/steamclient.so bin/linux_server/
- cp vg/dep/steam/libsteam_api.so bin/linux_server/
- cp vg/dep/steam/libsdkencryptedappticket.so bin/linux_server/
-
- _compiler=$_linux_compiler
- _options=$_linux_options
- _link="-pthread -lm -lsdkencryptedappticket $_linux_linksteam"
- _src="server.c"
- _folder=$_linux_server_folder
- _dst="skaterift_server"
- _ext=""
-
- compile_x
- ;;
- testaa)
- titleit "Dev"
- mkdir -p bin/aatest/cfg
-
- _compiler=$_linux_compiler
- _options=$_linux_options
- _link="-lm"
- _src="testaa.c"
- _folder=bin/aatest
- _dst="testaa"
- _ext=""
-
- compile_x
- ;;
-
- #TODO: These are not cross platform in the build script, a full build
- # from source is therefore not possible on windows, only a linux
- # host can do that.
- textures)
- titleit "Compiling textures"
- mkdir -p ./bin/content/textures
- for f in ./textures_src/*.png;
- do logit " qoiconv: $f";
- dest=./bin/content/textures/"$(basename "$f" .png).qoi"
- ./bin/linux/tools/qoiconv $f $dest
- done
- ;;
- sounds)
- titleit "Compiling sounds"
- mkdir -p ./bin/content/textures
-
- for f in ./sound_src/*.wav
- do
- dest=./bin/content/sounds/"$(basename "$f" .wav).44100.ima_adpcm"
- ./bin/linux/tools/audcomp $f $dest
- done
- ;;
-
- content)
- logit "Copying content"
- mkdir -p ./bin/content/models
- mkdir -p ./bin/content/sound
-
- cp ./models_src/* ./bin/content/models/
- cp ./sound_src/* ./bin/content/sound/
- ;;
-
- all)
- run_command tools
- run_command game
- run_command server
- ;;
- disb)
- mkdir -p ./dist
- run_command release
- run_command tools
- run_command game
- run_command game_win
- run_command content
- run_command textures
- run_command server
- ;;
-
- distribution)
- titleit "Compressing distributions"
- logit "Linux"
- tar -chzvf dist/skaterift_linux__$TIMESTAMP.tar.gz bin/linux/
- logit "Server"
- tar -chzvf dist/skaterift_server__$TIMESTAMP.tar.gz bin/linux_server
- logit "Windows"
- tar -chzvf dist/skaterift_win32__$TIMESTAMP.tar.gz bin/win32/
- zip -r9 dist/skaterift_win32__$TIMESTAMP.zip bin/win32/
- ;;
- # Runners
- # ========================================================================
- test)
- run_game
- ;;
- gdb)
- cd $_linux_folder
- gdb -tui ./skaterift
- cd ./../
- ;;
- testserver)
- run_server
- ;;
- testnet)
- delay_run_game &
- run_server
- wait
- ;;
- aa)
- run_command testaa
- cd bin/aatest
- ./testaa
- cd ./../
- ;;
- *)
- echo "Unrecognised command $1"
- esac
-}
-
-lsan_file=$(realpath ".lsan_suppress.txt")
-export LSAN_OPTIONS="suppressions=$lsan_file"
-
-vg_command debug
-source vg/vg_build.sh
+clang -fsanitize=address -O0 -Ivg/src build.c -o /tmp/tmpsr && /tmp/tmpsr $@
+++ /dev/null
-/*
- * =============================================================================
- *
- * Copyright . . . -----, ,----- ,---. .---.
- * 2021-2022 |\ /| | / | | | | /|
- * | \ / | +-- / +----- +---' | / |
- * | \ / | | / | | \ | / |
- * | \/ | | / | | \ | / |
- * ' ' '--' [] '----- '----- ' ' '---' SOFTWARE
- *
- * =============================================================================
- *
- * register: shader register & init scheduling
- * init: initialization
- * update: logic
- * render: graphics
- * free: resource free
- *
- */
-
-#define VG_3D
-#define VG_STATIC static
-//#define VG_STATIC
-
-//#define VG_MINIMAL_TEST
-#ifndef VG_MINIMAL_TEST
-
-#define SR_NETWORKED
-
-#include "common.h"
-#include "steam.h"
-#include "render.h"
-#include "audio.h"
-#include "world.h"
-#include "player.h"
-#include "network.h"
-#include "menu.h"
-
-static int cl_ui = 1;
-
-int main( int argc, char *argv[] )
-{
- vg_mem.use_libc_malloc = 0;
- vg_set_mem_quota( 128*1024*1024 );
- vg_enter( argc, argv, "Voyager Game Engine" );
-}
-
-VG_STATIC void highscores_save_at_exit(void*_)
-{
- highscores_serialize_all();
-}
-
-VG_STATIC void vg_preload(void)
-{
-
- vg_convar_push( (struct vg_convar){
- .name = "cl_ui",
- .data = &cl_ui,
- .data_type = k_convar_dtype_i32,
- .opt_i32 = { .min=0, .max=1, .clamp=1 },
- .persistent = 1
- });
-
-vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
-vg_info(" 2021-2022 |\\ /| | / | | | | /| \n" );
-vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
-vg_info(" | \\ / | | / | | \\ | / | \n" );
-vg_info(" | \\/ | | / | | \\ | / | \n" );
-vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
- "SOFTWARE\n" );
-
- highscores_init( 2000, 50 );
- if( !highscores_read() )
- highscores_create_db();
-
- vg_loader_highwater( NULL, highscores_save_at_exit, NULL );
-
- //vg_sleep_ms(200);
-
- steam_init();
- vg_loader_highwater( NULL, steam_end, NULL );
- vg_loader_highwater( network_init, network_end, NULL );
-}
-
-VG_STATIC void vg_load(void)
-{
- vg_loader_highwater( render_init, NULL, NULL );
- vg_loader_highwater( menu_init, NULL, NULL );
- vg_loader_highwater( world_init, NULL, NULL );
- vg_loader_highwater( player_init, NULL, NULL );
-
- vg_bake_shaders();
- vg_loader_highwater( audio_init, audio_free, NULL );
- world_audio_init();
-
- /* 'systems' are completely loaded now */
- strcpy( world.world_name, "models/mp_dev.mdl" );
- world_load();
- vg_console_load_autos();
-}
-
-VG_STATIC void vg_start(void)
-{
- reset_player( 1, (const char *[]){ "start" } );
-}
-
-VG_STATIC void draw_origin_axis(void)
-{
- vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 1.0f, 0.0f, 0.0f }, 0xffff0000 );
- vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
- vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
-}
-
-VG_STATIC void vg_update( int loaded )
-{
- steam_update();
-
- if( loaded )
- {
- draw_origin_axis();
- network_update();
-
- player_update_pre();
- world_update( player.phys.rb.co );
- }
-}
-
-VG_STATIC void vg_update_fixed( int loaded )
-{
- if( loaded )
- {
- player_update_fixed();
- }
-}
-
-VG_STATIC void vg_update_post( int loaded )
-{
- if( loaded )
- {
- player_update_post();
- menu_update();
- }
-}
-
-VG_STATIC void vg_framebuffer_resize( int w, int h )
-{
- render_fb_resize();
- water_fb_resize();
-}
-
-VG_STATIC void render_main_game(void)
-{
- m4x4f world_4x4;
- m4x3_expand( camera_mtx_inverse, world_4x4 );
-
- static float fov = 97.0f;
-
- float fov_target = 108.0f;
- if( player.phys.on_board )
- fov_target = 125.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,
- (float)vg.window_x / (float)vg.window_y,
- 0.1f, 2100.0f );
-
- m4x4_mul( vg.pv, world_4x4, vg.pv );
- glEnable( GL_DEPTH_TEST );
-
- /*
- * Draw world
- */
-
- int draw_solid = player.is_dead | freecam;
-
- render_world( vg.pv, camera_mtx );
- if( draw_solid )
- draw_player( camera_mtx );
-
- render_water_texture( camera_mtx );
-
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- 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 );
- glBindFramebuffer( GL_DRAW_FRAMEBUFFER, gpipeline.fb_background );
- glBlitFramebuffer( 0,0, vg.window_x, vg.window_y,
- 0,0, vg.window_x, vg.window_y,
- GL_COLOR_BUFFER_BIT,
- GL_LINEAR );
-
- /* Clear out the colour buffer, but keep depth */
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
-
- if( !player.is_dead )
- glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
- else
- glClear( GL_COLOR_BUFFER_BIT );
-
- if( !draw_solid )
- {
- m4x4_projection( vg.pv, gpipeline.fov,
- (float)vg.window_x / (float)vg.window_y,
- 0.05f, 60.0f );
- m4x4_mul( vg.pv, world_4x4, vg.pv );
- draw_player( camera_mtx );
- }
-
- /* Draw back in the background
- *
- * TODO: need to disable alpha write in the terrain shader so this works
- * again.
- */
- glEnable(GL_BLEND);
- glDisable(GL_DEPTH_TEST);
- glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
- glBlendEquation(GL_FUNC_ADD);
-
- shader_blit_use();
- shader_blit_uTexMain( 0 );
- glActiveTexture(GL_TEXTURE0);
- glBindTexture( GL_TEXTURE_2D, gpipeline.rgb_background );
-
- render_fsquad();
-}
-
-VG_STATIC void vg_render(void)
-{
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glViewport( 0,0, vg.window_x, vg.window_y );
- glDisable( GL_DEPTH_TEST );
-
- glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
-
- render_main_game();
-
-
- /* 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_STATIC void vg_ui(void)
-{
-#if 0
- 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( lightedit )
- {
- ui_global_ctx.cursor[0] = 10;
- ui_global_ctx.cursor[1] = 10;
- ui_global_ctx.cursor[2] = 200;
- ui_global_ctx.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] );
-
- 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;
- struct ui_checkbox c1 = {.data = &wl->g_light_preview};
- ui_checkbox( &ui_global_ctx, &c1 );
-
- render_update_lighting_ub();
- }
-#endif
-
- //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
- if( cl_ui )
- {
- render_world_routes_ui();
- }
- //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-
- audio_debug_soundscapes();
-}
-
-#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 );
-
- 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( &ui_global_ctx, &colour );
- ui_global_ctx.cursor[1] += 4;
- ui_slider_vector( &ui_global_ctx, &dir );
- }
-}
-#endif
-
-VG_STATIC void run_debug_info(void)
-{
- char buf[40];
-
- snprintf( buf, 40, "%.2fm/s", v3_length( player.phys.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.gamepad_ready )
- {
- for( int i=0; i<6; i++ )
- {
- snprintf( buf, 40, "%.2f", vg.gamepad.axes[i] );
- ui_text( (ui_px [2]){ 0, (i+3)*20 }, buf, 1, k_text_align_left );
- }
- }
- else
- {
- ui_text( (ui_px [2]){ 0, 60 },
- "Gamepad not ready", 1, k_text_align_left );
- }
-}
-
-#else
-
-#define VG_TIMESTEP_FIXED (1.0/60.0)
-#define VG_3D
-#define VG_FRAMEBUFFER_RESIZE 1
-#include "vg/vg.h"
-
-int main( int argc, char *argv[] )
-{
- vg_prealloc_quota( 512*1024*1024 );
- vg_enter( argc, argv, "Voyager Game Engine" );
-}
-
-VG_STATIC void vg_preload(void)
-{
-vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
-vg_info(" 2021-2022 |\\ /| | / | | | | /| \n" );
-vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
-vg_info(" | \\ / | | / | | \\ | / | \n" );
-vg_info(" | \\/ | | / | | \\ | / | \n" );
-vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
- "SOFTWARE\n" );
-}
-
-VG_STATIC void vg_load(void)
-{
- vg_bake_shaders();
- vg_console_load_autos();
-}
-
-VG_STATIC void vg_start(void)
-{
-}
-
-VG_STATIC void vg_update( int loaded )
-{
-}
-
-VG_STATIC void vg_update_fixed( int loaded )
-{
-}
-
-VG_STATIC void vg_update_post( int loaded )
-{
-}
-
-VG_STATIC void vg_framebuffer_resize( int w, int h )
-{
-}
-
-VG_STATIC void vg_render(void)
-{
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glViewport( 0,0, vg.window_x, vg.window_y );
- glDisable( GL_DEPTH_TEST );
-
- glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
-
- /* 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_STATIC void vg_ui(void)
-{
-}
-
-#endif
--- /dev/null
+cd bin/skaterift-clang/
+./skaterift
+cd ../../
--- /dev/null
+/*
+ * =============================================================================
+ *
+ * Copyright . . . -----, ,----- ,---. .---.
+ * 2021-2022 |\ /| | / | | | | /|
+ * | \ / | +-- / +----- +---' | / |
+ * | \ / | | / | | \ | / |
+ * | \/ | | / | | \ | / |
+ * ' ' '--' [] '----- '----- ' ' '---' SOFTWARE
+ *
+ * =============================================================================
+ *
+ * register: shader register & init scheduling
+ * init: initialization
+ * update: logic
+ * render: graphics
+ * free: resource free
+ *
+ */
+
+#define VG_3D
+#define VG_STATIC static
+//#define VG_STATIC
+
+//#define VG_MINIMAL_TEST
+#ifndef VG_MINIMAL_TEST
+
+#define SR_NETWORKED
+
+#include "common.h"
+#include "steam.h"
+#include "render.h"
+#include "audio.h"
+#include "world.h"
+#include "player.h"
+#include "network.h"
+#include "menu.h"
+
+static int cl_ui = 1;
+
+int main( int argc, char *argv[] )
+{
+ vg_mem.use_libc_malloc = 0;
+ vg_set_mem_quota( 128*1024*1024 );
+ vg_enter( argc, argv, "Voyager Game Engine" );
+}
+
+VG_STATIC void highscores_save_at_exit(void*_)
+{
+ highscores_serialize_all();
+}
+
+VG_STATIC void vg_preload(void)
+{
+
+ vg_convar_push( (struct vg_convar){
+ .name = "cl_ui",
+ .data = &cl_ui,
+ .data_type = k_convar_dtype_i32,
+ .opt_i32 = { .min=0, .max=1, .clamp=1 },
+ .persistent = 1
+ });
+
+vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
+vg_info(" 2021-2022 |\\ /| | / | | | | /| \n" );
+vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
+vg_info(" | \\ / | | / | | \\ | / | \n" );
+vg_info(" | \\/ | | / | | \\ | / | \n" );
+vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
+ "SOFTWARE\n" );
+
+ highscores_init( 2000, 50 );
+ if( !highscores_read() )
+ highscores_create_db();
+
+ vg_loader_highwater( NULL, highscores_save_at_exit, NULL );
+
+ //vg_sleep_ms(200);
+
+ steam_init();
+ vg_loader_highwater( NULL, steam_end, NULL );
+ vg_loader_highwater( network_init, network_end, NULL );
+}
+
+VG_STATIC void vg_load(void)
+{
+ vg_loader_highwater( render_init, NULL, NULL );
+ vg_loader_highwater( menu_init, NULL, NULL );
+ vg_loader_highwater( world_init, NULL, NULL );
+ vg_loader_highwater( player_init, NULL, NULL );
+
+ vg_bake_shaders();
+ vg_loader_highwater( audio_init, audio_free, NULL );
+ world_audio_init();
+
+ /* 'systems' are completely loaded now */
+ strcpy( world.world_name, "models/mp_dev.mdl" );
+ world_load();
+ vg_console_load_autos();
+}
+
+VG_STATIC void vg_start(void)
+{
+ reset_player( 1, (const char *[]){ "start" } );
+}
+
+VG_STATIC void draw_origin_axis(void)
+{
+ vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 1.0f, 0.0f, 0.0f }, 0xffff0000 );
+ vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
+ vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
+}
+
+VG_STATIC void vg_update( int loaded )
+{
+ steam_update();
+
+ if( loaded )
+ {
+ draw_origin_axis();
+ network_update();
+
+ player_update_pre();
+ world_update( player.phys.rb.co );
+ }
+}
+
+VG_STATIC void vg_update_fixed( int loaded )
+{
+ if( loaded )
+ {
+ player_update_fixed();
+ }
+}
+
+VG_STATIC void vg_update_post( int loaded )
+{
+ if( loaded )
+ {
+ player_update_post();
+ menu_update();
+ }
+}
+
+VG_STATIC void vg_framebuffer_resize( int w, int h )
+{
+ render_fb_resize();
+ water_fb_resize();
+}
+
+VG_STATIC void render_main_game(void)
+{
+ m4x4f world_4x4;
+ m4x3_expand( camera_mtx_inverse, world_4x4 );
+
+ static float fov = 97.0f;
+
+ float fov_target = 108.0f;
+ if( player.phys.on_board )
+ fov_target = 125.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,
+ (float)vg.window_x / (float)vg.window_y,
+ 0.1f, 2100.0f );
+
+ m4x4_mul( vg.pv, world_4x4, vg.pv );
+ glEnable( GL_DEPTH_TEST );
+
+ /*
+ * Draw world
+ */
+
+ int draw_solid = player.is_dead | freecam;
+
+ render_world( vg.pv, camera_mtx );
+ if( draw_solid )
+ draw_player( camera_mtx );
+
+ render_water_texture( camera_mtx );
+
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ 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 );
+ glBindFramebuffer( GL_DRAW_FRAMEBUFFER, gpipeline.fb_background );
+ glBlitFramebuffer( 0,0, vg.window_x, vg.window_y,
+ 0,0, vg.window_x, vg.window_y,
+ GL_COLOR_BUFFER_BIT,
+ GL_LINEAR );
+
+ /* Clear out the colour buffer, but keep depth */
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
+
+ if( !player.is_dead )
+ glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
+ else
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ if( !draw_solid )
+ {
+ m4x4_projection( vg.pv, gpipeline.fov,
+ (float)vg.window_x / (float)vg.window_y,
+ 0.05f, 60.0f );
+ m4x4_mul( vg.pv, world_4x4, vg.pv );
+ draw_player( camera_mtx );
+ }
+
+ /* Draw back in the background
+ *
+ * TODO: need to disable alpha write in the terrain shader so this works
+ * again.
+ */
+ glEnable(GL_BLEND);
+ glDisable(GL_DEPTH_TEST);
+ glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
+ glBlendEquation(GL_FUNC_ADD);
+
+ shader_blit_use();
+ shader_blit_uTexMain( 0 );
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture( GL_TEXTURE_2D, gpipeline.rgb_background );
+
+ render_fsquad();
+}
+
+VG_STATIC void vg_render(void)
+{
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ glViewport( 0,0, vg.window_x, vg.window_y );
+ glDisable( GL_DEPTH_TEST );
+
+ glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
+
+ render_main_game();
+
+
+ /* 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_STATIC void vg_ui(void)
+{
+#if 0
+ 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( lightedit )
+ {
+ ui_global_ctx.cursor[0] = 10;
+ ui_global_ctx.cursor[1] = 10;
+ ui_global_ctx.cursor[2] = 200;
+ ui_global_ctx.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] );
+
+ 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;
+ struct ui_checkbox c1 = {.data = &wl->g_light_preview};
+ ui_checkbox( &ui_global_ctx, &c1 );
+
+ render_update_lighting_ub();
+ }
+#endif
+
+ //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
+ if( cl_ui )
+ {
+ render_world_routes_ui();
+ }
+ //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
+
+ audio_debug_soundscapes();
+}
+
+#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 );
+
+ 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( &ui_global_ctx, &colour );
+ ui_global_ctx.cursor[1] += 4;
+ ui_slider_vector( &ui_global_ctx, &dir );
+ }
+}
+#endif
+
+VG_STATIC void run_debug_info(void)
+{
+ char buf[40];
+
+ snprintf( buf, 40, "%.2fm/s", v3_length( player.phys.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.gamepad_ready )
+ {
+ for( int i=0; i<6; i++ )
+ {
+ snprintf( buf, 40, "%.2f", vg.gamepad.axes[i] );
+ ui_text( (ui_px [2]){ 0, (i+3)*20 }, buf, 1, k_text_align_left );
+ }
+ }
+ else
+ {
+ ui_text( (ui_px [2]){ 0, 60 },
+ "Gamepad not ready", 1, k_text_align_left );
+ }
+}
+
+#else
+
+#define VG_TIMESTEP_FIXED (1.0/60.0)
+#define VG_3D
+#define VG_FRAMEBUFFER_RESIZE 1
+#include "vg/vg.h"
+
+int main( int argc, char *argv[] )
+{
+ vg_prealloc_quota( 512*1024*1024 );
+ vg_enter( argc, argv, "Voyager Game Engine" );
+}
+
+VG_STATIC void vg_preload(void)
+{
+vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
+vg_info(" 2021-2022 |\\ /| | / | | | | /| \n" );
+vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
+vg_info(" | \\ / | | / | | \\ | / | \n" );
+vg_info(" | \\/ | | / | | \\ | / | \n" );
+vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
+ "SOFTWARE\n" );
+}
+
+VG_STATIC void vg_load(void)
+{
+ vg_bake_shaders();
+ vg_console_load_autos();
+}
+
+VG_STATIC void vg_start(void)
+{
+}
+
+VG_STATIC void vg_update( int loaded )
+{
+}
+
+VG_STATIC void vg_update_fixed( int loaded )
+{
+}
+
+VG_STATIC void vg_update_post( int loaded )
+{
+}
+
+VG_STATIC void vg_framebuffer_resize( int w, int h )
+{
+}
+
+VG_STATIC void vg_render(void)
+{
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ glViewport( 0,0, vg.window_x, vg.window_y );
+ glDisable( GL_DEPTH_TEST );
+
+ glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
+
+ /* 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_STATIC void vg_ui(void)
+{
+}
+
+#endif