From: hgn Date: Fri, 29 Sep 2023 12:33:33 +0000 (+0100) Subject: replace VG_STATIC -> static X-Git-Url: https://harrygodden.com/git/?p=vg.git;a=commitdiff_plain;h=76d234b7dc5e6500e8a54009b367e7620f11ef97 replace VG_STATIC -> static --- diff --git a/submodules/SDL_GameControllerDB b/submodules/SDL_GameControllerDB index 6ed8d05..c5b4df0 160000 --- a/submodules/SDL_GameControllerDB +++ b/submodules/SDL_GameControllerDB @@ -1 +1 @@ -Subproject commit 6ed8d054340ee8a93a684e11360b66cd8a5c168e +Subproject commit c5b4df0e1061175cb11e3ebbf8045178339864a5 diff --git a/submodules/anyascii b/submodules/anyascii index 44e971c..eb5332d 160000 --- a/submodules/anyascii +++ b/submodules/anyascii @@ -1 +1 @@ -Subproject commit 44e971c774d9ec67ca6c1f16c5a476724821ab63 +Subproject commit eb5332d0b5e48d58397e6f27475a18e058330d23 diff --git a/submodules/qoi b/submodules/qoi index b8d77df..dfc056e 160000 --- a/submodules/qoi +++ b/submodules/qoi @@ -1 +1 @@ -Subproject commit b8d77df1e80b652a57f0b7270449b179a6b91f40 +Subproject commit dfc056e813c98d307238d35f7f041a725d699dfc diff --git a/submodules/stb b/submodules/stb index 8b5f1f3..5736b15 160000 --- a/submodules/stb +++ b/submodules/stb @@ -1 +1 @@ -Subproject commit 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55 +Subproject commit 5736b15f7ea0ffb08dd38af21067c314d6a3aae9 diff --git a/vg.h b/vg.h index a89efaf..4b8956a 100644 --- a/vg.h +++ b/vg.h @@ -80,23 +80,23 @@ #endif /* API */ -VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ); +static void vg_enter( int argc, char *argv[], const char *window_name ); /* Thread 1 */ -VG_STATIC void vg_preload(void); -VG_STATIC void vg_load(void); +static void vg_preload(void); +static void vg_load(void); /* Main thread */ -VG_STATIC void vg_launch_opt(void); -VG_STATIC void vg_start(void); +static void vg_launch_opt(void); +static void vg_start(void); -VG_STATIC void vg_framebuffer_resize(int w, int h); -VG_STATIC void vg_pre_update(void); -VG_STATIC void vg_fixed_update(void); -VG_STATIC void vg_post_update(void); +static void vg_framebuffer_resize(int w, int h); +static void vg_pre_update(void); +static void vg_fixed_update(void); +static void vg_post_update(void); -VG_STATIC void vg_render(void); -VG_STATIC void vg_gui(void); +static void vg_render(void); +static void vg_gui(void); struct vg{ /* Engine sync */ @@ -174,7 +174,7 @@ struct vg{ float loader_ring; } -VG_STATIC vg = { .time_rate = 1.0 }; +static vg = { .time_rate = 1.0 }; const char *vg_get_basepath(void){ return vg.base_path; } @@ -188,7 +188,7 @@ enum vg_thread_purpose #include "vg_async.h" -VG_STATIC enum engine_status _vg_engine_status(void) +static enum engine_status _vg_engine_status(void) { SDL_AtomicLock( &vg.sl_status ); enum engine_status status = vg.engine_status; @@ -197,7 +197,7 @@ VG_STATIC enum engine_status _vg_engine_status(void) return status; } -VG_STATIC enum vg_thread_purpose vg_thread_purpose(void) +static enum vg_thread_purpose vg_thread_purpose(void) { SDL_AtomicLock( &vg.sl_status ); @@ -211,7 +211,7 @@ VG_STATIC enum vg_thread_purpose vg_thread_purpose(void) } } -VG_STATIC void vg_assert_thread( enum vg_thread_purpose required ){ +static void vg_assert_thread( enum vg_thread_purpose required ){ enum vg_thread_purpose purpose = vg_thread_purpose(); if( purpose != required ){ @@ -219,12 +219,12 @@ VG_STATIC void vg_assert_thread( enum vg_thread_purpose required ){ } } -VG_STATIC void _vg_opengl_sync_init(void) +static void _vg_opengl_sync_init(void) { vg.sem_loader = SDL_CreateSemaphore(1); } -VG_STATIC void vg_checkgl( const char *src_info ); +static void vg_checkgl( const char *src_info ); #define VG_STRINGIT( X ) #X #define VG_CHECK_GL_ERR() vg_checkgl( __FILE__ ":L" VG_STRINGIT(__LINE__) ) @@ -242,11 +242,11 @@ VG_STATIC void vg_checkgl( const char *src_info ); #include "vg_opt.h" /* Diagnostic */ -VG_STATIC struct vg_profile vg_prof_update = {.name="update()"}, +static struct vg_profile vg_prof_update = {.name="update()"}, vg_prof_render = {.name="render()"}, vg_prof_swap = {.name="swap"}; -VG_STATIC void vg_checkgl( const char *src_info ) +static void vg_checkgl( const char *src_info ) { int fail = 0; @@ -260,12 +260,12 @@ VG_STATIC void vg_checkgl( const char *src_info ) vg_fatal_error( "OpenGL Error" ); } -VG_STATIC void async_vg_bake_shaders( void *payload, u32 size ) +static void async_vg_bake_shaders( void *payload, u32 size ) { vg_shaders_compile(); } -VG_STATIC void vg_bake_shaders(void) +static void vg_bake_shaders(void) { vg_console_reg_cmd( "reload_shaders", vg_shaders_live_recompile, NULL ); vg_async_call( async_vg_bake_shaders, NULL, 0 ); @@ -287,7 +287,7 @@ void async_internal_complete( void *payload, u32 size ) SDL_AtomicUnlock( &vg.sl_status ); } -VG_STATIC void _vg_load_full( void *data ) +static void _vg_load_full( void *data ) { vg_preload(); @@ -305,7 +305,7 @@ VG_STATIC void _vg_load_full( void *data ) vg_load(); } -VG_STATIC void _vg_process_events(void) +static void _vg_process_events(void) { v2_zero( vg.mouse_wheel ); v2_zero( vg.mouse_delta ); @@ -393,7 +393,7 @@ VG_STATIC void _vg_process_events(void) vg.mouse_pos[1] += vg.mouse_delta[1]; } -VG_STATIC void _vg_gameloop_update(void) +static void _vg_gameloop_update(void) { vg_profile_begin( &vg_prof_update ); @@ -425,7 +425,7 @@ VG_STATIC void _vg_gameloop_update(void) vg_profile_end( &vg_prof_update ); } -VG_STATIC void _vg_gameloop_render(void) +static void _vg_gameloop_render(void) { vg_profile_begin( &vg_prof_render ); @@ -487,7 +487,7 @@ VG_STATIC void _vg_gameloop_render(void) vg_profile_end( &vg_prof_render ); } -VG_STATIC int vg_framefilter( double dt ) +static int vg_framefilter( double dt ) { if( (vg.fps_limit <= 0) && (vg.vsync_feature != k_vsync_feature_error) ){ /* turn on vsync if not enabled */ @@ -553,7 +553,7 @@ VG_STATIC int vg_framefilter( double dt ) return 0; } -VG_STATIC int _vg_crashscreen(void) +static int _vg_crashscreen(void) { #if 0 if( vg_getkey( SDLK_ESCAPE ) ) @@ -575,7 +575,7 @@ VG_STATIC int _vg_crashscreen(void) return 0; } -VG_STATIC void _vg_gameloop(void){ +static void _vg_gameloop(void){ //vg.time_fixed_accumulator = 0.75f * (1.0f/60.0f); vg.time_hp = SDL_GetPerformanceCounter(); @@ -635,7 +635,7 @@ VG_STATIC void _vg_gameloop(void){ } } -VG_STATIC void _vg_process_launch_opts_internal( int argc, char *argv[] ) +static void _vg_process_launch_opts_internal( int argc, char *argv[] ) { char *arg; while( vg_argp( argc, argv ) ){ @@ -663,7 +663,7 @@ VG_STATIC void _vg_process_launch_opts_internal( int argc, char *argv[] ) } } -VG_STATIC void _vg_init_window( const char *window_name ) +static void _vg_init_window( const char *window_name ) { vg_info( "SDL_INIT\n" ); @@ -816,7 +816,7 @@ VG_STATIC void _vg_init_window( const char *window_name ) #endif } -VG_STATIC void _vg_terminate(void) +static void _vg_terminate(void) { /* Shutdown */ _vg_console_write_persistent(); @@ -834,7 +834,7 @@ VG_STATIC void _vg_terminate(void) exit(0); } -VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) +static void vg_enter( int argc, char *argv[], const char *window_name ) { vg_rand_seed( 461 ); _vg_process_launch_opts_internal( argc, argv ); @@ -863,7 +863,7 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) _vg_terminate(); } -VG_STATIC void vg_fatal_error( const char *fmt, ... ) +static void vg_fatal_error( const char *fmt, ... ) { va_list args; va_start( args, fmt ); @@ -888,7 +888,7 @@ VG_STATIC void vg_fatal_error( const char *fmt, ... ) #else /* VG_GAME */ #include "vg_log.h" -VG_STATIC void vg_fatal_error( const char *fmt, ... ) +static void vg_fatal_error( const char *fmt, ... ) { va_list args; va_start( args, fmt ); diff --git a/vg_async.h b/vg_async.h index 825cad8..7537aae 100644 --- a/vg_async.h +++ b/vg_async.h @@ -9,7 +9,7 @@ #define VG_GAME #include "vg/vg.h" -VG_STATIC void vg_assert_thread( enum vg_thread_purpose required ); +static void vg_assert_thread( enum vg_thread_purpose required ); typedef struct vg_async_item vg_async_item; @@ -32,13 +32,13 @@ struct vg_async{ } static vg_async; -VG_STATIC enum vg_thread_purpose vg_thread_purpose(void); -VG_STATIC enum engine_status _vg_engine_status(void); +static enum vg_thread_purpose vg_thread_purpose(void); +static enum engine_status _vg_engine_status(void); /* * Allocate an asynchronous call with a bit of memory */ -VG_STATIC vg_async_item *vg_async_alloc( u32 size ) +static vg_async_item *vg_async_alloc( u32 size ) { /* ditch out here if engine crashed. this serves as the 'quit checking' */ if( _vg_engine_status() == k_engine_status_crashed ){ @@ -101,7 +101,7 @@ VG_STATIC vg_async_item *vg_async_alloc( u32 size ) /* * Wait until the current stack of async calls is completely flushed out */ -VG_STATIC void vg_async_stall(void) +static void vg_async_stall(void) { vg_assert_thread(k_thread_purpose_loader); vg_info( "async_stall: %d\n", SDL_SemValue( vg_async.sem_wait_for_flush ) ); @@ -111,7 +111,7 @@ VG_STATIC void vg_async_stall(void) /* * Mark the call as being filled and ready to go */ -VG_STATIC void vg_async_dispatch( vg_async_item *item, +static void vg_async_dispatch( vg_async_item *item, void (*runner)( void *payload, u32 size ) ) { vg_assert_thread(k_thread_purpose_loader); @@ -126,7 +126,7 @@ VG_STATIC void vg_async_dispatch( vg_async_item *item, /* * Make a simple async call without allocating extra. */ -VG_STATIC void vg_async_call( void (*runner)( void *payload, u32 size ), +static void vg_async_call( void (*runner)( void *payload, u32 size ), void *payload, u32 size ) { vg_assert_thread(k_thread_purpose_loader); @@ -139,7 +139,7 @@ VG_STATIC void vg_async_call( void (*runner)( void *payload, u32 size ), /* * Run as much of the async buffer as possible */ -VG_STATIC void vg_run_async_checked(void) +static void vg_run_async_checked(void) { SDL_AtomicLock( &vg_async.sl_index ); @@ -175,7 +175,7 @@ VG_STATIC void vg_run_async_checked(void) SDL_AtomicUnlock( &vg_async.sl_index ); } -VG_STATIC void vg_async_init(void) +static void vg_async_init(void) { vg_async.sem_wait_for_flush = SDL_CreateSemaphore(0); vg_async.buffer = vg_create_linear_allocator( NULL, 50*1024*1024, diff --git a/vg_audio.h b/vg_audio.h index b0c4823..39f494f 100644 --- a/vg_audio.h +++ b/vg_audio.h @@ -223,7 +223,7 @@ static struct vg_profile * These functions are called from the main thread and used to prevent bad * access. TODO: They should be no-ops in release builds. */ -VG_STATIC int audio_lock_checker_load(void) +static int audio_lock_checker_load(void) { int value; SDL_AtomicLock( &vg_audio.sl_checker ); @@ -232,14 +232,14 @@ VG_STATIC int audio_lock_checker_load(void) return value; } -VG_STATIC void audio_lock_checker_store( int value ) +static void audio_lock_checker_store( int value ) { SDL_AtomicLock( &vg_audio.sl_checker ); vg_audio.sync_locked = value; SDL_AtomicUnlock( &vg_audio.sl_checker ); } -VG_STATIC void audio_require_lock(void) +static void audio_require_lock(void) { if( audio_lock_checker_load() ) return; @@ -248,20 +248,20 @@ VG_STATIC void audio_require_lock(void) abort(); } -VG_STATIC void audio_lock(void) +static void audio_lock(void) { SDL_AtomicLock( &vg_audio.sl_sync ); audio_lock_checker_store(1); } -VG_STATIC void audio_unlock(void) +static void audio_unlock(void) { audio_lock_checker_store(0); SDL_AtomicUnlock( &vg_audio.sl_sync ); } -VG_STATIC void audio_mixer_callback( void *user, u8 *stream, int frame_count ); -VG_STATIC void vg_audio_init(void) +static void audio_mixer_callback( void *user, u8 *stream, int frame_count ); +static void vg_audio_init(void) { /* TODO: Move here? */ vg_console_reg_var( "debug_audio", &vg_audio.debug_ui, @@ -310,7 +310,7 @@ VG_STATIC void vg_audio_init(void) } } -VG_STATIC void vg_audio_free(void) +static void vg_audio_free(void) { vg_dsp_free(); SDL_CloseAudioDevice( vg_audio.sdl_output_device ); @@ -623,7 +623,7 @@ static int audio_channel_load_source( audio_channel *ch ) return 1; } -VG_STATIC void audio_decode_uncompressed_mono( i16 *src, u32 count, float *dst ) +static void audio_decode_uncompressed_mono( i16 *src, u32 count, float *dst ) { for( u32 i=0; istereo */ -VG_STATIC int +static int stb_vorbis_get_samples_float_interleaved_stereo( stb_vorbis *f, float *buffer, int len ) { @@ -668,7 +668,7 @@ stb_vorbis_get_samples_float_interleaved_stereo( stb_vorbis *f, float *buffer, /* * ........ more wrecked code sorry! */ -VG_STATIC int +static int stb_vorbis_get_samples_i16_downmixed( stb_vorbis *f, i16 *buffer, int len ) { int n = 0, @@ -935,7 +935,7 @@ static void audio_channel_mix( audio_channel *ch, float *buffer ) vg_profile_end( &_vg_prof_audio_mix ); } -VG_STATIC void audio_mixer_callback( void *user, u8 *stream, int byte_count ) +static void audio_mixer_callback( void *user, u8 *stream, int byte_count ) { /* * Copy data and move edit flags to commit flags @@ -1153,7 +1153,7 @@ VG_STATIC void audio_mixer_callback( void *user, u8 *stream, int byte_count ) audio_unlock(); } -VG_STATIC void audio_clip_load( audio_clip *clip, void *lin_alloc ) +static void audio_clip_load( audio_clip *clip, void *lin_alloc ) { if( lin_alloc == NULL ) lin_alloc = vg_audio.audio_pool; @@ -1254,13 +1254,13 @@ VG_STATIC void audio_clip_load( audio_clip *clip, void *lin_alloc ) } } -VG_STATIC void audio_clip_loadn( audio_clip *arr, int count, void *lin_alloc ) +static void audio_clip_loadn( audio_clip *arr, int count, void *lin_alloc ) { for( int i=0; idata && clip->size ) return; @@ -1273,7 +1273,7 @@ VG_STATIC void audio_require_clip_loaded( audio_clip *clip ) * Debugging */ -VG_STATIC void audio_debug_ui( m4x4f mtx_pv ) +static void audio_debug_ui( m4x4f mtx_pv ) { if( !vg_audio.debug_ui ) return; diff --git a/vg_console.h b/vg_console.h index 25bad63..1024b82 100644 --- a/vg_console.h +++ b/vg_console.h @@ -73,29 +73,29 @@ struct vg_console{ } static vg_console; -VG_STATIC void _vg_console_draw( void ); +static void _vg_console_draw( void ); void _vg_console_println( const char *str ); -VG_STATIC int _vg_console_list( int argc, char const *argv[] ); -VG_STATIC void _vg_console_init(void); -VG_STATIC void _vg_console_write_persistent(void); -VG_STATIC void _vg_console_free(void); -VG_STATIC void vg_execute_console_input( const char *cmd ); +static int _vg_console_list( int argc, char const *argv[] ); +static void _vg_console_init(void); +static void _vg_console_write_persistent(void); +static void _vg_console_free(void); +static void vg_execute_console_input( const char *cmd ); /* * Console interface */ -VG_STATIC void console_history_get( char* buf, int entry_num ); -VG_STATIC int _vg_console_enabled(void); -VG_STATIC void console_proc_key( SDL_Keysym ev ); +static void console_history_get( char* buf, int entry_num ); +static int _vg_console_enabled(void); +static void console_proc_key( SDL_Keysym ev ); /* * Implementation */ -VG_STATIC int _vg_console_enabled(void){ +static int _vg_console_enabled(void){ return vg_console.enabled; } -VG_STATIC +static void vg_console_reg_var( const char *alias, void *ptr, enum vg_var_dtype type, u32 flags ) { @@ -115,7 +115,7 @@ void vg_console_reg_var( const char *alias, void *ptr, enum vg_var_dtype type, vg_info( "Console variable '%s' registered\n", alias ); } -VG_STATIC +static void vg_console_reg_cmd( const char *alias, int (*function)(int argc, const char *argv[]), void (*poll_suggest)(int argc, const char *argv[]) ) @@ -132,7 +132,7 @@ void vg_console_reg_cmd( const char *alias, vg_info( "Console function '%s' registered\n", alias ); } -VG_STATIC int _vg_console_list( int argc, char const *argv[] ){ +static int _vg_console_list( int argc, char const *argv[] ){ for( int i=0; iname ); @@ -194,7 +194,7 @@ int _ccmd_vg_console_defaults( int argc, const char *argv[] ){ return 0; } -VG_STATIC void _vg_console_init(void){ +static void _vg_console_init(void){ vg_console_reg_cmd( "list", _vg_console_list, NULL ); vg_console_reg_cmd( "crash", _test_break, NULL ); vg_console_reg_cmd( "exec", _vg_console_exec, NULL ); @@ -208,11 +208,11 @@ VG_STATIC void _vg_console_init(void){ ); } -VG_STATIC void vg_console_load_autos(void){ +static void vg_console_load_autos(void){ _vg_console_exec( 1, (const char *[]){ "auto.conf" } ); } -VG_STATIC void _vg_console_write_persistent(void){ +static void _vg_console_write_persistent(void){ FILE *fp = fopen( "cfg/auto.conf", "w" ); for( int i=0; itype == SDL_CONTROLLERDEVICEADDED ){ int is_controller = SDL_IsGameController( ev->cdevice.which ); @@ -154,7 +154,7 @@ VG_STATIC void vg_input_device_event( SDL_Event *ev ) } } -VG_STATIC void vg_input_controller_event( SDL_Event *ev ) +static void vg_input_controller_event( SDL_Event *ev ) { if( ev->type == SDL_CONTROLLERAXISMOTION ){ for( int i=0; i %s )\n", src, dst ); u32 size; @@ -241,7 +241,7 @@ VG_STATIC int vg_file_copy( const char *src, const char *dst, void *lin_alloc ) return vg_asset_write( dst, data, size ); } -VG_STATIC const char *vg_path_filename( const char *path ) +static const char *vg_path_filename( const char *path ) { const char *base = path; diff --git a/vg_lines.h b/vg_lines.h index c44f071..569ae16 100644 --- a/vg_lines.h +++ b/vg_lines.h @@ -68,7 +68,7 @@ struct{ } static vg_lines; -VG_STATIC void async_vg_lines_init( void *payload, u32 payload_size ){ +static void async_vg_lines_init( void *payload, u32 payload_size ){ glGenVertexArrays( 1, &vg_lines.vao ); glGenBuffers( 1, &vg_lines.vbo ); glBindVertexArray( vg_lines.vao ); @@ -108,7 +108,7 @@ VG_STATIC void async_vg_lines_init( void *payload, u32 payload_size ){ vg_lines.allow_input = 1; } -VG_STATIC void vg_lines_init(void){ +static void vg_lines_init(void){ vg_async_call( async_vg_lines_init, NULL, 0 ); vg_console_reg_var( "vg_lines", &vg_lines.draw, k_var_dtype_i32, @@ -117,7 +117,7 @@ VG_STATIC void vg_lines_init(void){ } -VG_STATIC void vg_lines_drawall( void ){ +static void vg_lines_drawall( void ){ glUseProgram( _shader_lines.id ); glUniformMatrix4fv( glGetUniformLocation( _shader_lines.id, "uPv" ), @@ -141,7 +141,7 @@ VG_STATIC void vg_lines_drawall( void ){ vg_linear_clear( vg_lines.vertex_buffer ); } -VG_STATIC void vg_line2( line_co from, line_co to, u32 fc, u32 tc ){ +static void vg_line2( line_co from, line_co to, u32 fc, u32 tc ){ if( !vg_lines.allow_input ) return; if( !vg_lines.draw ) return; @@ -155,11 +155,11 @@ VG_STATIC void vg_line2( line_co from, line_co to, u32 fc, u32 tc ){ v[1].colour = tc; } -VG_STATIC void vg_line( line_co from, line_co to, u32 colour ){ +static void vg_line( line_co from, line_co to, u32 colour ){ vg_line2( from, to, colour, colour ); } -VG_STATIC void vg_line_arrow( line_co co, line_co dir, float size, u32 colour ){ +static void vg_line_arrow( line_co co, line_co dir, float size, u32 colour ){ v3f p1, tx, ty, p2, p3; v3_muladds( co, dir, size, p1 ); v3_tangent_basis( dir, tx, ty ); @@ -173,7 +173,7 @@ VG_STATIC void vg_line_arrow( line_co co, line_co dir, float size, u32 colour ){ vg_line( p1, p3, colour ); } -VG_STATIC void vg_line_box_verts( boxf box, v3f verts[8] ){ +static void vg_line_box_verts( boxf box, v3f verts[8] ){ for( u32 i=0; i<8; i++ ){ for( u32 j=0; j<3; j++ ){ verts[i][j] = i&(0x1<=box[0][0]) && (point[1]>=box[0][1]) && (point[2]>=box[0][2]) ) @@ -1675,13 +1675,13 @@ VG_STATIC int point_inside_aabb( boxf box, v3f point ) return 0; } -VG_STATIC void closest_point_aabb( v3f p, boxf box, v3f dest ) +static void closest_point_aabb( v3f p, boxf box, v3f dest ) { v3_maxv( p, box[0], dest ); v3_minv( dest, box[1], dest ); } -VG_STATIC void closest_point_obb( v3f p, boxf box, +static void closest_point_obb( v3f p, boxf box, m4x3f mtx, m4x3f inv_mtx, v3f dest ) { v3f local; @@ -1690,7 +1690,7 @@ VG_STATIC void closest_point_obb( v3f p, boxf box, m4x3_mulv( mtx, local, dest ); } -VG_STATIC f32 closest_point_segment( v3f a, v3f b, v3f point, v3f dest ) +static f32 closest_point_segment( v3f a, v3f b, v3f point, v3f dest ) { v3f v0, v1; v3_sub( b, a, v0 ); @@ -1702,7 +1702,7 @@ VG_STATIC f32 closest_point_segment( v3f a, v3f b, v3f point, v3f dest ) return t; } -VG_STATIC void closest_on_triangle( v3f p, v3f tri[3], v3f dest ) +static void closest_on_triangle( v3f p, v3f tri[3], v3f dest ) { v3f ab, ac, ap; f32 d1, d2; @@ -1798,7 +1798,7 @@ enum contact_type k_contact_type_edge }; -VG_STATIC enum contact_type closest_on_triangle_1( v3f p, v3f tri[3], v3f dest ) +static enum contact_type closest_on_triangle_1( v3f p, v3f tri[3], v3f dest ) { v3f ab, ac, ap; f32 d1, d2; diff --git a/vg_mem.h b/vg_mem.h index 12a04f9..be11ddd 100644 --- a/vg_mem.h +++ b/vg_mem.h @@ -9,7 +9,7 @@ #include #include -VG_STATIC void vg_print_backtrace(void); +static void vg_print_backtrace(void); #define VG_MAX_ALLOCATIONS 128 #define VG_FUZZ_ALLOCATIONS @@ -64,46 +64,46 @@ struct vg_linear_allocator }; #pragma pack(pop) -VG_STATIC u32 vg_align8( u32 s ); -VG_STATIC u32 vg_align4( u32 s ); +static u32 vg_align8( u32 s ); +static u32 vg_align4( u32 s ); /* allocate something from a linear allocator */ __attribute__((warn_unused_result)) -VG_STATIC void *_vg_linear_alloc( void *buffer, u32 size, +static void *_vg_linear_alloc( void *buffer, u32 size, const char *constr_name ); /* resize latest block of memory from linear */ __attribute__((warn_unused_result)) -VG_STATIC void *vg_linear_resize( void *buffer, void *data, u32 newsize ); +static void *vg_linear_resize( void *buffer, void *data, u32 newsize ); /* its possible to delete just the last item */ -VG_STATIC void vg_linear_del( void *buffer, void *data ); +static void vg_linear_del( void *buffer, void *data ); /* extend latest block of memory from linear */ __attribute__((warn_unused_result)) -VG_STATIC void *_vg_linear_extend( void *buffer, void *data, u32 extra, +static void *_vg_linear_extend( void *buffer, void *data, u32 extra, const char *constr_name ); /* get the current usage of allocator */ -VG_STATIC u32 vg_linear_get_cur( void *buffer ); +static u32 vg_linear_get_cur( void *buffer ); /* get the capacity of allocator. */ -VG_STATIC u32 vg_linear_get_capacity( void *buffer ); +static u32 vg_linear_get_capacity( void *buffer ); /* get the remaining size of the allocator */ -VG_STATIC u32 vg_linear_remaining( void *buffer ); +static u32 vg_linear_remaining( void *buffer ); /* yeet all memory from linear allocator */ -VG_STATIC void vg_linear_clear( void *buffer ); +static void vg_linear_clear( void *buffer ); /* request all the memory we need in advance */ -VG_STATIC void vg_set_mem_quota( u32 size ); +static void vg_set_mem_quota( u32 size ); /* essentially init() */ -VG_STATIC void vg_alloc_quota(void); +static void vg_alloc_quota(void); /* print out tree of current memory used. only works with libc mode */ -VG_STATIC void vg_mem_log( void *lin_alloc, int depth, const char *name ); +static void vg_mem_log( void *lin_alloc, int depth, const char *name ); #define VG_MEM_MCSTR(S) VG_MEM_MCSTR2(S) #define VG_MEM_MCSTR2(S) #S @@ -119,20 +119,20 @@ VG_STATIC void vg_mem_log( void *lin_alloc, int depth, const char *name ); * ---------------------------------------- */ -VG_STATIC void vg_fatal_error( const char *fmt, ... ); +static void vg_fatal_error( const char *fmt, ... ); #if 0 -VG_STATIC void vg_error(const char *fmt, ...); -VG_STATIC void vg_info(const char *fmt, ...); +static void vg_error(const char *fmt, ...); +static void vg_info(const char *fmt, ...); #endif -VG_STATIC u32 vg_align8( u32 s ) +static u32 vg_align8( u32 s ) { u32 m = (s + 7) >> 3; return m << 3; } -VG_STATIC u32 vg_align4( u32 s ) +static u32 vg_align4( u32 s ) { u32 m = (s + 3) >> 2; return m << 2; @@ -149,7 +149,7 @@ static vg_linear_allocator *vg_linear_header( void *data ) /* allocate something from a linear allocator */ __attribute__((warn_unused_result)) -VG_STATIC void *_vg_linear_alloc( void *buffer, u32 size, +static void *_vg_linear_alloc( void *buffer, u32 size, const char *constr_name ) { if( size % 8 ){ @@ -214,7 +214,7 @@ VG_STATIC void *_vg_linear_alloc( void *buffer, u32 size, /* resize latest block of memory from linear */ __attribute__((warn_unused_result)) -VG_STATIC void *vg_linear_resize( void *buffer, void *data, u32 newsize ) +static void *vg_linear_resize( void *buffer, void *data, u32 newsize ) { vg_linear_allocator *alloc = vg_linear_header( buffer ); @@ -249,7 +249,7 @@ VG_STATIC void *vg_linear_resize( void *buffer, void *data, u32 newsize ) } /* its possible to delete just the last item */ -VG_STATIC void vg_linear_del( void *buffer, void *data ) +static void vg_linear_del( void *buffer, void *data ) { vg_linear_allocator *alloc = vg_linear_header( buffer ); @@ -274,7 +274,7 @@ VG_STATIC void vg_linear_del( void *buffer, void *data ) /* extend latest block of memory from linear */ __attribute__((warn_unused_result)) -VG_STATIC void *_vg_linear_extend( void *buffer, void *data, u32 extra, +static void *_vg_linear_extend( void *buffer, void *data, u32 extra, const char *constr_name ) { if( !data ) @@ -290,28 +290,28 @@ VG_STATIC void *_vg_linear_extend( void *buffer, void *data, u32 extra, } /* get the current usage of allocator */ -VG_STATIC u32 vg_linear_get_cur( void *buffer ) +static u32 vg_linear_get_cur( void *buffer ) { vg_linear_allocator *alloc = vg_linear_header( buffer ); return alloc->cur; } /* get the capacity of allocator. */ -VG_STATIC u32 vg_linear_get_capacity( void *buffer ) +static u32 vg_linear_get_capacity( void *buffer ) { vg_linear_allocator *alloc = vg_linear_header( buffer ); return alloc->size; } /* get the remaining size of the allocator */ -VG_STATIC u32 vg_linear_remaining( void *buffer ) +static u32 vg_linear_remaining( void *buffer ) { vg_linear_allocator *alloc = vg_linear_header( buffer ); return alloc->size - alloc->cur; } /* yeet all memory from linear allocator */ -VG_STATIC void vg_linear_clear( void *buffer ) +static void vg_linear_clear( void *buffer ) { vg_linear_allocator *alloc = vg_linear_header( buffer ); @@ -340,7 +340,7 @@ VG_STATIC void vg_linear_clear( void *buffer ) } /* allocate a FIXED SIZE linear allocator */ -VG_STATIC void *_vg_create_linear_allocator( void *lin_alloc, u32 size, +static void *_vg_create_linear_allocator( void *lin_alloc, u32 size, u16 flags, const char *constr_name) { assert( sizeof( vg_linear_allocator ) == 32 ); @@ -410,12 +410,12 @@ VG_STATIC void *_vg_create_linear_allocator( void *lin_alloc, u32 size, } /* request all the memory we need in advance */ -VG_STATIC void vg_set_mem_quota( u32 size ) +static void vg_set_mem_quota( u32 size ) { vg_mem.quota = size; } -VG_STATIC void vg_alloc_quota(void) +static void vg_alloc_quota(void) { u32 size_scratch = 10*1024*1024; u32 size = VG_MAX( vg_mem.quota, size_scratch ); @@ -428,7 +428,7 @@ VG_STATIC void vg_alloc_quota(void) "Scratch buffer" ); } -VG_STATIC void vg_mem_log( void *lin_alloc, int depth, const char *name ) +static void vg_mem_log( void *lin_alloc, int depth, const char *name ) { if( vg_mem.use_libc_malloc ){ vg_linear_allocator *alloc = vg_linear_header( lin_alloc ); diff --git a/vg_platform.h b/vg_platform.h index 1b0317c..30751f2 100644 --- a/vg_platform.h +++ b/vg_platform.h @@ -1,12 +1,6 @@ #ifndef VG_PLATFORM_H #define VG_PLATFORM_H -#ifdef VG_RELEASE - #define VG_STATIC static -#else - #define VG_STATIC -#endif - //#include "vg.h" #include "vg_stdint.h" @@ -57,8 +51,8 @@ enum strncpy_behaviour{ k_strncpy_overflow_fatal = 2 }; -VG_STATIC void vg_fatal_error( const char *fmt, ... ); -VG_STATIC u32 vg_strncpy( const char *src, char *dst, u32 len, +static void vg_fatal_error( const char *fmt, ... ); +static u32 vg_strncpy( const char *src, char *dst, u32 len, enum strncpy_behaviour behaviour ) { for( u32 i=0; ibuffer = buffer; str->buffer[0] = '\0'; @@ -94,7 +88,7 @@ VG_STATIC void vg_strnull( vg_str *str, char *buffer, u32 len ) str->len = len; } -VG_STATIC void vg_strcat( vg_str *str, const char *append ) +static void vg_strcat( vg_str *str, const char *append ) { if( !append ) return; for( u32 i=0; str->i < str->len; i++, str->i ++ ){ @@ -104,7 +98,7 @@ VG_STATIC void vg_strcat( vg_str *str, const char *append ) } } -VG_STATIC int vg_strgood( vg_str *str ) +static int vg_strgood( vg_str *str ) { if( str->i == str->len ){ if( str->buffer[str->i -1] == '\0' ) return 1; @@ -113,7 +107,7 @@ VG_STATIC int vg_strgood( vg_str *str ) else return 1; } -VG_STATIC char *vg_strch( vg_str *str, char c ) +static char *vg_strch( vg_str *str, char c ) { char *ptr = NULL; for( u32 i=0; ii; i++ ){ @@ -124,7 +118,7 @@ VG_STATIC char *vg_strch( vg_str *str, char c ) return ptr; } -VG_STATIC u32 vg_strdjb2( const char *str ) +static u32 vg_strdjb2( const char *str ) { u32 hash = 5381, c; @@ -134,7 +128,7 @@ VG_STATIC u32 vg_strdjb2( const char *str ) return hash; } -VG_STATIC int vg_strdjb2_eq( const char *s1, u32 h1, +static int vg_strdjb2_eq( const char *s1, u32 h1, const char *s2, u32 h2 ) { if( h1 == h2 ){ diff --git a/vg_profiler.h b/vg_profiler.h index dedea02..67808a7 100644 --- a/vg_profiler.h +++ b/vg_profiler.h @@ -26,12 +26,12 @@ struct vg_profile u64 start; }; -VG_STATIC void vg_profile_begin( struct vg_profile *profile ) +static void vg_profile_begin( struct vg_profile *profile ) { profile->start = SDL_GetPerformanceCounter(); } -VG_STATIC void vg_profile_increment( struct vg_profile *profile ) +static void vg_profile_increment( struct vg_profile *profile ) { profile->buffer_current ++; @@ -44,7 +44,7 @@ VG_STATIC void vg_profile_increment( struct vg_profile *profile ) profile->samples[ profile->buffer_current ] = 0; } -VG_STATIC void vg_profile_end( struct vg_profile *profile ) +static void vg_profile_end( struct vg_profile *profile ) { u64 time_end = SDL_GetPerformanceCounter(), delta = time_end - profile->start; @@ -58,7 +58,7 @@ VG_STATIC void vg_profile_end( struct vg_profile *profile ) } } -VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count, +static void vg_profile_drawn( struct vg_profile **profiles, u32 count, float budget, ui_rect panel, u32 colour_offset ) { if( !vg_profiler ) @@ -135,7 +135,7 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count, } } -VG_STATIC void vg_profiler_init(void) +static void vg_profiler_init(void) { VG_VAR_I32( vg_profiler, flags=VG_VAR_PERSISTENT ); } diff --git a/vg_shader.h b/vg_shader.h index 3334922..6537ec9 100644 --- a/vg_shader.h +++ b/vg_shader.h @@ -40,7 +40,7 @@ struct } static vg_shaders; -VG_STATIC GLuint vg_shader_subshader( const char *src, GLint gliShaderType ) +static GLuint vg_shader_subshader( const char *src, GLint gliShaderType ) { GLint shader = glCreateShader( gliShaderType ); @@ -69,7 +69,7 @@ VG_STATIC GLuint vg_shader_subshader( const char *src, GLint gliShaderType ) return shader; } -VG_STATIC int vg_shader_compile( struct vg_shader *shader ) +static int vg_shader_compile( struct vg_shader *shader ) { GLuint program, vert, frag; @@ -167,7 +167,7 @@ VG_STATIC int vg_shader_compile( struct vg_shader *shader ) return 1; } -VG_STATIC void vg_free_shader( struct vg_shader *shader ) +static void vg_free_shader( struct vg_shader *shader ) { if( shader->compiled ) { @@ -176,7 +176,7 @@ VG_STATIC void vg_free_shader( struct vg_shader *shader ) } } -VG_STATIC void vg_shaders_compile(void) +static void vg_shaders_compile(void) { vg_info( "Compiling shaders\n" ); @@ -188,7 +188,7 @@ VG_STATIC void vg_shaders_compile(void) } } -VG_STATIC int vg_shaders_live_recompile(int argc, const char *argv[]) +static int vg_shaders_live_recompile(int argc, const char *argv[]) { vg_info( "Recompiling shaders\n" ); for( int i=0; i