};
audio_clip audio_splash =
-{ .path = "sound/splash.ogg" };
+{ .path = "sound/splash.ogg", k_audio_source_compressed };
audio_clip audio_jumps[] = {
{ .path = "sound/jump0.ogg" },
audio_clip audio_ambience[] =
{
- { .path="sound/town_generic.ogg" }
+ { .path="sound/town_generic.ogg", k_audio_source_compressed }
};
audio_clip audio_gate_pass = {
};
audio_clip audio_rewind[] = {
-{ .path = "sound/rewind_start.ogg" },
-{ .path = "sound/rewind_end_1.5.ogg" },
-{ .path = "sound/rewind_end_2.5.ogg" },
-{ .path = "sound/rewind_end_6.5.ogg" },
-{ .path = "sound/rewind_clack.ogg" },
+{ .path = "sound/rewind_start.ogg", k_audio_source_compressed },
+{ .path = "sound/rewind_end_1.5.ogg", k_audio_source_compressed },
+{ .path = "sound/rewind_end_2.5.ogg", k_audio_source_compressed },
+{ .path = "sound/rewind_end_6.5.ogg", k_audio_source_compressed },
+{ .path = "sound/rewind_clack.ogg", k_audio_source_compressed },
};
audio_clip audio_ui[] = {
_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
./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/
+ #cp ./sound_src/* ./bin/content/sound/
;;
all)
#define VG_3D
#define VG_STATIC static
+//#define VG_STATIC
//#define VG_MINIMAL_TEST
#ifndef VG_MINIMAL_TEST
vg_loader_highwater( NULL, highscores_save_at_exit, NULL );
- vg_sleep_ms(200);
+ //vg_sleep_ms(200);
steam_init();
vg_loader_highwater( NULL, steam_end, NULL );
vg_loader_highwater( audio_init, audio_free, NULL );
/* 'systems' are completely loaded now */
- world_load( "models/mp_dev.mdl" );
+ strcpy( world.world_name, "models/mp_dev.mdl" );
+ world_load();
vg_console_load_autos();
}
glDeleteVertexArrays( 1, &mesh->vao );
glDeleteBuffers( 1, &mesh->ebo );
glDeleteBuffers( 1, &mesh->vbo );
+ mesh->loaded = 0;
}
}
{
double delta = world.time - world.last_use;
- if( delta <= RESET_MAX_TIME )
+ if( (delta <= RESET_MAX_TIME) && (world.last_use != 0.0) )
{
player.rewinding = 1;
player.rewind_sound_wait = 1;
float horizontal = vg_get_axis("horizontal"),
vertical = vg_get_axis("vertical");
- if( (phys->rb.co[1] < 0.0f) && !player.is_dead )
+ if( world.water.enabled )
{
- audio_lock();
- audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
- audio_player_set_position( &audio_player_extra, phys->rb.co );
- audio_player_set_vol( &audio_player_extra, 20.0f );
- audio_player_playclip( &audio_player_extra, &audio_splash );
- audio_unlock();
-
- player_kill();
+ if( (phys->rb.co[1] < 0.0f) && !player.is_dead )
+ {
+ audio_lock();
+ audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
+ audio_player_set_position( &audio_player_extra, phys->rb.co );
+ audio_player_set_vol( &audio_player_extra, 20.0f );
+ audio_player_playclip( &audio_player_extra, &audio_splash );
+ audio_unlock();
+
+ player_kill();
+ }
}
if( phys->on_board )
pscene->max_vertices = max_verts;
pscene->max_indices = max_indices;
- pscene->submesh.indice_start = 0;
- pscene->submesh.indice_count = 0;
+ memset( &pscene->submesh, 0, sizeof(mdl_submesh) );
v3_fill( pscene->bbx[0], 999999.9f );
v3_fill( pscene->bbx[1], -999999.9f );
u32 indices_head;
u32 vertex_head;
- float last_notch;
-
struct route_ui_segment
{
float length;
v3f render_gate_pos;
int active_route_board;
+ /* This is a small flag we use to changelevel.
+ * It will not be cleared until all sounds stop playing
+ */
+ int switching_to_new_world;
+ char world_name[ 64 ];
+
/*
* Dynamically allocated when world_load is called.
*
* -----------------------------------------------------------------------------
*/
+VG_STATIC int world_stop_sound( int argc, const char *argv[] )
+{
+ /*
+ * None of our world audio runs as one shots, they always have a player.
+ * Therefore it is safe to delete clip data after the players are
+ * disconnected
+ */
+ audio_lock();
+ for( int i=0; i<world.audio_things_count; i++ )
+ {
+ struct world_audio_thing *at = &world.audio_things[i];
+
+ if( audio_player_is_playing( &at->player ) )
+ {
+ u32 cflags = audio_player_get_flags( &at->player );
+ audio_player_set_flags( &at->player, cflags | AUDIO_FLAG_KILL );
+ }
+ }
+ audio_unlock();
+
+ return 0;
+}
+
+VG_STATIC int world_change_world( int argc, const char *argv[] )
+{
+ if( argc == 0 )
+ {
+ vg_info( "%s\n", world.world_name );
+ return 0;
+ }
+ else
+ {
+ vg_info( "Switching world...\n" );
+ strcpy( world.world_name, argv[0] );
+ world.switching_to_new_world = 1;
+ world_stop_sound( 0, NULL );
+ }
+
+ return 0;
+}
+
VG_STATIC void world_init(void)
{
vg_convar_push( (struct vg_convar){
.persistent = 0
});
+ vg_function_push( (struct vg_cmd)
+ {
+ .name = "world_stop_sound",
+ .function = world_stop_sound
+ });
+
+ vg_function_push( (struct vg_cmd)
+ {
+ .name = "world",
+ .function = world_change_world
+ });
+
world.sky_rate = 1.0;
world.sky_target_rate = 1.0;
/* Allocate dynamic world memory arena */
u32 max_size = 72*1024*1024;
world.dynamic_vgl = vg_create_linear_allocator( vg_mem.rtmemory, max_size );
+ for( u32 i=0; i<72*1024*1024; i++ )
+ ((u8 *)world.dynamic_vgl)[i] = 0xfe;
}
VG_STATIC void world_update( v3f pos )
{
+ if( world.switching_to_new_world )
+ {
+ int all_stopped = 1;
+
+ audio_lock();
+ for( int i=0; i<world.audio_things_count; i++ )
+ {
+ struct world_audio_thing *at = &world.audio_things[i];
+
+ if( audio_player_is_playing( &at->player ) )
+ {
+ all_stopped = 0;
+ break;
+ }
+ }
+ audio_unlock();
+
+ if( all_stopped )
+ {
+ world.switching_to_new_world = 0;
+ world_unload();
+ world_load();
+ }
+ }
+
+
world.sky_time += world.sky_rate * vg.time_delta;
world.sky_rate = vg_lerp( world.sky_rate, world.sky_target_rate,
vg.time_delta * 5.0 );
#include "world.h"
/* load world TODO: Put back vg back in loading state while this happens */
-VG_STATIC void world_load( const char *mdl_file );
-
+VG_STATIC void world_load(void);
VG_STATIC void world_add_all_if_material( m4x3f transform, scene *pscene,
ortho[3][3] = 1.0f;
m4x3_identity( camera );
- glViewport( 0, 0, 1024, 1024 );
glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
+ glDisable(GL_CULL_FACE);
glBindFramebuffer( GL_FRAMEBUFFER, gpipeline.fb_depthmap );
+ glViewport( 0, 0, 1024, 1024 );
shader_fscolour_use();
shader_fscolour_uColour( (v4f){-9999.0f,-9999.0f,-9999.0f,-9999.0f} );
render_fsquad();
+ /* todo: hmm?? */
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_MAX);
mesh_free( &world.mesh_route_lines );
mesh_free( &world.mesh_water );
+ world.time = 0.0;
+ world.rewind_from = 0.0;
+ world.rewind_to = 0.0;
+ world.last_use = 0.0;
+ world.active_gate = 0;
+ world.current_run_version = 2;
+ world.active_route_board = 0;
+ v3_zero( world.render_gate_pos );
+
+ for( int i=0; i<vg_list_size(world.ui_bars); i++ )
+ {
+ struct route_ui_bar *uib = &world.ui_bars[i];
+ uib->segment_start = 0;
+ uib->segment_count = 0;
+ uib->fade_start = 0;
+ uib->fade_count = 0;
+ uib->fade_timer_start = 0.0;
+ uib->xpos = 0.0f;
+ }
+
/* delete the entire block of memory */
+ memset( world.dynamic_vgl, 0xff, 72*1024*1024 );
+
vg_linear_clear( world.dynamic_vgl );
+ for( u32 i=0; i<72*1024*1024; i++ )
+ ((u8 *)world.dynamic_vgl)[i] = 0xff^i;
+
/* clean dangling pointers */
world.meta = NULL;
world.water.enabled = 0;
}
-VG_STATIC void world_load( const char *mdl_file )
+VG_STATIC void world_load(void)
{
world_unload();
- world.meta = mdl_load_full( world.dynamic_vgl, mdl_file );
- vg_info( "Loading world: %s\n", mdl_file );
+ world.meta = mdl_load_full( world.dynamic_vgl, world.world_name );
+ vg_info( "Loading world: %s\n", world.world_name );
/* dynamic allocations */
world_ents_allocate();
VG_STATIC void world_routes_ui_newseg( u32 route )
{
struct route_ui_bar *pui = &world.ui_bars[route];
-
- pui->last_notch = 0.0;
glBindVertexArray( pui->vao );
if( pui->segment_count )
pui->vertex_head = k_route_ui_max_verts - 200;
pui->segment_start = 0;
pui->segment_count = 0;
- pui->last_notch = 0.0;
pui->fade_start = 0;
pui->fade_count = 0;
pui->fade_timer_start = 0.0;