2023-07-30 19:18:50 +00:00
|
|
|
--autogenerated luajit bindings. do not edit.
|
|
|
|
local ffi = require("ffi")
|
|
|
|
ffi.cdef([[
|
|
|
|
typedef struct FILE FILE;
|
|
|
|
typedef long int ptrdiff_t;
|
|
|
|
typedef long unsigned int size_t;
|
|
|
|
int less_64(uint64_t a, uint64_t b);
|
|
|
|
int less_int(int a, int b);
|
|
|
|
int less_ptr(void *a, void *b);
|
|
|
|
int less_str(char *a, char *b);
|
2023-11-01 11:24:16 +00:00
|
|
|
int less_64_ptr(const void *a, const void *b);
|
|
|
|
int less_int_ptr(const void *a, const void *b);
|
2023-07-30 19:18:50 +00:00
|
|
|
uint32_t unhash_32(uint32_t x);
|
|
|
|
uint32_t hash_32(uint32_t x);
|
|
|
|
uint64_t hash_64(uint64_t x);
|
|
|
|
uint64_t hash_flt(double x);
|
|
|
|
uint64_t hash_int(int key);
|
|
|
|
uint64_t hash_ptr(const void* ptr);
|
2023-10-01 06:49:08 +00:00
|
|
|
uint64_t hash_bin(const void* ptr, unsigned len);
|
|
|
|
uint64_t hash_str(const char* str);
|
2023-07-30 19:18:50 +00:00
|
|
|
uint64_t popcnt64(uint64_t x);
|
|
|
|
void* vrealloc( void* p, size_t sz );
|
|
|
|
size_t vlen( void* p );
|
|
|
|
unsigned array_c_;
|
|
|
|
unsigned array_n_;
|
|
|
|
typedef struct set_item {
|
2024-01-02 19:52:20 +00:00
|
|
|
struct set_item *next;
|
|
|
|
uint64_t keyhash;
|
|
|
|
void *key;
|
|
|
|
void *super;
|
2023-07-30 19:18:50 +00:00
|
|
|
} set_item;
|
|
|
|
typedef struct set {
|
2024-01-02 19:52:20 +00:00
|
|
|
set_item** array;
|
|
|
|
int (*cmp)(void *, void *);
|
|
|
|
uint64_t (*hash)(void *);
|
|
|
|
int count;
|
2023-07-30 19:18:50 +00:00
|
|
|
} set;
|
2024-01-02 19:52:20 +00:00
|
|
|
void (set_init)(set *m);
|
|
|
|
void (set_free)(set *m);
|
|
|
|
void (set_insert)(set *m, set_item *p, void *key, uint64_t keyhash, void *super);
|
|
|
|
void (set_erase)(set *m, void *key, uint64_t keyhash);
|
2023-07-30 19:18:50 +00:00
|
|
|
void* (set_find)(const set *m, void *key, uint64_t keyhash);
|
2024-01-02 19:52:20 +00:00
|
|
|
int (set_isempty)(const set *m);
|
|
|
|
int (set_count)(const set *m);
|
|
|
|
void (set_gc)(set *m);
|
|
|
|
void (set_clear)(set* m);
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef struct pair {
|
2024-01-02 19:52:20 +00:00
|
|
|
struct pair *next;
|
|
|
|
uint64_t keyhash;
|
|
|
|
void *key;
|
|
|
|
void *value;
|
|
|
|
void *super;
|
2023-07-30 19:18:50 +00:00
|
|
|
} pair;
|
|
|
|
typedef struct map {
|
2024-01-02 19:52:20 +00:00
|
|
|
pair** array;
|
|
|
|
int (*cmp)(void *, void *);
|
|
|
|
uint64_t (*hash)(void *);
|
|
|
|
int count:31;
|
|
|
|
int is_sorted:1;
|
|
|
|
pair** sorted;
|
2023-07-30 19:18:50 +00:00
|
|
|
} map;
|
2024-01-02 19:52:20 +00:00
|
|
|
void (map_init)(map *m);
|
|
|
|
void (map_free)(map *m);
|
|
|
|
void (map_insert)(map *m, pair *p, void *key, void *value, uint64_t keyhash, void *super);
|
|
|
|
void (map_erase)(map *m, void *key, uint64_t keyhash);
|
2023-07-30 19:18:50 +00:00
|
|
|
void* (map_find)(map *m, void *key, uint64_t keyhash);
|
2024-01-02 19:52:20 +00:00
|
|
|
int (map_isempty)(map *m);
|
|
|
|
int (map_count)(map *m);
|
|
|
|
void (map_gc)(map *m);
|
|
|
|
bool (map_sort)(map* m);
|
|
|
|
void (map_clear)(map* m);
|
|
|
|
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 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 vec3 { struct { float X,Y,Z; }; struct { float x,y,z; }; struct { float r,g,b; }; struct { float min,max; }; struct { float from,to; }; vec2 xy; vec2 rg; vec2 wh; float v3[3]; float array[1]; } vec3;
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef union vec4 { struct { float X,Y,Z,W; }; struct { float x,y,z,w; }; struct { float r,g,b,a; }; struct { float min,max; }; struct { float from,to; }; vec2 xy; vec3 xyz; vec2 rg; vec3 rgb; vec2 wh; vec3 whd; float v4[4]; float array[1]; } vec4;
|
|
|
|
typedef union quat { struct { float X,Y,Z,W; }; struct { float x,y,z,w; }; vec3 xyz; vec4 xyzw; float v4[4]; float array[1]; } quat;
|
|
|
|
typedef float mat33[9];
|
|
|
|
typedef float mat34[12];
|
|
|
|
typedef float mat44[16];
|
2024-01-02 19:52:20 +00:00
|
|
|
void randset(uint64_t state);
|
2023-07-30 19:18:50 +00:00
|
|
|
uint64_t rand64(void);
|
2024-01-02 19:52:20 +00:00
|
|
|
double randf(void);
|
|
|
|
int randi(int mini, int maxi);
|
2023-07-30 19:18:50 +00:00
|
|
|
float simplex1( float x );
|
|
|
|
float simplex2( vec2 xy );
|
|
|
|
float simplex3( vec3 xyz );
|
|
|
|
float simplex4( vec4 xyzw );
|
2024-01-02 19:52:20 +00:00
|
|
|
float deg (float radians);
|
|
|
|
float rad (float degrees);
|
|
|
|
int mini (int a, int b);
|
|
|
|
int maxi (int a, int b);
|
|
|
|
int absi (int a );
|
|
|
|
int clampi (int v,int a,int b);
|
|
|
|
float minf (float a, float b);
|
|
|
|
float maxf (float a, float b);
|
|
|
|
float absf (float a );
|
|
|
|
float pmodf (float a, float b);
|
|
|
|
float signf (float a) ;
|
|
|
|
float clampf (float v,float a,float b);
|
|
|
|
float mixf (float a,float b,float t);
|
|
|
|
float fractf (float a);
|
|
|
|
vec2 ptr2 (const float *a );
|
|
|
|
vec2 neg2 (vec2 a );
|
|
|
|
vec2 add2 (vec2 a, vec2 b);
|
|
|
|
vec2 sub2 (vec2 a, vec2 b);
|
|
|
|
vec2 mul2 (vec2 a, vec2 b);
|
|
|
|
vec2 div2 (vec2 a, vec2 b);
|
|
|
|
vec2 inc2 (vec2 a, float b);
|
|
|
|
vec2 dec2 (vec2 a, float b);
|
|
|
|
vec2 scale2 (vec2 a, float b);
|
|
|
|
vec2 pmod2 (vec2 a, float b);
|
|
|
|
vec2 min2 (vec2 a, vec2 b);
|
|
|
|
vec2 max2 (vec2 a, vec2 b);
|
|
|
|
vec2 abs2 (vec2 a );
|
|
|
|
vec2 floor2 (vec2 a );
|
|
|
|
vec2 fract2 (vec2 a );
|
|
|
|
vec2 ceil2 (vec2 a );
|
|
|
|
float dot2 (vec2 a, vec2 b);
|
|
|
|
vec2 refl2 (vec2 a, vec2 b);
|
|
|
|
float cross2 (vec2 a, vec2 b);
|
|
|
|
float len2sq (vec2 a );
|
|
|
|
float len2 (vec2 a );
|
|
|
|
vec2 norm2 (vec2 a );
|
|
|
|
int finite2 (vec2 a );
|
|
|
|
vec2 mix2 (vec2 a,vec2 b,float t);
|
|
|
|
vec2 clamp2(vec2 v,vec2 a,vec2 b);
|
|
|
|
vec2 clamp2f(vec2 v,float a,float b);
|
|
|
|
vec3 rnd3 (void);
|
|
|
|
vec3 ptr3 (const float *a );
|
|
|
|
vec3 vec23 (vec2 a, float z );
|
|
|
|
vec3 neg3 (vec3 a );
|
|
|
|
vec3 add3 (vec3 a, vec3 b);
|
|
|
|
vec3 sub3 (vec3 a, vec3 b);
|
|
|
|
vec3 mul3 (vec3 a, vec3 b);
|
|
|
|
vec3 div3 (vec3 a, vec3 b);
|
|
|
|
vec3 inc3 (vec3 a, float b);
|
|
|
|
vec3 dec3 (vec3 a, float b);
|
|
|
|
vec3 scale3 (vec3 a, float b);
|
|
|
|
vec3 pmod3 (vec3 a, float b);
|
|
|
|
vec3 min3 (vec3 a, vec3 b);
|
|
|
|
vec3 max3 (vec3 a, vec3 b);
|
|
|
|
vec3 abs3 (vec3 a );
|
|
|
|
vec3 floor3 (vec3 a );
|
|
|
|
vec3 fract3 (vec3 a );
|
|
|
|
vec3 ceil3 (vec3 a );
|
|
|
|
vec3 cross3 (vec3 a, vec3 b);
|
|
|
|
float dot3 (vec3 a, vec3 b);
|
|
|
|
vec3 refl3 (vec3 a, vec3 b);
|
|
|
|
float len3sq (vec3 a );
|
|
|
|
float len3 (vec3 a );
|
|
|
|
vec3 norm3 (vec3 a );
|
|
|
|
vec3 norm3sq (vec3 a );
|
|
|
|
int finite3 (vec3 a );
|
|
|
|
vec3 mix3 (vec3 a,vec3 b,float t);
|
|
|
|
vec3 clamp3(vec3 v,vec3 a,vec3 b);
|
|
|
|
vec3 clamp3f(vec3 v,float a,float b);
|
|
|
|
void ortho3 (vec3 *left, vec3 *up, vec3 v);
|
|
|
|
vec3 rotatex3 (vec3 dir, float degrees);
|
|
|
|
vec3 rotatey3 (vec3 dir, float degrees);
|
|
|
|
vec3 rotatez3 (vec3 dir, float degrees);
|
|
|
|
vec4 ptr4 (const float *a );
|
|
|
|
vec4 vec34 (vec3 a, float w );
|
|
|
|
vec4 neg4 (vec4 a );
|
|
|
|
vec4 add4 (vec4 a, vec4 b);
|
|
|
|
vec4 sub4 (vec4 a, vec4 b);
|
|
|
|
vec4 mul4 (vec4 a, vec4 b);
|
|
|
|
vec4 div4 (vec4 a, vec4 b);
|
|
|
|
vec4 inc4 (vec4 a, float b);
|
|
|
|
vec4 dec4 (vec4 a, float b);
|
|
|
|
vec4 scale4 (vec4 a, float b);
|
|
|
|
vec4 pmod4 (vec4 a, float b);
|
|
|
|
vec4 min4 (vec4 a, vec4 b);
|
|
|
|
vec4 max4 (vec4 a, vec4 b);
|
|
|
|
vec4 abs4 (vec4 a );
|
|
|
|
vec4 floor4 (vec4 a );
|
|
|
|
vec4 fract4 (vec4 a );
|
|
|
|
vec4 ceil4 (vec4 a );
|
|
|
|
float dot4 (vec4 a, vec4 b);
|
|
|
|
vec4 refl4 (vec4 a, vec4 b);
|
|
|
|
float len4sq (vec4 a );
|
|
|
|
float len4 (vec4 a );
|
|
|
|
vec4 norm4 (vec4 a );
|
|
|
|
vec4 norm4sq (vec4 a );
|
|
|
|
int finite4 (vec4 a );
|
|
|
|
vec4 mix4 (vec4 a,vec4 b,float t);
|
|
|
|
vec4 clamp4(vec4 v,vec4 a,vec4 b);
|
|
|
|
vec4 clamp4f(vec4 v,float a,float b);
|
|
|
|
quat idq ( );
|
|
|
|
quat ptrq (const float *a );
|
|
|
|
quat vec3q (vec3 a, float w );
|
|
|
|
quat vec4q (vec4 a );
|
|
|
|
quat negq (quat a );
|
|
|
|
quat conjq (quat a );
|
|
|
|
quat addq (quat a, quat b);
|
|
|
|
quat subq (quat a, quat b);
|
|
|
|
quat mulq (quat p, quat q);
|
|
|
|
quat scaleq (quat a, float s);
|
|
|
|
quat normq (quat a );
|
|
|
|
float dotq (quat a, quat b);
|
|
|
|
quat mixq(quat a, quat b, float t);
|
2023-07-30 19:18:50 +00:00
|
|
|
quat slerpq(quat a, quat b, float s);
|
2024-01-02 19:52:20 +00:00
|
|
|
quat rotationq(float deg,float x,float y,float z);
|
|
|
|
quat mat44q (mat44 M);
|
2023-07-30 19:18:50 +00:00
|
|
|
vec3 rotate3q_2(vec3 v, quat q);
|
|
|
|
vec3 rotate3q(vec3 v, quat r);
|
2024-01-02 19:52:20 +00:00
|
|
|
vec3 euler (quat q);
|
|
|
|
quat eulerq (vec3 pyr_degrees);
|
2023-07-30 19:18:50 +00:00
|
|
|
void scaling33(mat33 m, float x, float y, float z);
|
|
|
|
void scale33(mat33 m, float x, float y, float z);
|
|
|
|
void id33(mat33 m);
|
|
|
|
void extract33(mat33 m, const mat44 m4);
|
|
|
|
void copy33(mat33 m, const mat33 a);
|
|
|
|
vec3 mulv33(mat33 m, vec3 v);
|
|
|
|
void multiply33x2(mat33 m, const mat33 a, const mat33 b);
|
|
|
|
void rotation33(mat33 m, float degrees, float x,float y,float z);
|
|
|
|
void rotationq33(mat33 m, quat q);
|
|
|
|
void rotate33(mat33 r, float degrees, float x,float y,float z);
|
|
|
|
void compose33(mat33 m, quat r, vec3 s);
|
|
|
|
void id34(mat34 m);
|
|
|
|
void copy34(mat34 m, const mat34 a);
|
|
|
|
void scale34(mat34 m, float s);
|
|
|
|
void add34(mat34 m, mat34 n);
|
|
|
|
void muladd34(mat34 m, mat34 n, float s);
|
|
|
|
void add34x2(mat34 m, mat34 n, mat34 o);
|
|
|
|
void lerp34(mat34 m, mat34 n, mat34 o, float alpha);
|
|
|
|
void multiply34x2(mat34 m, const mat34 m0, const mat34 m1);
|
|
|
|
void multiply34(mat34 m, const mat34 a);
|
|
|
|
void multiply34x3(mat34 m, const mat34 a, const mat34 b, const mat34 c);
|
|
|
|
void compose34(mat34 m, vec3 t, quat q, vec3 s);
|
|
|
|
void invert34(mat34 m, const mat34 o);
|
|
|
|
void id44(mat44 m);
|
|
|
|
void identity44(mat44 m);
|
|
|
|
void copy44(mat44 m, const mat44 a);
|
|
|
|
void multiply44x2(mat44 m, const mat44 a, const mat44 b);
|
|
|
|
void multiply44x3(mat44 m, const mat44 a, const mat44 b, const mat44 c);
|
|
|
|
void multiply44(mat44 m, const mat44 a);
|
|
|
|
void ortho44(mat44 m, float l, float r, float b, float t, float n, float f);
|
|
|
|
void frustum44(mat44 m, float l, float r, float b, float t, float n, float f);
|
|
|
|
void perspective44(mat44 m, float fovy_degrees, float aspect, float nearp, float farp);
|
|
|
|
void lookat44(mat44 m, vec3 eye, vec3 center, vec3 up);
|
|
|
|
void translation44(mat44 m, float x, float y, float z);
|
|
|
|
void translate44(mat44 m, float x, float y, float z);
|
|
|
|
void relocate44(mat44 m, float x, float y, float z);
|
|
|
|
void rotationq44(mat44 m, quat q);
|
|
|
|
void rotation44(mat44 m, float degrees, float x, float y, float z);
|
|
|
|
void rotate44(mat44 m, float degrees, float x, float y, float z);
|
|
|
|
void scaling44(mat44 m, float x, float y, float z);
|
|
|
|
void scale44(mat44 m, float x, float y, float z);
|
|
|
|
void transpose44(mat44 m, const mat44 a);
|
|
|
|
float det44(const mat44 M);
|
|
|
|
bool invert44(mat44 T, const mat44 M);
|
|
|
|
void compose44(mat44 m, vec3 t, quat q, vec3 s);
|
|
|
|
vec3 transformq(const quat q, const vec3 v);
|
|
|
|
vec3 transform33(const mat33 m, vec3 p);
|
|
|
|
vec3 transform344(const mat44 m, const vec3 p);
|
|
|
|
vec4 transform444(const mat44 m, const vec4 p);
|
|
|
|
bool unproject44(vec3 *out, vec3 xyd, vec4 viewport, mat44 mvp);
|
2023-10-07 17:34:09 +00:00
|
|
|
void print2i( vec2i v );
|
|
|
|
void print3i( vec3i v );
|
2023-07-30 19:18:50 +00:00
|
|
|
void print2( vec2 v );
|
|
|
|
void print3( vec3 v );
|
|
|
|
void print4( vec4 v );
|
|
|
|
void printq( quat q );
|
|
|
|
void print33( float *m );
|
|
|
|
void print34( float *m );
|
|
|
|
void print44( float *m );
|
2023-11-20 20:19:53 +00:00
|
|
|
uintptr_t id_make(void *ptr);
|
2024-01-02 19:52:20 +00:00
|
|
|
void * id_handle(uintptr_t id);
|
|
|
|
void id_dispose(uintptr_t id);
|
|
|
|
bool id_valid(uintptr_t id);
|
|
|
|
typedef struct obj { struct { const char *objname; uintptr_t objheader; struct obj** objchildren; }; } obj;
|
|
|
|
typedef struct entity { struct { struct { const char *objname; uintptr_t objheader; struct obj** objchildren; }; uintptr_t cflags; void *c[32]; }; } entity;
|
2023-11-02 09:54:49 +00:00
|
|
|
obj *objtmp;
|
2024-01-02 19:52:20 +00:00
|
|
|
void* obj_malloc(unsigned sz);
|
|
|
|
void* obj_free(void *o);
|
|
|
|
extern void (*obj_ctor[256])();
|
|
|
|
extern void (*obj_dtor[256])();
|
2023-11-02 09:54:49 +00:00
|
|
|
extern char* (*obj_save[256])();
|
2024-01-02 19:52:20 +00:00
|
|
|
extern bool (*obj_load[256])();
|
|
|
|
extern int (*obj_test[256])();
|
|
|
|
extern int (*obj_init[256])();
|
|
|
|
extern int (*obj_quit[256])();
|
|
|
|
extern int (*obj_tick[256])();
|
|
|
|
extern int (*obj_draw[256])();
|
|
|
|
extern int (*obj_lerp[256])();
|
|
|
|
extern int (*obj_aabb[256])();
|
|
|
|
extern int (*obj_edit[256])();
|
|
|
|
extern int (*obj_menu[256])();
|
2023-11-20 20:19:53 +00:00
|
|
|
extern char* (*obj_icon[256])();
|
2023-11-19 13:16:48 +00:00
|
|
|
extern const char*OBJTYPES[256];
|
2024-01-02 19:52:20 +00:00
|
|
|
uintptr_t obj_header(const void *o);
|
|
|
|
uintptr_t obj_id(const void *o);
|
2023-11-02 09:54:49 +00:00
|
|
|
const char* obj_type(const void *o);
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned obj_typeid(const void *o);
|
|
|
|
int obj_sizeof(const void *o);
|
|
|
|
int obj_size(const void *o);
|
|
|
|
char* obj_data(void *o);
|
2023-11-02 09:54:49 +00:00
|
|
|
const char* obj_datac(const void *o);
|
2024-01-02 19:52:20 +00:00
|
|
|
void* obj_payload(const void *o);
|
|
|
|
void* obj_zero(void *o);
|
|
|
|
void* obj_ref(void *oo);
|
|
|
|
void* obj_unref(void *oo);
|
|
|
|
obj* obj_detach(void *c);
|
|
|
|
obj* obj_attach(void *o, void *c);
|
|
|
|
obj* obj_root(const void *o);
|
|
|
|
obj* obj_parent(const void *o);
|
2023-11-02 09:54:49 +00:00
|
|
|
obj***obj_children(const void *o);
|
|
|
|
obj***obj_siblings(const void *o);
|
2024-01-02 19:52:20 +00:00
|
|
|
int obj_dumptree(const void *o);
|
|
|
|
void* obj_setmeta(void *o, const char *key, const char *value);
|
2023-11-02 09:54:49 +00:00
|
|
|
const char* obj_meta(const void *o, const char *key);
|
2024-01-02 19:52:20 +00:00
|
|
|
void* obj_setname(void *o, const char *name);
|
2023-11-02 09:54:49 +00:00
|
|
|
const char* obj_name(const void *o);
|
2024-01-02 19:52:20 +00:00
|
|
|
void* obj_swap(void *dst, void *src);
|
|
|
|
void* obj_copy_fast(void *dst, const void *src);
|
|
|
|
void* obj_copy(void *dst, const void *src);
|
|
|
|
int obj_comp_fast(const void *a, const void *b);
|
|
|
|
int obj_comp(const void *a, const void *b);
|
|
|
|
int obj_lesser(const void *a, const void *b);
|
|
|
|
int obj_greater(const void *a, const void *b);
|
|
|
|
int obj_equal(const void *a, const void *b);
|
|
|
|
uint64_t obj_hash(const void *o);
|
|
|
|
bool obj_hexdump(const void *oo);
|
|
|
|
int obj_print(const void *o);
|
|
|
|
int obj_printf(const void *o, const char *text);
|
|
|
|
int obj_console(const void *o);
|
|
|
|
char* obj_saveini(const void *o);
|
|
|
|
obj* obj_mergeini(void *o, const char *ini);
|
|
|
|
obj* obj_loadini(void *o, const char *ini);
|
|
|
|
char* obj_savejson(const void *o);
|
|
|
|
obj* obj_mergejson(void *o, const char *json);
|
|
|
|
obj* obj_loadjson(void *o, const char *json);
|
|
|
|
char* obj_savebin(const void *o);
|
|
|
|
obj* obj_mergebin(void *o, const char *sav);
|
|
|
|
obj* obj_loadbin(void *o, const char *sav);
|
|
|
|
char* obj_savempack(const void *o);
|
|
|
|
obj* obj_mergempack(void *o, const char *sav);
|
|
|
|
obj* obj_loadmpack(void *o, const char *sav);
|
|
|
|
int obj_push(const void *o);
|
|
|
|
int obj_pop(void *o);
|
|
|
|
bool obj_addcomponent(entity *e, unsigned c, void *ptr);
|
|
|
|
bool obj_hascomponent(entity *e, unsigned c);
|
|
|
|
void* obj_getcomponent(entity *e, unsigned c);
|
|
|
|
bool obj_delcomponent(entity *e, unsigned c);
|
|
|
|
bool obj_usecomponent(entity *e, unsigned c);
|
|
|
|
bool obj_offcomponent(entity *e, unsigned c);
|
|
|
|
char* entity_save(entity *self);
|
|
|
|
void* obj_clone(const void *src);
|
|
|
|
void* obj_merge(void *dst, const void *src);
|
|
|
|
void* obj_mutate(void *dst, const void *src);
|
|
|
|
void* obj_make(const char *str);
|
2023-11-02 09:54:49 +00:00
|
|
|
typedef enum OBJTYPE_BUILTINS {
|
2024-01-02 19:52:20 +00:00
|
|
|
OBJTYPE_obj = 0,
|
|
|
|
OBJTYPE_entity = 1,
|
|
|
|
OBJTYPE_vec2 = 2,
|
|
|
|
OBJTYPE_vec3 = 3,
|
|
|
|
OBJTYPE_vec4 = 4,
|
|
|
|
OBJTYPE_quat = 5,
|
|
|
|
OBJTYPE_mat33 = 6,
|
|
|
|
OBJTYPE_mat34 = 7,
|
|
|
|
OBJTYPE_mat44 = 8,
|
|
|
|
OBJTYPE_vec2i = 9,
|
|
|
|
OBJTYPE_vec3i = 10,
|
2023-11-02 09:54:49 +00:00
|
|
|
} OBJTYPE_BUILTINS;
|
|
|
|
int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
|
|
|
|
typedef int (*bt_func)();
|
|
|
|
typedef struct bt_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
uint64_t type;
|
|
|
|
int (*action)();
|
|
|
|
union {
|
|
|
|
int argi;
|
|
|
|
float argf;
|
|
|
|
};
|
|
|
|
struct bt_t* children;
|
2023-11-02 09:54:49 +00:00
|
|
|
} bt_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
bt_t bt(const char *ini_file, unsigned flags);
|
|
|
|
int bt_run(bt_t *b);
|
|
|
|
void bt_addfun(const char *name, int(*func)());
|
2023-11-02 09:54:49 +00:00
|
|
|
bt_func bt_findfun(const char *name);
|
2024-01-02 19:52:20 +00:00
|
|
|
char *bt_funcname(bt_func fn);
|
2023-11-02 09:54:49 +00:00
|
|
|
int ui_bt(bt_t *b);
|
|
|
|
typedef enum SWARM_DISTANCE {
|
2024-01-02 19:52:20 +00:00
|
|
|
SWARM_DISTANCE_LINEAR,
|
|
|
|
SWARM_DISTANCE_INVERSE_LINEAR,
|
|
|
|
SWARM_DISTANCE_QUADRATIC,
|
|
|
|
SWARM_DISTANCE_INVERSE_QUADRATIC
|
2023-11-02 09:54:49 +00:00
|
|
|
} SWARM_DISTANCE;
|
|
|
|
typedef struct boid_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
vec3 position;
|
|
|
|
vec3 velocity;
|
|
|
|
vec3 acceleration;
|
|
|
|
vec3 prev_position;
|
2023-11-02 09:54:49 +00:00
|
|
|
} boid_t;
|
|
|
|
typedef struct swarm_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
boid_t* boids;
|
|
|
|
float perception_radius;
|
|
|
|
float separation_weight;
|
|
|
|
SWARM_DISTANCE separation_type;
|
|
|
|
float alignment_weight;
|
|
|
|
float cohesion_weight;
|
|
|
|
float steering_weight;
|
|
|
|
vec3* steering_targets;
|
|
|
|
SWARM_DISTANCE steering_target_type;
|
|
|
|
float blindspot_angledeg;
|
|
|
|
float max_acceleration;
|
|
|
|
float max_velocity;
|
|
|
|
struct { map base; struct { pair p; vec3* key; boid_t** val; } tmp, *ptr; boid_t*** tmpval; int (*typed_cmp)(vec3*, vec3*); uint64_t (*typed_hash)(vec3*); } * voxel_cache_;
|
|
|
|
float blindspot_angledeg_compare_value_;
|
2023-11-02 09:54:49 +00:00
|
|
|
} swarm_t;
|
|
|
|
swarm_t swarm();
|
2024-01-02 19:52:20 +00:00
|
|
|
void swarm_update(swarm_t *self, float delta);
|
|
|
|
void swarm_update_acceleration_only(swarm_t *self);
|
|
|
|
void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta);
|
|
|
|
int ui_swarm(swarm_t *self);
|
|
|
|
void midi_send(unsigned midi_msg);
|
2023-11-02 09:54:49 +00:00
|
|
|
typedef struct audio_handle* audio_t;
|
|
|
|
audio_t audio_clip( const char *pathfile );
|
|
|
|
audio_t audio_stream( const char *pathfile );
|
2024-01-02 19:52:20 +00:00
|
|
|
int audio_play( audio_t s, int flags );
|
|
|
|
int audio_play_gain( audio_t a, int flags, float gain );
|
|
|
|
int audio_play_gain_pitch( audio_t a, int flags, float gain, float pitch );
|
|
|
|
int audio_play_gain_pitch_pan( audio_t a, int flags, float gain, float pitch, float pan );
|
|
|
|
int audio_stop( audio_t a );
|
|
|
|
void audio_loop( audio_t a, bool loop );
|
|
|
|
bool audio_playing( audio_t a );
|
|
|
|
float audio_volume_clip(float gain);
|
|
|
|
float audio_volume_stream(float gain);
|
|
|
|
float audio_volume_master(float gain);
|
|
|
|
int audio_mute(int mute);
|
|
|
|
int audio_muted();
|
2023-10-05 05:16:41 +00:00
|
|
|
int ui_audio();
|
2023-07-30 19:18:50 +00:00
|
|
|
enum AUDIO_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
AUDIO_1CH = 0,
|
|
|
|
AUDIO_2CH = 1,
|
|
|
|
AUDIO_8 = 2,
|
|
|
|
AUDIO_16 = 0,
|
|
|
|
AUDIO_32 = 4,
|
|
|
|
AUDIO_FLOAT = 8,
|
|
|
|
AUDIO_8KHZ = 16,
|
|
|
|
AUDIO_11KHZ = 32,
|
|
|
|
AUDIO_22KHZ = 0,
|
|
|
|
AUDIO_32KHZ = 64,
|
|
|
|
AUDIO_44KHZ = 128,
|
|
|
|
AUDIO_MIXER_GAIN = 0,
|
|
|
|
AUDIO_IGNORE_MIXER_GAIN = 256,
|
|
|
|
AUDIO_MULTIPLE_INSTANCES = 0,
|
|
|
|
AUDIO_SINGLE_INSTANCE = 512,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
int audio_queue( const void *samples, int num_samples, int flags );
|
|
|
|
typedef struct gjk_support {
|
2024-01-02 19:52:20 +00:00
|
|
|
int aid, bid;
|
|
|
|
vec3 a;
|
|
|
|
vec3 b;
|
2023-07-30 19:18:50 +00:00
|
|
|
} gjk_support;
|
|
|
|
typedef struct gjk_vertex {
|
2024-01-02 19:52:20 +00:00
|
|
|
vec3 a;
|
|
|
|
vec3 b;
|
|
|
|
vec3 p;
|
|
|
|
int aid, bid;
|
2023-07-30 19:18:50 +00:00
|
|
|
} gjk_vertex;
|
|
|
|
typedef struct gjk_simplex {
|
2024-01-02 19:52:20 +00:00
|
|
|
int max_iter, iter;
|
|
|
|
int hit, cnt;
|
|
|
|
gjk_vertex v[4];
|
|
|
|
float bc[4], D;
|
2023-07-30 19:18:50 +00:00
|
|
|
} gjk_simplex;
|
|
|
|
typedef struct gjk_result {
|
2024-01-02 19:52:20 +00:00
|
|
|
int hit;
|
|
|
|
vec3 p0;
|
|
|
|
vec3 p1;
|
|
|
|
float distance_squared;
|
|
|
|
int iterations;
|
2023-07-30 19:18:50 +00:00
|
|
|
} gjk_result;
|
|
|
|
int gjk(gjk_simplex *s, const gjk_support *sup, vec3 *dv);
|
|
|
|
gjk_result gjk_analyze(const gjk_simplex *s);
|
|
|
|
gjk_result gjk_quad(float a_radius, float b_radius);
|
2024-01-02 19:52:20 +00:00
|
|
|
typedef struct line { vec3 a, b; } line;
|
|
|
|
typedef struct sphere { vec3 c; float r; } sphere;
|
|
|
|
typedef struct aabb { vec3 min, max; } aabb;
|
|
|
|
typedef struct plane { vec3 p, n; } plane;
|
|
|
|
typedef struct capsule { vec3 a, b; float r; } capsule;
|
|
|
|
typedef struct ray { vec3 p, d; } ray;
|
|
|
|
typedef struct triangle { vec3 p0,p1,p2; } triangle;
|
|
|
|
typedef struct poly { vec3* verts; int cnt; } poly;
|
|
|
|
typedef union frustum { struct { vec4 l, r, t, b, n, f; }; vec4 pl[6]; float v[24]; } frustum;
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef struct hit {
|
2024-01-02 19:52:20 +00:00
|
|
|
union {
|
|
|
|
float depth;
|
|
|
|
struct { float t0, t1; };
|
|
|
|
struct { int hits; vec3 p0, p1; float distance2; int iterations; };
|
|
|
|
};
|
|
|
|
union { vec3 p; vec3 contact_point; };
|
|
|
|
union { vec3 n; vec3 normal; };
|
2023-07-30 19:18:50 +00:00
|
|
|
} hit;
|
2024-01-02 19:52:20 +00:00
|
|
|
float line_distance2_point(line l, vec3 p);
|
|
|
|
vec3 line_closest_point(line l, vec3 p);
|
|
|
|
float ray_test_plane(ray r, vec4 p4);
|
|
|
|
float ray_test_triangle(ray r, triangle t);
|
|
|
|
int ray_test_sphere(float *t0, float *t1, ray r, sphere s);
|
|
|
|
int ray_test_aabb(float *t0, float *t1, ray r, aabb a);
|
|
|
|
hit* ray_hit_plane(ray r, plane p);
|
|
|
|
hit* ray_hit_triangle(ray r, triangle t);
|
|
|
|
hit* ray_hit_sphere(ray r, sphere s);
|
|
|
|
hit* ray_hit_aabb(ray r, aabb a);
|
|
|
|
vec3 sphere_closest_point(sphere s, vec3 p);
|
|
|
|
hit* sphere_hit_aabb(sphere s, aabb a);
|
|
|
|
hit* sphere_hit_capsule(sphere s, capsule c);
|
|
|
|
hit* sphere_hit_sphere(sphere a, sphere b);
|
|
|
|
int sphere_test_aabb(sphere s, aabb a);
|
|
|
|
int sphere_test_capsule(sphere s, capsule c);
|
|
|
|
int sphere_test_poly(sphere s, poly p);
|
|
|
|
int sphere_test_sphere(sphere a, sphere b);
|
|
|
|
vec3 aabb_closest_point(aabb a, vec3 p);
|
|
|
|
float aabb_distance2_point(aabb a, vec3 p);
|
|
|
|
int aabb_contains_point(aabb a, vec3 p);
|
|
|
|
hit* aabb_hit_aabb(aabb a, aabb b);
|
|
|
|
hit* aabb_hit_capsule(aabb a, capsule c);
|
|
|
|
hit* aabb_hit_sphere(aabb a, sphere s);
|
|
|
|
int aabb_test_aabb(aabb a, aabb b);
|
|
|
|
int aabb_test_capsule(aabb a, capsule c);
|
|
|
|
int aabb_test_poly(aabb a, poly p);
|
|
|
|
int aabb_test_sphere(aabb a, sphere s);
|
|
|
|
float capsule_distance2_point(capsule c, vec3 p);
|
|
|
|
vec3 capsule_closest_point(capsule c, vec3 p);
|
|
|
|
hit* capsule_hit_aabb(capsule c, aabb a);
|
|
|
|
hit* capsule_hit_capsule(capsule a, capsule b);
|
|
|
|
hit* capsule_hit_sphere(capsule c, sphere s);
|
|
|
|
int capsule_test_aabb(capsule c, aabb a);
|
|
|
|
int capsule_test_capsule(capsule a, capsule b);
|
|
|
|
int capsule_test_poly(capsule c, poly p);
|
|
|
|
int capsule_test_sphere(capsule c, sphere s);
|
|
|
|
int poly_test_sphere(poly p, sphere s);
|
|
|
|
int poly_test_aabb(poly p, aabb a);
|
|
|
|
int poly_test_capsule(poly p, capsule c);
|
|
|
|
int poly_test_poly(poly a, poly b);
|
|
|
|
int poly_test_sphere_transform(poly p, vec3 pos3, mat33 rot33, sphere s);
|
|
|
|
int poly_test_aabb_transform(poly p, vec3 apos3, mat33 arot33, aabb a);
|
|
|
|
int poly_test_capsule_transform(poly p, vec3 pos3, mat33 rot33, capsule c);
|
|
|
|
int poly_test_poly_transform(poly a, vec3 apos3, mat33 arot33, poly b, vec3 bpos3, mat33 brot33);
|
|
|
|
int poly_hit_sphere(struct gjk_result *res, poly p, sphere s);
|
|
|
|
int poly_hit_aabb(struct gjk_result *res, poly p, aabb a);
|
|
|
|
int poly_hit_capsule(struct gjk_result *res, poly p, capsule c);
|
|
|
|
int poly_hit_poly(struct gjk_result *res, poly a, poly b);
|
|
|
|
int poly_hit_sphere_transform(struct gjk_result *res, poly p, vec3 pos3, mat33 rot33, sphere s);
|
|
|
|
int poly_hit_aabb_transform(struct gjk_result *res, poly p, vec3 pos3, mat33 rot33, aabb a);
|
|
|
|
int poly_hit_capsule_transform(struct gjk_result *res, poly p, vec3 pos3, mat33 rot33, capsule c);
|
|
|
|
int poly_hit_poly_transform(struct gjk_result *res, poly a, vec3 at3, mat33 ar33, poly b, vec3 bt3, mat33 br33);
|
|
|
|
vec4 plane4(vec3 p, vec3 n);
|
2023-07-30 19:18:50 +00:00
|
|
|
frustum frustum_build(mat44 projview);
|
2024-01-02 19:52:20 +00:00
|
|
|
int frustum_test_sphere(frustum f, sphere s);
|
|
|
|
int frustum_test_aabb(frustum f, aabb a);
|
|
|
|
poly poly_alloc(int cnt);
|
|
|
|
void poly_free(poly *p);
|
|
|
|
poly pyramid(vec3 from, vec3 to, float size);
|
|
|
|
poly diamond(vec3 from, vec3 to, float size);
|
|
|
|
void collide_demo();
|
2023-07-30 19:18:50 +00:00
|
|
|
enum COOK_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
COOK_SYNC = 0,
|
|
|
|
COOK_ASYNC = 1,
|
|
|
|
COOK_CANCELABLE = 2,
|
|
|
|
COOK_DEBUGLOG = 4,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
void cook_config( const char *path_to_cook_ini );
|
|
|
|
bool cook_start( const char *path_to_cook_ini, const char *masks, int flags );
|
|
|
|
void cook_stop();
|
|
|
|
void cook_cancel();
|
2024-01-02 19:52:20 +00:00
|
|
|
int cook_jobs();
|
|
|
|
int cook_progress();
|
2023-10-15 11:22:55 +00:00
|
|
|
bool have_tools();
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t* arr; } json_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
bool json_push(const char *json_content);
|
|
|
|
const char* json_key(const char *keypath);
|
|
|
|
json_t* json_find(const char *type_keypath);
|
|
|
|
json_t json_get(const char *type_keypath);
|
|
|
|
int json_count(const char *keypath);
|
|
|
|
bool json_pop();
|
|
|
|
int xml_push(const char *xml_content);
|
|
|
|
const char * xml_string(char *key);
|
|
|
|
unsigned xml_count(char *key);
|
|
|
|
char* xml_blob(char *key);
|
|
|
|
void xml_pop();
|
2023-07-30 19:18:50 +00:00
|
|
|
bool data_tests();
|
|
|
|
void* dll(const char *filename, const char *symbol);
|
2024-01-02 19:52:20 +00:00
|
|
|
enum {
|
|
|
|
SCRIPT_LUA = 1,
|
|
|
|
SCRIPT_DEBUGGER = 2,
|
|
|
|
};
|
2023-11-02 09:54:49 +00:00
|
|
|
void script_init();
|
2024-01-02 19:52:20 +00:00
|
|
|
void *script_init_env(unsigned flags);
|
|
|
|
bool script_push(void *env);
|
2023-11-02 09:54:49 +00:00
|
|
|
void script_run(const char *script);
|
|
|
|
void script_runfile(const char *pathfile);
|
|
|
|
void script_bind_class(const char *objname, int num_methods, const char **c_names, void **c_functions);
|
|
|
|
void script_bind_function(const char *c_name, void *c_function);
|
|
|
|
void script_call(const char *lua_function);
|
|
|
|
bool script_tests();
|
2024-01-02 19:52:20 +00:00
|
|
|
bool script_pop();
|
2023-10-14 19:47:24 +00:00
|
|
|
char** file_list( const char *pathmasks );
|
2024-01-02 19:52:20 +00:00
|
|
|
bool file_write( const char *file, const void *ptr, int len );
|
|
|
|
bool file_append( const char *file, const void *ptr, int len );
|
|
|
|
char * file_read(const char *filename);
|
|
|
|
char * file_load(const char *filename, int *len);
|
|
|
|
uint64_t file_size(const char *pathfile);
|
|
|
|
bool file_directory(const char *pathfile);
|
|
|
|
char * file_pathabs(const char *pathfile);
|
|
|
|
char * file_path(const char *pathfile);
|
|
|
|
char * file_name(const char *pathfile);
|
|
|
|
char * file_base(const char *pathfile);
|
|
|
|
char * file_ext(const char *pathfile);
|
|
|
|
char * file_id(const char *pathfile);
|
|
|
|
char * file_normalize(const char *pathfile);
|
|
|
|
char * file_counter(const char *pathfile);
|
|
|
|
uint64_t file_stamp(const char *pathfile);
|
|
|
|
uint64_t file_stamp10(const char *pathfile);
|
|
|
|
bool file_exist(const char *pathfile);
|
|
|
|
bool file_delete(const char *pathfile);
|
|
|
|
bool file_copy(const char *src, const char *dst);
|
|
|
|
bool file_move(const char *src, const char *dst);
|
|
|
|
FILE* file_temp();
|
|
|
|
char* file_tempname();
|
|
|
|
void* file_md5(const char *file);
|
|
|
|
void* file_sha1(const char *file);
|
|
|
|
void* file_crc32(const char *file);
|
2023-07-30 19:18:50 +00:00
|
|
|
char** file_zip_list(const char *zipfile);
|
2024-01-02 19:52:20 +00:00
|
|
|
char* file_zip_extract(const char *zipfile, const char *filename);
|
|
|
|
bool file_zip_append(const char *zipfile, const char *filename, int clevel);
|
|
|
|
bool file_zip_appendmem(const char *zipfile, const char *entryname, const void *ptr, unsigned len, int clevel);
|
|
|
|
void storage_mount(const char* folder);
|
|
|
|
void storage_read();
|
|
|
|
void storage_flush();
|
|
|
|
bool vfs_mount(const char *mount_point);
|
2023-10-15 11:22:55 +00:00
|
|
|
char** vfs_list(const char *masks);
|
2024-01-02 19:52:20 +00:00
|
|
|
char * vfs_read(const char *pathfile);
|
|
|
|
char * vfs_load(const char *pathfile, int *size);
|
|
|
|
int vfs_size(const char *pathfile);
|
|
|
|
void vfs_reload();
|
2023-07-30 19:18:50 +00:00
|
|
|
const char * vfs_resolve(const char *fuzzyname);
|
2024-01-02 19:52:20 +00:00
|
|
|
FILE* vfs_handle(const char *pathfile);
|
|
|
|
void * cache_insert(const char *key, void *value, int size);
|
|
|
|
void * cache_lookup(const char *key, int *size);
|
|
|
|
typedef struct { map base; struct { pair p; char* key; char* val; } tmp, *ptr; char** tmpval; int (*typed_cmp)(char*, char*); uint64_t (*typed_hash)(char*); } * ini_t;
|
|
|
|
ini_t ini(const char *filename);
|
|
|
|
ini_t ini_from_mem(const char *data);
|
|
|
|
void ini_destroy(ini_t);
|
|
|
|
bool ini_write(const char *filename, const char *section, const char *key, const char *value);
|
2023-11-05 15:30:11 +00:00
|
|
|
enum FONT_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
FONT_512 = 0x0,
|
|
|
|
FONT_1024 = 0x1,
|
|
|
|
FONT_2048 = 0x2,
|
|
|
|
FONT_4096 = 0x4,
|
|
|
|
FONT_NO_OVERSAMPLE = 0x0,
|
|
|
|
FONT_OVERSAMPLE_X = 0x08,
|
|
|
|
FONT_OVERSAMPLE_Y = 0x10,
|
|
|
|
FONT_ASCII = 0x800,
|
|
|
|
FONT_AR = 0x001000,
|
|
|
|
FONT_ZH = 0x002000,
|
|
|
|
FONT_EL = 0x004000,
|
|
|
|
FONT_EM = 0x008000,
|
|
|
|
FONT_EU = 0x010000,
|
|
|
|
FONT_HE = 0x020000,
|
|
|
|
FONT_JP = 0x040000,
|
|
|
|
FONT_KR = 0x080000,
|
|
|
|
FONT_RU = 0x100000,
|
|
|
|
FONT_TH = 0x200000,
|
|
|
|
FONT_VI = 0x400000,
|
|
|
|
FONT_CJK = FONT_ZH|FONT_JP|FONT_KR,
|
2023-11-05 15:30:11 +00:00
|
|
|
};
|
2023-12-10 15:48:21 +00:00
|
|
|
typedef struct font_metrics_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
float ascent;
|
|
|
|
float descent;
|
|
|
|
float linegap;
|
|
|
|
float linedist;
|
2023-12-10 15:48:21 +00:00
|
|
|
} font_metrics_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
void font_face(const char *face_tag, const char *filename_ttf, float font_size, unsigned flags);
|
|
|
|
void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
|
2024-02-08 10:24:55 +00:00
|
|
|
void font_scale(const char *face_tag, int scale_index, float value);
|
2024-01-02 19:52:20 +00:00
|
|
|
void font_scales(const char *face_tag, float h1, float h2, float h3, float h4, float h5, float h6);
|
|
|
|
void font_color(const char *color_tag, uint32_t color);
|
|
|
|
vec2 font_xy();
|
|
|
|
void font_goto(float x, float y);
|
|
|
|
vec2 font_print(const char *text);
|
2024-02-10 16:05:45 +00:00
|
|
|
vec2 font_clip(const char *text, vec4 rect);
|
2024-01-02 19:52:20 +00:00
|
|
|
vec2 font_rect(const char *text);
|
2023-12-10 15:48:21 +00:00
|
|
|
font_metrics_t font_metrics(const char *text);
|
2024-02-11 14:34:47 +00:00
|
|
|
const char* font_wrap(const char *text, float max_width);
|
2023-11-05 15:30:11 +00:00
|
|
|
void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords);
|
2024-01-02 19:52:20 +00:00
|
|
|
vec2 font_highlight(const char *text, const void *colors);
|
|
|
|
void ui_font();
|
|
|
|
int input_use( int controller_id );
|
|
|
|
float input( int vk );
|
|
|
|
vec2 input2( int vk );
|
|
|
|
float input_diff( int vk );
|
|
|
|
vec2 input_diff2( int vk );
|
2023-10-01 06:49:08 +00:00
|
|
|
const char* input_string( int vk );
|
2024-01-02 19:52:20 +00:00
|
|
|
float input_frame( int vk, int Nth_frame );
|
|
|
|
vec2 input_frame2( int vk, int Nth_frame );
|
|
|
|
int input_up( int vk );
|
|
|
|
int input_down( int vk );
|
|
|
|
int input_held( int vk );
|
|
|
|
int input_idle( int vk );
|
|
|
|
int input_click( int vk, int ms );
|
|
|
|
int input_click2( int vk, int ms );
|
|
|
|
int input_repeat( int vk, int ms );
|
|
|
|
int input_chord2( int vk1, int vk2 );
|
|
|
|
int input_chord3( int vk1, int vk2, int vk3 );
|
|
|
|
int input_chord4( int vk1, int vk2, int vk3, int vk4 );
|
|
|
|
float input_filter_positive( float v );
|
|
|
|
vec2 input_filter_positive2( vec2 v );
|
|
|
|
vec2 input_filter_deadzone( vec2 v, float deadzone_treshold );
|
|
|
|
vec2 input_filter_deadzone_4way( vec2 v, float deadzone_treshold );
|
2023-07-30 19:18:50 +00:00
|
|
|
enum TOUCH_BUTTONS {
|
2024-01-02 19:52:20 +00:00
|
|
|
TOUCH_0,
|
|
|
|
TOUCH_1,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
2024-01-02 19:52:20 +00:00
|
|
|
void input_touch_area(unsigned button, vec2 begin_coord_ndc, vec2 end_coord_ndc);
|
|
|
|
vec2 input_touch(unsigned button, float sensitivity);
|
|
|
|
vec2 input_touch_delta(unsigned button, float sensitivity);
|
|
|
|
vec2 input_touch_delta_from_origin(unsigned button, float sensitivity);
|
|
|
|
bool input_touch_active();
|
|
|
|
void input_mappings(const char *filename);
|
|
|
|
char input_keychar(unsigned code);
|
|
|
|
int input_enum(const char *sym);
|
|
|
|
int input_anykey();
|
|
|
|
int input_eval(const char *expression);
|
|
|
|
void input_send( int vk );
|
2023-10-01 06:49:08 +00:00
|
|
|
char* save_input();
|
2024-01-02 19:52:20 +00:00
|
|
|
bool load_input(char* replay);
|
|
|
|
int ui_keyboard();
|
|
|
|
int ui_mouse();
|
|
|
|
int ui_gamepad(int id);
|
|
|
|
int ui_gamepads();
|
2023-07-30 19:18:50 +00:00
|
|
|
enum INPUT_ENUMS {
|
2024-01-02 19:52:20 +00:00
|
|
|
KEY_0,KEY_1,KEY_2,KEY_3,KEY_4,KEY_5,KEY_6,KEY_7,KEY_8,KEY_9, KEY_TICK,KEY_BS, KEY_ESC,
|
|
|
|
KEY_TAB, KEY_Q,KEY_W,KEY_E,KEY_R,KEY_T,KEY_Y,KEY_U,KEY_I,KEY_O,KEY_P,
|
|
|
|
KEY_CAPS, KEY_A,KEY_S,KEY_D,KEY_F,KEY_G,KEY_H,KEY_J,KEY_K,KEY_L, KEY_ENTER,
|
|
|
|
KEY_LSHIFT, KEY_Z,KEY_X,KEY_C,KEY_V,KEY_B,KEY_N,KEY_M, KEY_RSHIFT, KEY_UP,
|
|
|
|
KEY_LCTRL,KEY_LALT, KEY_SPACE, KEY_RALT,KEY_RCTRL, KEY_LEFT,KEY_DOWN,KEY_RIGHT,
|
|
|
|
KEY_INS,KEY_HOME,KEY_PGUP,KEY_DEL,KEY_END,KEY_PGDN,
|
|
|
|
KEY_LMETA,KEY_RMETA,KEY_MENU,KEY_PRINT,KEY_PAUSE,KEY_SCROLL,KEY_NUMLOCK,
|
|
|
|
KEY_MINUS,KEY_EQUAL,KEY_LSQUARE,KEY_RSQUARE,KEY_SEMICOLON,KEY_QUOTE,KEY_HASH,KEY_BAR,KEY_COMMA,KEY_DOT,KEY_SLASH,
|
|
|
|
KEY_F1,KEY_F2,KEY_F3,KEY_F4,KEY_F5,KEY_F6,KEY_F7,KEY_F8,KEY_F9,KEY_F10,KEY_F11,KEY_F12,
|
|
|
|
KEY_PAD1,KEY_PAD2,KEY_PAD3,KEY_PAD4,KEY_PAD5,KEY_PAD6,KEY_PAD7,KEY_PAD8,KEY_PAD9,KEY_PAD0,
|
|
|
|
KEY_PADADD,KEY_PADSUB,KEY_PADMUL,KEY_PADDIV,KEY_PADDOT,KEY_PADENTER,
|
|
|
|
MOUSE_L, MOUSE_M, MOUSE_R,
|
|
|
|
GAMEPAD_CONNECTED, GAMEPAD_A, GAMEPAD_B, GAMEPAD_X, GAMEPAD_Y,
|
|
|
|
GAMEPAD_UP, GAMEPAD_DOWN, GAMEPAD_LEFT, GAMEPAD_RIGHT, GAMEPAD_MENU, GAMEPAD_START,
|
|
|
|
GAMEPAD_LB, GAMEPAD_RB, GAMEPAD_LTHUMB, GAMEPAD_RTHUMB,
|
|
|
|
WINDOW_BLUR, WINDOW_FOCUS, WINDOW_CLOSE, WINDOW_MINIMIZE, WINDOW_MAXIMIZE, WINDOW_FULLSCREEN, WINDOW_WINDOWED,
|
|
|
|
GAMEPAD_LPAD, GAMEPAD_LPADX = GAMEPAD_LPAD, GAMEPAD_LPADY,
|
|
|
|
GAMEPAD_RPAD, GAMEPAD_RPADX = GAMEPAD_RPAD, GAMEPAD_RPADY,
|
|
|
|
GAMEPAD_LTRIGGER, GAMEPAD_LT = GAMEPAD_LTRIGGER, GAMEPAD_RTRIGGER, GAMEPAD_RT = GAMEPAD_RTRIGGER, GAMEPAD_BATTERY,
|
|
|
|
MOUSE, MOUSE_X = MOUSE, MOUSE_Y, MOUSE_W,
|
|
|
|
TOUCH_X1, TOUCH_Y1, TOUCH_X2, TOUCH_Y2,
|
|
|
|
WINDOW_RESIZE, WINDOW_RESIZEX = WINDOW_RESIZE, WINDOW_RESIZEY, WINDOW_ORIENTATION, WINDOW_BATTERY,
|
|
|
|
GAMEPAD_GUID, GAMEPAD_NAME,
|
2023-10-26 07:27:46 +00:00
|
|
|
};
|
|
|
|
enum INPUT_ALIASES {
|
2024-01-02 19:52:20 +00:00
|
|
|
KEY_SHIFT = KEY_LSHIFT,
|
|
|
|
KEY_ALT = KEY_LALT,
|
|
|
|
KEY_CTRL = KEY_LCTRL,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
2024-01-02 19:52:20 +00:00
|
|
|
void* xrealloc(void* p, size_t sz);
|
2023-07-30 19:18:50 +00:00
|
|
|
size_t xsize(void* p);
|
2024-01-02 19:52:20 +00:00
|
|
|
char* xstats(void);
|
|
|
|
void* stack(int bytes);
|
|
|
|
void* watch( void *ptr, int sz );
|
|
|
|
void* forget( void *ptr );
|
2023-07-30 19:18:50 +00:00
|
|
|
inline void *(REALLOC_)(void *p, size_t n) { return n ? (xrealloc(p,n)) : xrealloc((p),0); }
|
|
|
|
inline void *(CALLOC_)(size_t m, size_t n) { return n *= m, memset(REALLOC_((0),(n)),0,n); }
|
|
|
|
inline char *(STRDUP_)(const char *s) { size_t n = strlen(s)+1; return ((char*)memcpy(REALLOC_((0),(n)), s, n)); }
|
|
|
|
char* download( const char *url );
|
2024-01-02 19:52:20 +00:00
|
|
|
int download_file( FILE *out, const char *url );
|
|
|
|
int portname( const char *service_name, unsigned retries );
|
|
|
|
bool network_tests();
|
|
|
|
int udp_bind(const char *address, const char *port);
|
|
|
|
int udp_open(const char *address, const char *port);
|
|
|
|
int udp_send(int, const void *buf, int len );
|
|
|
|
int udp_sendto(int, const char *ip, const char *port, const void *buf, int len );
|
|
|
|
int udp_recv(int, void *buf, int len );
|
|
|
|
int udp_peek(int);
|
|
|
|
int tcp_open(const char *address, const char *port);
|
|
|
|
int tcp_bind(const char *interface_, const char *port, int queue);
|
|
|
|
int tcp_peek(int, int(*callback)(int));
|
|
|
|
int tcp_send(int, const void* buf, int len);
|
|
|
|
int tcp_recv(int, void* buf, int len);
|
2023-07-30 19:18:50 +00:00
|
|
|
char* tcp_host(int);
|
|
|
|
char* tcp_port(int);
|
2024-01-02 19:52:20 +00:00
|
|
|
int tcp_close(int);
|
|
|
|
int tcp_debug(int);
|
2023-10-24 09:43:43 +00:00
|
|
|
int track_init(char const *host, char const *port);
|
|
|
|
int track_destroy(void);
|
|
|
|
int track_event(char const *event_id, char const *user_id, char const *json_payload);
|
|
|
|
int track_ident(char const *user_id, char const *traits);
|
|
|
|
int track_group(char const *user_id, char const *group_id, char const *traits);
|
2023-10-24 09:44:36 +00:00
|
|
|
typedef struct track_prop {
|
2024-01-02 19:52:20 +00:00
|
|
|
char const *key;
|
|
|
|
char const *val;
|
2023-10-24 09:43:43 +00:00
|
|
|
} track_prop;
|
|
|
|
int track_event_props(char const *event_id, char const *user_id, const track_prop *props);
|
2023-08-10 14:30:56 +00:00
|
|
|
enum { NETWORK_BIND = 2, NETWORK_CONNECT = 4, NETWORK_NOFAIL = 8 };
|
2024-01-02 19:52:20 +00:00
|
|
|
void network_create(unsigned max_clients, const char *ip, const char *port, unsigned flags);
|
2023-08-10 14:30:56 +00:00
|
|
|
enum { NETWORK_SEND = 2, NETWORK_RECV = 4 };
|
2023-08-21 10:33:11 +00:00
|
|
|
enum { NETWORK_UNRELIABLE = 8, NETWORK_UNORDERED = 16 };
|
2024-01-02 19:52:20 +00:00
|
|
|
void* network_buffer(void *ptr, unsigned sz, uint64_t flags, int64_t rank);
|
|
|
|
char** network_sync(unsigned timeout_ms);
|
2023-08-21 12:24:47 +00:00
|
|
|
enum {
|
2024-01-02 19:52:20 +00:00
|
|
|
NETWORK_EVENT_CONNECT,
|
|
|
|
NETWORK_EVENT_DISCONNECT,
|
|
|
|
NETWORK_EVENT_RECEIVE,
|
|
|
|
NETWORK_EVENT_DISCONNECT_TIMEOUT,
|
|
|
|
NETWORK_EVENT_RPC = 10,
|
|
|
|
NETWORK_EVENT_RPC_RESP,
|
2023-08-21 12:24:47 +00:00
|
|
|
};
|
|
|
|
int network_event(const char *msg, int *errcode, char **errstr);
|
2023-08-10 14:30:56 +00:00
|
|
|
enum { NETWORK_RANK = 0 };
|
|
|
|
enum { NETWORK_PING = 1 };
|
|
|
|
enum { NETWORK_PORT = 2, NETWORK_IP, NETWORK_LIVE };
|
2023-08-21 10:33:11 +00:00
|
|
|
enum { NETWORK_SEND_MS = 4 };
|
2023-08-21 18:23:43 +00:00
|
|
|
enum { NETWORK_BUF_CLEAR_ON_JOIN = 5 };
|
2024-01-02 19:52:20 +00:00
|
|
|
enum { NETWORK_USERID = 7, NETWORK_COUNT , NETWORK_CAPACITY };
|
2023-08-10 14:30:56 +00:00
|
|
|
int64_t network_get(uint64_t key);
|
|
|
|
int64_t network_put(uint64_t key, int64_t value);
|
2023-08-10 17:56:28 +00:00
|
|
|
void network_rpc(const char *signature, void *function);
|
|
|
|
void network_rpc_send_to(int64_t rank, unsigned id, const char *cmdline);
|
|
|
|
void network_rpc_send(unsigned id, const char *cmdline);
|
2024-01-02 19:52:20 +00:00
|
|
|
bool server_bind(int max_clients, int port);
|
2023-11-02 09:54:49 +00:00
|
|
|
char** server_poll(unsigned timeout_ms);
|
|
|
|
char** client_poll(unsigned timeout_ms);
|
2024-01-02 19:52:20 +00:00
|
|
|
void server_broadcast_bin_flags(const void *ptr, int len, uint64_t flags);
|
|
|
|
void server_broadcast_bin(const void *ptr, int len);
|
|
|
|
void server_broadcast_flags(const char *msg, uint64_t flags);
|
|
|
|
void server_broadcast(const char *msg);
|
|
|
|
void server_terminate();
|
|
|
|
void server_send(int64_t handle, const char *msg);
|
|
|
|
void server_send_bin(int64_t handle, const void *ptr, int len);
|
|
|
|
void server_drop(int64_t handle);
|
|
|
|
int64_t client_join(const char *ip, int port);
|
2023-11-02 09:54:49 +00:00
|
|
|
enum COMPRESS_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
COMPRESS_RAW = 0,
|
|
|
|
COMPRESS_PPP = (1<<4),
|
|
|
|
COMPRESS_ULZ = (2<<4),
|
|
|
|
COMPRESS_LZ4 = (3<<4),
|
|
|
|
COMPRESS_CRUSH = (4<<4),
|
|
|
|
COMPRESS_DEFLATE = (5<<4),
|
|
|
|
COMPRESS_LZP1 = (6<<4),
|
|
|
|
COMPRESS_LZMA = (7<<4),
|
|
|
|
COMPRESS_BALZ = (8<<4),
|
|
|
|
COMPRESS_LZW3 = (9<<4),
|
|
|
|
COMPRESS_LZSS = (10<<4),
|
|
|
|
COMPRESS_BCM = (11<<4),
|
|
|
|
COMPRESS_ZLIB = (12<<4),
|
2023-11-02 09:54:49 +00:00
|
|
|
};
|
|
|
|
unsigned zbounds(unsigned inlen, unsigned flags);
|
|
|
|
unsigned zencode(void *out, unsigned outlen, const void *in, unsigned inlen, unsigned flags);
|
|
|
|
unsigned zexcess(unsigned flags);
|
|
|
|
unsigned zdecode(void *out, unsigned outlen, const void *in, unsigned inlen, unsigned flags);
|
|
|
|
void *interleave( void *out, const void *list, int list_count, int sizeof_item, unsigned columns );
|
|
|
|
unsigned cobs_bounds(unsigned len);
|
|
|
|
unsigned cobs_encode(const void *in, unsigned inlen, void *out, unsigned outlen);
|
|
|
|
unsigned cobs_decode(const void *in, unsigned inlen, void *out, unsigned outlen);
|
|
|
|
unsigned base92_encode(const void *in, unsigned inlen, void* out, unsigned outlen);
|
|
|
|
unsigned base92_decode(const void *in, unsigned inlen, void* out, unsigned outlen);
|
|
|
|
unsigned base92_bounds(unsigned inlen);
|
|
|
|
unsigned netstring_bounds(unsigned inlen);
|
|
|
|
unsigned netstring_encode(const char *in, unsigned inlen, char *out, unsigned outlen);
|
|
|
|
unsigned netstring_decode(const char *in, unsigned inlen, char *out, unsigned outlen);
|
|
|
|
void delta8_encode(void *buffer, unsigned count);
|
|
|
|
void delta8_decode(void *buffer, unsigned count);
|
|
|
|
void delta16_encode(void *buffer, unsigned count);
|
|
|
|
void delta16_decode(void *buffer, unsigned count);
|
|
|
|
void delta32_encode(void *buffer, unsigned count);
|
|
|
|
void delta32_decode(void *buffer, unsigned count);
|
|
|
|
void delta64_encode(void *buffer, unsigned count);
|
|
|
|
void delta64_decode(void *buffer, unsigned count);
|
|
|
|
uint64_t zig64( int64_t value );
|
|
|
|
int64_t zag64( uint64_t value );
|
|
|
|
uint32_t enczig32u( int32_t n);
|
|
|
|
uint64_t enczig64u( int64_t n);
|
2024-01-02 19:52:20 +00:00
|
|
|
int32_t deczig32i(uint32_t n);
|
|
|
|
int64_t deczig64i(uint64_t n);
|
2023-11-02 09:54:49 +00:00
|
|
|
void *arc4( void *buffer, unsigned buflen, const void *pass, unsigned passlen );
|
|
|
|
uint64_t crc64(uint64_t h, const void *ptr, uint64_t len);
|
|
|
|
void entropy( void *buf, unsigned n );
|
|
|
|
int semver( int major, int minor, int patch );
|
|
|
|
int semvercmp( int v1, int v2 );
|
|
|
|
typedef struct byte2 { uint8_t x,y; } byte2;
|
|
|
|
typedef struct byte3 { uint8_t x,y,z; } byte3;
|
|
|
|
typedef struct byte4 { uint8_t x,y,z,w; } byte4;
|
|
|
|
typedef struct int2 { int x,y; } int2;
|
|
|
|
typedef struct int3 { int x,y,z; } int3;
|
|
|
|
typedef struct int4 { int x,y,z,w; } int4;
|
|
|
|
typedef struct uint2 { unsigned int x,y; } uint2;
|
|
|
|
typedef struct uint3 { unsigned int x,y,z; } uint3;
|
|
|
|
typedef struct uint4 { unsigned int x,y,z,w; } uint4;
|
|
|
|
typedef struct float2 { float x,y; } float2;
|
|
|
|
typedef struct float3 { float x,y,z; } float3;
|
|
|
|
typedef struct float4 { float x,y,z,w; } float4;
|
|
|
|
typedef struct double2 { double x,y; } double2;
|
|
|
|
typedef struct double3 { double x,y,z; } double3;
|
|
|
|
typedef struct double4 { double x,y,z,w; } double4;
|
|
|
|
char *cc4str(unsigned cc);
|
|
|
|
char *cc8str(uint64_t cc);
|
|
|
|
enum {
|
2024-01-02 19:52:20 +00:00
|
|
|
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,
|
2023-11-02 09:54:49 +00:00
|
|
|
};
|
|
|
|
char* ftoa1(float v);
|
2024-01-02 19:52:20 +00:00
|
|
|
char* ftoa2(vec2 v);
|
|
|
|
char* ftoa3(vec3 v);
|
|
|
|
char* ftoa4(vec4 v);
|
2023-11-02 09:54:49 +00:00
|
|
|
float atof1(const char *s);
|
2024-01-02 19:52:20 +00:00
|
|
|
vec2 atof2(const char *s);
|
|
|
|
vec3 atof3(const char *s);
|
|
|
|
vec4 atof4(const char *s);
|
|
|
|
char* itoa1(int v);
|
2023-11-02 09:54:49 +00:00
|
|
|
char* itoa2(vec2i v);
|
|
|
|
char* itoa3(vec3i v);
|
2024-01-02 19:52:20 +00:00
|
|
|
int atoi1(const char *s);
|
2023-11-02 09:54:49 +00:00
|
|
|
vec2i atoi2(const char *s);
|
|
|
|
vec3i atoi3(const char *s);
|
2024-01-02 19:52:20 +00:00
|
|
|
int is_big();
|
|
|
|
int is_little();
|
|
|
|
uint16_t swap16( uint16_t x );
|
|
|
|
uint32_t swap32( uint32_t x );
|
|
|
|
uint64_t swap64( uint64_t x );
|
|
|
|
float swap32f(float 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);
|
|
|
|
uint32_t lil32(uint32_t n);
|
|
|
|
uint64_t lil64(uint64_t n);
|
|
|
|
float lil32f(float n);
|
|
|
|
double lil64f(double n);
|
|
|
|
uint16_t big16(uint16_t n);
|
|
|
|
uint32_t big32(uint32_t n);
|
|
|
|
uint64_t big64(uint64_t n);
|
|
|
|
float big32f(float n);
|
|
|
|
double big64f(double n);
|
|
|
|
uint16_t* lil16p(void *p, int sz);
|
|
|
|
uint32_t* lil32p(void *p, int sz);
|
|
|
|
uint64_t* lil64p(void *p, int sz);
|
|
|
|
float * lil32pf(void *p, int sz);
|
|
|
|
double * lil64pf(void *p, int sz);
|
|
|
|
uint16_t* big16p(void *p, int sz);
|
|
|
|
uint32_t* big32p(void *p, int sz);
|
|
|
|
uint64_t* big64p(void *p, int sz);
|
|
|
|
float * big32pf(void *p, int sz);
|
|
|
|
double * big64pf(void *p, int sz);
|
2023-11-02 09:54:49 +00:00
|
|
|
typedef uint16_t half;
|
|
|
|
float half_to_float(half value);
|
2024-01-02 19:52:20 +00:00
|
|
|
half float_to_half(float value);
|
2023-11-02 09:54:49 +00:00
|
|
|
void pack16i(uint8_t *buf, uint16_t i, int swap);
|
|
|
|
void pack32i(uint8_t *buf, uint32_t i, int swap);
|
|
|
|
void pack64i(uint8_t *buf, uint64_t i, int swap);
|
|
|
|
int16_t unpack16i(const uint8_t *buf, int swap);
|
|
|
|
int32_t unpack32i(const uint8_t *buf, int swap);
|
|
|
|
int64_t unpack64i(const uint8_t *buf, int swap);
|
2024-01-02 19:52:20 +00:00
|
|
|
uint64_t pack754(long double f, unsigned bits, unsigned expbits);
|
2023-11-02 09:54:49 +00:00
|
|
|
long double unpack754(uint64_t i, unsigned bits, unsigned expbits);
|
|
|
|
uint64_t pack64uv( uint8_t *buffer, uint64_t value );
|
|
|
|
uint64_t unpack64uv( const uint8_t *buffer, uint64_t *value );
|
|
|
|
uint64_t pack64iv( uint8_t *buffer, int64_t value_ );
|
|
|
|
uint64_t unpack64iv( const uint8_t *buffer, int64_t *value );
|
2024-01-02 19:52:20 +00:00
|
|
|
int msgpack(const char *fmt, ... );
|
|
|
|
int msgunpack(const char *fmt, ... );
|
2023-11-02 09:54:49 +00:00
|
|
|
int msgpack_new(uint8_t *w, size_t l);
|
|
|
|
int msgpack_nil();
|
|
|
|
int msgpack_chr(bool n);
|
|
|
|
int msgpack_uns(uint64_t n);
|
|
|
|
int msgpack_int(int64_t n);
|
|
|
|
int msgpack_str(const char *s);
|
|
|
|
int msgpack_bin(const char *s, size_t n);
|
|
|
|
int msgpack_flt(double g);
|
|
|
|
int msgpack_ext(uint8_t key, void *val, size_t n);
|
|
|
|
int msgpack_arr(uint32_t n);
|
|
|
|
int msgpack_map(uint32_t n);
|
|
|
|
int msgpack_eof();
|
|
|
|
int msgpack_err();
|
|
|
|
bool msgunpack_new( const void *opaque_or_FILE, size_t bytes );
|
|
|
|
bool msgunpack_nil();
|
|
|
|
bool msgunpack_chr(bool *chr);
|
|
|
|
bool msgunpack_uns(uint64_t *uns);
|
|
|
|
bool msgunpack_int(int64_t *sig);
|
|
|
|
bool msgunpack_str(char **str);
|
|
|
|
bool msgunpack_bin(void **bin, uint64_t *len);
|
|
|
|
bool msgunpack_flt(float *flt);
|
|
|
|
bool msgunpack_dbl(double *dbl);
|
|
|
|
bool msgunpack_ext(uint8_t *key, void **val, uint64_t *len);
|
|
|
|
bool msgunpack_arr(uint64_t *len);
|
|
|
|
bool msgunpack_map(uint64_t *len);
|
|
|
|
bool msgunpack_eof();
|
|
|
|
bool msgunpack_err();
|
|
|
|
int savef(FILE *file, const char *format, ...);
|
|
|
|
int saveb(unsigned char *buf, const char *format, ...);
|
|
|
|
int loadf(FILE *file, const char *format, ...);
|
|
|
|
int loadb(const unsigned char *buf, const char *format, ...);
|
2023-09-27 06:49:59 +00:00
|
|
|
int profiler_enable(bool on);
|
2023-07-30 19:18:50 +00:00
|
|
|
struct profile_t { double stat; int32_t cost, avg; };
|
2024-01-02 19:52:20 +00:00
|
|
|
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;
|
2023-07-30 19:18:50 +00:00
|
|
|
extern profiler_t profiler;
|
|
|
|
extern int profiler_enabled;
|
2023-10-15 11:22:55 +00:00
|
|
|
typedef struct reflect_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned id, objtype;
|
|
|
|
union {
|
|
|
|
unsigned sz;
|
|
|
|
unsigned member_offset;
|
|
|
|
unsigned enum_value;
|
|
|
|
};
|
|
|
|
const char *name;
|
|
|
|
const char *info;
|
|
|
|
void *addr;
|
|
|
|
unsigned parent;
|
|
|
|
const char *type;
|
|
|
|
unsigned bytes;
|
2023-10-15 11:22:55 +00:00
|
|
|
} reflect_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned enum_find(const char *E);
|
|
|
|
void * function_find(const char *F);
|
|
|
|
reflect_t member_find(const char *T, const char *M);
|
|
|
|
void * member_findptr(void *obj, const char *T, const char *M);
|
|
|
|
reflect_t** members_find(const char *T);
|
|
|
|
void type_inscribe(const char *TY,unsigned TYsz,const char *infos);
|
|
|
|
void enum_inscribe(const char *E,unsigned Eval,const char *infos);
|
|
|
|
void struct_inscribe(const char *T,unsigned Tsz,unsigned OBJTYPEid, const char *infos);
|
|
|
|
void member_inscribe(const char *T, const char *M,unsigned Msz, const char *infos, const char *type, unsigned bytes);
|
|
|
|
void function_inscribe(const char *F,void *func,const char *infos);
|
|
|
|
const char* symbol_naked(const char *s);
|
|
|
|
int ui_reflect(const char *mask);
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef unsigned handle;
|
|
|
|
unsigned rgba( uint8_t r, uint8_t g, uint8_t b, uint8_t a );
|
|
|
|
unsigned bgra( uint8_t b, uint8_t g, uint8_t r, uint8_t a );
|
|
|
|
unsigned rgbaf( float r, float g, float b, float a );
|
|
|
|
unsigned bgraf( float b, float g, float r, float a );
|
2023-10-21 09:18:13 +00:00
|
|
|
unsigned alpha( unsigned rgba );
|
2023-11-19 13:16:48 +00:00
|
|
|
unsigned atorgba(const char *s);
|
2024-01-02 19:52:20 +00:00
|
|
|
char * rgbatoa(unsigned rgba);
|
2023-07-30 19:18:50 +00:00
|
|
|
enum IMAGE_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
IMAGE_R = 0x01000,
|
|
|
|
IMAGE_RG = 0x02000,
|
|
|
|
IMAGE_RGB = 0x04000,
|
|
|
|
IMAGE_RGBA = 0x08000,
|
|
|
|
IMAGE_FLIP = 0x10000,
|
|
|
|
IMAGE_FLOAT = 0x20000,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
typedef struct image_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
union { unsigned x, w; };
|
|
|
|
union { unsigned y, h; };
|
|
|
|
union { unsigned n, comps; };
|
|
|
|
union { void *pixels; uint8_t *pixels8; uint16_t *pixels16; uint32_t *pixels32; float *pixelsf; };
|
2023-07-30 19:18:50 +00:00
|
|
|
} image_t;
|
|
|
|
image_t image(const char *pathfile, int flags);
|
|
|
|
image_t image_from_mem(const void *ptr, int len, int flags);
|
2024-01-02 19:52:20 +00:00
|
|
|
void image_destroy(image_t *img);
|
2023-07-30 19:18:50 +00:00
|
|
|
enum TEXTURE_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
TEXTURE_BC1 = 8,
|
|
|
|
TEXTURE_BC2 = 16,
|
|
|
|
TEXTURE_BC3 = 32,
|
|
|
|
TEXTURE_NEAREST = 0,
|
|
|
|
TEXTURE_LINEAR = 64,
|
|
|
|
TEXTURE_MIPMAPS = 128,
|
|
|
|
TEXTURE_CLAMP = 0,
|
|
|
|
TEXTURE_BORDER = 0x100,
|
|
|
|
TEXTURE_REPEAT = 0x200,
|
|
|
|
TEXTURE_BYTE = 0,
|
|
|
|
TEXTURE_FLOAT = IMAGE_FLOAT,
|
|
|
|
TEXTURE_COLOR = 0,
|
|
|
|
TEXTURE_DEPTH = 0x800,
|
|
|
|
TEXTURE_R = IMAGE_R,
|
|
|
|
TEXTURE_RG = IMAGE_RG,
|
|
|
|
TEXTURE_RGB = IMAGE_RGB,
|
|
|
|
TEXTURE_RGBA = IMAGE_RGBA,
|
|
|
|
TEXTURE_FLIP = IMAGE_FLIP,
|
|
|
|
TEXTURE_SRGB = 1 << 24,
|
|
|
|
TEXTURE_BGR = 1 << 25,
|
|
|
|
TEXTURE_BGRA = TEXTURE_BGR,
|
|
|
|
TEXTURE_ARRAY = 1 << 26,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
typedef struct texture_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
union { unsigned x, w; };
|
|
|
|
union { unsigned y, h; };
|
|
|
|
union { unsigned z, d; };
|
|
|
|
union { unsigned n, bpp; };
|
|
|
|
handle id, unit;
|
|
|
|
unsigned texel_type;
|
|
|
|
unsigned flags;
|
|
|
|
char* filename;
|
|
|
|
bool transparent;
|
|
|
|
unsigned fbo;
|
|
|
|
union { unsigned userdata, delay; };
|
2023-07-30 19:18:50 +00:00
|
|
|
} texture_t;
|
|
|
|
texture_t texture_compressed(const char *filename, unsigned flags);
|
|
|
|
texture_t texture_compressed_from_mem(const void *data, int len, unsigned flags);
|
|
|
|
texture_t texture(const char* filename, int flags);
|
|
|
|
texture_t texture_from_mem(const void* ptr, int len, int flags);
|
|
|
|
texture_t texture_create(unsigned w, unsigned h, unsigned n, const void *pixels, int flags);
|
|
|
|
texture_t texture_checker();
|
2024-01-02 19:52:20 +00:00
|
|
|
void texture_destroy(texture_t *t);
|
|
|
|
unsigned texture_update(texture_t *t, unsigned w, unsigned h, unsigned n, const void *pixels, int flags);
|
|
|
|
bool texture_rec_begin(texture_t *t, unsigned w, unsigned h);
|
|
|
|
void texture_rec_end(texture_t *t);
|
2023-07-30 19:18:50 +00:00
|
|
|
texture_t brdf_lut();
|
|
|
|
typedef struct colormap_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
vec4 color;
|
|
|
|
texture_t *texture;
|
2023-07-30 19:18:50 +00:00
|
|
|
} colormap_t;
|
|
|
|
bool colormap( colormap_t *cm, const char *pbr_material_type, bool load_as_srgb );
|
|
|
|
typedef struct pbr_material_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
char* name;
|
|
|
|
colormap_t diffuse;
|
|
|
|
colormap_t normals;
|
|
|
|
colormap_t specular;
|
|
|
|
colormap_t albedo;
|
|
|
|
colormap_t roughness;
|
|
|
|
colormap_t metallic;
|
|
|
|
colormap_t ao;
|
|
|
|
colormap_t ambient;
|
|
|
|
colormap_t emissive;
|
|
|
|
float specular_shininess;
|
2023-07-30 19:18:50 +00:00
|
|
|
} pbr_material_t;
|
|
|
|
bool pbr_material(pbr_material_t *pbr, const char *material);
|
|
|
|
void pbr_material_destroy(pbr_material_t *m);
|
2023-09-17 20:56:51 +00:00
|
|
|
void fullscreen_quad_rgb( texture_t texture_rgb, float gamma );
|
|
|
|
void fullscreen_quad_rgb_flipped( texture_t texture, float gamma );
|
|
|
|
void fullscreen_quad_ycbcr( texture_t texture_YCbCr[3], float gamma );
|
|
|
|
void fullscreen_quad_ycbcr_flipped( texture_t texture_YCbCr[3], float gamma );
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef struct cubemap_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned id;
|
|
|
|
vec3 sh[9];
|
2023-07-30 19:18:50 +00:00
|
|
|
} cubemap_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
cubemap_t cubemap( const image_t image, int flags );
|
|
|
|
cubemap_t cubemap6( const image_t images[6], int flags );
|
|
|
|
void cubemap_destroy(cubemap_t *c);
|
2023-07-30 19:18:50 +00:00
|
|
|
cubemap_t* cubemap_get_active();
|
|
|
|
unsigned fbo( unsigned texture_color, unsigned texture_depth, int wr_flags );
|
2024-01-02 19:52:20 +00:00
|
|
|
void fbo_bind(unsigned id);
|
|
|
|
void fbo_unbind();
|
|
|
|
void fbo_destroy(unsigned id);
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef struct shadowmap_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
mat44 shadowmatrix;
|
|
|
|
mat44 mvp;
|
|
|
|
mat44 mv;
|
|
|
|
mat44 proj;
|
|
|
|
vec4 light_position;
|
|
|
|
int saved_fb;
|
|
|
|
int saved_viewport[4];
|
|
|
|
handle fbo, texture;
|
|
|
|
int texture_width;
|
2023-07-30 19:18:50 +00:00
|
|
|
} shadowmap_t;
|
|
|
|
shadowmap_t shadowmap(int texture_width);
|
|
|
|
void shadowmap_destroy(shadowmap_t *s);
|
|
|
|
void shadowmap_set_shadowmatrix(shadowmap_t *s, vec3 aLightPos, vec3 aLightAt, vec3 aLightUp, const mat44 projection);
|
|
|
|
void shadowmap_begin(shadowmap_t *s);
|
|
|
|
void shadowmap_end(shadowmap_t *s);
|
|
|
|
void shadowmatrix_proj(mat44 shm_proj, float aLightFov, float znear, float zfar);
|
|
|
|
void shadowmatrix_ortho(mat44 shm_proj, float left, float right, float bottom, float top, float znear, float zfar);
|
2023-09-19 04:50:53 +00:00
|
|
|
unsigned shader(const char *vs, const char *fs, const char *attribs, const char *fragcolor, const char *defines);
|
|
|
|
unsigned shader_geom(const char *gs, const char *vs, const char *fs, const char *attribs, const char *fragcolor, const char *defines);
|
2023-07-30 19:18:50 +00:00
|
|
|
unsigned shader_bind(unsigned program);
|
2024-01-02 19:52:20 +00:00
|
|
|
void shader_bool(const char *uniform, bool i );
|
|
|
|
void shader_int(const char *uniform, int i);
|
|
|
|
void shader_uint(const char *uniform, unsigned i );
|
|
|
|
void shader_float(const char *uniform, float f);
|
|
|
|
void shader_vec2(const char *uniform, vec2 v);
|
|
|
|
void shader_vec3(const char *uniform, vec3 v);
|
|
|
|
void shader_vec3v(const char *uniform, int count, vec3 *v);
|
|
|
|
void shader_vec4(const char *uniform, vec4 v);
|
|
|
|
void shader_mat44(const char *uniform, mat44 m);
|
|
|
|
void shader_texture(const char *sampler, texture_t texture);
|
|
|
|
void shader_texture_unit(const char *sampler, unsigned texture, unsigned unit);
|
|
|
|
void shader_colormap(const char *name, colormap_t cm);
|
2023-07-30 19:18:50 +00:00
|
|
|
unsigned shader_get_active();
|
2024-01-02 19:52:20 +00:00
|
|
|
void shader_destroy(unsigned shader);
|
|
|
|
unsigned shader_properties(unsigned shader);
|
|
|
|
char** shader_property(unsigned shader, unsigned property_no);
|
|
|
|
void shader_apply_param(unsigned shader, unsigned param_no);
|
|
|
|
void shader_apply_params(unsigned shader, const char *parameter_mask);
|
|
|
|
int ui_shader(unsigned shader);
|
|
|
|
int ui_shaders();
|
2023-09-11 10:23:33 +00:00
|
|
|
enum BUFFER_MODE {
|
2024-01-02 19:52:20 +00:00
|
|
|
BUFFER_READ,
|
|
|
|
BUFFER_WRITE,
|
|
|
|
BUFFER_READ_WRITE
|
2023-09-08 06:16:32 +00:00
|
|
|
};
|
|
|
|
unsigned compute(const char *cs);
|
2023-09-08 20:14:11 +00:00
|
|
|
void compute_dispatch(unsigned wx, unsigned wy, unsigned wz);
|
|
|
|
void shader_image(texture_t t, unsigned unit, unsigned level, int layer, unsigned access);
|
|
|
|
void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access);
|
2023-09-08 06:31:58 +00:00
|
|
|
void write_barrier();
|
2023-09-27 06:49:59 +00:00
|
|
|
void write_barrier_image();
|
2023-09-11 10:23:33 +00:00
|
|
|
enum SSBO_USAGE {
|
2024-01-02 19:52:20 +00:00
|
|
|
STATIC_DRAW,
|
|
|
|
STATIC_READ,
|
|
|
|
STATIC_COPY,
|
|
|
|
DYNAMIC_DRAW,
|
|
|
|
DYNAMIC_READ,
|
|
|
|
DYNAMIC_COPY,
|
|
|
|
STREAM_DRAW,
|
|
|
|
STREAM_READ,
|
|
|
|
STREAM_COPY
|
2023-09-10 16:16:25 +00:00
|
|
|
};
|
|
|
|
enum SSBO_ACCESS {
|
2024-01-02 19:52:20 +00:00
|
|
|
SSBO_READ = BUFFER_READ,
|
|
|
|
SSBO_WRITE = BUFFER_WRITE,
|
|
|
|
SSBO_READ_WRITE = BUFFER_READ_WRITE
|
2023-09-08 08:00:26 +00:00
|
|
|
};
|
|
|
|
unsigned ssbo_create(const void *data, int len, unsigned usage);
|
|
|
|
void ssbo_destroy(unsigned ssbo);
|
|
|
|
void ssbo_update(int offset, int len, const void *data);
|
|
|
|
void ssbo_bind(unsigned ssbo, unsigned unit);
|
|
|
|
void *ssbo_map(unsigned access);
|
|
|
|
void ssbo_unmap();
|
|
|
|
void ssbo_unbind();
|
2023-07-30 19:18:50 +00:00
|
|
|
enum MESH_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
MESH_STATIC = 0,
|
|
|
|
MESH_STREAM = 1,
|
|
|
|
MESH_TRIANGLE_STRIP = 2,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
typedef struct mesh_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
handle vao, vbo, ibo;
|
|
|
|
unsigned vertex_count;
|
|
|
|
unsigned index_count;
|
|
|
|
unsigned flags;
|
|
|
|
int* lod_collapse_map;
|
|
|
|
union {
|
|
|
|
unsigned* in_index;
|
|
|
|
vec3i* in_index3;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
unsigned* out_index;
|
|
|
|
vec3i* out_index3;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
float* in_vertex;
|
|
|
|
vec3* in_vertex3;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
float* out_vertex;
|
|
|
|
vec3* out_vertex3;
|
|
|
|
};
|
2023-07-30 19:18:50 +00:00
|
|
|
} mesh_t;
|
|
|
|
mesh_t mesh();
|
2024-01-02 19:52:20 +00:00
|
|
|
void mesh_update(mesh_t *m, const char *format, int vertex_stride,int vertex_count,const void *interleaved_vertex_data, int index_count,const void *index_data, int flags);
|
|
|
|
void mesh_render(mesh_t *m);
|
|
|
|
void mesh_render_prim(mesh_t *sm, unsigned prim);
|
|
|
|
void mesh_destroy(mesh_t *m);
|
|
|
|
aabb mesh_bounds(mesh_t *m);
|
2023-07-30 19:18:50 +00:00
|
|
|
enum MATERIAL_ENUMS {
|
2024-01-02 19:52:20 +00:00
|
|
|
MAX_CHANNELS_PER_MATERIAL = 8
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
typedef struct material_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
char *name;
|
|
|
|
int count;
|
|
|
|
struct material_layer_t {
|
|
|
|
char texname[32];
|
|
|
|
handle texture;
|
|
|
|
float value;
|
|
|
|
vec4 color;
|
|
|
|
} layer[MAX_CHANNELS_PER_MATERIAL];
|
2023-07-30 19:18:50 +00:00
|
|
|
} material_t;
|
2023-09-17 20:56:51 +00:00
|
|
|
enum {
|
2024-01-02 19:52:20 +00:00
|
|
|
SHADERTOY_FLIP_Y = 2,
|
|
|
|
SHADERTOY_IGNORE_FBO = 4,
|
|
|
|
SHADERTOY_IGNORE_MOUSE = 8,
|
2023-09-17 20:56:51 +00:00
|
|
|
};
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef struct shadertoy_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
handle vao, program;
|
|
|
|
int uniforms[32];
|
|
|
|
int texture_channels[4];
|
|
|
|
int frame;
|
|
|
|
uint64_t t;
|
|
|
|
texture_t tx;
|
|
|
|
vec2i dims;
|
|
|
|
int flags;
|
|
|
|
vec4 mouse;
|
2023-07-30 19:18:50 +00:00
|
|
|
} shadertoy_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
shadertoy_t shadertoy( const char *shaderfile, unsigned flags );
|
2023-07-30 19:18:50 +00:00
|
|
|
shadertoy_t* shadertoy_render( shadertoy_t *s, float delta );
|
|
|
|
enum ANIM_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
ANIM_LOOP = 1,
|
|
|
|
ANIM_DONT_RESET_AFTER_USE = 2,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
typedef struct anim_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
int from;
|
|
|
|
int to;
|
|
|
|
float blendtime;
|
|
|
|
unsigned flags;
|
|
|
|
float curframe;
|
|
|
|
unsigned easing;
|
|
|
|
float alpha;
|
|
|
|
float timer;
|
|
|
|
bool active;
|
|
|
|
vec3 pose;
|
|
|
|
char* name;
|
2023-07-30 19:18:50 +00:00
|
|
|
} anim_t;
|
|
|
|
anim_t clip(float minframe, float maxframe, float blendtime, unsigned flags);
|
|
|
|
anim_t loop(float minframe, float maxframe, float blendtime, unsigned flags);
|
2024-02-08 10:24:55 +00:00
|
|
|
anim_t* animlist(const char *filename);
|
2023-07-30 19:18:50 +00:00
|
|
|
enum MODEL_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
MODEL_NO_ANIMATIONS = 1,
|
|
|
|
MODEL_NO_MESHES = 2,
|
|
|
|
MODEL_NO_TEXTURES = 4,
|
|
|
|
MODEL_MATCAPS = 8,
|
|
|
|
MODEL_RIMLIGHT = 16
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
typedef struct model_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
struct iqm_t *iqm;
|
|
|
|
unsigned num_textures;
|
|
|
|
handle *textures;
|
|
|
|
char **texture_names;
|
|
|
|
material_t* materials;
|
|
|
|
texture_t lightmap;
|
|
|
|
float *lmdata;
|
|
|
|
unsigned num_meshes;
|
|
|
|
unsigned num_triangles;
|
|
|
|
unsigned num_joints;
|
|
|
|
unsigned num_anims;
|
|
|
|
unsigned num_frames;
|
|
|
|
handle program;
|
|
|
|
float curframe;
|
|
|
|
mat44 pivot;
|
|
|
|
int stride;
|
|
|
|
void *verts;
|
|
|
|
int num_verts;
|
|
|
|
void *tris;
|
|
|
|
int num_tris;
|
|
|
|
handle vao, ibo, vbo, vao_instanced;
|
|
|
|
unsigned flags;
|
|
|
|
unsigned billboard;
|
|
|
|
float *instanced_matrices;
|
|
|
|
unsigned num_instances;
|
2023-07-30 19:18:50 +00:00
|
|
|
} model_t;
|
2023-11-06 12:51:17 +00:00
|
|
|
enum BILLBOARD_MODE {
|
2024-01-02 19:52:20 +00:00
|
|
|
BILLBOARD_X = 0x1,
|
|
|
|
BILLBOARD_Y = 0x2,
|
|
|
|
BILLBOARD_Z = 0x4,
|
|
|
|
BILLBOARD_CYLINDRICAL = BILLBOARD_X|BILLBOARD_Z,
|
|
|
|
BILLBOARD_SPHERICAL = BILLBOARD_X|BILLBOARD_Y|BILLBOARD_Z
|
2023-11-06 12:51:17 +00:00
|
|
|
};
|
2024-01-02 19:52:20 +00:00
|
|
|
model_t model(const char *filename, int flags);
|
|
|
|
model_t model_from_mem(const void *mem, int sz, int flags);
|
|
|
|
float model_animate(model_t, float curframe);
|
|
|
|
float model_animate_clip(model_t, float curframe, int minframe, int maxframe, bool loop);
|
|
|
|
float model_animate_blends(model_t m, anim_t *primary, anim_t *secondary, float delta);
|
|
|
|
aabb model_aabb(model_t, mat44 transform);
|
|
|
|
void model_render(model_t, mat44 proj, mat44 view, mat44 model, int shader);
|
|
|
|
void model_render_skeleton(model_t, mat44 model);
|
|
|
|
void model_render_instanced(model_t, mat44 proj, mat44 view, mat44 *models, int shader, unsigned count);
|
|
|
|
void model_set_texture(model_t, texture_t t);
|
|
|
|
bool model_get_bone_pose(model_t m, unsigned joint, mat34 *out);
|
|
|
|
void model_destroy(model_t);
|
|
|
|
vec3 pose(bool forward, float curframe, int minframe, int maxframe, bool loop, float *opt_retframe);
|
2023-08-14 16:30:52 +00:00
|
|
|
typedef struct anims_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
int inuse;
|
|
|
|
float speed;
|
|
|
|
anim_t* anims;
|
2023-08-14 16:30:52 +00:00
|
|
|
} anims_t;
|
|
|
|
anims_t animations(const char *pathfile, int flags);
|
2023-11-30 13:33:49 +00:00
|
|
|
typedef struct lightmap_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
struct lm_context *ctx;
|
|
|
|
bool ready;
|
|
|
|
int w, h;
|
|
|
|
int atlas_w, atlas_h;
|
|
|
|
texture_t atlas;
|
|
|
|
model_t** models;
|
|
|
|
unsigned shader;
|
2023-11-30 13:33:49 +00:00
|
|
|
} lightmap_t;
|
2023-12-01 11:01:03 +00:00
|
|
|
lightmap_t lightmap(int hmsize , float near, float far, vec3 color , int passes , float threshold , float distmod );
|
2024-01-02 19:52:20 +00:00
|
|
|
void lightmap_setup(lightmap_t *lm, int w, int h);
|
|
|
|
void lightmap_bake(lightmap_t *lm, int bounces, void (*drawscene)(lightmap_t *lm, model_t *m, float *view, float *proj, void *userdata), void (*progressupdate)(float progress), void *userdata);
|
|
|
|
void lightmap_destroy(lightmap_t *lm);
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef struct skybox_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
handle program;
|
|
|
|
mesh_t geometry;
|
|
|
|
cubemap_t cubemap;
|
|
|
|
int flags;
|
|
|
|
int framebuffers[6];
|
|
|
|
int textures[6];
|
|
|
|
float *pixels;
|
2023-07-30 19:18:50 +00:00
|
|
|
} skybox_t;
|
|
|
|
skybox_t skybox(const char *panorama_or_cubemap_folder, int flags);
|
2024-01-02 19:52:20 +00:00
|
|
|
int skybox_render(skybox_t *sky, mat44 proj, mat44 view);
|
|
|
|
void skybox_destroy(skybox_t *sky);
|
|
|
|
void skybox_mie_calc_sh(skybox_t *sky, float sky_intensity);
|
|
|
|
void skybox_sh_reset(skybox_t *sky);
|
|
|
|
void skybox_sh_add_light(skybox_t *sky, vec3 light, vec3 dir, float strength);
|
|
|
|
int skybox_push_state(skybox_t *sky, mat44 proj, mat44 view);
|
|
|
|
int skybox_pop_state();
|
|
|
|
void viewport_clear(bool color, bool depth);
|
|
|
|
void viewport_clip(vec2 from, vec2 to);
|
|
|
|
int fx_load(const char *file);
|
|
|
|
int fx_load_from_mem(const char *nameid, const char *content);
|
|
|
|
void fx_begin();
|
|
|
|
void fx_begin_res(int w, int h);
|
|
|
|
void fx_end();
|
|
|
|
void fx_enable(int pass, int enabled);
|
|
|
|
int fx_enabled(int pass);
|
|
|
|
void fx_enable_all(int enabled);
|
|
|
|
char * fx_name(int pass);
|
|
|
|
int fx_find(const char *name);
|
|
|
|
int ui_fx(int pass);
|
|
|
|
int ui_fxs();
|
|
|
|
void* screenshot(int components);
|
|
|
|
void* screenshot_async(int components);
|
2023-07-30 19:18:50 +00:00
|
|
|
void ddraw_color(unsigned rgb);
|
|
|
|
void ddraw_color_push(unsigned rgb);
|
|
|
|
void ddraw_color_pop();
|
|
|
|
void ddraw_ontop(int enabled);
|
|
|
|
void ddraw_ontop_push(int enabled);
|
|
|
|
void ddraw_ontop_pop();
|
|
|
|
void ddraw_push_2d();
|
|
|
|
void ddraw_pop_2d();
|
|
|
|
void ddraw_aabb(vec3 minbb, vec3 maxbb);
|
|
|
|
void ddraw_aabb_corners(vec3 minbb, vec3 maxbb);
|
|
|
|
void ddraw_arrow(vec3 begin, vec3 end);
|
|
|
|
void ddraw_axis(float units);
|
|
|
|
void ddraw_boid(vec3 pos, vec3 dir);
|
|
|
|
void ddraw_bone(vec3 center, vec3 end);
|
|
|
|
void ddraw_bounds(const vec3 points[8]);
|
|
|
|
void ddraw_box(vec3 center, vec3 extents);
|
|
|
|
void ddraw_capsule(vec3 from, vec3 to, float radius);
|
|
|
|
void ddraw_circle(vec3 pos, vec3 n, float radius);
|
|
|
|
void ddraw_ring(vec3 pos, vec3 n, float radius);
|
|
|
|
void ddraw_cone(vec3 center, vec3 top, float radius);
|
|
|
|
void ddraw_cube(vec3 center, float radius);
|
|
|
|
void ddraw_cube33(vec3 center, vec3 radius, mat33 M);
|
|
|
|
void ddraw_diamond(vec3 from, vec3 to, float size);
|
|
|
|
void ddraw_frustum(float projview[16]);
|
|
|
|
void ddraw_ground(float scale);
|
|
|
|
void ddraw_grid(float scale);
|
|
|
|
void ddraw_hexagon(vec3 pos, float radius);
|
|
|
|
void ddraw_line(vec3 from, vec3 to);
|
|
|
|
void ddraw_line_dashed(vec3 from, vec3 to);
|
|
|
|
void ddraw_line_thin(vec3 from, vec3 to);
|
|
|
|
void ddraw_normal(vec3 pos, vec3 n);
|
|
|
|
void ddraw_pentagon(vec3 pos, float radius);
|
|
|
|
void ddraw_plane(vec3 p, vec3 n, float scale);
|
|
|
|
void ddraw_point(vec3 from);
|
|
|
|
void ddraw_position(vec3 pos, float radius);
|
|
|
|
void ddraw_position_dir(vec3 pos, vec3 dir, float radius);
|
|
|
|
void ddraw_pyramid(vec3 center, float height, int segments);
|
|
|
|
void ddraw_cylinder(vec3 center, float height, int segments);
|
|
|
|
void ddraw_sphere(vec3 pos, float radius);
|
|
|
|
void ddraw_square(vec3 pos, float radius);
|
|
|
|
void ddraw_text(vec3 pos, float scale, const char *text);
|
|
|
|
void ddraw_text2d(vec2 pos, const char *text);
|
|
|
|
void ddraw_triangle(vec3 p1, vec3 p2, vec3 p3);
|
|
|
|
void ddraw_prism(vec3 center, float radius, float height, vec3 normal, int segments);
|
|
|
|
void ddraw_demo();
|
|
|
|
void ddraw_flush();
|
|
|
|
void ddraw_flush_projview(mat44 proj, mat44 view);
|
2024-01-02 19:52:20 +00:00
|
|
|
int gizmo(vec3 *pos, vec3 *rot, vec3 *sca);
|
2023-11-26 15:27:33 +00:00
|
|
|
bool gizmo_active();
|
|
|
|
bool gizmo_hover();
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef struct camera_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
mat44 view, proj;
|
|
|
|
vec3 position, updir, lookdir;
|
|
|
|
float yaw, pitch;
|
|
|
|
float speed, fov;
|
|
|
|
float move_friction, move_damping;
|
|
|
|
float look_friction, look_damping;
|
|
|
|
vec2 last_look; vec3 last_move;
|
|
|
|
bool damping;
|
|
|
|
bool orthographic;
|
|
|
|
float distance;
|
2023-07-30 19:18:50 +00:00
|
|
|
} camera_t;
|
|
|
|
camera_t camera();
|
|
|
|
void camera_teleport(camera_t *cam, vec3 pos);
|
2023-10-01 06:49:08 +00:00
|
|
|
void camera_moveby(camera_t *cam, vec3 inc);
|
2023-07-30 19:18:50 +00:00
|
|
|
void camera_fov(camera_t *cam, float fov);
|
|
|
|
void camera_fps(camera_t *cam, float yaw, float pitch);
|
|
|
|
void camera_orbit(camera_t *cam, float yaw, float pitch, float inc_distance);
|
|
|
|
void camera_lookat(camera_t *cam, vec3 target);
|
|
|
|
void camera_enable(camera_t *cam);
|
|
|
|
camera_t *camera_get_active();
|
2024-01-02 19:52:20 +00:00
|
|
|
int ui_camera(camera_t *cam);
|
2023-10-01 06:49:08 +00:00
|
|
|
void ddraw_camera(camera_t *cam);
|
2023-07-30 19:18:50 +00:00
|
|
|
typedef struct object_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
uint64_t renderbucket;
|
|
|
|
mat44 transform;
|
|
|
|
quat rot;
|
|
|
|
vec3 sca, pos, euler, pivot;
|
|
|
|
handle* textures;
|
|
|
|
model_t model;
|
2024-02-08 10:24:55 +00:00
|
|
|
anim_t anim;
|
|
|
|
float anim_speed;
|
2024-01-02 19:52:20 +00:00
|
|
|
aabb bounds;
|
|
|
|
unsigned billboard;
|
|
|
|
bool light_cached;
|
2023-07-30 19:18:50 +00:00
|
|
|
} object_t;
|
|
|
|
object_t object();
|
|
|
|
void object_rotate(object_t *obj, vec3 euler);
|
|
|
|
void object_pivot(object_t *obj, vec3 euler);
|
|
|
|
void object_teleport(object_t *obj, vec3 pos);
|
|
|
|
void object_move(object_t *obj, vec3 inc);
|
|
|
|
vec3 object_position(object_t *obj);
|
|
|
|
void object_scale(object_t *obj, vec3 sca);
|
|
|
|
void object_model(object_t *obj, model_t model);
|
2024-02-08 10:24:55 +00:00
|
|
|
void object_anim(object_t *obj, anim_t anim, float speed);
|
2023-07-30 19:18:50 +00:00
|
|
|
void object_diffuse(object_t *obj, texture_t tex);
|
|
|
|
void object_diffuse_push(object_t *obj, texture_t tex);
|
|
|
|
void object_diffuse_pop(object_t *obj);
|
|
|
|
void object_billboard(object_t *obj, unsigned mode);
|
2023-09-23 15:22:48 +00:00
|
|
|
enum LIGHT_TYPE {
|
2024-01-02 19:52:20 +00:00
|
|
|
LIGHT_DIRECTIONAL,
|
|
|
|
LIGHT_POINT,
|
|
|
|
LIGHT_SPOT,
|
2023-09-23 15:22:48 +00:00
|
|
|
};
|
|
|
|
enum LIGHT_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
LIGHT_CAST_SHADOWS = 1,
|
2023-09-23 15:22:48 +00:00
|
|
|
};
|
|
|
|
typedef struct light_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
char type;
|
|
|
|
vec3 diffuse, specular, ambient;
|
|
|
|
vec3 pos, dir;
|
|
|
|
struct {
|
|
|
|
float constant, linear, quadratic;
|
|
|
|
} falloff;
|
|
|
|
float specularPower;
|
|
|
|
float innerCone, outerCone;
|
|
|
|
bool cached;
|
2023-09-23 15:22:48 +00:00
|
|
|
} light_t;
|
|
|
|
light_t light();
|
2024-01-02 19:52:20 +00:00
|
|
|
void light_type(light_t* l, char type);
|
|
|
|
void light_diffuse(light_t* l, vec3 color);
|
|
|
|
void light_specular(light_t* l, vec3 color);
|
|
|
|
void light_ambient(light_t* l, vec3 color);
|
|
|
|
void light_teleport(light_t* l, vec3 pos);
|
|
|
|
void light_dir(light_t* l, vec3 dir);
|
|
|
|
void light_power(light_t* l, float power);
|
|
|
|
void light_falloff(light_t* l, float constant, float linear, float quadratic);
|
|
|
|
void light_cone(light_t* l, float innerCone, float outerCone);
|
|
|
|
void light_update(unsigned num_lights, light_t *lv);
|
2023-07-30 19:18:50 +00:00
|
|
|
enum SCENE_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
SCENE_WIREFRAME = 1,
|
|
|
|
SCENE_CULLFACE = 2,
|
|
|
|
SCENE_BACKGROUND = 4,
|
|
|
|
SCENE_FOREGROUND = 8,
|
|
|
|
SCENE_UPDATE_SH_COEF = 16,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
typedef struct scene_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
object_t* objs;
|
|
|
|
light_t* lights;
|
|
|
|
skybox_t skybox;
|
|
|
|
int u_coefficients_sh;
|
2023-07-30 19:18:50 +00:00
|
|
|
} scene_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
scene_t* scene_push();
|
|
|
|
void scene_pop();
|
|
|
|
scene_t* scene_get_active();
|
|
|
|
int scene_merge(const char *source);
|
|
|
|
void scene_render(int flags);
|
2023-07-30 19:18:50 +00:00
|
|
|
object_t* scene_spawn();
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned scene_count();
|
2023-07-30 19:18:50 +00:00
|
|
|
object_t* scene_index(unsigned index);
|
2024-01-02 19:52:20 +00:00
|
|
|
light_t* scene_spawn_light();
|
|
|
|
unsigned scene_count_light();
|
|
|
|
light_t* scene_index_light(unsigned index);
|
|
|
|
char* tempvl(const char *fmt, va_list);
|
|
|
|
char* tempva(const char *fmt, ...);
|
|
|
|
char* strcatf(char **s, const char *buf);
|
|
|
|
int strmatch(const char *s, const char *wildcard);
|
|
|
|
int strmatchi(const char *s, const char *wildcard);
|
|
|
|
int strcmp_qsort(const void *a, const void *b);
|
|
|
|
int strcmpi_qsort(const void *a, const void *b);
|
|
|
|
bool strbeg(const char *src, const char *sub);
|
|
|
|
bool strend(const char *src, const char *sub);
|
|
|
|
bool strbegi(const char *src, const char *sub);
|
|
|
|
bool strendi(const char *src, const char *sub);
|
2023-11-26 15:00:28 +00:00
|
|
|
const char * strstri(const char *src, const char *sub);
|
2024-01-02 19:52:20 +00:00
|
|
|
char * strupper(const char *str);
|
|
|
|
char * strlower(const char *str);
|
|
|
|
char * strrepl(char **copy, const char *target, const char *replace);
|
|
|
|
char * strswap(char *copy, const char *target, const char *replace);
|
|
|
|
char * strcut(char *copy, const char *target);
|
2023-11-26 15:00:28 +00:00
|
|
|
const char * strlerp(unsigned numpairs, const char **pairs, const char *str);
|
2024-01-02 19:52:20 +00:00
|
|
|
size_t strlcat(char *dst, const char *src, size_t dstcap);
|
|
|
|
size_t strlcpy(char *dst, const char *src, size_t dstcap);
|
|
|
|
char** strsplit(const char *string, const char *delimiters);
|
|
|
|
char* strjoin(char** list, const char *separator);
|
|
|
|
char* string8(const wchar_t *str);
|
2023-11-26 15:00:28 +00:00
|
|
|
uint32_t* string32( const char *utf8 );
|
2024-01-02 19:52:20 +00:00
|
|
|
const char* codepoint_to_utf8(unsigned cp);
|
|
|
|
unsigned intern( const char *string );
|
2023-11-26 15:00:28 +00:00
|
|
|
const char *quark( unsigned key );
|
|
|
|
typedef struct quarks_db {
|
2024-01-02 19:52:20 +00:00
|
|
|
char* blob;
|
|
|
|
vec2i* entries;
|
2023-11-26 15:00:28 +00:00
|
|
|
} quarks_db;
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned quark_intern( quarks_db*, const char *string );
|
2023-11-26 15:00:28 +00:00
|
|
|
const char *quark_string( quarks_db*, unsigned key );
|
2024-01-02 19:52:20 +00:00
|
|
|
bool kit_load( const char *filename );
|
|
|
|
bool kit_merge( const char *filename );
|
|
|
|
void kit_insert( const char *id, const char *translation );
|
|
|
|
void kit_clear();
|
|
|
|
void kit_set( const char *variable, const char *value );
|
|
|
|
void kit_reset();
|
|
|
|
void kit_dump_state( FILE *fp );
|
2023-11-26 15:00:28 +00:00
|
|
|
char* kit_translate2( const char *id, const char *langcode_iso639_1 );
|
2024-01-02 19:52:20 +00:00
|
|
|
void kit_locale( const char *langcode_iso639_1 );
|
2023-11-26 15:00:28 +00:00
|
|
|
char* kit_translate( const char *id );
|
2023-11-19 13:16:48 +00:00
|
|
|
typedef enum SPRITE_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
SPRITE_PROJECTED = 1,
|
|
|
|
SPRITE_ADDITIVE = 2,
|
|
|
|
SPRITE_CENTERED = 4,
|
|
|
|
SPRITE_RESOLUTION_INDEPENDANT = 128,
|
2023-11-19 13:16:48 +00:00
|
|
|
} SPRITE_FLAGS;
|
|
|
|
void sprite( texture_t texture, float position[3], float rotation , unsigned color , unsigned flags);
|
|
|
|
void sprite_rect( texture_t t, vec4 rect, vec4 pos, vec4 scaleoff, float tilt_deg, unsigned tint_rgba, unsigned flags);
|
|
|
|
void sprite_sheet( texture_t texture, float sheet[3], float position[3], float rotation, float offset[2], float scale[2], unsigned rgba, unsigned flags);
|
|
|
|
void sprite_flush();
|
|
|
|
typedef struct tileset_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
texture_t tex;
|
|
|
|
unsigned tile_w, tile_h;
|
|
|
|
unsigned cols, rows;
|
|
|
|
unsigned selected;
|
2023-11-19 13:16:48 +00:00
|
|
|
} tileset_t;
|
|
|
|
tileset_t tileset(texture_t tex, unsigned tile_w, unsigned tile_h, unsigned cols, unsigned rows);
|
2024-01-02 19:52:20 +00:00
|
|
|
int ui_tileset( tileset_t t );
|
2023-11-19 13:16:48 +00:00
|
|
|
typedef struct tilemap_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
int blank_chr;
|
|
|
|
unsigned cols, rows;
|
|
|
|
int* map;
|
|
|
|
vec3 position;
|
|
|
|
float zindex;
|
|
|
|
float tilt;
|
|
|
|
unsigned tint;
|
|
|
|
bool is_additive;
|
2023-11-19 13:16:48 +00:00
|
|
|
} tilemap_t;
|
|
|
|
tilemap_t tilemap(const char *map, int blank_chr, int linefeed_chr);
|
2024-01-02 19:52:20 +00:00
|
|
|
void tilemap_render( tilemap_t m, tileset_t style );
|
|
|
|
void tilemap_render_ext( tilemap_t m, tileset_t style, float zindex, float xy_zoom[3], float tilt, unsigned tint, bool is_additive );
|
2023-11-19 13:16:48 +00:00
|
|
|
typedef struct tiled_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
char *map_name;
|
|
|
|
unsigned first_gid, tilew, tileh, w, h;
|
|
|
|
bool parallax;
|
|
|
|
vec3 position;
|
|
|
|
bool* visible;
|
|
|
|
tilemap_t* layers;
|
|
|
|
tileset_t* sets;
|
|
|
|
char** names;
|
2023-11-19 13:16:48 +00:00
|
|
|
} tiled_t;
|
|
|
|
tiled_t tiled(const char *file_tmx);
|
2024-01-02 19:52:20 +00:00
|
|
|
void tiled_render(tiled_t tmx, vec3 pos);
|
|
|
|
void ui_tiled(tiled_t *t);
|
2023-11-19 13:16:48 +00:00
|
|
|
typedef struct spine_t spine_t;
|
|
|
|
spine_t*spine(const char *file_json, const char *file_atlas, unsigned flags);
|
2024-01-02 19:52:20 +00:00
|
|
|
void spine_skin(spine_t *p, unsigned skin);
|
|
|
|
void spine_render(spine_t *p, vec3 offset, unsigned flags);
|
|
|
|
void spine_animate(spine_t *p, float delta);
|
|
|
|
void ui_spine(spine_t *p);
|
2023-11-26 15:00:28 +00:00
|
|
|
typedef struct atlas_frame_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned delay;
|
|
|
|
vec4 sheet;
|
|
|
|
vec2 anchor;
|
|
|
|
vec3i* indices;
|
|
|
|
vec2* coords;
|
|
|
|
vec2* uvs;
|
2023-11-26 15:00:28 +00:00
|
|
|
} atlas_frame_t;
|
|
|
|
typedef struct atlas_anim_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned name;
|
|
|
|
unsigned* frames;
|
2023-11-26 15:00:28 +00:00
|
|
|
} atlas_anim_t;
|
|
|
|
typedef struct atlas_slice_frame_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
vec4 bounds;
|
|
|
|
bool has_9slice;
|
|
|
|
vec4 core;
|
|
|
|
vec2 pivot;
|
|
|
|
unsigned color;
|
|
|
|
char *text;
|
2023-11-26 15:00:28 +00:00
|
|
|
} atlas_slice_frame_t;
|
|
|
|
typedef struct atlas_slice_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
unsigned name;
|
|
|
|
unsigned* frames;
|
2023-11-26 15:00:28 +00:00
|
|
|
} atlas_slice_t;
|
|
|
|
typedef struct atlas_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
texture_t tex;
|
|
|
|
atlas_frame_t* frames;
|
|
|
|
atlas_anim_t* anims;
|
|
|
|
atlas_slice_t* slices;
|
|
|
|
atlas_slice_frame_t* slice_frames;
|
|
|
|
quarks_db db;
|
2023-11-26 15:00:28 +00:00
|
|
|
} atlas_t;
|
|
|
|
atlas_t atlas_create(const char *inifile, unsigned flags);
|
2024-01-02 19:52:20 +00:00
|
|
|
int ui_atlas(atlas_t *a);
|
|
|
|
int ui_atlas_frame(atlas_frame_t *f);
|
|
|
|
void atlas_destroy(atlas_t *a);
|
|
|
|
typedef struct sprite_t { struct { const char *objname; uintptr_t objheader; struct obj** objchildren; };
|
|
|
|
vec4 gamepad;
|
|
|
|
vec2 fire;
|
|
|
|
vec4 pos;
|
|
|
|
vec2 sca;
|
|
|
|
float tilt;
|
|
|
|
unsigned tint;
|
|
|
|
unsigned frame;
|
|
|
|
unsigned timer, timer_ms;
|
|
|
|
unsigned flip_, flipped;
|
|
|
|
unsigned play;
|
|
|
|
bool paused;
|
|
|
|
struct atlas_t *a;
|
2023-11-19 13:16:48 +00:00
|
|
|
} sprite_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
enum { OBJTYPE_sprite_t = 10 }; ; ;;
|
|
|
|
void sprite_ctor(sprite_t *s);
|
|
|
|
void sprite_dtor(sprite_t *s);
|
|
|
|
void sprite_tick(sprite_t *s);
|
|
|
|
void sprite_draw(sprite_t *s);
|
|
|
|
void sprite_edit(sprite_t *s);
|
2023-11-19 13:16:48 +00:00
|
|
|
sprite_t*sprite_new(const char *ase, int bindings[6]);
|
2024-01-02 19:52:20 +00:00
|
|
|
void sprite_del(sprite_t *s);
|
|
|
|
void sprite_setanim(sprite_t *s, unsigned name);
|
2023-11-26 15:27:33 +00:00
|
|
|
typedef struct guiskin_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
void (*drawrect)(void* userdata, const char *skin, const char *fallback, vec4 rect);
|
|
|
|
void (*getskinsize)(void* userdata, const char *skin, const char *fallback, vec2 *size);
|
|
|
|
void (*getskincolor)(void* userdata, const char *skin, const char *fallback, unsigned *color);
|
|
|
|
void (*getscissorrect)(void* userdata, const char *skin, const char *fallback, vec4 rect, vec4 *dims);
|
|
|
|
bool (*ismouseinrect)(void* userdata, const char *skin, const char *fallback, vec4 rect);
|
|
|
|
void (*free)(void* userdata);
|
|
|
|
void *userdata;
|
2023-11-26 15:27:33 +00:00
|
|
|
} guiskin_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
void gui_pushskin(guiskin_t skin);
|
|
|
|
void* gui_userdata();
|
|
|
|
vec2 gui_getskinsize(const char *skin, const char *fallback);
|
|
|
|
unsigned gui_getskincolor(const char *skin, const char *fallback);
|
|
|
|
bool gui_ismouseinrect(const char *skin, const char *fallback, vec4 rect);
|
|
|
|
vec4 gui_getscissorrect(const char *skin, const char *fallback, vec4 rect);
|
|
|
|
void gui_panel_id(int id, vec4 rect, const char *skin);
|
|
|
|
void gui_rect_id(int id, vec4 rect, const char *skin);
|
|
|
|
void gui_label_id(int id, const char *skin, const char *text, vec4 rect);
|
|
|
|
bool gui_button_id(int id, vec4 rect, const char *skin);
|
|
|
|
bool gui_button_label_id(int id, const char *text, vec4 rect, const char *skin);
|
|
|
|
bool gui_slider_id(int id, vec4 rect, const char *skin, float min, float max, float step, float *value);
|
|
|
|
bool gui_slider_label_id(int id, const char *text, vec4 rect, const char *skin, float min, float max, float step, float *value);
|
|
|
|
void gui_panel_end();
|
|
|
|
void gui_popskin();
|
2023-11-26 15:27:33 +00:00
|
|
|
typedef struct skinned_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
atlas_t atlas;
|
|
|
|
float scale;
|
2023-11-26 15:27:33 +00:00
|
|
|
} skinned_t;
|
2023-11-28 13:48:54 +00:00
|
|
|
guiskin_t gui_skinned(const char *asefile, float scale);
|
2024-01-01 10:47:45 +00:00
|
|
|
bool steam_init(unsigned app_id);
|
|
|
|
void steam_tick();
|
|
|
|
void steam_trophy(const char *trophy_id, bool redeem);
|
|
|
|
void steam_screenshot();
|
|
|
|
void steam_destroy();
|
2024-01-02 19:52:20 +00:00
|
|
|
int ui_steam();
|
|
|
|
void* thread( int (*thread_func)(void* user_data), void* user_data );
|
|
|
|
void thread_destroy( void *thd );
|
|
|
|
int argc();
|
|
|
|
char* argv(int);
|
|
|
|
void argvadd(const char *arg);
|
|
|
|
int flag(const char *commalist);
|
2023-11-05 15:30:11 +00:00
|
|
|
const char* option(const char *commalist, const char *defaults);
|
2024-01-02 19:52:20 +00:00
|
|
|
int optioni(const char *commalist, int defaults);
|
|
|
|
float optionf(const char *commalist, float defaults);
|
|
|
|
void tty_attach();
|
|
|
|
void tty_detach();
|
|
|
|
void tty_color(unsigned color);
|
|
|
|
void tty_reset();
|
2023-11-05 15:30:11 +00:00
|
|
|
const char* app_exec(const char *command);
|
2024-01-02 19:52:20 +00:00
|
|
|
int app_spawn(const char *command);
|
|
|
|
int app_cores();
|
|
|
|
int app_battery();
|
2023-11-05 15:30:11 +00:00
|
|
|
const char* app_name();
|
|
|
|
const char* app_path();
|
|
|
|
const char* app_cache();
|
|
|
|
const char* app_temp();
|
|
|
|
const char* app_cmdline();
|
2024-01-02 19:52:20 +00:00
|
|
|
void app_beep();
|
|
|
|
void app_hang();
|
|
|
|
void app_crash();
|
|
|
|
void app_singleton(const char *guid);
|
|
|
|
bool app_open(const char *folder_file_or_url);
|
2023-11-05 15:30:11 +00:00
|
|
|
const char* app_loadfile();
|
|
|
|
const char* app_savefile();
|
2024-01-02 19:52:20 +00:00
|
|
|
char* callstack( int traces );
|
|
|
|
int callstackf( FILE *fp, int traces );
|
|
|
|
void die(const char *message);
|
|
|
|
void alert(const char *message);
|
|
|
|
void hexdump( const void *ptr, unsigned len );
|
|
|
|
void hexdumpf( FILE *fp, const void *ptr, unsigned len, int width );
|
|
|
|
void breakpoint();
|
|
|
|
bool has_debugger();
|
|
|
|
void trap_install(void);
|
2023-11-05 15:30:11 +00:00
|
|
|
const char *trap_name(int signal);
|
2024-01-02 19:52:20 +00:00
|
|
|
void trap_on_ignore(int signal);
|
|
|
|
void trap_on_quit(int signal);
|
|
|
|
void trap_on_abort(int signal);
|
|
|
|
void trap_on_debug(int signal);
|
2023-11-05 15:30:11 +00:00
|
|
|
int (PANIC)(const char *error, const char *file, int line);
|
|
|
|
int (PRINTF)(const char *text, const char *stack, const char *file, int line, const char *function);
|
|
|
|
int (test)(const char *file, int line, const char *expr, bool result);
|
2024-01-02 19:52:20 +00:00
|
|
|
uint64_t date();
|
|
|
|
uint64_t date_epoch();
|
|
|
|
char* date_string();
|
|
|
|
double time_hh();
|
|
|
|
double time_mm();
|
|
|
|
double time_ss();
|
|
|
|
uint64_t time_ms();
|
|
|
|
uint64_t time_us();
|
|
|
|
uint64_t time_ns();
|
|
|
|
void sleep_ss(double ss);
|
|
|
|
void sleep_ms(double ms);
|
|
|
|
void sleep_us(double us);
|
|
|
|
void sleep_ns(double us);
|
|
|
|
unsigned timer(unsigned ms, unsigned (*callback)(unsigned ms, void *arg), void *arg);
|
|
|
|
void timer_destroy(unsigned timer_handle);
|
2023-10-07 17:34:09 +00:00
|
|
|
typedef vec3i guid;
|
2024-01-02 19:52:20 +00:00
|
|
|
guid guid_create();
|
2023-12-01 21:27:44 +00:00
|
|
|
float ease_zero(float t);
|
|
|
|
float ease_one(float t);
|
2023-11-02 09:54:49 +00:00
|
|
|
float ease_linear(float t);
|
|
|
|
float ease_out_sine(float t);
|
|
|
|
float ease_out_quad(float t);
|
|
|
|
float ease_out_cubic(float t);
|
|
|
|
float ease_out_quart(float t);
|
|
|
|
float ease_out_quint(float t);
|
|
|
|
float ease_out_expo(float t);
|
|
|
|
float ease_out_circ(float t);
|
|
|
|
float ease_out_back(float t);
|
|
|
|
float ease_out_elastic(float t);
|
|
|
|
float ease_out_bounce(float t);
|
|
|
|
float ease_in_sine(float t);
|
|
|
|
float ease_in_quad(float t);
|
|
|
|
float ease_in_cubic(float t);
|
|
|
|
float ease_in_quart(float t);
|
|
|
|
float ease_in_quint(float t);
|
|
|
|
float ease_in_expo(float t);
|
|
|
|
float ease_in_circ(float t);
|
|
|
|
float ease_in_back(float t);
|
|
|
|
float ease_in_elastic(float t);
|
|
|
|
float ease_in_bounce(float t);
|
|
|
|
float ease_inout_sine(float t);
|
|
|
|
float ease_inout_quad(float t);
|
|
|
|
float ease_inout_cubic(float t);
|
|
|
|
float ease_inout_quart(float t);
|
|
|
|
float ease_inout_quint(float t);
|
|
|
|
float ease_inout_expo(float t);
|
|
|
|
float ease_inout_circ(float t);
|
|
|
|
float ease_inout_back(float t);
|
|
|
|
float ease_inout_elastic(float t);
|
|
|
|
float ease_inout_bounce(float t);
|
|
|
|
float ease_inout_perlin(float t);
|
|
|
|
enum EASE_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
EASE_SINE,
|
|
|
|
EASE_QUAD,
|
|
|
|
EASE_CUBIC,
|
|
|
|
EASE_QUART,
|
|
|
|
EASE_QUINT,
|
|
|
|
EASE_EXPO,
|
|
|
|
EASE_CIRC,
|
|
|
|
EASE_BACK,
|
|
|
|
EASE_ELASTIC,
|
|
|
|
EASE_BOUNCE,
|
|
|
|
EASE_IN,
|
|
|
|
EASE_OUT = 0,
|
|
|
|
EASE_INOUT = EASE_IN * 2,
|
|
|
|
EASE_ZERO = EASE_INOUT | (EASE_BOUNCE + 1),
|
|
|
|
EASE_ONE,
|
|
|
|
EASE_LINEAR,
|
|
|
|
EASE_INOUT_PERLIN,
|
|
|
|
EASE_NUM
|
2023-11-02 09:54:49 +00:00
|
|
|
};
|
|
|
|
float ease(float t01, unsigned fn);
|
|
|
|
float ease_pong(float t01, unsigned fn);
|
|
|
|
float ease_ping_pong(float t, unsigned fn1, unsigned fn2);
|
|
|
|
float ease_pong_ping(float t, unsigned fn1, unsigned fn2);
|
|
|
|
const char *ease_enum(unsigned fn);
|
|
|
|
const char**ease_enums();
|
|
|
|
typedef struct tween_keyframe_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
float t;
|
|
|
|
vec3 v;
|
|
|
|
unsigned ease;
|
2023-11-02 09:54:49 +00:00
|
|
|
} tween_keyframe_t;
|
|
|
|
typedef struct tween_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
tween_keyframe_t* keyframes;
|
|
|
|
vec3 result;
|
|
|
|
float time;
|
|
|
|
float duration;
|
2023-11-02 09:54:49 +00:00
|
|
|
} tween_t;
|
|
|
|
tween_t tween();
|
2024-01-02 19:52:20 +00:00
|
|
|
void tween_setkey(tween_t *tw, float t, vec3 v, unsigned easing_mode);
|
|
|
|
void tween_delkey(tween_t *tw, float t);
|
|
|
|
float tween_update(tween_t *tw, float dt);
|
|
|
|
void tween_reset(tween_t *tw);
|
|
|
|
void tween_destroy(tween_t *tw);
|
2023-11-02 17:45:44 +00:00
|
|
|
typedef struct curve_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
float* lengths;
|
|
|
|
unsigned* colors;
|
|
|
|
vec3* samples;
|
|
|
|
vec3* points;
|
|
|
|
int* indices;
|
2023-11-02 17:45:44 +00:00
|
|
|
} curve_t;
|
|
|
|
curve_t curve();
|
2024-01-02 19:52:20 +00:00
|
|
|
void curve_add(curve_t *c, vec3 p);
|
|
|
|
void curve_end(curve_t *c, int num_points);
|
|
|
|
vec3 curve_eval(curve_t *c, float dt, unsigned *color);
|
|
|
|
void curve_destroy(curve_t *c);
|
2023-07-30 19:18:50 +00:00
|
|
|
enum PANEL_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
PANEL_OPEN = 1,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
int ui_notify(const char *title, const char *body);
|
|
|
|
int ui_window(const char *title, int *enabled);
|
2024-01-02 19:52:20 +00:00
|
|
|
int ui_panel(const char *title, int flags);
|
|
|
|
int ui_collapse(const char *label, const char *id);
|
|
|
|
int ui_collapseo(const char *label, const char *id);
|
|
|
|
int ui_contextual();
|
|
|
|
int ui_section(const char *title);
|
|
|
|
int ui_int(const char *label, int *value);
|
|
|
|
int ui_bool(const char *label, bool *value);
|
|
|
|
int ui_short(const char *label, short *value);
|
|
|
|
int ui_float(const char *label, float *value);
|
|
|
|
int ui_float2(const char *label, float value[2]);
|
|
|
|
int ui_float3(const char *label, float value[3]);
|
|
|
|
int ui_float4(const char *label, float value[4]);
|
|
|
|
int ui_mat33(const char *label, float mat33[9]);
|
|
|
|
int ui_mat34(const char *label, float mat34[12]);
|
|
|
|
int ui_mat44(const char *label, float mat44[16]);
|
|
|
|
int ui_double(const char *label, double *value);
|
|
|
|
int ui_buffer(const char *label, char *buffer, int buflen);
|
|
|
|
int ui_string(const char *label, char **string);
|
|
|
|
int ui_color3(const char *label, unsigned *color);
|
|
|
|
int ui_color3f(const char *label, float color[3]);
|
|
|
|
int ui_color4(const char *label, unsigned *color);
|
|
|
|
int ui_color4f(const char *label, float color[4]);
|
|
|
|
int ui_unsigned(const char *label, unsigned *value);
|
|
|
|
int ui_unsigned2(const char *label, unsigned *value);
|
|
|
|
int ui_unsigned3(const char *label, unsigned *value);
|
|
|
|
int ui_button(const char *label);
|
|
|
|
int ui_button_transparent(const char *label);
|
|
|
|
int ui_buttons(int buttons, ...);
|
|
|
|
int ui_toolbar(const char *options);
|
|
|
|
int ui_submenu(const char *options);
|
|
|
|
int ui_browse(const char **outfile, bool *inlined);
|
|
|
|
int ui_toggle(const char *label, bool *value);
|
|
|
|
int ui_dialog(const char *title, const char *text, int choices, bool *show);
|
|
|
|
int ui_list(const char *label, const char **items, int num_items, int *selector);
|
|
|
|
int ui_radio(const char *label, const char **items, int num_items, int *selector);
|
|
|
|
int ui_texture(const char *label, texture_t t);
|
|
|
|
int ui_subtexture(const char *label, texture_t t, unsigned x, unsigned y, unsigned w, unsigned h);
|
|
|
|
int ui_image(const char *label, handle id, unsigned w, unsigned h);
|
|
|
|
int ui_subimage(const char *label, handle id, unsigned iw, unsigned ih, unsigned sx, unsigned sy, unsigned sw, unsigned sh);
|
|
|
|
int ui_colormap(const char *label, colormap_t *cm);
|
|
|
|
int ui_separator();
|
|
|
|
int ui_bitmask8(const char *label, uint8_t *bits);
|
|
|
|
int ui_bitmask16(const char *label, uint16_t *bits);
|
|
|
|
int ui_console();
|
|
|
|
int ui_clampf(const char *label, float *value, float minf, float maxf);
|
|
|
|
int ui_label(const char *label);
|
|
|
|
int ui_label2(const char *label, const char *caption);
|
|
|
|
int ui_label2_bool(const char *label, bool enabled);
|
|
|
|
int ui_label2_float(const char *label, float value);
|
|
|
|
int ui_label2_toolbar(const char *label, const char *icons);
|
|
|
|
int ui_slider(const char *label, float *value);
|
|
|
|
int ui_slider2(const char *label, float *value, const char *caption);
|
|
|
|
int ui_contextual_end(int close);
|
|
|
|
int ui_collapse_clicked();
|
|
|
|
int ui_collapse_end();
|
|
|
|
int ui_panel_end();
|
2023-07-30 19:18:50 +00:00
|
|
|
int ui_window_end();
|
2024-01-02 19:52:20 +00:00
|
|
|
int ui_show(const char *panel_or_window_title, int enabled);
|
|
|
|
int ui_dims(const char *panel_or_window_title, float width, float height);
|
|
|
|
int ui_visible(const char *panel_or_window_title);
|
2023-09-17 20:56:51 +00:00
|
|
|
vec2 ui_get_dims();
|
2024-01-02 19:52:20 +00:00
|
|
|
int ui_enable();
|
|
|
|
int ui_enabled();
|
|
|
|
int ui_disable();
|
2023-07-30 19:18:50 +00:00
|
|
|
int ui_has_menubar();
|
|
|
|
int ui_menu(const char *items);
|
|
|
|
int ui_menu_editbox(char *buf, int bufcap);
|
|
|
|
int ui_item();
|
|
|
|
int ui_popups();
|
|
|
|
int ui_hover();
|
|
|
|
int ui_active();
|
|
|
|
int ui_demo(int do_windows);
|
2023-10-28 12:16:41 +00:00
|
|
|
void *ui_handle();
|
2023-07-30 19:18:50 +00:00
|
|
|
enum VIDEO_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
VIDEO_YCBCR = 0,
|
|
|
|
VIDEO_RGB = 2,
|
|
|
|
VIDEO_AUDIO = 0,
|
|
|
|
VIDEO_NO_AUDIO = 4,
|
|
|
|
VIDEO_LOOP = 8,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
|
|
|
typedef struct video_t video_t;
|
2024-01-02 19:52:20 +00:00
|
|
|
video_t* video( const char *filename, int flags );
|
|
|
|
texture_t* video_decode( video_t *v );
|
|
|
|
texture_t* video_textures( video_t *v );
|
|
|
|
int video_has_finished(video_t *v);
|
|
|
|
double video_duration(video_t *v);
|
|
|
|
int video_seek(video_t *v, double seek_to);
|
|
|
|
double video_position(video_t *v);
|
|
|
|
void video_pause(video_t *v, bool paused);
|
|
|
|
bool video_is_paused(video_t *v);
|
|
|
|
bool video_is_rgb(video_t *v);
|
|
|
|
void video_destroy( video_t *v );
|
|
|
|
bool record_start(const char *outfile_mp4);
|
|
|
|
bool record_active();
|
|
|
|
void record_stop(void);
|
2023-07-30 19:18:50 +00:00
|
|
|
enum WINDOW_FLAGS {
|
2024-01-02 19:52:20 +00:00
|
|
|
WINDOW_MSAA2 = 0x02,
|
|
|
|
WINDOW_MSAA4 = 0x04,
|
|
|
|
WINDOW_MSAA8 = 0x08,
|
|
|
|
WINDOW_SQUARE = 0x20,
|
|
|
|
WINDOW_PORTRAIT = 0x40,
|
|
|
|
WINDOW_LANDSCAPE = 0x80,
|
|
|
|
WINDOW_ASPECT = 0x100,
|
|
|
|
WINDOW_FIXED = 0x200,
|
|
|
|
WINDOW_TRANSPARENT = 0x400,
|
|
|
|
WINDOW_BORDERLESS = 0x800,
|
2024-02-11 10:57:05 +00:00
|
|
|
WINDOW_VSYNC_DISABLED = 0,
|
2024-01-02 19:52:20 +00:00
|
|
|
WINDOW_VSYNC_ADAPTIVE = 0x1000,
|
2024-02-11 10:57:05 +00:00
|
|
|
WINDOW_VSYNC = 0x2000,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
2024-01-02 19:52:20 +00:00
|
|
|
bool window_create(float scale, unsigned flags);
|
|
|
|
bool window_create_from_handle(void *handle, float scale, unsigned flags);
|
|
|
|
void window_reload();
|
|
|
|
int window_frame_begin();
|
|
|
|
void window_frame_end();
|
|
|
|
void window_frame_swap();
|
|
|
|
int window_swap();
|
|
|
|
void window_loop(void (*function)(void* loopArg), void* loopArg );
|
|
|
|
void window_loop_exit();
|
|
|
|
void window_title(const char *title);
|
|
|
|
void window_color(unsigned color);
|
|
|
|
vec2 window_canvas();
|
|
|
|
void* window_handle();
|
|
|
|
char* window_stats();
|
2024-01-30 23:48:42 +00:00
|
|
|
void window_debug(bool visible);
|
2023-07-30 19:18:50 +00:00
|
|
|
uint64_t window_frame();
|
2024-01-02 19:52:20 +00:00
|
|
|
int window_width();
|
|
|
|
int window_height();
|
|
|
|
double window_time();
|
|
|
|
double window_delta();
|
|
|
|
void window_focus();
|
|
|
|
int window_has_focus();
|
|
|
|
void window_fullscreen(int enabled);
|
|
|
|
int window_has_fullscreen();
|
|
|
|
void window_cursor(int visible);
|
|
|
|
int window_has_cursor();
|
|
|
|
void window_pause(int paused);
|
|
|
|
int window_has_pause();
|
|
|
|
void window_visible(int visible);
|
|
|
|
int window_has_visible();
|
|
|
|
void window_maximize(int enabled);
|
|
|
|
int window_has_maximize();
|
|
|
|
void window_transparent(int enabled);
|
|
|
|
int window_has_transparent();
|
|
|
|
void window_icon(const char *file_icon);
|
|
|
|
int window_has_icon();
|
|
|
|
double window_aspect();
|
|
|
|
void window_aspect_lock(unsigned numer, unsigned denom);
|
|
|
|
void window_aspect_unlock();
|
|
|
|
double window_fps();
|
|
|
|
double window_fps_target();
|
|
|
|
void window_fps_lock(float fps);
|
|
|
|
void window_fps_unlock();
|
|
|
|
void window_screenshot(const char* outfile_png);
|
|
|
|
int window_record(const char *outfile_mp4);
|
|
|
|
vec2 window_dpi();
|
2023-07-30 19:18:50 +00:00
|
|
|
enum CURSOR_SHAPES {
|
2024-01-02 19:52:20 +00:00
|
|
|
CURSOR_NONE,
|
|
|
|
CURSOR_HW_ARROW,
|
|
|
|
CURSOR_HW_IBEAM,
|
|
|
|
CURSOR_HW_HDRAG,
|
|
|
|
CURSOR_HW_VDRAG,
|
|
|
|
CURSOR_HW_HAND,
|
|
|
|
CURSOR_HW_CROSS,
|
|
|
|
CURSOR_SW_AUTO,
|
2023-07-30 19:18:50 +00:00
|
|
|
};
|
2024-01-02 19:52:20 +00:00
|
|
|
void window_cursor_shape(unsigned shape);
|
2023-11-05 15:30:11 +00:00
|
|
|
const char *window_clipboard();
|
2024-01-02 19:52:20 +00:00
|
|
|
void window_setclipboard(const char *text);
|
2023-11-20 20:19:53 +00:00
|
|
|
typedef struct editor_bind_t {
|
2024-01-02 19:52:20 +00:00
|
|
|
const char *command;
|
|
|
|
const char *bindings;
|
|
|
|
void (*fn)();
|
2023-11-20 20:19:53 +00:00
|
|
|
} editor_bind_t;
|
|
|
|
void editor_addbind(editor_bind_t bind);
|
2024-01-02 19:52:20 +00:00
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_open_map_t; editor_open_map_t *editor_open_map(); int editor_open(const void *obj); void editor_setopen(const void *obj, int value); void editor_altopen(const void *obj); void editor_noopen(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_selected_map_t; editor_selected_map_t *editor_selected_map(); int editor_selected(const void *obj); void editor_setselected(const void *obj, int value); void editor_altselected(const void *obj); void editor_noselected(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_changed_map_t; editor_changed_map_t *editor_changed_map(); int editor_changed(const void *obj); void editor_setchanged(const void *obj, int value); void editor_altchanged(const void *obj); void editor_nochanged(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_popup_map_t; editor_popup_map_t *editor_popup_map(); int editor_popup(const void *obj); void editor_setpopup(const void *obj, int value); void editor_altpopup(const void *obj); void editor_nopopup(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_bookmarked_map_t; editor_bookmarked_map_t *editor_bookmarked_map(); int editor_bookmarked(const void *obj); void editor_setbookmarked(const void *obj, int value); void editor_altbookmarked(const void *obj); void editor_nobookmarked(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_visible_map_t; editor_visible_map_t *editor_visible_map(); int editor_visible(const void *obj); void editor_setvisible(const void *obj, int value); void editor_altvisible(const void *obj); void editor_novisible(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_script_map_t; editor_script_map_t *editor_script_map(); int editor_script(const void *obj); void editor_setscript(const void *obj, int value); void editor_altscript(const void *obj); void editor_noscript(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_event_map_t; editor_event_map_t *editor_event_map(); int editor_event(const void *obj); void editor_setevent(const void *obj, int value); void editor_altevent(const void *obj); void editor_noevent(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; char* val; } tmp, *ptr; char** tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_iconinstance_map_t; editor_iconinstance_map_t *editor_iconinstance_map(); char* editor_iconinstance(const void *obj); void editor_seticoninstance(const void *obj, char* value); void editor_alticoninstance(const void *obj); void editor_noiconinstance(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; char* val; } tmp, *ptr; char** tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_iconclass_map_t; editor_iconclass_map_t *editor_iconclass_map(); char* editor_iconclass(const void *obj); void editor_seticonclass(const void *obj, char* value); void editor_alticonclass(const void *obj); void editor_noiconclass(void *obj);;
|
|
|
|
typedef struct { map base; struct { pair p; void* key; int val; } tmp, *ptr; int* tmpval; int (*typed_cmp)(void*, void*); uint64_t (*typed_hash)(void*); } * editor_treeoffsety_map_t; editor_treeoffsety_map_t *editor_treeoffsety_map(); int editor_treeoffsety(const void *obj); void editor_settreeoffsety(const void *obj, int value); void editor_alttreeoffsety(const void *obj); void editor_notreeoffsety(void *obj);;
|
2023-11-20 20:19:53 +00:00
|
|
|
void editor_destroy_properties(void *o);
|
|
|
|
void editor_load_on_boot(void);
|
|
|
|
void editor_save_on_quit(void);
|
2023-11-26 15:27:33 +00:00
|
|
|
enum EDITOR_MODE {
|
2024-01-02 19:52:20 +00:00
|
|
|
EDITOR_PANEL,
|
|
|
|
EDITOR_WINDOW,
|
|
|
|
EDITOR_WINDOW_NK,
|
|
|
|
EDITOR_WINDOW_NK_SMALL,
|
2023-11-20 20:19:53 +00:00
|
|
|
};
|
|
|
|
int editor_begin(const char *title, int mode);
|
|
|
|
int editor_end(int mode);
|
|
|
|
int editor_filter();
|
|
|
|
void editor_select(const char *mask);
|
|
|
|
void editor_unselect();
|
|
|
|
void editor_select_aabb(aabb box);
|
|
|
|
void editor_selectgroup(obj *first, obj *last);
|
|
|
|
void* editor_first_selected();
|
|
|
|
void* editor_last_selected();
|
|
|
|
void editor_addtoworld(obj *o);
|
|
|
|
void editor_watch(const void *o);
|
|
|
|
void* editor_spawn(const char *ini);
|
|
|
|
void editor_spawn1();
|
|
|
|
void editor_destroy_selected();
|
|
|
|
void editor_inspect(obj *o);
|
2024-01-02 19:52:20 +00:00
|
|
|
vec3 editor_pick(float mouse_x, float mouse_y);
|
|
|
|
char* editor_path(const char *path);
|
2023-11-26 15:27:33 +00:00
|
|
|
void editor_setmouse(int x, int y);
|
2023-11-26 21:21:57 +00:00
|
|
|
vec2 editor_glyph(int x, int y, const char *style, unsigned codepoint);
|
|
|
|
vec2 editor_glyphs(int x, int y, const char *style, const char *utf8);
|
2023-11-26 15:27:33 +00:00
|
|
|
void editor_gizmos(int dim);
|
2024-01-02 19:52:20 +00:00
|
|
|
int editor_send(const char *cmd);
|
2023-11-20 20:19:53 +00:00
|
|
|
const char* editor_recv(int jobid, double timeout_ss);
|
|
|
|
void editor_pump();
|
|
|
|
void editor_frame( void (*game)(unsigned, float, double) );
|
2023-11-19 13:16:48 +00:00
|
|
|
float* engine_getf(const char *key);
|
2024-01-02 19:52:20 +00:00
|
|
|
int* engine_geti(const char *key);
|
2023-11-19 13:16:48 +00:00
|
|
|
char** engine_gets(const char *key);
|
2024-01-02 19:52:20 +00:00
|
|
|
int engine_send(const char *cmd, const char *optional_value);
|
|
|
|
int ui_engine();
|
2023-07-30 19:18:50 +00:00
|
|
|
]])
|
|
|
|
local _M = {}
|
|
|
|
function _M.vec2(x,y)
|
|
|
|
local v = ffi.new("union vec2")
|
|
|
|
v.x = x
|
|
|
|
v.y = y
|
|
|
|
return v
|
|
|
|
end
|
|
|
|
function _M.vec3(x,y,z)
|
|
|
|
local v = ffi.new("union vec3")
|
|
|
|
v.x = x
|
|
|
|
v.y = y
|
|
|
|
v.z = z
|
|
|
|
return v
|
|
|
|
end
|
|
|
|
function _M.vec4(x,y,z,w)
|
|
|
|
local v = ffi.new("union vec4")
|
|
|
|
v.x = x
|
|
|
|
v.y = y
|
|
|
|
v.z = z
|
|
|
|
v.w = w
|
|
|
|
return v
|
|
|
|
end
|
|
|
|
function _M.quat(x,y,z,w)
|
|
|
|
local q = ffi.new("union quat")
|
|
|
|
v.x = x
|
|
|
|
v.y = y
|
|
|
|
v.z = z
|
|
|
|
v.w = w
|
|
|
|
return q
|
|
|
|
end
|
|
|
|
function _M.mat44()
|
|
|
|
local m = ffi.new("float [16]")
|
|
|
|
return m
|
|
|
|
end
|
|
|
|
|
2024-01-02 19:52:20 +00:00
|
|
|
local v4k = ffi.load("v4k")
|
2023-07-30 19:18:50 +00:00
|
|
|
|
|
|
|
return setmetatable( _M, {
|
|
|
|
__index = function( table, key )
|
2024-01-02 19:52:20 +00:00
|
|
|
return v4k[ key ]
|
2023-07-30 19:18:50 +00:00
|
|
|
end
|
|
|
|
} )
|
|
|
|
|