-Subproject commit 6ed8d054340ee8a93a684e11360b66cd8a5c168e
+Subproject commit c5b4df0e1061175cb11e3ebbf8045178339864a5
-Subproject commit 44e971c774d9ec67ca6c1f16c5a476724821ab63
+Subproject commit eb5332d0b5e48d58397e6f27475a18e058330d23
-Subproject commit b8d77df1e80b652a57f0b7270449b179a6b91f40
+Subproject commit dfc056e813c98d307238d35f7f041a725d699dfc
-Subproject commit 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55
+Subproject commit 5736b15f7ea0ffb08dd38af21067c314d6a3aae9
#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 */
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;
}
#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;
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 );
}
}
-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 ){
}
}
-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__) )
#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;
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 );
SDL_AtomicUnlock( &vg.sl_status );
}
-VG_STATIC void _vg_load_full( void *data )
+static void _vg_load_full( void *data )
{
vg_preload();
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 );
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 );
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 );
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 */
return 0;
}
-VG_STATIC int _vg_crashscreen(void)
+static int _vg_crashscreen(void)
{
#if 0
if( vg_getkey( SDLK_ESCAPE ) )
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();
}
}
-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 ) ){
}
}
-VG_STATIC void _vg_init_window( const char *window_name )
+static void _vg_init_window( const char *window_name )
{
vg_info( "SDL_INIT\n" );
#endif
}
-VG_STATIC void _vg_terminate(void)
+static void _vg_terminate(void)
{
/* Shutdown */
_vg_console_write_persistent();
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 );
_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 );
#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 );
#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;
}
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 ){
/*
* 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 ) );
/*
* 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);
/*
* 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);
/*
* 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 );
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,
* 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 );
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;
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,
}
}
-VG_STATIC void vg_audio_free(void)
+static void vg_audio_free(void)
{
vg_dsp_free();
SDL_CloseAudioDevice( vg_audio.sdl_output_device );
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; i<count; i++ ){
dst[ i*2 + 0 ] = ((float)src[i]) * (1.0f/32767.0f);
/*
* adapted from stb_vorbis.h, since the original does not handle mono->stereo
*/
-VG_STATIC int
+static int
stb_vorbis_get_samples_float_interleaved_stereo( stb_vorbis *f, float *buffer,
int len )
{
/*
* ........ 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,
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
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;
}
}
-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; i<count; i++ )
audio_clip_load( &arr[i], lin_alloc );
}
-VG_STATIC void audio_require_clip_loaded( audio_clip *clip )
+static void audio_require_clip_loaded( audio_clip *clip )
{
if( clip->data && clip->size )
return;
* Debugging
*/
-VG_STATIC void audio_debug_ui( m4x4f mtx_pv )
+static void audio_debug_ui( m4x4f mtx_pv )
{
if( !vg_audio.debug_ui )
return;
}
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 )
{
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[]) )
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; i<vg_console.function_count; i ++ ){
struct vg_cmd *cmd = &vg_console.functions[ i ];
vg_info( "* %s\n", cmd->name );
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 );
);
}
-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; i<vg_console.var_count; i ++ ){
fclose( fp );
}
-VG_STATIC void _vg_console_free(void)
+static void _vg_console_free(void)
{
_vg_console_write_persistent();
}
* returns number of tokens
* dst must be as long as src
*/
-VG_STATIC int vg_console_tokenize( const char *src, char *dst,
+static int vg_console_tokenize( const char *src, char *dst,
const char *args[8] )
{
int arg_count = 0,
return arg_count;
}
-VG_STATIC vg_var *vg_console_match_var( const char *kw )
+static vg_var *vg_console_match_var( const char *kw )
{
for( int i=0; i<vg_console.var_count; i ++ ){
struct vg_var *cv = &vg_console.vars[ i ];
return NULL;
}
-VG_STATIC vg_cmd *vg_console_match_cmd( const char *kw )
+static vg_cmd *vg_console_match_cmd( const char *kw )
{
for( int i=0; i<vg_console.function_count; i ++ ){
struct vg_cmd *cmd = &vg_console.functions[ i ];
return NULL;
}
-VG_STATIC void vg_execute_console_input( const char *cmd )
+static void vg_execute_console_input( const char *cmd )
{
char temp[512];
char const *args[8];
}
/* str must not fuckoff ever! */
-VG_STATIC void console_suggest_score_text( const char *str, const char *input,
+static void console_suggest_score_text( const char *str, const char *input,
int minscore )
{
/* filter duplicates */
}
}
-VG_STATIC void console_update_suggestions(void)
+static void console_update_suggestions(void)
{
if( vg_ui.focused_control_type != k_ui_control_textbox ||
vg_ui.textbuf != vg_console.input )
/*
* Suggestion controls
*/
-VG_STATIC void _console_fetch_suggestion(void)
+static void _console_fetch_suggestion(void)
{
char *target = &vg_console.input[ vg_console.suggestion_pastepos ];
}
}
-VG_STATIC void _console_suggest_store_normal(void)
+static void _console_suggest_store_normal(void)
{
if( vg_console.suggestion_select == -1 ){
char *target = &vg_console.input[ vg_console.suggestion_pastepos ];
}
}
-VG_STATIC void _console_suggest_next(void)
+static void _console_suggest_next(void)
{
if( vg_console.suggestion_count ){
_console_suggest_store_normal();
}
}
-VG_STATIC void _console_suggest_prev(void)
+static void _console_suggest_prev(void)
{
if( vg_console.suggestion_count ){
_console_suggest_store_normal();
}
}
-VG_STATIC void _vg_console_on_update( char *buf, u32 len )
+static void _vg_console_on_update( char *buf, u32 len )
{
if( buf == vg_console.input ){
console_update_suggestions();
}
}
-VG_STATIC void console_history_get( char* buf, int entry_num )
+static void console_history_get( char* buf, int entry_num )
{
if( !vg_console.history_count )
return;
strcpy( buf, vg_console.history[ pick ] );
}
-VG_STATIC void _vg_console_on_up( char *buf, u32 len )
+static void _vg_console_on_up( char *buf, u32 len )
{
if( buf == vg_console.input ){
vg_console.history_pos =
}
}
-VG_STATIC void _vg_console_on_down( char *buf, u32 len )
+static void _vg_console_on_down( char *buf, u32 len )
{
if( buf == vg_console.input ){
vg_console.history_pos = VG_MAX( 0, vg_console.history_pos-1 );
}
}
-VG_STATIC void _vg_console_on_enter( char *buf, u32 len )
+static void _vg_console_on_enter( char *buf, u32 len )
{
if( buf == vg_console.input ){
if( !strlen( vg_console.input ) )
}
}
-VG_STATIC void _vg_console_draw(void)
+static void _vg_console_draw(void)
{
if( !vg_console.enabled ) return;
GLuint vao, vbo, ebo;
};
-VG_STATIC void vg_graph_init( struct vg_graph *graph )
+static void vg_graph_init( struct vg_graph *graph )
{
vg_acquire_thread_sync();
{
}
}
-VG_STATIC void vg_graph_add_sample( struct vg_graph *graph )
+static void vg_graph_add_sample( struct vg_graph *graph )
{
}
}
};
-VG_STATIC void _vg_ui_init(void){
+static void _vg_ui_init(void){
if( !vg_shader_compile( &_shader_ui ) ||
!vg_shader_compile( &_shader_ui_image ) )
vg_fatal_error( "Failed to compile ui shader" );
b[i] = a[i];
}
-VG_STATIC void ui_flush( enum ui_shader shader ){
+static void ui_flush( enum ui_shader shader ){
u32 vertex_offset = vg_ui.vert_start*sizeof(ui_vert),
vertex_count = vg_ui.cur_vert-vg_ui.vert_start,
vertex_size = vertex_count*sizeof(ui_vert),
/*
* Callback for text entry mode
*/
-VG_STATIC void ui_proc_utf8( const char *text ){
+static void ui_proc_utf8( const char *text ){
if( vg_ui.focused_control_type == k_ui_control_textbox ){
const char *ptr = text;
#define VG_MAX_CONTROLLERS 4
-VG_STATIC float controller_deadzone = 0.05f;
+static float controller_deadzone = 0.05f;
struct{
const u8 *sdl_keys;
}
static vg_input = { .active_controller_index = -2 };
-VG_STATIC u8 vg_getkey( SDL_Keycode kc )
+static u8 vg_getkey( SDL_Keycode kc )
{
SDL_Scancode sc = SDL_GetScancodeFromKey( kc );
return vg_input.sdl_keys[sc];
/*
* takes SDL device index, and tries to open that on any free channel
*/
-VG_STATIC int vg_open_gamecontroller( Sint32 index )
+static int vg_open_gamecontroller( Sint32 index )
{
struct vg_controller *controller = NULL;
int vg_id = 0;
}
}
-VG_STATIC void vg_input_device_event( SDL_Event *ev )
+static void vg_input_device_event( SDL_Event *ev )
{
if( ev->type == SDL_CONTROLLERDEVICEADDED ){
int is_controller = SDL_IsGameController( ev->cdevice.which );
}
}
-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<VG_MAX_CONTROLLERS; i++ ){
}
}
-VG_STATIC void vg_process_inputs(void)
+static void vg_process_inputs(void)
{
int count;
vg_input.sdl_keys = SDL_GetKeyboardState( &count );
}
}
-VG_STATIC void async_vg_input_init( void *payload, u32 size )
+static void async_vg_input_init( void *payload, u32 size )
{
VG_VAR_F32( controller_deadzone, flags=VG_VAR_PERSISTENT );
}
}
-VG_STATIC void vg_input_init(void)
+static void vg_input_init(void)
{
vg_async_call( async_vg_input_init, NULL, 0 );
}
-VG_STATIC void vg_input_free(void)
+static void vg_input_free(void)
{
for( int i=0; i<VG_MAX_CONTROLLERS; i++ ){
struct vg_controller *controller = &vg_input.controllers[i];
#endif
#endif
-VG_STATIC void vg_file_print_invalid( FILE *fp )
+static void vg_file_print_invalid( FILE *fp )
{
if( feof( fp )) {
vg_error( "mdl_open: header too short\n" );
}
/* read entire binary file */
-VG_STATIC void *vg_file_read( void *lin_alloc, const char *path, u32 *size )
+static void *vg_file_read( void *lin_alloc, const char *path, u32 *size )
{
FILE *f = fopen( path, "rb" );
if( f ){
}
/* read entire file and append a null on the end */
-VG_STATIC char *vg_file_read_text( void *lin_alloc, const char *path, u32 *sz )
+static char *vg_file_read_text( void *lin_alloc, const char *path, u32 *sz )
{
u32 size;
char *str = vg_file_read( lin_alloc, path, &size );
}
-VG_STATIC int vg_asset_write( const char *path, void *data, i64 size ){
+static int vg_asset_write( const char *path, void *data, i64 size ){
FILE *f = fopen( path, "wb" );
if( f ){
fwrite( data, size, 1, f );
}
/* TODO: error handling if read fails */
-VG_STATIC int vg_file_copy( const char *src, const char *dst, void *lin_alloc )
+static int vg_file_copy( const char *src, const char *dst, void *lin_alloc )
{
vg_info( "vg_file_copy( %s -> %s )\n", src, dst );
u32 size;
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;
}
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 );
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,
}
-VG_STATIC void vg_lines_drawall( void ){
+static void vg_lines_drawall( void ){
glUseProgram( _shader_lines.id );
glUniformMatrix4fv( glGetUniformLocation( _shader_lines.id, "uPv" ),
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;
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 );
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<<j)? box[1][j]: box[0][j];
}
}
-VG_STATIC void vg_line_mesh( v3f verts[], u32 indices[][2], u32 indice_count,
+static void vg_line_mesh( v3f verts[], u32 indices[][2], u32 indice_count,
u32 colour ){
for( u32 i=0; i<indice_count; i++ ){
vg_line( verts[indices[i][0]], verts[indices[i][1]], colour );
}
}
-VG_STATIC void vg_line_boxf( boxf box, u32 colour ){
+static void vg_line_boxf( boxf box, u32 colour ){
v3f verts[8];
vg_line_box_verts( box, verts );
u32 indices[][2] = {{0,1},{1,3},{3,2},{2,0},
vg_line_mesh( verts, indices, vg_list_size(indices), colour );
}
-VG_STATIC void vg_line_boxf_transformed( m4x3f m, boxf box, u32 colour ){
+static void vg_line_boxf_transformed( m4x3f m, boxf box, u32 colour ){
v3f verts[8];
vg_line_box_verts( box, verts );
vg_line_mesh( verts, indices, vg_list_size(indices), colour );
}
-VG_STATIC void vg_line_cross(v3f pos,u32 colour, float scale){
+static void vg_line_cross(v3f pos,u32 colour, float scale){
v3f p0, p1;
v3_add( (v3f){ scale,0.0f,0.0f}, pos, p0 );
v3_add( (v3f){-scale,0.0f,0.0f}, pos, p1 );
vg_line( p0, p1, colour );
}
-VG_STATIC void vg_line_point( v3f pt, float size, u32 colour ){
+static void vg_line_point( v3f pt, float size, u32 colour ){
boxf box =
{
{ pt[0]-size, pt[1]-size, pt[2]-size },
}
-VG_STATIC void vg_line_sphere( m4x3f m, float radius, u32 colour ){
+static void vg_line_sphere( m4x3f m, float radius, u32 colour ){
v3f ly = { 0.0f, 0.0f, radius },
lx = { 0.0f, radius, 0.0f },
lz = { 0.0f, 0.0f, radius };
}
}
-VG_STATIC void vg_line_capsule( m4x3f m, float radius, float h, u32 colour ){
+static void vg_line_capsule( m4x3f m, float radius, float h, u32 colour ){
v3f ly = { 0.0f, 0.0f, radius },
lx = { 0.0f, radius, 0.0f },
lz = { 0.0f, 0.0f, radius };
#include "vg/vg.h"
#include "vg/vg_shader.h"
-VG_STATIC void vg_loader_start( void(*pfn)(void *data), void *data );
-VG_STATIC void vg_loader_step( void( *fn_load )(void), void( *fn_free )(void) );
+static void vg_loader_start( void(*pfn)(void *data), void *data );
+static void vg_loader_step( void( *fn_load )(void), void( *fn_free )(void) );
static struct vg_shader _shader_loader =
{
}
vg_loader;
-VG_STATIC void _vg_loader_init(void)
+static void _vg_loader_init(void)
{
float quad[] = { 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f };
vg_fatal_error( "failed to compile shader" );
}
-VG_STATIC void _vg_loader_free(void)
+static void _vg_loader_free(void)
{
vg_info( "vg_loader_free\n" );
glDeleteVertexArrays( 1, &vg_loader.vao );
}
}
-VG_STATIC void _vg_render_log(void)
+static void _vg_render_log(void)
{
#if 0
ui_begin( vg.window_x, vg.window_y );
#endif
}
-VG_STATIC void _vg_loader_render_ring( float opacity )
+static void _vg_loader_render_ring( float opacity )
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays( GL_TRIANGLES, 0, 6 );
}
-VG_STATIC void _vg_loader_render(void)
+static void _vg_loader_render(void)
{
glViewport( 0,0, vg.window_x, vg.window_y );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
}
-VG_STATIC void vg_load_full(void);
+static void vg_load_full(void);
-VG_STATIC int _vg_loader_thread( void *pfn ){
+static int _vg_loader_thread( void *pfn ){
if( setjmp( vg.env_loader_exit ) )
return 0;
return 0;
}
-VG_STATIC void vg_loader_start( void(*pfn)(void *data), void *data )
+static void vg_loader_start( void(*pfn)(void *data), void *data )
{
SDL_SemWait( vg.sem_loader );
/*
* Schedule something to be ran now, freed later. Checks in with engine status
*/
-VG_STATIC void vg_loader_step( void( *fn_load )(void), void( *fn_free )(void) )
+static void vg_loader_step( void( *fn_load )(void), void( *fn_free )(void) )
{
if( fn_load )
fn_load();
* These closest point tests were learned from Real-Time Collision Detection by
* Christer Ericson
*/
-VG_STATIC f32 closest_segment_segment( v3f p1, v3f q1, v3f p2, v3f q2,
+static f32 closest_segment_segment( v3f p1, v3f q1, v3f p2, v3f q2,
f32 *s, f32 *t, v3f c1, v3f c2)
{
v3f d1,d2,r;
return v3_length2( v0 );
}
-VG_STATIC int point_inside_aabb( boxf box, v3f point )
+static int point_inside_aabb( boxf box, v3f point )
{
if((point[0]<=box[1][0]) && (point[1]<=box[1][1]) && (point[2]<=box[1][2]) &&
(point[0]>=box[0][0]) && (point[1]>=box[0][1]) && (point[2]>=box[0][2]) )
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;
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 );
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;
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;
#include <stdlib.h>
#include <malloc.h>
-VG_STATIC void vg_print_backtrace(void);
+static void vg_print_backtrace(void);
#define VG_MAX_ALLOCATIONS 128
#define VG_FUZZ_ALLOCATIONS
};
#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
* ----------------------------------------
*/
-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;
/* 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 ){
/* 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 );
}
/* 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 );
/* 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 )
}
/* 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 );
}
/* 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 );
}
/* 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 );
"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 );
#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"
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; i<len; i++ ){
u32 i, len;
};
-VG_STATIC void vg_strnull( vg_str *str, char *buffer, u32 len )
+static void vg_strnull( vg_str *str, char *buffer, u32 len )
{
str->buffer = buffer;
str->buffer[0] = '\0';
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 ++ ){
}
}
-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;
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; i<str->i; i++ ){
return ptr;
}
-VG_STATIC u32 vg_strdjb2( const char *str )
+static u32 vg_strdjb2( const char *str )
{
u32 hash = 5381, c;
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 ){
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 ++;
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;
}
}
-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 )
}
}
-VG_STATIC void vg_profiler_init(void)
+static void vg_profiler_init(void)
{
VG_VAR_I32( vg_profiler, flags=VG_VAR_PERSISTENT );
}
}
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 );
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;
return 1;
}
-VG_STATIC void vg_free_shader( struct vg_shader *shader )
+static void vg_free_shader( struct vg_shader *shader )
{
if( shader->compiled )
{
}
}
-VG_STATIC void vg_shaders_compile(void)
+static void vg_shaders_compile(void)
{
vg_info( "Compiling shaders\n" );
}
}
-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<vg_shaders.count; i ++ )
return 0;
}
-VG_STATIC void vg_shader_register( struct vg_shader *shader )
+static void vg_shader_register( struct vg_shader *shader )
{
if( vg_shaders.count == vg_list_size(vg_shaders.shaders) )
vg_fatal_error( "Too many shaders" );
u8 *rgba;
};
-VG_STATIC void async_vg_tex2d_upload( void *payload, u32 size )
+static void async_vg_tex2d_upload( void *payload, u32 size )
{
if( vg_thread_purpose() != k_thread_purpose_main ){
vg_fatal_error( "Catastrophic programming error.\n" );
}
}
-VG_STATIC void vg_tex2d_replace_with_error( GLuint *dest )
+static void vg_tex2d_replace_with_error( GLuint *dest )
{
u32 hdr_size = vg_align8(sizeof(struct texture_load_info));
vg_async_dispatch( call, async_vg_tex2d_upload );
}
-VG_STATIC
+static
void vg_tex2d_load_qoi_async( const u8 *bytes, u32 size,
u32 flags, GLuint *dest )
{
vg_async_dispatch( call, async_vg_tex2d_upload );
}
-VG_STATIC
+static
void vg_tex2d_load_qoi_async_file( const char *path, u32 flags, GLuint *dest )
{
vg_linear_clear( vg_mem.scratch );