main
Dominik Madarász 2023-10-15 13:22:55 +02:00
parent dd783b1f54
commit c281f82c38
5 changed files with 486 additions and 486 deletions

View File

@ -957,42 +957,6 @@ ffi.cdef([[
//lcpp INF [0000] quat: macro name but used as C declaration in:API void printq( quat q ); //lcpp INF [0000] quat: macro name but used as C declaration in:API void printq( quat q );
//lcpp INF [0000] quat: macro name but used as C declaration in:STATIC void printq( quat q ); //lcpp INF [0000] quat: macro name but used as C declaration in:STATIC void printq( quat q );
//lcpp INF [0000] quat: macro name but used as C declaration in: void printq( quat q ); //lcpp INF [0000] quat: macro name but used as C declaration in: void printq( quat q );
//lcpp INF [0000] vec2: macro name but used as C declaration in:API vec2 atof2(const char *s);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC vec2 atof2(const char *s);
//lcpp INF [0000] vec2: macro name but used as C declaration in: vec2 atof2(const char *s);
//lcpp INF [0000] vec3: macro name but used as C declaration in:API vec3 atof3(const char *s);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC vec3 atof3(const char *s);
//lcpp INF [0000] vec3: macro name but used as C declaration in: vec3 atof3(const char *s);
//lcpp INF [0000] vec4: macro name but used as C declaration in:API vec4 atof4(const char *s);
//lcpp INF [0000] vec4: macro name but used as C declaration in:STATIC vec4 atof4(const char *s);
//lcpp INF [0000] vec4: macro name but used as C declaration in: vec4 atof4(const char *s);
//lcpp INF [0000] vec2: macro name but used as C declaration in:API char* ftoa2(vec2 v);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC char* ftoa2(vec2 v);
//lcpp INF [0000] vec2: macro name but used as C declaration in: char* ftoa2(vec2 v);
//lcpp INF [0000] vec3: macro name but used as C declaration in:API char* ftoa3(vec3 v);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC char* ftoa3(vec3 v);
//lcpp INF [0000] vec3: macro name but used as C declaration in: char* ftoa3(vec3 v);
//lcpp INF [0000] vec4: macro name but used as C declaration in:API char* ftoa4(vec4 v);
//lcpp INF [0000] vec4: macro name but used as C declaration in:STATIC char* ftoa4(vec4 v);
//lcpp INF [0000] vec4: macro name but used as C declaration in: char* ftoa4(vec4 v);
//lcpp INF [0000] vec2: macro name but used as C declaration in:API void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in:API void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in: void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in: void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:API void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:API void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in: void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in: void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in:API void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in:API void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in:STATIC void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in:STATIC void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in: void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in: void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 position; //lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 position;
//lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 velocity; //lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 velocity;
//lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 acceleration; //lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 acceleration;
@ -1179,6 +1143,42 @@ ffi.cdef([[
//lcpp INF [0000] vec2: macro name but used as C declaration in:API vec2 font_highlight(const char *text, const void *colors); //lcpp INF [0000] vec2: macro name but used as C declaration in:API vec2 font_highlight(const char *text, const void *colors);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC vec2 font_highlight(const char *text, const void *colors); //lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC vec2 font_highlight(const char *text, const void *colors);
//lcpp INF [0000] vec2: macro name but used as C declaration in: vec2 font_highlight(const char *text, const void *colors); //lcpp INF [0000] vec2: macro name but used as C declaration in: vec2 font_highlight(const char *text, const void *colors);
//lcpp INF [0000] vec2: macro name but used as C declaration in:API vec2 atof2(const char *s);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC vec2 atof2(const char *s);
//lcpp INF [0000] vec2: macro name but used as C declaration in: vec2 atof2(const char *s);
//lcpp INF [0000] vec3: macro name but used as C declaration in:API vec3 atof3(const char *s);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC vec3 atof3(const char *s);
//lcpp INF [0000] vec3: macro name but used as C declaration in: vec3 atof3(const char *s);
//lcpp INF [0000] vec4: macro name but used as C declaration in:API vec4 atof4(const char *s);
//lcpp INF [0000] vec4: macro name but used as C declaration in:STATIC vec4 atof4(const char *s);
//lcpp INF [0000] vec4: macro name but used as C declaration in: vec4 atof4(const char *s);
//lcpp INF [0000] vec2: macro name but used as C declaration in:API char* ftoa2(vec2 v);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC char* ftoa2(vec2 v);
//lcpp INF [0000] vec2: macro name but used as C declaration in: char* ftoa2(vec2 v);
//lcpp INF [0000] vec3: macro name but used as C declaration in:API char* ftoa3(vec3 v);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC char* ftoa3(vec3 v);
//lcpp INF [0000] vec3: macro name but used as C declaration in: char* ftoa3(vec3 v);
//lcpp INF [0000] vec4: macro name but used as C declaration in:API char* ftoa4(vec4 v);
//lcpp INF [0000] vec4: macro name but used as C declaration in:STATIC char* ftoa4(vec4 v);
//lcpp INF [0000] vec4: macro name but used as C declaration in: char* ftoa4(vec4 v);
//lcpp INF [0000] vec2: macro name but used as C declaration in:API void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in:API void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in: void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in: void swapf2(vec2 *a, vec2 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:API void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:API void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in: void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec3: macro name but used as C declaration in: void swapf3(vec3 *a, vec3 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in:API void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in:API void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in:STATIC void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in:STATIC void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in: void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec4: macro name but used as C declaration in: void swapf4(vec4 *a, vec4 *b);
//lcpp INF [0000] vec2: macro name but used as C declaration in:API vec2 input2( int vk ); //lcpp INF [0000] vec2: macro name but used as C declaration in:API vec2 input2( int vk );
//lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC vec2 input2( int vk ); //lcpp INF [0000] vec2: macro name but used as C declaration in:STATIC vec2 input2( int vk );
//lcpp INF [0000] vec2: macro name but used as C declaration in: vec2 input2( int vk ); //lcpp INF [0000] vec2: macro name but used as C declaration in: vec2 input2( int vk );
@ -1270,6 +1270,7 @@ ffi.cdef([[
//lcpp INF [0000] vec3: macro name but used as C declaration in:vec3* out_vertex3; //lcpp INF [0000] vec3: macro name but used as C declaration in:vec3* out_vertex3;
//lcpp INF [0000] vec4: macro name but used as C declaration in:vec4 color; //lcpp INF [0000] vec4: macro name but used as C declaration in:vec4 color;
//lcpp INF [0000] vec2i: macro name but used as C declaration in:vec2i dims; //lcpp INF [0000] vec2i: macro name but used as C declaration in:vec2i dims;
//lcpp INF [0000] vec4: macro name but used as C declaration in:vec4 mouse;
//lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 pose; //lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 pose;
//lcpp INF [0000] vec3: macro name but used as C declaration in:API vec3 pose(bool forward, float curframe, int minframe, int maxframe, bool loop, float *opt_retframe); //lcpp INF [0000] vec3: macro name but used as C declaration in:API vec3 pose(bool forward, float curframe, int minframe, int maxframe, bool loop, float *opt_retframe);
//lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC vec3 pose(bool forward, float curframe, int minframe, int maxframe, bool loop, float *opt_retframe); //lcpp INF [0000] vec3: macro name but used as C declaration in:STATIC vec3 pose(bool forward, float curframe, int minframe, int maxframe, bool loop, float *opt_retframe);
@ -1575,13 +1576,6 @@ pair** sorted;
void (map_gc)(map *m); void (map_gc)(map *m);
bool (map_sort)(map* m); bool (map_sort)(map* m);
void (map_clear)(map* m); void (map_clear)(map* m);
char *cc4str(unsigned cc);
char *cc8str(uint64_t cc);
enum {
cc__1 = '1', cc__2, cc__3, cc__4, cc__5, cc__6,cc__7, cc__8, cc__9, cc__0, cc___, cc__ = ' ',
cc__A = 'A', cc__B, cc__C, cc__D, cc__E, cc__F,cc__G, cc__H, cc__I, cc__J, cc__K,cc__L, cc__M, cc__N, cc__O, cc__P,cc__Q, cc__R, cc__S, cc__T, cc__U,cc__V, cc__W, cc__X, cc__Y, cc__Z,
cc__a = 'a', cc__b, cc__c, cc__d, cc__e, cc__f,cc__g, cc__h, cc__i, cc__j, cc__k,cc__l, cc__m, cc__n, cc__o, cc__p,cc__q, cc__r, cc__s, cc__t, cc__u,cc__v, cc__w, cc__x, cc__y, cc__z,
};
typedef union vec2i{ struct { int X,Y; }; struct { int x,y; }; struct { int r,g; }; struct { int w,h; }; struct { int min,max; }; struct { int from,to; }; struct { int src,dst; }; int v2[2]; int array[1]; } vec2i; typedef union vec2i{ struct { int X,Y; }; struct { int x,y; }; struct { int r,g; }; struct { int w,h; }; struct { int min,max; }; struct { int from,to; }; struct { int src,dst; }; int v2[2]; int array[1]; } vec2i;
typedef union vec3i{ struct { int X,Y,Z; }; struct { int x,y,z; }; struct { int r,g,b; }; struct { int w,h,d; }; struct { int min,max; }; struct { int from,to,step; }; struct { int src,dst; }; int v3[3]; int array[1]; } vec3i; typedef union vec3i{ struct { int X,Y,Z; }; struct { int x,y,z; }; struct { int r,g,b; }; struct { int w,h,d; }; struct { int min,max; }; struct { int from,to,step; }; struct { int src,dst; }; int v3[3]; int array[1]; } vec3i;
typedef union vec2 { struct { float X,Y; }; struct { float x,y; }; struct { float r,g; }; struct { float w,h; }; struct { float min,max; }; struct { float from,to; }; struct { float src,dst; }; float v2[2]; float array[1]; } vec2; typedef union vec2 { struct { float X,Y; }; struct { float x,y; }; struct { float r,g; }; struct { float w,h; }; struct { float min,max; }; struct { float from,to; }; struct { float src,dst; }; float v2[2]; float array[1]; } vec2;
@ -1829,17 +1823,6 @@ EASE_OUT = 0,
void print33( float *m ); void print33( float *m );
void print34( float *m ); void print34( float *m );
void print44( float *m ); void print44( float *m );
vec2 atof2(const char *s);
vec3 atof3(const char *s);
vec4 atof4(const char *s);
char* ftoa(float f);
char* ftoa2(vec2 v);
char* ftoa3(vec3 v);
char* ftoa4(vec4 v);
void swapf(float *a, float *b);
void swapf2(vec2 *a, vec2 *b);
void swapf3(vec3 *a, vec3 *b);
void swapf4(vec4 *a, vec4 *b);
typedef enum SWARM_DISTANCE { typedef enum SWARM_DISTANCE {
SWARM_DISTANCE_LINEAR, SWARM_DISTANCE_LINEAR,
SWARM_DISTANCE_INVERSE_LINEAR, SWARM_DISTANCE_INVERSE_LINEAR,
@ -2088,6 +2071,7 @@ COOK_DEBUGLOG = 4,
void cook_cancel(); void cook_cancel();
int cook_jobs(); int cook_jobs();
int cook_progress(); int cook_progress();
bool have_tools();
typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t* arr; } json_t; typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t* arr; } json_t;
bool json_push(const char *json_content); bool json_push(const char *json_content);
const char* json_key(const char *keypath); const char* json_key(const char *keypath);
@ -2157,7 +2141,7 @@ typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t*
void storage_read(); void storage_read();
void storage_flush(); void storage_flush();
bool vfs_mount(const char *mount_point); bool vfs_mount(const char *mount_point);
const char** vfs_list(const char *masks); char** vfs_list(const char *masks);
char * vfs_read(const char *pathfile); char * vfs_read(const char *pathfile);
char * vfs_load(const char *pathfile, int *size); char * vfs_load(const char *pathfile, int *size);
int vfs_size(const char *pathfile); int vfs_size(const char *pathfile);
@ -2206,6 +2190,20 @@ uintptr_t id_make(void *ptr);
void * id_handle(uintptr_t id); void * id_handle(uintptr_t id);
void id_dispose(uintptr_t id); void id_dispose(uintptr_t id);
bool id_valid(uintptr_t id); bool id_valid(uintptr_t id);
char *cc4str(unsigned cc);
char *cc8str(uint64_t cc);
enum {
cc__1 = '1', cc__2, cc__3, cc__4, cc__5, cc__6,cc__7, cc__8, cc__9, cc__0, cc___, cc__ = ' ',
cc__A = 'A', cc__B, cc__C, cc__D, cc__E, cc__F,cc__G, cc__H, cc__I, cc__J, cc__K,cc__L, cc__M, cc__N, cc__O, cc__P,cc__Q, cc__R, cc__S, cc__T, cc__U,cc__V, cc__W, cc__X, cc__Y, cc__Z,
cc__a = 'a', cc__b, cc__c, cc__d, cc__e, cc__f,cc__g, cc__h, cc__i, cc__j, cc__k,cc__l, cc__m, cc__n, cc__o, cc__p,cc__q, cc__r, cc__s, cc__t, cc__u,cc__v, cc__w, cc__x, cc__y, cc__z,
};
vec2 atof2(const char *s);
vec3 atof3(const char *s);
vec4 atof4(const char *s);
char* ftoa(float f);
char* ftoa2(vec2 v);
char* ftoa3(vec3 v);
char* ftoa4(vec4 v);
int is_big(); int is_big();
int is_little(); int is_little();
uint16_t swap16( uint16_t x ); uint16_t swap16( uint16_t x );
@ -2213,6 +2211,10 @@ bool id_valid(uintptr_t id);
uint64_t swap64( uint64_t x ); uint64_t swap64( uint64_t x );
float swap32f(float n); float swap32f(float n);
double swap64f(double n); double swap64f(double n);
void swapf(float *a, float *b);
void swapf2(vec2 *a, vec2 *b);
void swapf3(vec3 *a, vec3 *b);
void swapf4(vec4 *a, vec4 *b);
uint16_t lil16(uint16_t n); uint16_t lil16(uint16_t n);
uint32_t lil32(uint32_t n); uint32_t lil32(uint32_t n);
uint64_t lil64(uint64_t n); uint64_t lil64(uint64_t n);
@ -2436,7 +2438,7 @@ struct profile_t { double stat; int32_t cost, avg; };
typedef struct { map base; struct { pair p; char * key; struct profile_t val; } tmp, *ptr; struct profile_t* tmpval; int (*typed_cmp)(char *, char *); uint64_t (*typed_hash)(char *); } * profiler_t; typedef struct { map base; struct { pair p; char * key; struct profile_t val; } tmp, *ptr; struct profile_t* tmpval; int (*typed_cmp)(char *, char *); uint64_t (*typed_hash)(char *); } * profiler_t;
extern profiler_t profiler; extern profiler_t profiler;
extern int profiler_enabled; extern int profiler_enabled;
typedef struct reflected_t { typedef struct reflect_t {
unsigned id, objtype; unsigned id, objtype;
unsigned sz; unsigned sz;
const char *name; const char *name;
@ -2444,18 +2446,18 @@ const char *info;
void *addr; void *addr;
unsigned parent; unsigned parent;
const char *type; const char *type;
} reflected_t; } reflect_t;
unsigned enum_find(const char *E); unsigned enum_find(const char *E);
void * function_find(const char *F); void * function_find(const char *F);
reflected_t member_find(const char *T, const char *M); reflect_t member_find(const char *T, const char *M);
void * member_findptr(void *obj, const char *T, const char *M); void * member_findptr(void *obj, const char *T, const char *M);
reflected_t* members_find(const char *T); reflect_t* members_find(const char *T);
void type_inscribe(const char *TY,unsigned TYid,unsigned TYsz,const char *infos); void type_inscribe(const char *TY,unsigned TYid,unsigned TYsz,const char *infos);
void enum_inscribe(const char *E,unsigned Eid,unsigned Eval,const char *infos); void enum_inscribe(const char *E,unsigned Eid,unsigned Eval,const char *infos);
void struct_inscribe(const char *T,unsigned Tid,unsigned Tsz,unsigned OBJTYPEid, const char *infos); void struct_inscribe(const char *T,unsigned Tid,unsigned Tsz,unsigned OBJTYPEid, const char *infos);
void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type); void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type);
void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos); void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos);
void reflected_printf(reflected_t *r); void reflected_printf(reflect_t *r);
void reflected_printf_all(); void reflected_printf_all();
typedef unsigned handle; typedef unsigned handle;
unsigned rgba( uint8_t r, uint8_t g, uint8_t b, uint8_t a ); unsigned rgba( uint8_t r, uint8_t g, uint8_t b, uint8_t a );
@ -2738,11 +2740,11 @@ handle vao, program;
int uniforms[32]; int uniforms[32];
int texture_channels[4]; int texture_channels[4];
int frame; int frame;
float clickx, clicky;
uint64_t t; uint64_t t;
texture_t tx; texture_t tx;
vec2i dims; vec2i dims;
int flags; int flags;
vec4 mouse;
} shadertoy_t; } shadertoy_t;
shadertoy_t shadertoy( const char *shaderfile, unsigned flags ); shadertoy_t shadertoy( const char *shaderfile, unsigned flags );
shadertoy_t* shadertoy_render( shadertoy_t *s, float delta ); shadertoy_t* shadertoy_render( shadertoy_t *s, float delta );

View File

@ -661,4 +661,4 @@ int main() {
ui_panel_end(); ui_panel_end();
} }
} }
} }

View File

@ -14845,34 +14845,6 @@ API int (map_count)(map *m);
API void (map_gc)(map *m); // only if using MAP_DONT_ERASE API void (map_gc)(map *m); // only if using MAP_DONT_ERASE
API bool (map_sort)(map* m); API bool (map_sort)(map* m);
API void (map_clear)(map* m); API void (map_clear)(map* m);
// -----------------------------------------------------------------------------
// compile-time fourcc, eightcc
API char *cc4str(unsigned cc);
API char *cc8str(uint64_t cc);
enum {
# define _(a,b,c,d,e) cc__##a, cc__##b, cc__##c, cc__##d, cc__##e
cc__1 = '1', _(2,3,4,5,6),_(7,8,9,0,_), cc__ = ' ',
cc__A = 'A', _(B,C,D,E,F),_(G,H,I,J,K),_(L,M,N,O,P),_(Q,R,S,T,U),_(V,W,X,Y,Z),
cc__a = 'a', _(b,c,d,e,f),_(g,h,i,j,k),_(l,m,n,o,p),_(q,r,s,t,u),_(v,w,x,y,z),
# undef _
};
#ifdef BIG
#define cc4(a,b,c,d) ((uint32_t)(cc__##a<<24) | (cc__##b<<16) | (cc__##c<<8) | (cc__##d<<0))
#define cc8(a,b,c,d,e,f,g,h) (((uint64_t)cc4(a,b,c,d) << 32ULL) | cc4(e,f,g,h))
#else
#define cc4(a,b,c,d) ((uint32_t)(cc__##d<<24) | (cc__##c<<16) | (cc__##b<<8) | (cc__##a<<0))
#define cc8(a,b,c,d,e,f,g,h) (((uint64_t)cc4(e,f,g,h) << 32ULL) | cc4(a,b,c,d))
#endif
#define cc3(a,b,c) cc4(,a,b,c)
#define cc5(a,b,c,d,e) cc6(,a,b,c,d,e)
#define cc6(a,b,c,d,e,f) cc7(,a,b,c,d,e,f)
#define cc7(a,b,c,d,e,f,g) cc8(,a,b,c,d,e,f,g)
#line 0 #line 0
#line 1 "engine/split/v4k_math.h" #line 1 "engine/split/v4k_math.h"
@ -15217,21 +15189,6 @@ API void printq( quat q );
API void print33( float *m ); API void print33( float *m );
API void print34( float *m ); API void print34( float *m );
API void print44( float *m ); API void print44( float *m );
API vec2 atof2(const char *s);
API vec3 atof3(const char *s);
API vec4 atof4(const char *s);
API char* ftoa(float f);
API char* ftoa2(vec2 v);
API char* ftoa3(vec3 v);
API char* ftoa4(vec4 v);
API void swapf(float *a, float *b);
API void swapf2(vec2 *a, vec2 *b);
API void swapf3(vec3 *a, vec3 *b);
API void swapf4(vec4 *a, vec4 *b);
#line 0 #line 0
#line 1 "engine/split/v4k_ai.h" #line 1 "engine/split/v4k_ai.h"
@ -15665,6 +15622,8 @@ API void cook_cancel();
API int cook_jobs(); // [0..N] API int cook_jobs(); // [0..N]
API int cook_progress(); // [0..100] API int cook_progress(); // [0..100]
// utils
API bool have_tools();
#line 0 #line 0
#line 1 "engine/split/v4k_data.h" #line 1 "engine/split/v4k_data.h"
@ -15831,7 +15790,7 @@ API void storage_flush();
// virtual filesystem // virtual filesystem
API bool vfs_mount(const char *mount_point); API bool vfs_mount(const char *mount_point);
API const char** vfs_list(const char *masks); // **.png;*.c API array(char*) vfs_list(const char *masks); // **.png;*.c
API char * vfs_read(const char *pathfile); API char * vfs_read(const char *pathfile);
API char * vfs_load(const char *pathfile, int *size); API char * vfs_load(const char *pathfile, int *size);
@ -15988,6 +15947,45 @@ bool id_valid(uintptr_t id);
#line 0 #line 0
#line 1 "engine/split/v4k_pack.h" #line 1 "engine/split/v4k_pack.h"
// -----------------------------------------------------------------------------
// compile-time fourcc, eightcc
API char *cc4str(unsigned cc);
API char *cc8str(uint64_t cc);
enum {
# define _(a,b,c,d,e) cc__##a, cc__##b, cc__##c, cc__##d, cc__##e
cc__1 = '1', _(2,3,4,5,6),_(7,8,9,0,_), cc__ = ' ',
cc__A = 'A', _(B,C,D,E,F),_(G,H,I,J,K),_(L,M,N,O,P),_(Q,R,S,T,U),_(V,W,X,Y,Z),
cc__a = 'a', _(b,c,d,e,f),_(g,h,i,j,k),_(l,m,n,o,p),_(q,r,s,t,u),_(v,w,x,y,z),
# undef _
};
#ifdef BIG
#define cc4(a,b,c,d) ((uint32_t)(cc__##a<<24) | (cc__##b<<16) | (cc__##c<<8) | (cc__##d<<0))
#define cc8(a,b,c,d,e,f,g,h) (((uint64_t)cc4(a,b,c,d) << 32ULL) | cc4(e,f,g,h))
#else
#define cc4(a,b,c,d) ((uint32_t)(cc__##d<<24) | (cc__##c<<16) | (cc__##b<<8) | (cc__##a<<0))
#define cc8(a,b,c,d,e,f,g,h) (((uint64_t)cc4(e,f,g,h) << 32ULL) | cc4(a,b,c,d))
#endif
#define cc3(a,b,c) cc4(,a,b,c)
#define cc5(a,b,c,d,e) cc6(,a,b,c,d,e)
#define cc6(a,b,c,d,e,f) cc7(,a,b,c,d,e,f)
#define cc7(a,b,c,d,e,f,g) cc8(,a,b,c,d,e,f,g)
// ----------------------------------------------------------------------------
// float conversion (text)
API vec2 atof2(const char *s);
API vec3 atof3(const char *s);
API vec4 atof4(const char *s);
API char* ftoa(float f);
API char* ftoa2(vec2 v);
API char* ftoa3(vec3 v);
API char* ftoa4(vec4 v);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// endianness // endianness
@ -15999,6 +15997,10 @@ API uint32_t swap32( uint32_t x );
API uint64_t swap64( uint64_t x ); API uint64_t swap64( uint64_t x );
API float swap32f(float n); API float swap32f(float n);
API double swap64f(double n); API double swap64f(double n);
API void swapf(float *a, float *b);
API void swapf2(vec2 *a, vec2 *b);
API void swapf3(vec3 *a, vec3 *b);
API void swapf4(vec4 *a, vec4 *b);
API uint16_t lil16(uint16_t n); // swap16 as lil API uint16_t lil16(uint16_t n); // swap16 as lil
API uint32_t lil32(uint32_t n); // swap32 as lil API uint32_t lil32(uint32_t n); // swap32 as lil
@ -16579,7 +16581,7 @@ extern API int profiler_enabled; ///-
#define ifdef_objapi(T,...) __VA_ARGS__ #define ifdef_objapi(T,...) __VA_ARGS__
#endif #endif
typedef struct reflected_t { typedef struct reflect_t {
unsigned id, objtype; unsigned id, objtype;
unsigned sz; unsigned sz;
const char *name; const char *name;
@ -16587,7 +16589,7 @@ typedef struct reflected_t {
void *addr; void *addr;
unsigned parent; unsigned parent;
const char *type; const char *type;
} reflected_t; } reflect_t;
// inscribe api // inscribe api
@ -16607,16 +16609,16 @@ typedef struct reflected_t {
API unsigned enum_find(const char *E); API unsigned enum_find(const char *E);
API void * function_find(const char *F); API void * function_find(const char *F);
API reflected_t member_find(const char *T, const char *M); /// find specific member API reflect_t member_find(const char *T, const char *M); /// find specific member
API void * member_findptr(void *obj, const char *T, const char *M); API void * member_findptr(void *obj, const char *T, const char *M);
API array(reflected_t) members_find(const char *T); API array(reflect_t) members_find(const char *T);
// iterate members in a struct // iterate members in a struct
#define each_member(T,R) \ #define each_member(T,R) \
(array(reflected_t)*found_ = map_find(members, intern(T)); found_; found_ = 0) \ (array(reflect_t)*found_ = map_find(members, intern(T)); found_; found_ = 0) \
for(int it_ = 0, end_ = array_count(*found_); it_ != end_; ++it_ ) \ for(int it_ = 0, end_ = array_count(*found_); it_ != end_; ++it_ ) \
for(reflected_t *R = (*found_)+it_; R; R = 0 ) for(reflect_t *R = (*found_)+it_; R; R = 0 )
// private api, still exposed // private api, still exposed
@ -16626,7 +16628,7 @@ API void struct_inscribe(const char *T,unsigned Tid,unsigned Tsz,u
API void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type); API void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type);
API void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos); API void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos);
API void reflected_printf(reflected_t *r); API void reflected_printf(reflect_t *r);
API void reflected_printf_all(); API void reflected_printf_all();
#line 0 #line 0
@ -17168,11 +17170,11 @@ typedef struct shadertoy_t {
int uniforms[32]; int uniforms[32];
int texture_channels[4]; int texture_channels[4];
int frame; int frame;
float clickx, clicky;
uint64_t t; uint64_t t;
texture_t tx; texture_t tx;
vec2i dims; vec2i dims;
int flags; int flags;
vec4 mouse;
} shadertoy_t; } shadertoy_t;
API shadertoy_t shadertoy( const char *shaderfile, unsigned flags ); API shadertoy_t shadertoy( const char *shaderfile, unsigned flags );
@ -331528,28 +331530,6 @@ void (set_free)(set* m) {
set zero = {0}; set zero = {0};
*m = zero; *m = zero;
} }
char *cc4str(unsigned x) {
static __thread char type[4+1] = {0};
type[3] = (x >> 24ULL) & 255;
type[2] = (x >> 16ULL) & 255;
type[1] = (x >> 8ULL) & 255;
type[0] = (x >> 0ULL) & 255;
return type;
}
char *cc8str(uint64_t x) {
static __thread char type[8+1] = {0};
type[7] = (x >> 56ULL) & 255;
type[6] = (x >> 48ULL) & 255;
type[5] = (x >> 40ULL) & 255;
type[4] = (x >> 32ULL) & 255;
type[3] = (x >> 24ULL) & 255;
type[2] = (x >> 16ULL) & 255;
type[1] = (x >> 8ULL) & 255;
type[0] = (x >> 0ULL) & 255;
return type;
}
#line 0 #line 0
#line 1 "engine/split/v4k_string.c" #line 1 "engine/split/v4k_string.c"
@ -335684,6 +335664,11 @@ void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"
COOK_INI = pathfile_to_cook_ini; COOK_INI = pathfile_to_cook_ini;
ASSERT( file_exist(COOK_INI) ); ASSERT( file_exist(COOK_INI) );
} }
bool have_tools() {
static bool found; do_once found = file_exist(COOK_INI);
return ifdef(retail, false, found);
}
#line 0 #line 0
#line 1 "engine/split/v4k_data.c" #line 1 "engine/split/v4k_data.c"
@ -336226,12 +336211,12 @@ char *ext = strrchr(base, '.'); //if (ext) ext[0] = '\0'; // remove all extensio
return va("%s", buffer); return va("%s", buffer);
} }
array(char*) file_list(const char *pathmasks) { array(char*) file_list(const char *pathmasks) {
static __thread array(char*) list = 0; // @fixme: should we add 16 slots in here similar to what we do in va() ? static __thread array(char*) list = 0; // @fixme: add 16 slots
for( int i = 0; i < array_count(list); ++i ) { for( int i = 0; i < array_count(list); ++i ) {
FREE(list[i]); FREE(list[i]);
} }
array_resize(list, 0);//array_free(list); array_resize(list, 0);
for each_substring(pathmasks,";",pathmask) { for each_substring(pathmasks,";",pathmask) {
char *cwd = 0, *masks = 0; char *cwd = 0, *masks = 0;
@ -336270,6 +336255,7 @@ array(char*) file_list(const char *pathmasks) {
} }
} }
array_sort(list, strcmp);
return list; return list;
} }
@ -336600,8 +336586,8 @@ struct vfs_entry {
const char *id; const char *id;
unsigned size; unsigned size;
}; };
array(struct vfs_entry) vfs_hints; // mounted raw assets static array(struct vfs_entry) vfs_hints; // mounted raw assets
array(struct vfs_entry) vfs_entries; // mounted cooked assets static array(struct vfs_entry) vfs_entries; // mounted cooked assets
static bool vfs_mount_hints(const char *path); static bool vfs_mount_hints(const char *path);
static static
@ -336718,13 +336704,13 @@ bool vfs_mount_hints(const char *path) {
bool vfs_mount(const char *path) { bool vfs_mount(const char *path) {
return vfs_mount_(path, &vfs_entries); return vfs_mount_(path, &vfs_entries);
} }
const char** vfs_list(const char *masks) { array(char*) vfs_list(const char *masks) {
static __thread array(char*) list = 0; static __thread array(char*) list = 0; // @fixme: add 16 slots
for( int i = 0; i < array_count(list); ++i ) { for( int i = 0; i < array_count(list); ++i ) {
FREE(list[i]); FREE(list[i]);
} }
array_free(list); array_resize(list, 0);
for each_substring(masks,";",it) { for each_substring(masks,";",it) {
if( COOK_ON_DEMAND ) // edge case: any game using only vfs api + cook-on-demand flag will never find any file if( COOK_ON_DEMAND ) // edge case: any game using only vfs api + cook-on-demand flag will never find any file
@ -336750,8 +336736,7 @@ const char** vfs_list(const char *masks) {
array_sort(list, strcmp); array_sort(list, strcmp);
array_unique(list, strcmp_qsort); array_unique(list, strcmp_qsort);
array_push(list, 0); // terminator return list;
return (const char**)list;
} }
static static
@ -336936,8 +336921,7 @@ if( found && *found == 0 ) {
// yet another last resort: redirect vfs_load() calls to file_load() // yet another last resort: redirect vfs_load() calls to file_load()
// (for environments without tools or cooked assets) // (for environments without tools or cooked assets)
if(!ptr) { if(!ptr) {
static bool have_tools; do_once have_tools = file_exist(COOK_INI); if( !have_tools() ) {
if( !have_tools ) {
ptr = file_load(pathfile, size_out); ptr = file_load(pathfile, size_out);
} }
} }
@ -340268,54 +340252,6 @@ int ui_gamepads() {
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
vec2 atof2(const char *s) {
vec2 v = {0};
sscanf(s, "%f,%f", &v.x, &v.y);
return v;
}
vec3 atof3(const char *s) {
vec3 v = {0};
sscanf(s, "%f,%f,%f", &v.x, &v.y, &v.z);
return v;
}
vec4 atof4(const char *s) {
vec4 v = {0};
sscanf(s, "%f,%f,%f,%f", &v.x, &v.y, &v.z, &v.w);
return v;
}
char* ftoa(float f) {
return va("%f", f);
}
char* ftoa2(vec2 v) {
return va("%f,%f", v.x, v.y);
}
char* ftoa3(vec3 v) {
return va("%f,%f,%f", v.x, v.y, v.z);
}
char* ftoa4(vec4 v) {
return va("%f,%f,%f,%f", v.x, v.y, v.z, v.w);
}
void swapf(float *a, float *b) {
float t = *a; *a = *b; *b = *a;
}
void swapf2(vec2 *a, vec2 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
}
void swapf3(vec3 *a, vec3 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
float z = a->z; a->z = b->z; b->z = a->z;
}
void swapf4(vec4 *a, vec4 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
float z = a->z; a->z = b->z; b->z = a->z;
float w = a->w; a->w = b->w; b->w = a->w;
}
static uint64_t rand_xoro256(uint64_t x256_s[4]) { // xoshiro256+ 1.0 by David Blackman and Sebastiano Vigna (PD) static uint64_t rand_xoro256(uint64_t x256_s[4]) { // xoshiro256+ 1.0 by David Blackman and Sebastiano Vigna (PD)
const uint64_t result = x256_s[0] + x256_s[3]; const uint64_t result = x256_s[0] + x256_s[3];
const uint64_t t = x256_s[1] << 17; const uint64_t t = x256_s[1] << 17;
@ -341458,19 +341394,6 @@ int portname( const char *service_name, unsigned retries ) {
return ((hash & 0xFFF) * 677 / 100 + 5001); return ((hash & 0xFFF) * 677 / 100 + 5001);
} }
static
void netdump( const void *ptr, int len ) {
char hexbuf[256] = {0}, strbuf[256] = {0}, *data = (char*)ptr, width = 16;
for( int jt = 0; jt < len; jt += width ) {
char *hex = hexbuf, *str = strbuf;
for( int it = jt, next = it + width; it < len && it < next; ++it, ++data ) {
hex += sprintf( hex, "%02x ", (unsigned char)*data);
str += sprintf( str, "%c", *data >= 32 && *data != '\\' ? *data : '.');
}
printf("%06x %-*s%s\n", jt, width*3, hexbuf, strbuf);
}
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define UDP_DEBUG 0 #define UDP_DEBUG 0
@ -341515,7 +341438,7 @@ int udp_send( int fd, const void *buf, int len ) { // returns bytes sent, or -1
int rc2 = swrapAddressInfo(&sa, host, 128, serv, 128 ); int rc2 = swrapAddressInfo(&sa, host, 128, serv, 128 );
if( rc2 != 0 ) PANIC("swrapAddressInfo error"); if( rc2 != 0 ) PANIC("swrapAddressInfo error");
printf("udp_send: %d bytes to %s:%s : %.*s\n", rc, host, serv, rc, buf ); printf("udp_send: %d bytes to %s:%s : %.*s\n", rc, host, serv, rc, buf );
netdump(buf, rc); hexdump(buf, rc);
} }
#endif #endif
return rc; return rc;
@ -341569,7 +341492,7 @@ int udp_recv( int fd, void *buf, int len ) { // <0 error, 0 orderly shutdown, >0
int rc2 = swrapAddressInfo(&sa, host, 128, serv, 128 ); int rc2 = swrapAddressInfo(&sa, host, 128, serv, 128 );
if( rc2 != 0 ) PANIC("swrapAddressInfo error"); if( rc2 != 0 ) PANIC("swrapAddressInfo error");
printf("udp_recv: %d bytes from %s:%s : %.*s\n", rc, host, serv, rc, buf ); printf("udp_recv: %d bytes from %s:%s : %.*s\n", rc, host, serv, rc, buf );
netdump(buf, rc); hexdump(buf, rc);
#endif #endif
return rc; return rc;
@ -341613,7 +341536,7 @@ int tcp_send(int fd, const void *buf, int len) {
#if TCP_DEBUG #if TCP_DEBUG
if( set_find(tcp_set, fd) ) { if( set_find(tcp_set, fd) ) {
printf("send -> %11d (status: %d) %s:%s\n", len, rc, tcp_host(fd), tcp_port(fd)); printf("send -> %11d (status: %d) %s:%s\n", len, rc, tcp_host(fd), tcp_port(fd));
if( rc > 0 ) netdump(buf, rc); if( rc > 0 ) hexdump(buf, rc);
} }
#endif #endif
return rc; return rc;
@ -341623,7 +341546,7 @@ int tcp_recv(int fd, void *buf, int len) {
#if TCP_DEBUG #if TCP_DEBUG
if( rc != 0 && set_find(tcp_set, fd) ) { if( rc != 0 && set_find(tcp_set, fd) ) {
printf("recv <- %11d (status: %d) %s:%s\n", len, rc, tcp_host(fd), tcp_port(fd)); printf("recv <- %11d (status: %d) %s:%s\n", len, rc, tcp_host(fd), tcp_port(fd));
if( rc > 0 ) netdump(buf, rc); if( rc > 0 ) hexdump(buf, rc);
} }
#endif #endif
return rc; return rc;
@ -342357,17 +342280,67 @@ void network_rpc_send(unsigned id, const char *cmdline) {
#line 0 #line 0
#line 1 "engine/split/v4k_pack.c" #line 1 "engine/split/v4k_pack.c"
// -----------------------------------------------------------------------------
// compile-time fourcc, eightcc
char *cc4str(unsigned x) {
static __thread char type[4+1] = {0};
type[3] = (x >> 24ULL) & 255;
type[2] = (x >> 16ULL) & 255;
type[1] = (x >> 8ULL) & 255;
type[0] = (x >> 0ULL) & 255;
return type;
}
char *cc8str(uint64_t x) {
static __thread char type[8+1] = {0};
type[7] = (x >> 56ULL) & 255;
type[6] = (x >> 48ULL) & 255;
type[5] = (x >> 40ULL) & 255;
type[4] = (x >> 32ULL) & 255;
type[3] = (x >> 24ULL) & 255;
type[2] = (x >> 16ULL) & 255;
type[1] = (x >> 8ULL) & 255;
type[0] = (x >> 0ULL) & 255;
return type;
}
// ----------------------------------------------------------------------------
// float conversion (text)
vec2 atof2(const char *s) {
vec2 v = {0};
sscanf(s, "%f,%f", &v.x, &v.y);
return v;
}
vec3 atof3(const char *s) {
vec3 v = {0};
sscanf(s, "%f,%f,%f", &v.x, &v.y, &v.z);
return v;
}
vec4 atof4(const char *s) {
vec4 v = {0};
sscanf(s, "%f,%f,%f,%f", &v.x, &v.y, &v.z, &v.w);
return v;
}
char* ftoa(float f) {
return va("%f", f);
}
char* ftoa2(vec2 v) {
return va("%f,%f", v.x, v.y);
}
char* ftoa3(vec3 v) {
return va("%f,%f,%f", v.x, v.y, v.z);
}
char* ftoa4(vec4 v) {
return va("%f,%f,%f,%f", v.x, v.y, v.z, v.w);
}
// endianness ----------------------------------------------------------------- // endianness -----------------------------------------------------------------
// - rlyeh, public domain // - rlyeh, public domain
#if !is(cl) && !is(gcc) int is_big() { return IS_BIG; }
uint16_t (swap16)( uint16_t x ) { return (x << 8) | (x >> 8); } int is_little() { return IS_LITTLE; }
uint32_t (swap32)( uint32_t x ) { x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); return (x << 16) | (x >> 16); }
uint64_t (swap64)( uint64_t x ) { x = ((x << 8) & 0xff00ff00ff00ff00ULL) | ((x >> 8) & 0x00ff00ff00ff00ffULL); x = ((x << 16) & 0xffff0000ffff0000ULL) | ((x >> 16) & 0x0000ffff0000ffffULL); return (x << 32) | (x >> 32); }
#endif
float swap32f(float n) { union { float t; uint32_t i; } conv; conv.t = n; conv.i = swap32(conv.i); return conv.t; }
double swap64f(double n) { union { double t; uint64_t i; } conv; conv.t = n; conv.i = swap64(conv.i); return conv.t; }
uint16_t lil16(uint16_t n) { return IS_BIG ? swap16(n) : n; } uint16_t lil16(uint16_t n) { return IS_BIG ? swap16(n) : n; }
uint32_t lil32(uint32_t n) { return IS_BIG ? swap32(n) : n; } uint32_t lil32(uint32_t n) { return IS_BIG ? swap32(n) : n; }
@ -342393,8 +342366,33 @@ float * big32pf(void *p, int sz) { if(IS_LITTLE ) { float *n = (float *)
double * lil64pf(void *p, int sz) { if(IS_BIG ) { double *n = (double *)p; for(int i = 0; i < sz; ++i) n[i] = swap64f(n[i]); } return p; } double * lil64pf(void *p, int sz) { if(IS_BIG ) { double *n = (double *)p; for(int i = 0; i < sz; ++i) n[i] = swap64f(n[i]); } return p; }
double * big64pf(void *p, int sz) { if(IS_LITTLE ) { double *n = (double *)p; for(int i = 0; i < sz; ++i) n[i] = swap64f(n[i]); } return p; } double * big64pf(void *p, int sz) { if(IS_LITTLE ) { double *n = (double *)p; for(int i = 0; i < sz; ++i) n[i] = swap64f(n[i]); } return p; }
int is_big() { return IS_BIG; } #if !is(cl) && !is(gcc)
int is_little() { return IS_LITTLE; } uint16_t (swap16)( uint16_t x ) { return (x << 8) | (x >> 8); }
uint32_t (swap32)( uint32_t x ) { x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); return (x << 16) | (x >> 16); }
uint64_t (swap64)( uint64_t x ) { x = ((x << 8) & 0xff00ff00ff00ff00ULL) | ((x >> 8) & 0x00ff00ff00ff00ffULL); x = ((x << 16) & 0xffff0000ffff0000ULL) | ((x >> 16) & 0x0000ffff0000ffffULL); return (x << 32) | (x >> 32); }
#endif
float swap32f(float n) { union { float t; uint32_t i; } conv; conv.t = n; conv.i = swap32(conv.i); return conv.t; }
double swap64f(double n) { union { double t; uint64_t i; } conv; conv.t = n; conv.i = swap64(conv.i); return conv.t; }
void swapf(float *a, float *b) {
float t = *a; *a = *b; *b = *a;
}
void swapf2(vec2 *a, vec2 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
}
void swapf3(vec3 *a, vec3 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
float z = a->z; a->z = b->z; b->z = a->z;
}
void swapf4(vec4 *a, vec4 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
float z = a->z; a->z = b->z; b->z = a->z;
float w = a->w; a->w = b->w; b->w = a->w;
}
// half packing ----------------------------------------------------------------- // half packing -----------------------------------------------------------------
// from GingerBill's gbmath.h (public domain) // from GingerBill's gbmath.h (public domain)
@ -343823,15 +343821,15 @@ AUTORUN {
// @todo: nested structs? pointers in members? // @todo: nested structs? pointers in members?
// @todo: declare TYPEDEF(vec3, float[3]), TYPEDEF(mat4, vec4[4]/*float[16]*/) // @todo: declare TYPEDEF(vec3, float[3]), TYPEDEF(mat4, vec4[4]/*float[16]*/)
static map(unsigned, reflected_t) reflects; static map(unsigned, reflect_t) reflects;
static map(unsigned, array(reflected_t)) members; static map(unsigned, array(reflect_t)) members;
void reflected_printf(reflected_t *r) { void reflected_printf(reflect_t *r) {
printf("name:%s info:'%s' id:%u objtype:%u sz:%u addr:%p parent:%u type:%s", printf("name:%s info:'%s' id:%u objtype:%u sz:%u addr:%p parent:%u type:%s",
r->name ? r->name : "", r->info ? r->info : "", r->id, r->objtype, r->sz, r->addr, r->parent, r->type ? r->type : ""); r->name ? r->name : "", r->info ? r->info : "", r->id, r->objtype, r->sz, r->addr, r->parent, r->type ? r->type : "");
} }
void reflected_printf_all() { void reflected_printf_all() {
for each_map_ptr(reflects, unsigned, k, reflected_t, p) { for each_map_ptr(reflects, unsigned, k, reflect_t, p) {
reflected_printf(p); reflected_printf(p);
puts(""); puts("");
} }
@ -343839,42 +343837,42 @@ void reflected_printf_all() {
void type_inscribe(const char *TY,unsigned TYid,unsigned TYsz,const char *infos) { void type_inscribe(const char *TY,unsigned TYid,unsigned TYsz,const char *infos) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, TYid, ((reflected_t){TYid, 0, TYsz, TY, infos})); map_find_or_add(reflects, TYid, ((reflect_t){TYid, 0, TYsz, TY, infos}));
} }
void enum_inscribe(const char *E,unsigned Eid,unsigned Eval,const char *infos) { void enum_inscribe(const char *E,unsigned Eid,unsigned Eval,const char *infos) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, Eid, ((reflected_t){Eid,0, Eval, E,infos})); map_find_or_add(reflects, Eid, ((reflect_t){Eid,0, Eval, E,infos}));
} }
unsigned enum_find(const char *E) { unsigned enum_find(const char *E) {
return map_find(reflects, intern(E))->sz; return map_find(reflects, intern(E))->sz;
} }
void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos) { void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, Fid, ((reflected_t){Fid,0, 0, F,infos, func})); map_find_or_add(reflects, Fid, ((reflect_t){Fid,0, 0, F,infos, func}));
reflected_t *found = map_find(reflects,Fid); reflect_t *found = map_find(reflects,Fid);
} }
void *function_find(const char *F) { void *function_find(const char *F) {
return map_find(reflects, intern(F))->addr; return map_find(reflects, intern(F))->addr;
} }
void struct_inscribe(const char *T,unsigned Tid,unsigned Tsz,unsigned OBJTYPEid, const char *infos) { void struct_inscribe(const char *T,unsigned Tid,unsigned Tsz,unsigned OBJTYPEid, const char *infos) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, Tid, ((reflected_t){Tid, OBJTYPEid, Tsz, T, infos})); map_find_or_add(reflects, Tid, ((reflect_t){Tid, OBJTYPEid, Tsz, T, infos}));
} }
void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type) { void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, (Mid<<16)|Tid, ((reflected_t){Mid, 0, Msz, M, infos, NULL, Tid, type })); map_find_or_add(reflects, (Mid<<16)|Tid, ((reflect_t){Mid, 0, Msz, M, infos, NULL, Tid, type }));
// add member separately as well // add member separately as well
if(!members) map_init_int(members); if(!members) map_init_int(members);
array(reflected_t) *found = map_find_or_add(members, Tid, 0); array(reflect_t) *found = map_find_or_add(members, Tid, 0);
array_push(*found, ((reflected_t){Mid, 0, Msz, M, infos, NULL, Tid, type })); array_push(*found, ((reflect_t){Mid, 0, Msz, M, infos, NULL, Tid, type }));
} }
reflected_t member_find(const char *T, const char *M) { reflect_t member_find(const char *T, const char *M) {
return *map_find(reflects, (intern(M)<<16)|intern(T)); return *map_find(reflects, (intern(M)<<16)|intern(T));
} }
void *member_findptr(void *obj, const char *T, const char *M) { void *member_findptr(void *obj, const char *T, const char *M) {
return (char*)obj + member_find(T,M).sz; return (char*)obj + member_find(T,M).sz;
} }
array(reflected_t) members_find(const char *T) { array(reflect_t) members_find(const char *T) {
return *map_find(members, intern(T)); return *map_find(members, intern(T));
} }
@ -346596,7 +346594,7 @@ skybox_t skybox(const char *asset, int flags) {
// sky cubemap & SH // sky cubemap & SH
if( asset ) { if( asset ) {
int is_panorama = vfs_size( asset ); int is_panorama = vfs_size( asset );
if( is_panorama ) { if( is_panorama ) { // is file
stbi_hdr_to_ldr_gamma(1.2f); stbi_hdr_to_ldr_gamma(1.2f);
image_t panorama = image( asset, IMAGE_RGBA ); image_t panorama = image( asset, IMAGE_RGBA );
sky.cubemap = cubemap( panorama, 0 ); // RGBA required sky.cubemap = cubemap( panorama, 0 ); // RGBA required
@ -346613,7 +346611,7 @@ skybox_t skybox(const char *asset, int flags) {
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]); for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
} }
} else { } else {
// set up mie defaults // set up mie defaults // @fixme: use shader params instead
shader_bind(sky.program); shader_bind(sky.program);
shader_vec3("uSunPos", vec3( 0, 0.1, -1 )); shader_vec3("uSunPos", vec3( 0, 0.1, -1 ));
shader_vec3("uRayOrigin", vec3(0.0, 6372000.0, 0.0)); shader_vec3("uRayOrigin", vec3(0.0, 6372000.0, 0.0));
@ -347377,9 +347375,9 @@ int fx_load_from_mem(const char *nameid, const char *content) {
} }
int fx_load(const char *filemask) { int fx_load(const char *filemask) {
static set(char*) added = 0; do_once set_init_str(added); static set(char*) added = 0; do_once set_init_str(added);
for(const char **list = vfs_list(filemask); *list; list++) { for each_array( vfs_list(filemask), char*, list ) {
if( set_find(added, (char*)*list) ) continue; if( set_find(added, list) ) continue;
char *name = STRDUP(*list); // @leak char *name = STRDUP(list); // @leak
set_insert(added, name); set_insert(added, name);
(void)postfx_load_from_mem(&fx, file_name(name), vfs_read(name)); (void)postfx_load_from_mem(&fx, file_name(name), vfs_read(name));
} }
@ -347439,7 +347437,8 @@ static void brdf_load() {
brdf = texture_compressed( filename, brdf = texture_compressed( filename,
TEXTURE_CLAMP | TEXTURE_NEAREST | TEXTURE_RG | TEXTURE_FLOAT | TEXTURE_SRGB TEXTURE_CLAMP | TEXTURE_NEAREST | TEXTURE_RG | TEXTURE_FLOAT | TEXTURE_SRGB
); );
ASSERT(brdf.id != texture_checker().id, "!Couldn't load BRDF lookup table '%s'!", filename ); unsigned texchecker = texture_checker().id;
ASSERT(brdf.id != texchecker, "!Couldn't load BRDF lookup table '%s'!", filename );
} }
texture_t brdf_lut() { texture_t brdf_lut() {
@ -347607,8 +347606,9 @@ shadertoy_t* shadertoy_render(shadertoy_t *s, float delta) {
return s; return s;
} }
float mx = input(MOUSE_X), my = input(MOUSE_Y); if(input_down(MOUSE_L) || input_down(MOUSE_R) ) s->mouse.z = input(MOUSE_X), s->mouse.w = -(window_height() - input(MOUSE_Y));
if(input(MOUSE_L)) s->clickx = mx, s->clicky = my; if(input(MOUSE_L) || input(MOUSE_R)) s->mouse.x = input(MOUSE_X), s->mouse.y = (window_height() - input(MOUSE_Y));
vec4 m = mul4(s->mouse, vec4(1,1,1-2*(!input(MOUSE_L) && !input(MOUSE_R)),1-2*(input_down(MOUSE_L) || input_down(MOUSE_R))));
time_t tmsec = time(0); time_t tmsec = time(0);
struct tm *tm = localtime(&tmsec); struct tm *tm = localtime(&tmsec);
@ -347619,7 +347619,7 @@ shadertoy_t* shadertoy_render(shadertoy_t *s, float delta) {
glUniform1f(s->uniforms[iGlobalFrame], s->frame++); glUniform1f(s->uniforms[iGlobalFrame], s->frame++);
glUniform1f(s->uniforms[iGlobalDelta], delta / 1000.f ); glUniform1f(s->uniforms[iGlobalDelta], delta / 1000.f );
glUniform2f(s->uniforms[iResolution], s->dims.x ? s->dims.x : window_width(), s->dims.y ? s->dims.y : window_height()); glUniform2f(s->uniforms[iResolution], s->dims.x ? s->dims.x : window_width(), s->dims.y ? s->dims.y : window_height());
if (!(s->flags&SHADERTOY_IGNORE_MOUSE)) glUniform4f(s->uniforms[iMouse], mx, my, s->clickx, s->clicky ); if (!(s->flags&SHADERTOY_IGNORE_MOUSE)) glUniform4f(s->uniforms[iMouse], m.x,m.y,m.z,m.w );
glUniform1i(s->uniforms[iFrame], (int)window_frame()); glUniform1i(s->uniforms[iFrame], (int)window_frame());
glUniform1f(s->uniforms[iTime], time_ss()); glUniform1f(s->uniforms[iTime], time_ss());
@ -351155,13 +351155,13 @@ void tty_attach() {
// "following calls are the closest i'm aware you can get to /SUBSYSTEM:CONSOLE in a gui program // "following calls are the closest i'm aware you can get to /SUBSYSTEM:CONSOLE in a gui program
// while cleanly handling existing consoles (cmd.exe), pipes (ninja) and no console (VS/RemedyBG; double-clicking the game)" // while cleanly handling existing consoles (cmd.exe), pipes (ninja) and no console (VS/RemedyBG; double-clicking the game)"
do_once { do_once {
if( !AttachConsole(ATTACH_PARENT_PROCESS) && GetLastError() != ERROR_ACCESS_DENIED ) ASSERT( AllocConsole() ); if( !AttachConsole(ATTACH_PARENT_PROCESS) && GetLastError() != ERROR_ACCESS_DENIED ) { bool ok = !!AllocConsole(); ASSERT( ok ); }
printf("\n"); // print >= 1 byte to distinguish empty stdout from a redirected stdout (fgetpos() position <= 0) printf("\n"); // print >= 1 byte to distinguish empty stdout from a redirected stdout (fgetpos() position <= 0)
fpos_t pos = 0; fpos_t pos = 0;
if( fgetpos(stdout, &pos) != 0 || pos <= 0 ) { if( fgetpos(stdout, &pos) != 0 || pos <= 0 ) {
ASSERT(freopen("CONIN$" , "r", stdin )); bool ok1 = !!freopen("CONIN$" , "r", stdin ); ASSERT( ok1 );
ASSERT(freopen("CONOUT$", "w", stderr)); bool ok2 = !!freopen("CONOUT$", "w", stderr); ASSERT( ok2 );
ASSERT(freopen("CONOUT$", "w", stdout)); bool ok3 = !!freopen("CONOUT$", "w", stdout); ASSERT( ok3 );
} }
} }
#endif #endif
@ -351366,6 +351366,10 @@ void app_singleton(const char *guid) {
#endif #endif
} }
#ifdef APP_SINGLETON_GUID
AUTORUN { app_singleton(APP_SINGLETON_GUID); }
#endif
static static
bool app_open_folder(const char *file) { bool app_open_folder(const char *file) {
char buf[1024]; char buf[1024];
@ -354766,7 +354770,7 @@ bool window_create_from_handle(void *handle, float scale, unsigned flags) {
// display a progress bar meanwhile cook is working in the background // display a progress bar meanwhile cook is working in the background
// Sleep(500); // Sleep(500);
if( !COOK_ON_DEMAND ) if( !COOK_ON_DEMAND )
if( file_exist(COOK_INI) && cook_jobs() ) if( have_tools() && cook_jobs() )
while( cook_progress() < 100 ) { while( cook_progress() < 100 ) {
for( int frames = 0; frames < 2/*10*/ && window_swap(); frames += cook_progress() >= 100 ) { for( int frames = 0; frames < 2/*10*/ && window_swap(); frames += cook_progress() >= 100 ) {
window_title(va("%s %.2d%%", cook_cancelling ? "Aborting" : "Cooking assets", cook_progress())); window_title(va("%s %.2d%%", cook_cancelling ? "Aborting" : "Cooking assets", cook_progress()));
@ -354855,7 +354859,7 @@ char* window_stats() {
prev_frame = now; prev_frame = now;
++num_frames; ++num_frames;
return buf + 3 * (buf[0] == ' '); return buf + strspn(buf, " ");
} }
int window_frame_begin() { int window_frame_begin() {
@ -354863,7 +354867,7 @@ int window_frame_begin() {
// we cannot simply terminate threads on some OSes. also, aborted cook jobs could leave temporary files on disc. // we cannot simply terminate threads on some OSes. also, aborted cook jobs could leave temporary files on disc.
// so let's try to be polite: we will be disabling any window closing briefly until all cook is either done or canceled. // so let's try to be polite: we will be disabling any window closing briefly until all cook is either done or canceled.
static bool has_cook; do_once has_cook = !COOK_ON_DEMAND && file_exist(COOK_INI) && cook_jobs(); static bool has_cook; do_once has_cook = !COOK_ON_DEMAND && have_tools() && cook_jobs();
if( has_cook ) { if( has_cook ) {
has_cook = cook_progress() < 100; has_cook = cook_progress() < 100;
if( glfwWindowShouldClose(g->window) ) cook_cancel(); if( glfwWindowShouldClose(g->window) ) cook_cancel();
@ -354876,28 +354880,23 @@ int window_frame_begin() {
glNewFrame(); glNewFrame();
#if !ENABLE_RETAIL
ui_create(); ui_create();
bool may_render_stats = 1; #if !ENABLE_RETAIL
bool has_menu = 0; // ui_has_menubar();
bool may_render_debug_panel = 1;
int has_menu = ui_has_menubar(); if( have_tools() ) {
if( !has_menu ) { static int cook_has_progressbar; do_once cook_has_progressbar = !COOK_ON_DEMAND;
static int cook_on_demand; do_once cook_on_demand = COOK_ON_DEMAND; if( cook_has_progressbar) {
if( !cook_on_demand ) {
// render profiler, unless we are in the cook progress screen // render profiler, unless we are in the cook progress screen
static unsigned frames = 0; if(frames <= 0) frames += cook_progress() >= 100; static unsigned frames = 0; if(frames <= 0) frames += cook_progress() >= 100;
may_render_stats = (frames > 0); may_render_debug_panel = (frames > 0);
} }
} }
// @transparent
static bool has_transparent_attrib = 0; ifndef(ems, do_once has_transparent_attrib = glfwGetWindowAttrib(window_handle(), GLFW_TRANSPARENT_FRAMEBUFFER) == GLFW_TRUE);
if( has_transparent_attrib ) may_render_stats = 0;
// @transparent
// generate Debug panel contents // generate Debug panel contents
if( may_render_stats ) { if( may_render_debug_panel ) {
if( has_menu ? ui_window("Debug " ICON_MD_SETTINGS, 0) : ui_panel("Debug " ICON_MD_SETTINGS, 0) ) { if( has_menu ? ui_window("Debug " ICON_MD_SETTINGS, 0) : ui_panel("Debug " ICON_MD_SETTINGS, 0) ) {
static int time_factor = 0; static int time_factor = 0;
@ -356997,14 +356996,11 @@ static void v4k_pre_init() {
int i; int i;
#pragma omp parallel for #pragma omp parallel for
for( i = 0; i <= 6; ++i) { for( i = 0; i <= 3; ++i) {
/**/ if( i == 0 ) ddraw_init();// init this on thread#0 since it will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up /**/ if( i == 0 ) ddraw_init();// init this on thread#0 since it will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up
else if( i == 1 ) sprite_init(); else if( i == 1 ) sprite_init();
else if( i == 2 ) profiler_init(); else if( i == 2 ) profiler_init();
else if( i == 3 ) storage_mount("save/"), storage_read(), touch_init(); // for ems else if( i == 3 ) storage_mount("save/"), storage_read(), touch_init(); // for ems
else if( i == 4 ) audio_init(0);
else if( i == 5 ) script_init(), kit_init(), midi_init();
else if( i == 6 ) network_init();
} }
// window_swap(); // window_swap();
@ -357019,11 +357015,14 @@ static void v4k_post_init(float refresh_rate) {
int i; int i;
#pragma omp parallel for #pragma omp parallel for
for( i = 0; i <= 2; ++i ) { for( i = 0; i <= 3; ++i ) {
if(i == 0) ui_init(); // init these on thread #0, since both will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up
if(i == 0) scene_init(); // init these on thread #0, since both will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up if(i == 0) scene_init(); // init these on thread #0, since both will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up
if(i == 0) window_icon(va("%s.png", app_name())); if(i == 0) ui_init(); // init these on thread #0, since both will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up
if(i == 1) input_init(); if(i == 0) window_icon(va("%s.png", app_name())); // init on thread #0, because of glfw
if(i == 0) input_init(); // init on thread #0, because of glfw
if(i == 1) audio_init(0);
if(i == 2) script_init(), kit_init(), midi_init();
if(i == 3) network_init();
} }
// display window // display window
@ -357074,7 +357073,7 @@ void v4k_init() {
} }
// create or update cook.zip file // create or update cook.zip file
if( /* !COOK_ON_DEMAND && */ file_exist(COOK_INI) && cook_jobs() ) { if( /* !COOK_ON_DEMAND && */ have_tools() && cook_jobs() ) {
cook_start(COOK_INI, "**", 0|COOK_ASYNC|COOK_CANCELABLE ); cook_start(COOK_INI, "**", 0|COOK_ASYNC|COOK_CANCELABLE );
} }

View File

@ -490,28 +490,6 @@ void (set_free)(set* m) {
set zero = {0}; set zero = {0};
*m = zero; *m = zero;
} }
char *cc4str(unsigned x) {
static __thread char type[4+1] = {0};
type[3] = (x >> 24ULL) & 255;
type[2] = (x >> 16ULL) & 255;
type[1] = (x >> 8ULL) & 255;
type[0] = (x >> 0ULL) & 255;
return type;
}
char *cc8str(uint64_t x) {
static __thread char type[8+1] = {0};
type[7] = (x >> 56ULL) & 255;
type[6] = (x >> 48ULL) & 255;
type[5] = (x >> 40ULL) & 255;
type[4] = (x >> 32ULL) & 255;
type[3] = (x >> 24ULL) & 255;
type[2] = (x >> 16ULL) & 255;
type[1] = (x >> 8ULL) & 255;
type[0] = (x >> 0ULL) & 255;
return type;
}
#line 0 #line 0
#line 1 "engine/split/v4k_string.c" #line 1 "engine/split/v4k_string.c"
@ -4646,6 +4624,11 @@ void cook_config( const char *pathfile_to_cook_ini ) { // @todo: test run-from-"
COOK_INI = pathfile_to_cook_ini; COOK_INI = pathfile_to_cook_ini;
ASSERT( file_exist(COOK_INI) ); ASSERT( file_exist(COOK_INI) );
} }
bool have_tools() {
static bool found; do_once found = file_exist(COOK_INI);
return ifdef(retail, false, found);
}
#line 0 #line 0
#line 1 "engine/split/v4k_data.c" #line 1 "engine/split/v4k_data.c"
@ -5188,12 +5171,12 @@ char *ext = strrchr(base, '.'); //if (ext) ext[0] = '\0'; // remove all extensio
return va("%s", buffer); return va("%s", buffer);
} }
array(char*) file_list(const char *pathmasks) { array(char*) file_list(const char *pathmasks) {
static __thread array(char*) list = 0; // @fixme: should we add 16 slots in here similar to what we do in va() ? static __thread array(char*) list = 0; // @fixme: add 16 slots
for( int i = 0; i < array_count(list); ++i ) { for( int i = 0; i < array_count(list); ++i ) {
FREE(list[i]); FREE(list[i]);
} }
array_resize(list, 0);//array_free(list); array_resize(list, 0);
for each_substring(pathmasks,";",pathmask) { for each_substring(pathmasks,";",pathmask) {
char *cwd = 0, *masks = 0; char *cwd = 0, *masks = 0;
@ -5232,6 +5215,7 @@ array(char*) file_list(const char *pathmasks) {
} }
} }
array_sort(list, strcmp);
return list; return list;
} }
@ -5562,8 +5546,8 @@ struct vfs_entry {
const char *id; const char *id;
unsigned size; unsigned size;
}; };
array(struct vfs_entry) vfs_hints; // mounted raw assets static array(struct vfs_entry) vfs_hints; // mounted raw assets
array(struct vfs_entry) vfs_entries; // mounted cooked assets static array(struct vfs_entry) vfs_entries; // mounted cooked assets
static bool vfs_mount_hints(const char *path); static bool vfs_mount_hints(const char *path);
static static
@ -5680,13 +5664,13 @@ bool vfs_mount_hints(const char *path) {
bool vfs_mount(const char *path) { bool vfs_mount(const char *path) {
return vfs_mount_(path, &vfs_entries); return vfs_mount_(path, &vfs_entries);
} }
const char** vfs_list(const char *masks) { array(char*) vfs_list(const char *masks) {
static __thread array(char*) list = 0; static __thread array(char*) list = 0; // @fixme: add 16 slots
for( int i = 0; i < array_count(list); ++i ) { for( int i = 0; i < array_count(list); ++i ) {
FREE(list[i]); FREE(list[i]);
} }
array_free(list); array_resize(list, 0);
for each_substring(masks,";",it) { for each_substring(masks,";",it) {
if( COOK_ON_DEMAND ) // edge case: any game using only vfs api + cook-on-demand flag will never find any file if( COOK_ON_DEMAND ) // edge case: any game using only vfs api + cook-on-demand flag will never find any file
@ -5712,8 +5696,7 @@ const char** vfs_list(const char *masks) {
array_sort(list, strcmp); array_sort(list, strcmp);
array_unique(list, strcmp_qsort); array_unique(list, strcmp_qsort);
array_push(list, 0); // terminator return list;
return (const char**)list;
} }
static static
@ -5898,8 +5881,7 @@ if( found && *found == 0 ) {
// yet another last resort: redirect vfs_load() calls to file_load() // yet another last resort: redirect vfs_load() calls to file_load()
// (for environments without tools or cooked assets) // (for environments without tools or cooked assets)
if(!ptr) { if(!ptr) {
static bool have_tools; do_once have_tools = file_exist(COOK_INI); if( !have_tools() ) {
if( !have_tools ) {
ptr = file_load(pathfile, size_out); ptr = file_load(pathfile, size_out);
} }
} }
@ -9230,54 +9212,6 @@ int ui_gamepads() {
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
vec2 atof2(const char *s) {
vec2 v = {0};
sscanf(s, "%f,%f", &v.x, &v.y);
return v;
}
vec3 atof3(const char *s) {
vec3 v = {0};
sscanf(s, "%f,%f,%f", &v.x, &v.y, &v.z);
return v;
}
vec4 atof4(const char *s) {
vec4 v = {0};
sscanf(s, "%f,%f,%f,%f", &v.x, &v.y, &v.z, &v.w);
return v;
}
char* ftoa(float f) {
return va("%f", f);
}
char* ftoa2(vec2 v) {
return va("%f,%f", v.x, v.y);
}
char* ftoa3(vec3 v) {
return va("%f,%f,%f", v.x, v.y, v.z);
}
char* ftoa4(vec4 v) {
return va("%f,%f,%f,%f", v.x, v.y, v.z, v.w);
}
void swapf(float *a, float *b) {
float t = *a; *a = *b; *b = *a;
}
void swapf2(vec2 *a, vec2 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
}
void swapf3(vec3 *a, vec3 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
float z = a->z; a->z = b->z; b->z = a->z;
}
void swapf4(vec4 *a, vec4 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
float z = a->z; a->z = b->z; b->z = a->z;
float w = a->w; a->w = b->w; b->w = a->w;
}
static uint64_t rand_xoro256(uint64_t x256_s[4]) { // xoshiro256+ 1.0 by David Blackman and Sebastiano Vigna (PD) static uint64_t rand_xoro256(uint64_t x256_s[4]) { // xoshiro256+ 1.0 by David Blackman and Sebastiano Vigna (PD)
const uint64_t result = x256_s[0] + x256_s[3]; const uint64_t result = x256_s[0] + x256_s[3];
const uint64_t t = x256_s[1] << 17; const uint64_t t = x256_s[1] << 17;
@ -10420,19 +10354,6 @@ int portname( const char *service_name, unsigned retries ) {
return ((hash & 0xFFF) * 677 / 100 + 5001); return ((hash & 0xFFF) * 677 / 100 + 5001);
} }
static
void netdump( const void *ptr, int len ) {
char hexbuf[256] = {0}, strbuf[256] = {0}, *data = (char*)ptr, width = 16;
for( int jt = 0; jt < len; jt += width ) {
char *hex = hexbuf, *str = strbuf;
for( int it = jt, next = it + width; it < len && it < next; ++it, ++data ) {
hex += sprintf( hex, "%02x ", (unsigned char)*data);
str += sprintf( str, "%c", *data >= 32 && *data != '\\' ? *data : '.');
}
printf("%06x %-*s%s\n", jt, width*3, hexbuf, strbuf);
}
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define UDP_DEBUG 0 #define UDP_DEBUG 0
@ -10477,7 +10398,7 @@ int udp_send( int fd, const void *buf, int len ) { // returns bytes sent, or -1
int rc2 = swrapAddressInfo(&sa, host, 128, serv, 128 ); int rc2 = swrapAddressInfo(&sa, host, 128, serv, 128 );
if( rc2 != 0 ) PANIC("swrapAddressInfo error"); if( rc2 != 0 ) PANIC("swrapAddressInfo error");
printf("udp_send: %d bytes to %s:%s : %.*s\n", rc, host, serv, rc, buf ); printf("udp_send: %d bytes to %s:%s : %.*s\n", rc, host, serv, rc, buf );
netdump(buf, rc); hexdump(buf, rc);
} }
#endif #endif
return rc; return rc;
@ -10531,7 +10452,7 @@ int udp_recv( int fd, void *buf, int len ) { // <0 error, 0 orderly shutdown, >0
int rc2 = swrapAddressInfo(&sa, host, 128, serv, 128 ); int rc2 = swrapAddressInfo(&sa, host, 128, serv, 128 );
if( rc2 != 0 ) PANIC("swrapAddressInfo error"); if( rc2 != 0 ) PANIC("swrapAddressInfo error");
printf("udp_recv: %d bytes from %s:%s : %.*s\n", rc, host, serv, rc, buf ); printf("udp_recv: %d bytes from %s:%s : %.*s\n", rc, host, serv, rc, buf );
netdump(buf, rc); hexdump(buf, rc);
#endif #endif
return rc; return rc;
@ -10575,7 +10496,7 @@ int tcp_send(int fd, const void *buf, int len) {
#if TCP_DEBUG #if TCP_DEBUG
if( set_find(tcp_set, fd) ) { if( set_find(tcp_set, fd) ) {
printf("send -> %11d (status: %d) %s:%s\n", len, rc, tcp_host(fd), tcp_port(fd)); printf("send -> %11d (status: %d) %s:%s\n", len, rc, tcp_host(fd), tcp_port(fd));
if( rc > 0 ) netdump(buf, rc); if( rc > 0 ) hexdump(buf, rc);
} }
#endif #endif
return rc; return rc;
@ -10585,7 +10506,7 @@ int tcp_recv(int fd, void *buf, int len) {
#if TCP_DEBUG #if TCP_DEBUG
if( rc != 0 && set_find(tcp_set, fd) ) { if( rc != 0 && set_find(tcp_set, fd) ) {
printf("recv <- %11d (status: %d) %s:%s\n", len, rc, tcp_host(fd), tcp_port(fd)); printf("recv <- %11d (status: %d) %s:%s\n", len, rc, tcp_host(fd), tcp_port(fd));
if( rc > 0 ) netdump(buf, rc); if( rc > 0 ) hexdump(buf, rc);
} }
#endif #endif
return rc; return rc;
@ -11319,17 +11240,67 @@ void network_rpc_send(unsigned id, const char *cmdline) {
#line 0 #line 0
#line 1 "engine/split/v4k_pack.c" #line 1 "engine/split/v4k_pack.c"
// -----------------------------------------------------------------------------
// compile-time fourcc, eightcc
char *cc4str(unsigned x) {
static __thread char type[4+1] = {0};
type[3] = (x >> 24ULL) & 255;
type[2] = (x >> 16ULL) & 255;
type[1] = (x >> 8ULL) & 255;
type[0] = (x >> 0ULL) & 255;
return type;
}
char *cc8str(uint64_t x) {
static __thread char type[8+1] = {0};
type[7] = (x >> 56ULL) & 255;
type[6] = (x >> 48ULL) & 255;
type[5] = (x >> 40ULL) & 255;
type[4] = (x >> 32ULL) & 255;
type[3] = (x >> 24ULL) & 255;
type[2] = (x >> 16ULL) & 255;
type[1] = (x >> 8ULL) & 255;
type[0] = (x >> 0ULL) & 255;
return type;
}
// ----------------------------------------------------------------------------
// float conversion (text)
vec2 atof2(const char *s) {
vec2 v = {0};
sscanf(s, "%f,%f", &v.x, &v.y);
return v;
}
vec3 atof3(const char *s) {
vec3 v = {0};
sscanf(s, "%f,%f,%f", &v.x, &v.y, &v.z);
return v;
}
vec4 atof4(const char *s) {
vec4 v = {0};
sscanf(s, "%f,%f,%f,%f", &v.x, &v.y, &v.z, &v.w);
return v;
}
char* ftoa(float f) {
return va("%f", f);
}
char* ftoa2(vec2 v) {
return va("%f,%f", v.x, v.y);
}
char* ftoa3(vec3 v) {
return va("%f,%f,%f", v.x, v.y, v.z);
}
char* ftoa4(vec4 v) {
return va("%f,%f,%f,%f", v.x, v.y, v.z, v.w);
}
// endianness ----------------------------------------------------------------- // endianness -----------------------------------------------------------------
// - rlyeh, public domain // - rlyeh, public domain
#if !is(cl) && !is(gcc) int is_big() { return IS_BIG; }
uint16_t (swap16)( uint16_t x ) { return (x << 8) | (x >> 8); } int is_little() { return IS_LITTLE; }
uint32_t (swap32)( uint32_t x ) { x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); return (x << 16) | (x >> 16); }
uint64_t (swap64)( uint64_t x ) { x = ((x << 8) & 0xff00ff00ff00ff00ULL) | ((x >> 8) & 0x00ff00ff00ff00ffULL); x = ((x << 16) & 0xffff0000ffff0000ULL) | ((x >> 16) & 0x0000ffff0000ffffULL); return (x << 32) | (x >> 32); }
#endif
float swap32f(float n) { union { float t; uint32_t i; } conv; conv.t = n; conv.i = swap32(conv.i); return conv.t; }
double swap64f(double n) { union { double t; uint64_t i; } conv; conv.t = n; conv.i = swap64(conv.i); return conv.t; }
uint16_t lil16(uint16_t n) { return IS_BIG ? swap16(n) : n; } uint16_t lil16(uint16_t n) { return IS_BIG ? swap16(n) : n; }
uint32_t lil32(uint32_t n) { return IS_BIG ? swap32(n) : n; } uint32_t lil32(uint32_t n) { return IS_BIG ? swap32(n) : n; }
@ -11355,8 +11326,33 @@ float * big32pf(void *p, int sz) { if(IS_LITTLE ) { float *n = (float *)
double * lil64pf(void *p, int sz) { if(IS_BIG ) { double *n = (double *)p; for(int i = 0; i < sz; ++i) n[i] = swap64f(n[i]); } return p; } double * lil64pf(void *p, int sz) { if(IS_BIG ) { double *n = (double *)p; for(int i = 0; i < sz; ++i) n[i] = swap64f(n[i]); } return p; }
double * big64pf(void *p, int sz) { if(IS_LITTLE ) { double *n = (double *)p; for(int i = 0; i < sz; ++i) n[i] = swap64f(n[i]); } return p; } double * big64pf(void *p, int sz) { if(IS_LITTLE ) { double *n = (double *)p; for(int i = 0; i < sz; ++i) n[i] = swap64f(n[i]); } return p; }
int is_big() { return IS_BIG; } #if !is(cl) && !is(gcc)
int is_little() { return IS_LITTLE; } uint16_t (swap16)( uint16_t x ) { return (x << 8) | (x >> 8); }
uint32_t (swap32)( uint32_t x ) { x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); return (x << 16) | (x >> 16); }
uint64_t (swap64)( uint64_t x ) { x = ((x << 8) & 0xff00ff00ff00ff00ULL) | ((x >> 8) & 0x00ff00ff00ff00ffULL); x = ((x << 16) & 0xffff0000ffff0000ULL) | ((x >> 16) & 0x0000ffff0000ffffULL); return (x << 32) | (x >> 32); }
#endif
float swap32f(float n) { union { float t; uint32_t i; } conv; conv.t = n; conv.i = swap32(conv.i); return conv.t; }
double swap64f(double n) { union { double t; uint64_t i; } conv; conv.t = n; conv.i = swap64(conv.i); return conv.t; }
void swapf(float *a, float *b) {
float t = *a; *a = *b; *b = *a;
}
void swapf2(vec2 *a, vec2 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
}
void swapf3(vec3 *a, vec3 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
float z = a->z; a->z = b->z; b->z = a->z;
}
void swapf4(vec4 *a, vec4 *b) {
float x = a->x; a->x = b->x; b->x = a->x;
float y = a->y; a->y = b->y; b->y = a->y;
float z = a->z; a->z = b->z; b->z = a->z;
float w = a->w; a->w = b->w; b->w = a->w;
}
// half packing ----------------------------------------------------------------- // half packing -----------------------------------------------------------------
// from GingerBill's gbmath.h (public domain) // from GingerBill's gbmath.h (public domain)
@ -12785,15 +12781,15 @@ AUTORUN {
// @todo: nested structs? pointers in members? // @todo: nested structs? pointers in members?
// @todo: declare TYPEDEF(vec3, float[3]), TYPEDEF(mat4, vec4[4]/*float[16]*/) // @todo: declare TYPEDEF(vec3, float[3]), TYPEDEF(mat4, vec4[4]/*float[16]*/)
static map(unsigned, reflected_t) reflects; static map(unsigned, reflect_t) reflects;
static map(unsigned, array(reflected_t)) members; static map(unsigned, array(reflect_t)) members;
void reflected_printf(reflected_t *r) { void reflected_printf(reflect_t *r) {
printf("name:%s info:'%s' id:%u objtype:%u sz:%u addr:%p parent:%u type:%s", printf("name:%s info:'%s' id:%u objtype:%u sz:%u addr:%p parent:%u type:%s",
r->name ? r->name : "", r->info ? r->info : "", r->id, r->objtype, r->sz, r->addr, r->parent, r->type ? r->type : ""); r->name ? r->name : "", r->info ? r->info : "", r->id, r->objtype, r->sz, r->addr, r->parent, r->type ? r->type : "");
} }
void reflected_printf_all() { void reflected_printf_all() {
for each_map_ptr(reflects, unsigned, k, reflected_t, p) { for each_map_ptr(reflects, unsigned, k, reflect_t, p) {
reflected_printf(p); reflected_printf(p);
puts(""); puts("");
} }
@ -12801,42 +12797,42 @@ void reflected_printf_all() {
void type_inscribe(const char *TY,unsigned TYid,unsigned TYsz,const char *infos) { void type_inscribe(const char *TY,unsigned TYid,unsigned TYsz,const char *infos) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, TYid, ((reflected_t){TYid, 0, TYsz, TY, infos})); map_find_or_add(reflects, TYid, ((reflect_t){TYid, 0, TYsz, TY, infos}));
} }
void enum_inscribe(const char *E,unsigned Eid,unsigned Eval,const char *infos) { void enum_inscribe(const char *E,unsigned Eid,unsigned Eval,const char *infos) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, Eid, ((reflected_t){Eid,0, Eval, E,infos})); map_find_or_add(reflects, Eid, ((reflect_t){Eid,0, Eval, E,infos}));
} }
unsigned enum_find(const char *E) { unsigned enum_find(const char *E) {
return map_find(reflects, intern(E))->sz; return map_find(reflects, intern(E))->sz;
} }
void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos) { void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, Fid, ((reflected_t){Fid,0, 0, F,infos, func})); map_find_or_add(reflects, Fid, ((reflect_t){Fid,0, 0, F,infos, func}));
reflected_t *found = map_find(reflects,Fid); reflect_t *found = map_find(reflects,Fid);
} }
void *function_find(const char *F) { void *function_find(const char *F) {
return map_find(reflects, intern(F))->addr; return map_find(reflects, intern(F))->addr;
} }
void struct_inscribe(const char *T,unsigned Tid,unsigned Tsz,unsigned OBJTYPEid, const char *infos) { void struct_inscribe(const char *T,unsigned Tid,unsigned Tsz,unsigned OBJTYPEid, const char *infos) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, Tid, ((reflected_t){Tid, OBJTYPEid, Tsz, T, infos})); map_find_or_add(reflects, Tid, ((reflect_t){Tid, OBJTYPEid, Tsz, T, infos}));
} }
void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type) { void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type) {
if(!reflects) map_init_int(reflects); if(!reflects) map_init_int(reflects);
map_find_or_add(reflects, (Mid<<16)|Tid, ((reflected_t){Mid, 0, Msz, M, infos, NULL, Tid, type })); map_find_or_add(reflects, (Mid<<16)|Tid, ((reflect_t){Mid, 0, Msz, M, infos, NULL, Tid, type }));
// add member separately as well // add member separately as well
if(!members) map_init_int(members); if(!members) map_init_int(members);
array(reflected_t) *found = map_find_or_add(members, Tid, 0); array(reflect_t) *found = map_find_or_add(members, Tid, 0);
array_push(*found, ((reflected_t){Mid, 0, Msz, M, infos, NULL, Tid, type })); array_push(*found, ((reflect_t){Mid, 0, Msz, M, infos, NULL, Tid, type }));
} }
reflected_t member_find(const char *T, const char *M) { reflect_t member_find(const char *T, const char *M) {
return *map_find(reflects, (intern(M)<<16)|intern(T)); return *map_find(reflects, (intern(M)<<16)|intern(T));
} }
void *member_findptr(void *obj, const char *T, const char *M) { void *member_findptr(void *obj, const char *T, const char *M) {
return (char*)obj + member_find(T,M).sz; return (char*)obj + member_find(T,M).sz;
} }
array(reflected_t) members_find(const char *T) { array(reflect_t) members_find(const char *T) {
return *map_find(members, intern(T)); return *map_find(members, intern(T));
} }
@ -15558,7 +15554,7 @@ skybox_t skybox(const char *asset, int flags) {
// sky cubemap & SH // sky cubemap & SH
if( asset ) { if( asset ) {
int is_panorama = vfs_size( asset ); int is_panorama = vfs_size( asset );
if( is_panorama ) { if( is_panorama ) { // is file
stbi_hdr_to_ldr_gamma(1.2f); stbi_hdr_to_ldr_gamma(1.2f);
image_t panorama = image( asset, IMAGE_RGBA ); image_t panorama = image( asset, IMAGE_RGBA );
sky.cubemap = cubemap( panorama, 0 ); // RGBA required sky.cubemap = cubemap( panorama, 0 ); // RGBA required
@ -15575,7 +15571,7 @@ skybox_t skybox(const char *asset, int flags) {
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]); for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
} }
} else { } else {
// set up mie defaults // set up mie defaults // @fixme: use shader params instead
shader_bind(sky.program); shader_bind(sky.program);
shader_vec3("uSunPos", vec3( 0, 0.1, -1 )); shader_vec3("uSunPos", vec3( 0, 0.1, -1 ));
shader_vec3("uRayOrigin", vec3(0.0, 6372000.0, 0.0)); shader_vec3("uRayOrigin", vec3(0.0, 6372000.0, 0.0));
@ -16339,9 +16335,9 @@ int fx_load_from_mem(const char *nameid, const char *content) {
} }
int fx_load(const char *filemask) { int fx_load(const char *filemask) {
static set(char*) added = 0; do_once set_init_str(added); static set(char*) added = 0; do_once set_init_str(added);
for(const char **list = vfs_list(filemask); *list; list++) { for each_array( vfs_list(filemask), char*, list ) {
if( set_find(added, (char*)*list) ) continue; if( set_find(added, list) ) continue;
char *name = STRDUP(*list); // @leak char *name = STRDUP(list); // @leak
set_insert(added, name); set_insert(added, name);
(void)postfx_load_from_mem(&fx, file_name(name), vfs_read(name)); (void)postfx_load_from_mem(&fx, file_name(name), vfs_read(name));
} }
@ -16401,7 +16397,8 @@ static void brdf_load() {
brdf = texture_compressed( filename, brdf = texture_compressed( filename,
TEXTURE_CLAMP | TEXTURE_NEAREST | TEXTURE_RG | TEXTURE_FLOAT | TEXTURE_SRGB TEXTURE_CLAMP | TEXTURE_NEAREST | TEXTURE_RG | TEXTURE_FLOAT | TEXTURE_SRGB
); );
ASSERT(brdf.id != texture_checker().id, "!Couldn't load BRDF lookup table '%s'!", filename ); unsigned texchecker = texture_checker().id;
ASSERT(brdf.id != texchecker, "!Couldn't load BRDF lookup table '%s'!", filename );
} }
texture_t brdf_lut() { texture_t brdf_lut() {
@ -16569,8 +16566,9 @@ shadertoy_t* shadertoy_render(shadertoy_t *s, float delta) {
return s; return s;
} }
float mx = input(MOUSE_X), my = input(MOUSE_Y); if(input_down(MOUSE_L) || input_down(MOUSE_R) ) s->mouse.z = input(MOUSE_X), s->mouse.w = -(window_height() - input(MOUSE_Y));
if(input(MOUSE_L)) s->clickx = mx, s->clicky = my; if(input(MOUSE_L) || input(MOUSE_R)) s->mouse.x = input(MOUSE_X), s->mouse.y = (window_height() - input(MOUSE_Y));
vec4 m = mul4(s->mouse, vec4(1,1,1-2*(!input(MOUSE_L) && !input(MOUSE_R)),1-2*(input_down(MOUSE_L) || input_down(MOUSE_R))));
time_t tmsec = time(0); time_t tmsec = time(0);
struct tm *tm = localtime(&tmsec); struct tm *tm = localtime(&tmsec);
@ -16581,7 +16579,7 @@ shadertoy_t* shadertoy_render(shadertoy_t *s, float delta) {
glUniform1f(s->uniforms[iGlobalFrame], s->frame++); glUniform1f(s->uniforms[iGlobalFrame], s->frame++);
glUniform1f(s->uniforms[iGlobalDelta], delta / 1000.f ); glUniform1f(s->uniforms[iGlobalDelta], delta / 1000.f );
glUniform2f(s->uniforms[iResolution], s->dims.x ? s->dims.x : window_width(), s->dims.y ? s->dims.y : window_height()); glUniform2f(s->uniforms[iResolution], s->dims.x ? s->dims.x : window_width(), s->dims.y ? s->dims.y : window_height());
if (!(s->flags&SHADERTOY_IGNORE_MOUSE)) glUniform4f(s->uniforms[iMouse], mx, my, s->clickx, s->clicky ); if (!(s->flags&SHADERTOY_IGNORE_MOUSE)) glUniform4f(s->uniforms[iMouse], m.x,m.y,m.z,m.w );
glUniform1i(s->uniforms[iFrame], (int)window_frame()); glUniform1i(s->uniforms[iFrame], (int)window_frame());
glUniform1f(s->uniforms[iTime], time_ss()); glUniform1f(s->uniforms[iTime], time_ss());
@ -20117,13 +20115,13 @@ void tty_attach() {
// "following calls are the closest i'm aware you can get to /SUBSYSTEM:CONSOLE in a gui program // "following calls are the closest i'm aware you can get to /SUBSYSTEM:CONSOLE in a gui program
// while cleanly handling existing consoles (cmd.exe), pipes (ninja) and no console (VS/RemedyBG; double-clicking the game)" // while cleanly handling existing consoles (cmd.exe), pipes (ninja) and no console (VS/RemedyBG; double-clicking the game)"
do_once { do_once {
if( !AttachConsole(ATTACH_PARENT_PROCESS) && GetLastError() != ERROR_ACCESS_DENIED ) ASSERT( AllocConsole() ); if( !AttachConsole(ATTACH_PARENT_PROCESS) && GetLastError() != ERROR_ACCESS_DENIED ) { bool ok = !!AllocConsole(); ASSERT( ok ); }
printf("\n"); // print >= 1 byte to distinguish empty stdout from a redirected stdout (fgetpos() position <= 0) printf("\n"); // print >= 1 byte to distinguish empty stdout from a redirected stdout (fgetpos() position <= 0)
fpos_t pos = 0; fpos_t pos = 0;
if( fgetpos(stdout, &pos) != 0 || pos <= 0 ) { if( fgetpos(stdout, &pos) != 0 || pos <= 0 ) {
ASSERT(freopen("CONIN$" , "r", stdin )); bool ok1 = !!freopen("CONIN$" , "r", stdin ); ASSERT( ok1 );
ASSERT(freopen("CONOUT$", "w", stderr)); bool ok2 = !!freopen("CONOUT$", "w", stderr); ASSERT( ok2 );
ASSERT(freopen("CONOUT$", "w", stdout)); bool ok3 = !!freopen("CONOUT$", "w", stdout); ASSERT( ok3 );
} }
} }
#endif #endif
@ -20328,6 +20326,10 @@ void app_singleton(const char *guid) {
#endif #endif
} }
#ifdef APP_SINGLETON_GUID
AUTORUN { app_singleton(APP_SINGLETON_GUID); }
#endif
static static
bool app_open_folder(const char *file) { bool app_open_folder(const char *file) {
char buf[1024]; char buf[1024];
@ -23728,7 +23730,7 @@ bool window_create_from_handle(void *handle, float scale, unsigned flags) {
// display a progress bar meanwhile cook is working in the background // display a progress bar meanwhile cook is working in the background
// Sleep(500); // Sleep(500);
if( !COOK_ON_DEMAND ) if( !COOK_ON_DEMAND )
if( file_exist(COOK_INI) && cook_jobs() ) if( have_tools() && cook_jobs() )
while( cook_progress() < 100 ) { while( cook_progress() < 100 ) {
for( int frames = 0; frames < 2/*10*/ && window_swap(); frames += cook_progress() >= 100 ) { for( int frames = 0; frames < 2/*10*/ && window_swap(); frames += cook_progress() >= 100 ) {
window_title(va("%s %.2d%%", cook_cancelling ? "Aborting" : "Cooking assets", cook_progress())); window_title(va("%s %.2d%%", cook_cancelling ? "Aborting" : "Cooking assets", cook_progress()));
@ -23817,7 +23819,7 @@ char* window_stats() {
prev_frame = now; prev_frame = now;
++num_frames; ++num_frames;
return buf + 3 * (buf[0] == ' '); return buf + strspn(buf, " ");
} }
int window_frame_begin() { int window_frame_begin() {
@ -23825,7 +23827,7 @@ int window_frame_begin() {
// we cannot simply terminate threads on some OSes. also, aborted cook jobs could leave temporary files on disc. // we cannot simply terminate threads on some OSes. also, aborted cook jobs could leave temporary files on disc.
// so let's try to be polite: we will be disabling any window closing briefly until all cook is either done or canceled. // so let's try to be polite: we will be disabling any window closing briefly until all cook is either done or canceled.
static bool has_cook; do_once has_cook = !COOK_ON_DEMAND && file_exist(COOK_INI) && cook_jobs(); static bool has_cook; do_once has_cook = !COOK_ON_DEMAND && have_tools() && cook_jobs();
if( has_cook ) { if( has_cook ) {
has_cook = cook_progress() < 100; has_cook = cook_progress() < 100;
if( glfwWindowShouldClose(g->window) ) cook_cancel(); if( glfwWindowShouldClose(g->window) ) cook_cancel();
@ -23838,28 +23840,23 @@ int window_frame_begin() {
glNewFrame(); glNewFrame();
#if !ENABLE_RETAIL
ui_create(); ui_create();
bool may_render_stats = 1; #if !ENABLE_RETAIL
bool has_menu = 0; // ui_has_menubar();
bool may_render_debug_panel = 1;
int has_menu = ui_has_menubar(); if( have_tools() ) {
if( !has_menu ) { static int cook_has_progressbar; do_once cook_has_progressbar = !COOK_ON_DEMAND;
static int cook_on_demand; do_once cook_on_demand = COOK_ON_DEMAND; if( cook_has_progressbar) {
if( !cook_on_demand ) {
// render profiler, unless we are in the cook progress screen // render profiler, unless we are in the cook progress screen
static unsigned frames = 0; if(frames <= 0) frames += cook_progress() >= 100; static unsigned frames = 0; if(frames <= 0) frames += cook_progress() >= 100;
may_render_stats = (frames > 0); may_render_debug_panel = (frames > 0);
} }
} }
// @transparent
static bool has_transparent_attrib = 0; ifndef(ems, do_once has_transparent_attrib = glfwGetWindowAttrib(window_handle(), GLFW_TRANSPARENT_FRAMEBUFFER) == GLFW_TRUE);
if( has_transparent_attrib ) may_render_stats = 0;
// @transparent
// generate Debug panel contents // generate Debug panel contents
if( may_render_stats ) { if( may_render_debug_panel ) {
if( has_menu ? ui_window("Debug " ICON_MD_SETTINGS, 0) : ui_panel("Debug " ICON_MD_SETTINGS, 0) ) { if( has_menu ? ui_window("Debug " ICON_MD_SETTINGS, 0) : ui_panel("Debug " ICON_MD_SETTINGS, 0) ) {
static int time_factor = 0; static int time_factor = 0;
@ -25959,14 +25956,11 @@ static void v4k_pre_init() {
int i; int i;
#pragma omp parallel for #pragma omp parallel for
for( i = 0; i <= 6; ++i) { for( i = 0; i <= 3; ++i) {
/**/ if( i == 0 ) ddraw_init();// init this on thread#0 since it will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up /**/ if( i == 0 ) ddraw_init();// init this on thread#0 since it will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up
else if( i == 1 ) sprite_init(); else if( i == 1 ) sprite_init();
else if( i == 2 ) profiler_init(); else if( i == 2 ) profiler_init();
else if( i == 3 ) storage_mount("save/"), storage_read(), touch_init(); // for ems else if( i == 3 ) storage_mount("save/"), storage_read(), touch_init(); // for ems
else if( i == 4 ) audio_init(0);
else if( i == 5 ) script_init(), kit_init(), midi_init();
else if( i == 6 ) network_init();
} }
// window_swap(); // window_swap();
@ -25981,11 +25975,14 @@ static void v4k_post_init(float refresh_rate) {
int i; int i;
#pragma omp parallel for #pragma omp parallel for
for( i = 0; i <= 2; ++i ) { for( i = 0; i <= 3; ++i ) {
if(i == 0) ui_init(); // init these on thread #0, since both will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up
if(i == 0) scene_init(); // init these on thread #0, since both will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up if(i == 0) scene_init(); // init these on thread #0, since both will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up
if(i == 0) window_icon(va("%s.png", app_name())); if(i == 0) ui_init(); // init these on thread #0, since both will be compiling shaders, and shaders need to be compiled from the very same thread than glfwMakeContextCurrent() was set up
if(i == 1) input_init(); if(i == 0) window_icon(va("%s.png", app_name())); // init on thread #0, because of glfw
if(i == 0) input_init(); // init on thread #0, because of glfw
if(i == 1) audio_init(0);
if(i == 2) script_init(), kit_init(), midi_init();
if(i == 3) network_init();
} }
// display window // display window
@ -26036,7 +26033,7 @@ void v4k_init() {
} }
// create or update cook.zip file // create or update cook.zip file
if( /* !COOK_ON_DEMAND && */ file_exist(COOK_INI) && cook_jobs() ) { if( /* !COOK_ON_DEMAND && */ have_tools() && cook_jobs() ) {
cook_start(COOK_INI, "**", 0|COOK_ASYNC|COOK_CANCELABLE ); cook_start(COOK_INI, "**", 0|COOK_ASYNC|COOK_CANCELABLE );
} }

View File

@ -912,34 +912,6 @@ API int (map_count)(map *m);
API void (map_gc)(map *m); // only if using MAP_DONT_ERASE API void (map_gc)(map *m); // only if using MAP_DONT_ERASE
API bool (map_sort)(map* m); API bool (map_sort)(map* m);
API void (map_clear)(map* m); API void (map_clear)(map* m);
// -----------------------------------------------------------------------------
// compile-time fourcc, eightcc
API char *cc4str(unsigned cc);
API char *cc8str(uint64_t cc);
enum {
# define _(a,b,c,d,e) cc__##a, cc__##b, cc__##c, cc__##d, cc__##e
cc__1 = '1', _(2,3,4,5,6),_(7,8,9,0,_), cc__ = ' ',
cc__A = 'A', _(B,C,D,E,F),_(G,H,I,J,K),_(L,M,N,O,P),_(Q,R,S,T,U),_(V,W,X,Y,Z),
cc__a = 'a', _(b,c,d,e,f),_(g,h,i,j,k),_(l,m,n,o,p),_(q,r,s,t,u),_(v,w,x,y,z),
# undef _
};
#ifdef BIG
#define cc4(a,b,c,d) ((uint32_t)(cc__##a<<24) | (cc__##b<<16) | (cc__##c<<8) | (cc__##d<<0))
#define cc8(a,b,c,d,e,f,g,h) (((uint64_t)cc4(a,b,c,d) << 32ULL) | cc4(e,f,g,h))
#else
#define cc4(a,b,c,d) ((uint32_t)(cc__##d<<24) | (cc__##c<<16) | (cc__##b<<8) | (cc__##a<<0))
#define cc8(a,b,c,d,e,f,g,h) (((uint64_t)cc4(e,f,g,h) << 32ULL) | cc4(a,b,c,d))
#endif
#define cc3(a,b,c) cc4(,a,b,c)
#define cc5(a,b,c,d,e) cc6(,a,b,c,d,e)
#define cc6(a,b,c,d,e,f) cc7(,a,b,c,d,e,f)
#define cc7(a,b,c,d,e,f,g) cc8(,a,b,c,d,e,f,g)
#line 0 #line 0
#line 1 "engine/split/v4k_math.h" #line 1 "engine/split/v4k_math.h"
@ -1284,21 +1256,6 @@ API void printq( quat q );
API void print33( float *m ); API void print33( float *m );
API void print34( float *m ); API void print34( float *m );
API void print44( float *m ); API void print44( float *m );
API vec2 atof2(const char *s);
API vec3 atof3(const char *s);
API vec4 atof4(const char *s);
API char* ftoa(float f);
API char* ftoa2(vec2 v);
API char* ftoa3(vec3 v);
API char* ftoa4(vec4 v);
API void swapf(float *a, float *b);
API void swapf2(vec2 *a, vec2 *b);
API void swapf3(vec3 *a, vec3 *b);
API void swapf4(vec4 *a, vec4 *b);
#line 0 #line 0
#line 1 "engine/split/v4k_ai.h" #line 1 "engine/split/v4k_ai.h"
@ -1732,6 +1689,8 @@ API void cook_cancel();
API int cook_jobs(); // [0..N] API int cook_jobs(); // [0..N]
API int cook_progress(); // [0..100] API int cook_progress(); // [0..100]
// utils
API bool have_tools();
#line 0 #line 0
#line 1 "engine/split/v4k_data.h" #line 1 "engine/split/v4k_data.h"
@ -1898,7 +1857,7 @@ API void storage_flush();
// virtual filesystem // virtual filesystem
API bool vfs_mount(const char *mount_point); API bool vfs_mount(const char *mount_point);
API const char** vfs_list(const char *masks); // **.png;*.c API array(char*) vfs_list(const char *masks); // **.png;*.c
API char * vfs_read(const char *pathfile); API char * vfs_read(const char *pathfile);
API char * vfs_load(const char *pathfile, int *size); API char * vfs_load(const char *pathfile, int *size);
@ -2055,6 +2014,45 @@ bool id_valid(uintptr_t id);
#line 0 #line 0
#line 1 "engine/split/v4k_pack.h" #line 1 "engine/split/v4k_pack.h"
// -----------------------------------------------------------------------------
// compile-time fourcc, eightcc
API char *cc4str(unsigned cc);
API char *cc8str(uint64_t cc);
enum {
# define _(a,b,c,d,e) cc__##a, cc__##b, cc__##c, cc__##d, cc__##e
cc__1 = '1', _(2,3,4,5,6),_(7,8,9,0,_), cc__ = ' ',
cc__A = 'A', _(B,C,D,E,F),_(G,H,I,J,K),_(L,M,N,O,P),_(Q,R,S,T,U),_(V,W,X,Y,Z),
cc__a = 'a', _(b,c,d,e,f),_(g,h,i,j,k),_(l,m,n,o,p),_(q,r,s,t,u),_(v,w,x,y,z),
# undef _
};
#ifdef BIG
#define cc4(a,b,c,d) ((uint32_t)(cc__##a<<24) | (cc__##b<<16) | (cc__##c<<8) | (cc__##d<<0))
#define cc8(a,b,c,d,e,f,g,h) (((uint64_t)cc4(a,b,c,d) << 32ULL) | cc4(e,f,g,h))
#else
#define cc4(a,b,c,d) ((uint32_t)(cc__##d<<24) | (cc__##c<<16) | (cc__##b<<8) | (cc__##a<<0))
#define cc8(a,b,c,d,e,f,g,h) (((uint64_t)cc4(e,f,g,h) << 32ULL) | cc4(a,b,c,d))
#endif
#define cc3(a,b,c) cc4(,a,b,c)
#define cc5(a,b,c,d,e) cc6(,a,b,c,d,e)
#define cc6(a,b,c,d,e,f) cc7(,a,b,c,d,e,f)
#define cc7(a,b,c,d,e,f,g) cc8(,a,b,c,d,e,f,g)
// ----------------------------------------------------------------------------
// float conversion (text)
API vec2 atof2(const char *s);
API vec3 atof3(const char *s);
API vec4 atof4(const char *s);
API char* ftoa(float f);
API char* ftoa2(vec2 v);
API char* ftoa3(vec3 v);
API char* ftoa4(vec4 v);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// endianness // endianness
@ -2066,6 +2064,10 @@ API uint32_t swap32( uint32_t x );
API uint64_t swap64( uint64_t x ); API uint64_t swap64( uint64_t x );
API float swap32f(float n); API float swap32f(float n);
API double swap64f(double n); API double swap64f(double n);
API void swapf(float *a, float *b);
API void swapf2(vec2 *a, vec2 *b);
API void swapf3(vec3 *a, vec3 *b);
API void swapf4(vec4 *a, vec4 *b);
API uint16_t lil16(uint16_t n); // swap16 as lil API uint16_t lil16(uint16_t n); // swap16 as lil
API uint32_t lil32(uint32_t n); // swap32 as lil API uint32_t lil32(uint32_t n); // swap32 as lil
@ -2646,7 +2648,7 @@ extern API int profiler_enabled; ///-
#define ifdef_objapi(T,...) __VA_ARGS__ #define ifdef_objapi(T,...) __VA_ARGS__
#endif #endif
typedef struct reflected_t { typedef struct reflect_t {
unsigned id, objtype; unsigned id, objtype;
unsigned sz; unsigned sz;
const char *name; const char *name;
@ -2654,7 +2656,7 @@ typedef struct reflected_t {
void *addr; void *addr;
unsigned parent; unsigned parent;
const char *type; const char *type;
} reflected_t; } reflect_t;
// inscribe api // inscribe api
@ -2674,16 +2676,16 @@ typedef struct reflected_t {
API unsigned enum_find(const char *E); API unsigned enum_find(const char *E);
API void * function_find(const char *F); API void * function_find(const char *F);
API reflected_t member_find(const char *T, const char *M); /// find specific member API reflect_t member_find(const char *T, const char *M); /// find specific member
API void * member_findptr(void *obj, const char *T, const char *M); API void * member_findptr(void *obj, const char *T, const char *M);
API array(reflected_t) members_find(const char *T); API array(reflect_t) members_find(const char *T);
// iterate members in a struct // iterate members in a struct
#define each_member(T,R) \ #define each_member(T,R) \
(array(reflected_t)*found_ = map_find(members, intern(T)); found_; found_ = 0) \ (array(reflect_t)*found_ = map_find(members, intern(T)); found_; found_ = 0) \
for(int it_ = 0, end_ = array_count(*found_); it_ != end_; ++it_ ) \ for(int it_ = 0, end_ = array_count(*found_); it_ != end_; ++it_ ) \
for(reflected_t *R = (*found_)+it_; R; R = 0 ) for(reflect_t *R = (*found_)+it_; R; R = 0 )
// private api, still exposed // private api, still exposed
@ -2693,7 +2695,7 @@ API void struct_inscribe(const char *T,unsigned Tid,unsigned Tsz,u
API void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type); API void member_inscribe(unsigned Tid, const char *M,unsigned Mid,unsigned Msz, const char *infos, const char *type);
API void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos); API void function_inscribe(const char *F,unsigned Fid,void *func,const char *infos);
API void reflected_printf(reflected_t *r); API void reflected_printf(reflect_t *r);
API void reflected_printf_all(); API void reflected_printf_all();
#line 0 #line 0
@ -3235,11 +3237,11 @@ typedef struct shadertoy_t {
int uniforms[32]; int uniforms[32];
int texture_channels[4]; int texture_channels[4];
int frame; int frame;
float clickx, clicky;
uint64_t t; uint64_t t;
texture_t tx; texture_t tx;
vec2i dims; vec2i dims;
int flags; int flags;
vec4 mouse;
} shadertoy_t; } shadertoy_t;
API shadertoy_t shadertoy( const char *shaderfile, unsigned flags ); API shadertoy_t shadertoy( const char *shaderfile, unsigned flags );