v4k-git-backup/bind/v4k.lua

2344 lines
89 KiB
Lua
Raw Permalink Normal View History

2024-07-25 06:11:55 +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);
int less_64_ptr(const void *a, const void *b);
int less_int_ptr(const void *a, const void *b);
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);
uint64_t hash_bin(const void* ptr, unsigned len);
uint64_t hash_str(const char* str);
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 {
struct set_item *next;
uint64_t keyhash;
void *key;
void *super;
} set_item;
typedef struct set {
set_item** array;
int (*cmp)(void *, void *);
uint64_t (*hash)(void *);
int count;
} set;
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);
void* (set_find)(const set *m, void *key, uint64_t keyhash);
int (set_isempty)(const set *m);
int (set_count)(const set *m);
void (set_gc)(set *m);
void (set_clear)(set* m);
typedef struct pair {
struct pair *next;
uint64_t keyhash;
void *key;
void *value;
void *super;
} pair;
typedef struct map {
pair** array;
int (*cmp)(void *, void *);
uint64_t (*hash)(void *);
int count:31;
int is_sorted:1;
pair** sorted;
} map;
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);
void* (map_find)(map *m, void *key, uint64_t keyhash);
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;
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];
void randset(uint64_t state);
uint64_t rand64(void);
double randf(void);
int randi(int mini, int maxi);
float simplex1( float x );
float simplex2( vec2 xy );
float simplex3( vec3 xyz );
float simplex4( vec4 xyzw );
float deg (float radians);
float rad (float degrees);
2024-09-03 22:21:46 +00:00
float cycle180 (float angle);
float cycle360 (float angle);
2024-07-25 06:11:55 +00:00
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);
2024-08-16 07:04:01 +00:00
float unmixf (float a,float b,float t);
float mapf (float x,float a,float b,float c,float d);
2024-07-25 06:11:55 +00:00
float slerpf (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);
quat slerpq(quat a, quat b, float s);
quat rotationq(float deg,float x,float y,float z);
quat mat44q (mat44 M);
vec3 rotate3q_2(vec3 v, quat q);
vec3 rotate3q(vec3 v, quat r);
vec3 euler (quat q);
quat eulerq (vec3 pyr_degrees);
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);
2024-08-23 19:28:40 +00:00
vec3 pos44(mat44 m);
2024-07-25 06:11:55 +00:00
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);
void print2i( vec2i v );
void print3i( vec3i v );
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 );
uintptr_t id_make(void *ptr);
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;
obj *objtmp;
void* obj_malloc(unsigned sz);
void* obj_free(void *o);
extern void (*obj_ctor[256])();
extern void (*obj_dtor[256])();
extern char* (*obj_save[256])();
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])();
extern char* (*obj_icon[256])();
extern const char*OBJTYPES[256];
uintptr_t obj_header(const void *o);
uintptr_t obj_id(const void *o);
const char* obj_type(const void *o);
unsigned obj_typeid(const void *o);
int obj_sizeof(const void *o);
int obj_size(const void *o);
char* obj_data(void *o);
const char* obj_datac(const void *o);
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);
obj***obj_children(const void *o);
obj***obj_siblings(const void *o);
int obj_dumptree(const void *o);
void* obj_setmeta(void *o, const char *key, const char *value);
const char* obj_meta(const void *o, const char *key);
void* obj_setname(void *o, const char *name);
const char* obj_name(const void *o);
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);
typedef enum OBJTYPE_BUILTINS {
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,
} 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 {
uint64_t type;
int (*action)();
union {
int argi;
float argf;
};
struct bt_t* children;
} bt_t;
bt_t bt(const char *ini_file, unsigned flags);
int bt_run(bt_t *b);
void bt_addfun(const char *name, int(*func)());
bt_func bt_findfun(const char *name);
char *bt_funcname(bt_func fn);
int ui_bt(bt_t *b);
typedef enum SWARM_DISTANCE {
SWARM_DISTANCE_LINEAR,
SWARM_DISTANCE_INVERSE_LINEAR,
SWARM_DISTANCE_QUADRATIC,
SWARM_DISTANCE_INVERSE_QUADRATIC
} SWARM_DISTANCE;
typedef struct boid_t {
vec3 position;
vec3 velocity;
vec3 acceleration;
vec3 prev_position;
} boid_t;
typedef struct swarm_t {
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_;
} swarm_t;
swarm_t swarm();
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);
typedef struct audio_handle* audio_t;
audio_t audio_clip( const char *pathfile );
audio_t audio_stream( const char *pathfile );
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();
int ui_audio();
enum AUDIO_FLAGS {
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,
};
int audio_queue( const void *samples, int num_samples, int flags );
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;
2024-08-15 09:11:46 +00:00
typedef struct poly { vec3* verts; int cnt; } poly;
2024-07-25 06:11:55 +00:00
typedef union frustum { struct { vec4 l, r, t, b, n, f; }; vec4 pl[6]; float v[24]; } frustum;
typedef struct hit {
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; };
} hit;
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_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_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_sphere(capsule c, sphere s);
vec4 plane4(vec3 p, vec3 n);
frustum frustum_build(mat44 projview);
int frustum_test_sphere(frustum f, sphere s);
int frustum_test_aabb(frustum f, aabb a);
2024-08-15 09:11:46 +00:00
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);
2024-07-25 06:11:55 +00:00
void collide_demo();
enum COOK_FLAGS {
COOK_SYNC = 0,
COOK_ASYNC = 1,
COOK_CANCELABLE = 2,
COOK_DEBUGLOG = 4,
};
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();
int cook_jobs();
int cook_progress();
bool have_tools();
typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t* arr; } json_t;
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();
bool data_tests();
void* dll(const char *filename, const char *symbol);
enum {
SCRIPT_LUA = 1,
SCRIPT_DEBUGGER = 2,
};
void script_init();
void *script_init_env(unsigned flags);
bool script_push(void *env);
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();
bool script_pop();
char** file_list( const char *pathmasks );
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);
char** file_zip_list(const char *zipfile);
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);
char** vfs_list(const char *masks);
char * vfs_read(const char *pathfile);
char * vfs_load(const char *pathfile, int *size);
int vfs_size(const char *pathfile);
void vfs_reload();
const char * vfs_resolve(const char *fuzzyname);
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);
enum FONT_FLAGS {
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,
};
typedef struct font_metrics_t {
float ascent;
float descent;
float linegap;
float linedist;
} font_metrics_t;
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);
void font_scale(const char *face_tag, int scale_index, float value);
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);
vec2 font_clip(const char *text, vec4 rect);
const char* font_wrap(const char *text, float max_width);
vec2 font_rect(const char *text);
font_metrics_t font_metrics(const char *text);
void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords);
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 );
const char* input_string( int vk );
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 );
enum TOUCH_BUTTONS {
TOUCH_0,
TOUCH_1,
};
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 );
char* save_input();
bool load_input(char* replay);
int ui_keyboard();
int ui_mouse();
int ui_gamepad(int id);
int ui_gamepads();
enum INPUT_ENUMS {
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,
};
enum INPUT_ALIASES {
KEY_SHIFT = KEY_LSHIFT,
KEY_ALT = KEY_LALT,
KEY_CTRL = KEY_LCTRL,
};
void* xrealloc(void* p, size_t sz);
size_t xsize(void* p);
char* xstats(void);
void* stack(int bytes);
void* watch( void *ptr, int sz );
void* forget( void *ptr );
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 );
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);
char* tcp_host(int);
char* tcp_port(int);
int tcp_close(int);
int tcp_debug(int);
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);
typedef struct track_prop {
char const *key;
char const *val;
} track_prop;
int track_event_props(char const *event_id, char const *user_id, const track_prop *props);
enum { NETWORK_BIND = 2, NETWORK_CONNECT = 4, NETWORK_NOFAIL = 8 };
void network_create(unsigned max_clients, const char *ip, const char *port, unsigned flags);
enum { NETWORK_SEND = 2, NETWORK_RECV = 4 };
enum { NETWORK_UNRELIABLE = 8, NETWORK_UNORDERED = 16 };
void* network_buffer(void *ptr, unsigned sz, uint64_t flags, int64_t rank);
char** network_sync(unsigned timeout_ms);
enum {
NETWORK_EVENT_CONNECT,
NETWORK_EVENT_DISCONNECT,
NETWORK_EVENT_RECEIVE,
NETWORK_EVENT_DISCONNECT_TIMEOUT,
NETWORK_EVENT_RPC = 10,
NETWORK_EVENT_RPC_RESP,
};
int network_event(const char *msg, int *errcode, char **errstr);
enum { NETWORK_RANK = 0 };
enum { NETWORK_PING = 1 };
enum { NETWORK_PORT = 2, NETWORK_IP, NETWORK_LIVE };
enum { NETWORK_SEND_MS = 4 };
enum { NETWORK_BUF_CLEAR_ON_JOIN = 5 };
enum { NETWORK_USERID = 7, NETWORK_COUNT , NETWORK_CAPACITY };
int64_t network_get(uint64_t key);
int64_t network_put(uint64_t key, int64_t value);
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);
bool server_bind(int max_clients, int port);
char** server_poll(unsigned timeout_ms);
char** client_poll(unsigned timeout_ms);
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);
enum COMPRESS_FLAGS {
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),
};
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);
int32_t deczig32i(uint32_t n);
int64_t deczig64i(uint64_t n);
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 {
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,
};
char* ftoa1(float v);
char* ftoa2(vec2 v);
char* ftoa3(vec3 v);
char* ftoa4(vec4 v);
float atof1(const char *s);
vec2 atof2(const char *s);
vec3 atof3(const char *s);
vec4 atof4(const char *s);
char* itoa1(int v);
char* itoa2(vec2i v);
char* itoa3(vec3i v);
int atoi1(const char *s);
vec2i atoi2(const char *s);
vec3i atoi3(const char *s);
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);
typedef uint16_t half;
float half_to_float(half value);
half float_to_half(float value);
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);
uint64_t pack754(long double f, unsigned bits, unsigned expbits);
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 );
int msgpack(const char *fmt, ... );
int msgunpack(const char *fmt, ... );
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, ...);
int profiler_enable(bool on);
struct profile_t { double stat; int32_t cost, avg; };
typedef struct { map base; struct { pair p; char * key; struct profile_t val; } tmp, *ptr; struct profile_t* tmpval; int (*typed_cmp)(char *, char *); uint64_t (*typed_hash)(char *); } * profiler_t;
extern profiler_t profiler;
extern int profiler_enabled;
typedef struct reflect_t {
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;
} reflect_t;
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);
typedef unsigned handle;
typedef struct renderstate_t {
float clear_color[4];
bool color_mask[4];
double clear_depth;
bool depth_test_enabled;
bool depth_write_enabled;
unsigned depth_func;
bool polygon_offset_enabled;
float polygon_offset;
float polygon_offset_factor;
bool blend_enabled;
unsigned blend_func;
unsigned blend_src;
unsigned blend_dst;
bool cull_face_enabled;
unsigned cull_face_mode;
bool stencil_test_enabled;
unsigned stencil_func;
unsigned stencil_op_fail, stencil_op_zfail, stencil_op_zpass;
int stencil_ref;
unsigned stencil_read_mask;
unsigned stencil_write_mask;
unsigned front_face;
bool line_smooth_enabled;
float line_width;
bool point_size_enabled;
float point_size;
unsigned polygon_mode_face;
unsigned polygon_mode_draw;
bool scissor_test_enabled;
2024-08-29 15:32:34 +00:00
bool seamless_cubemap;
2024-08-30 01:46:46 +00:00
bool depth_clamp_enabled;
2024-07-25 06:11:55 +00:00
} renderstate_t;
renderstate_t renderstate();
bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *stateB);
void renderstate_apply(const renderstate_t *state);
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 );
unsigned alpha( unsigned rgba );
unsigned atorgba(const char *s);
char * rgbatoa(unsigned rgba);
enum IMAGE_FLAGS {
IMAGE_R = 0x01000,
IMAGE_RG = 0x02000,
IMAGE_RGB = 0x04000,
IMAGE_RGBA = 0x08000,
IMAGE_FLIP = 0x10000,
IMAGE_FLOAT = 0x20000,
};
typedef struct image_t {
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; };
} image_t;
image_t image(const char *pathfile, int flags);
image_t image_from_mem(const void *ptr, int len, int flags);
void image_destroy(image_t *img);
enum TEXTURE_FLAGS {
TEXTURE_BC1 = 8,
TEXTURE_BC2 = 16,
TEXTURE_BC3 = 32,
TEXTURE_NEAREST = 0,
TEXTURE_LINEAR = 64,
TEXTURE_MIPMAPS = 128,
TEXTURE_ANISOTROPY = 1 << 30,
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,
};
typedef struct texture_t {
union { unsigned x, w; };
union { unsigned y, h; };
union { unsigned z, d; };
union { unsigned n, bpp; };
handle id;
unsigned texel_type;
unsigned flags;
char* filename;
bool transparent;
unsigned fbo;
union { unsigned userdata, delay; };
} 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();
void texture_destroy(texture_t *t);
int texture_unit();
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);
texture_t brdf_lut();
typedef struct colormap_t {
vec4 color;
texture_t *texture;
} colormap_t;
bool colormap( colormap_t *cm, const char *texture_name, bool load_as_srgb );
2024-08-26 17:18:11 +00:00
unsigned query_test_point(mat44 proj, mat44 view, vec3 pos, float size);
2024-07-25 06:11:55 +00:00
void fullscreen_quad_rgb( texture_t texture_rgb );
void fullscreen_quad_rgb_flipped( texture_t texture );
void fullscreen_quad_ycbcr( texture_t texture_YCbCr[3] );
void fullscreen_quad_ycbcr_flipped( texture_t texture_YCbCr[3] );
typedef struct cubemap_t {
unsigned id;
vec3 sh[9];
2024-08-28 10:42:58 +00:00
int framebuffers[6];
int textures[6];
int depth_buffers[6];
unsigned width, height;
float *pixels;
int step;
vec3 pos;
2024-07-25 06:11:55 +00:00
} cubemap_t;
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);
cubemap_t* cubemap_get_active();
2024-08-28 10:42:58 +00:00
void cubemap_bake_begin(cubemap_t *c, vec3 pos, unsigned width, unsigned height);
bool cubemap_bake_step(cubemap_t *c, mat44 proj , mat44 view );
2024-08-28 14:41:47 +00:00
void cubemap_bake_end(cubemap_t *c, int step , float sky_intensity );
2024-08-28 10:42:58 +00:00
void cubemap_sh_reset(cubemap_t *c);
void cubemap_sh_shader(cubemap_t *c);
void cubemap_sh_add_light(cubemap_t *c, vec3 light, vec3 dir, float strength);
2024-08-28 15:02:13 +00:00
void cubemap_sh_blend(vec3 pos, float max_dist, unsigned count, cubemap_t *probes);
2024-07-25 06:11:55 +00:00
unsigned fbo( unsigned texture_color, unsigned texture_depth, int wr_flags );
void fbo_bind(unsigned id);
void fbo_unbind();
void fbo_destroy(unsigned id);
2024-08-29 15:32:34 +00:00
enum {
MAX_LIGHTS = 16,
};
enum LIGHT_TYPE {
LIGHT_DIRECTIONAL,
LIGHT_POINT,
LIGHT_SPOT,
};
2024-08-29 18:46:30 +00:00
enum SHADOW_TECHNIQUE {
SHADOW_VSM,
2024-08-30 19:00:04 +00:00
SHADOW_CSM,
2024-08-29 18:46:30 +00:00
};
2024-08-29 15:32:34 +00:00
typedef struct light_t {
2024-08-31 10:17:59 +00:00
unsigned type;
2024-08-29 15:32:34 +00:00
vec3 diffuse, specular, ambient;
vec3 pos, dir;
struct {
float constant, linear, quadratic;
} falloff;
float radius;
float specularPower;
float innerCone, outerCone;
bool cast_shadows;
2024-08-29 18:46:30 +00:00
unsigned shadow_technique;
2024-08-29 15:32:34 +00:00
float shadow_distance;
2024-08-31 10:17:59 +00:00
float shadow_near_clip;
2024-08-30 21:23:07 +00:00
mat44 shadow_matrix[4];
2024-08-31 10:17:59 +00:00
float min_variance;
float variance_transition;
float shadow_bias;
float normal_bias;
2024-09-02 13:45:52 +00:00
float shadow_softness;
2024-09-02 15:00:31 +00:00
float penumbra_size;
2024-08-29 15:32:34 +00:00
bool cached;
2024-08-31 10:17:59 +00:00
bool processed_shadows;
2024-08-29 15:32:34 +00:00
} light_t;
light_t light();
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_radius(light_t* l, float radius);
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);
2024-08-31 10:17:59 +00:00
void ui_light(light_t *l);
void ui_lights(unsigned num_lights, light_t *lights);
2024-07-25 06:11:55 +00:00
typedef struct shadowmap_t {
2024-08-29 15:32:34 +00:00
mat44 V;
mat44 PV;
2024-08-30 01:46:46 +00:00
int vsm_texture_width;
2024-08-30 19:00:04 +00:00
int csm_texture_width;
2024-08-29 15:32:34 +00:00
int step;
int light_step;
2024-08-30 01:46:46 +00:00
int cascade_index;
2024-08-29 18:46:30 +00:00
unsigned shadow_technique;
2024-08-30 21:23:07 +00:00
float cascade_splits[4];
2024-09-03 09:41:33 +00:00
frustum shadow_frustum;
2024-08-29 18:46:30 +00:00
bool skip_render;
int lights_pushed;
2024-08-30 19:00:04 +00:00
handle fbo;
2024-08-30 21:23:07 +00:00
uint64_t vram_usage;
uint64_t vram_usage_total;
uint64_t vram_usage_vsm;
uint64_t vram_usage_csm;
2024-08-31 10:17:59 +00:00
handle depth_texture;
handle depth_texture_2d;
2024-09-02 11:10:35 +00:00
int filter_size, window_size;
handle offsets_texture;
2024-08-29 15:32:34 +00:00
struct {
2024-08-30 21:23:07 +00:00
int gen;
2024-08-30 01:46:46 +00:00
unsigned shadow_technique;
2024-08-31 10:17:59 +00:00
handle texture;
handle texture_2d[4];
2024-08-30 21:23:07 +00:00
float cascade_distances[4];
2024-08-29 15:32:34 +00:00
} maps[MAX_LIGHTS];
handle saved_fb;
handle saved_pass;
int saved_vp[4];
2024-08-30 21:23:07 +00:00
int gen;
2024-09-02 11:10:35 +00:00
int old_filter_size;
int old_window_size;
2024-07-25 06:11:55 +00:00
} shadowmap_t;
2024-08-30 19:00:04 +00:00
shadowmap_t shadowmap(int vsm_texture_width, int csm_texture_width);
2024-09-02 11:10:35 +00:00
void shadowmap_offsets_build(shadowmap_t *s, int filter_size, int window_size);
2024-07-25 06:11:55 +00:00
void shadowmap_destroy(shadowmap_t *s);
void shadowmap_begin(shadowmap_t *s);
2024-08-29 15:32:34 +00:00
bool shadowmap_step(shadowmap_t *s);
2024-08-30 10:19:50 +00:00
void shadowmap_light(shadowmap_t *s, light_t *l, mat44 cam_proj, mat44 cam_view);
2024-07-25 06:11:55 +00:00
void shadowmap_end(shadowmap_t *s);
2024-08-31 07:02:19 +00:00
void ui_shadowmap(shadowmap_t *s);
2024-07-25 06:11:55 +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);
unsigned shader_bind(unsigned program);
int shader_uniform(const char *name);
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);
unsigned shader_get_active();
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();
enum BUFFER_MODE {
BUFFER_READ,
BUFFER_WRITE,
BUFFER_READ_WRITE
};
unsigned compute(const char *cs);
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);
void write_barrier();
void write_barrier_image();
enum SSBO_USAGE {
STATIC_DRAW,
STATIC_READ,
STATIC_COPY,
DYNAMIC_DRAW,
DYNAMIC_READ,
DYNAMIC_COPY,
STREAM_DRAW,
STREAM_READ,
STREAM_COPY
};
enum SSBO_ACCESS {
SSBO_READ = BUFFER_READ,
SSBO_WRITE = BUFFER_WRITE,
SSBO_READ_WRITE = BUFFER_READ_WRITE
};
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();
enum MESH_FLAGS {
MESH_STATIC = 0,
MESH_STREAM = 1,
MESH_TRIANGLE_STRIP = 2,
};
typedef struct mesh_t {
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;
};
} mesh_t;
mesh_t mesh();
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);
enum SKYBOX_FLAGS {
SKYBOX_RAYLEIGH,
SKYBOX_CUBEMAP,
SKYBOX_PBR,
};
typedef struct skybox_t {
2024-08-28 10:42:58 +00:00
handle program, rayleigh_program;
2024-07-25 06:11:55 +00:00
mesh_t geometry;
cubemap_t cubemap;
int flags;
2024-08-28 10:42:58 +00:00
bool rayleigh_immediate;
2024-07-25 06:11:55 +00:00
texture_t sky, refl, env;
} skybox_t;
skybox_t skybox(const char *panorama_or_cubemap_folder, int flags);
skybox_t skybox_pbr(const char *sky_map, const char *refl_map, const char *env_map);
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);
2024-08-19 12:10:35 +00:00
void skybox_sh_shader(skybox_t *sky);
2024-07-25 06:11:55 +00:00
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();
enum MATERIAL_ENUMS {
MATERIAL_CHANNEL_DIFFUSE,
MATERIAL_CHANNEL_NORMALS,
MATERIAL_CHANNEL_SPECULAR,
MATERIAL_CHANNEL_ALBEDO,
MATERIAL_CHANNEL_ROUGHNESS,
MATERIAL_CHANNEL_METALLIC,
MATERIAL_CHANNEL_AO,
MATERIAL_CHANNEL_AMBIENT,
MATERIAL_CHANNEL_EMISSIVE,
MAX_CHANNELS_PER_MATERIAL
};
typedef struct material_layer_t {
char texname[32];
float value;
colormap_t map;
} material_layer_t;
typedef struct material_t {
char *name;
material_layer_t layer[MAX_CHANNELS_PER_MATERIAL];
} material_t;
enum {
SHADERTOY_FLIP_Y = 2,
SHADERTOY_IGNORE_FBO = 4,
SHADERTOY_IGNORE_MOUSE = 8,
};
typedef struct shadertoy_t {
handle vao, program;
int uniforms[32];
int texture_channels[4];
int frame;
uint64_t t;
texture_t tx;
vec2i dims;
int flags;
vec4 mouse;
} shadertoy_t;
shadertoy_t shadertoy( const char *shaderfile, unsigned flags );
shadertoy_t* shadertoy_render( shadertoy_t *s, float delta );
enum ANIM_FLAGS {
ANIM_LOOP = 1,
ANIM_DONT_RESET_AFTER_USE = 2,
};
typedef struct anim_t {
int from;
int to;
float blendtime;
unsigned flags;
float curframe;
unsigned easing;
float alpha;
float timer;
bool active;
vec3 pose;
char* name;
} anim_t;
anim_t clip(float minframe, float maxframe, float blendtime, unsigned flags);
anim_t loop(float minframe, float maxframe, float blendtime, unsigned flags);
anim_t* animlist(const char *filename);
enum MODEL_FLAGS {
MODEL_NO_ANIMATIONS = 1,
MODEL_NO_MESHES = 2,
MODEL_NO_TEXTURES = 4,
MODEL_NO_FILTERING = 8,
MODEL_MATCAPS = 16,
MODEL_RIMLIGHT = 32,
MODEL_PBR = 64,
2024-08-23 22:21:38 +00:00
MODEL_TRANSPARENT = 128,
2024-07-25 06:11:55 +00:00
};
enum SHADING_MODE {
SHADING_NONE,
SHADING_PHONG,
2024-08-23 15:57:19 +00:00
SHADING_VERTEXLIT,
2024-07-25 06:11:55 +00:00
SHADING_PBR,
};
2024-08-25 00:58:34 +00:00
enum FOG_MODE {
FOG_NONE,
FOG_LINEAR,
FOG_EXP,
FOG_EXP2,
FOG_DEPTH,
};
2024-07-25 06:11:55 +00:00
enum RENDER_PASS {
2024-08-23 16:24:24 +00:00
RENDER_PASS_OPAQUE,
2024-08-23 19:28:40 +00:00
RENDER_PASS_TRANSPARENT,
RENDER_PASS_OVERRIDES_BEGIN,
2024-08-30 08:19:57 +00:00
RENDER_PASS_SHADOW_BEGIN,
2024-08-30 19:00:04 +00:00
RENDER_PASS_SHADOW_CSM,
2024-08-30 08:19:57 +00:00
RENDER_PASS_SHADOW_VSM,
RENDER_PASS_SHADOW_END,
2024-07-25 06:11:55 +00:00
RENDER_PASS_LIGHTMAP,
2024-08-23 19:28:40 +00:00
RENDER_PASS_CUSTOM,
RENDER_PASS_OVERRIDES_END,
2024-07-25 06:11:55 +00:00
NUM_RENDER_PASSES
};
enum MODEL_UNIFORMS {
MODEL_UNIFORM_MV,
MODEL_UNIFORM_MVP,
MODEL_UNIFORM_VP,
MODEL_UNIFORM_CAM_POS,
MODEL_UNIFORM_CAM_DIR,
MODEL_UNIFORM_BILLBOARD,
MODEL_UNIFORM_TEXLIT,
MODEL_UNIFORM_MODEL,
MODEL_UNIFORM_VIEW,
MODEL_UNIFORM_INV_VIEW,
MODEL_UNIFORM_PROJ,
MODEL_UNIFORM_SKINNED,
MODEL_UNIFORM_VS_BONE_MATRIX,
MODEL_UNIFORM_U_MATCAPS,
MODEL_UNIFORM_RESOLUTION,
MODEL_UNIFORM_HAS_TEX_SKYSPHERE,
MODEL_UNIFORM_HAS_TEX_SKYENV,
MODEL_UNIFORM_TEX_SKYSPHERE,
MODEL_UNIFORM_SKYSPHERE_MIP_COUNT,
MODEL_UNIFORM_TEX_SKYENV,
MODEL_UNIFORM_TEX_BRDF_LUT,
MODEL_UNIFORM_FRAME_COUNT,
NUM_MODEL_UNIFORMS
};
typedef struct model_t {
struct iqm_t *iqm;
int shading;
unsigned num_textures;
handle *textures;
char **texture_names;
material_t* materials;
int uniforms[NUM_MODEL_UNIFORMS];
texture_t sky_refl, sky_env;
texture_t lightmap;
float *lmdata;
unsigned num_meshes;
unsigned num_triangles;
unsigned num_joints;
unsigned num_anims;
unsigned num_frames;
handle program;
2024-08-29 15:32:34 +00:00
handle shadow_program;
shadowmap_t *shadow_map;
bool shadow_receiver;
2024-07-25 06:11:55 +00:00
float curframe;
mat44 pivot;
int stride;
void *verts;
int num_verts;
void *tris;
2024-08-23 19:28:40 +00:00
vec3 *meshcenters;
aabb *meshbounds;
float *meshradii;
2024-09-03 10:31:42 +00:00
bool *mesh_visible;
2024-07-25 06:11:55 +00:00
int num_tris;
handle vao, ibo, vbo, vao_instanced;
2024-08-19 12:10:35 +00:00
int* lod_collapse_map;
void *lod_verts;
int lod_num_verts;
void *lod_tris;
int lod_num_tris;
2024-07-25 06:11:55 +00:00
unsigned flags;
unsigned billboard;
float *instanced_matrices;
unsigned num_instances;
int stored_flags;
renderstate_t rs[NUM_RENDER_PASSES];
bool frustum_enabled;
frustum frustum_state;
2024-07-25 06:11:55 +00:00
} model_t;
enum BILLBOARD_MODE {
BILLBOARD_X = 0x1,
BILLBOARD_Y = 0x2,
BILLBOARD_Z = 0x4,
BILLBOARD_CYLINDRICAL = BILLBOARD_X|BILLBOARD_Z,
BILLBOARD_SPHERICAL = BILLBOARD_X|BILLBOARD_Y|BILLBOARD_Z
};
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);
2024-08-19 12:10:35 +00:00
void model_lod(model_t*, float lo_detail, float hi_detail, float morph);
2024-07-25 06:11:55 +00:00
void model_shading(model_t*, int shading);
2024-08-24 17:25:29 +00:00
void model_shading_custom(model_t*, int shading, const char *vs, const char *fs, const char *defines);
2024-07-25 06:11:55 +00:00
void model_skybox(model_t*, skybox_t sky, bool load_sh);
2024-08-29 15:32:34 +00:00
void model_shadow(model_t*, shadowmap_t *sm);
2024-08-25 00:58:34 +00:00
void model_fog(model_t*, unsigned mode, vec3 color, float start, float end, float density);
2024-07-25 06:11:55 +00:00
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);
2024-08-23 19:28:40 +00:00
void model_render_instanced_pass(model_t m, mat44 proj, mat44 view, mat44* models, int shader, unsigned count, int pass);
void model_render_pass(model_t m, mat44 proj, mat44 view, mat44 model, int shader, int pass);
2024-08-24 09:49:16 +00:00
void model_set_texture(model_t*, texture_t t);
bool model_has_transparency_mesh(model_t m, int mesh);
bool model_has_transparency(model_t m);
void model_set_frustum(model_t *m, frustum f);
void model_clear_frustum(model_t *m);
2024-07-25 06:11:55 +00:00
bool model_get_bone_pose(model_t m, unsigned joint, mat34 *out);
2024-08-25 15:13:34 +00:00
bool model_get_bone_position(model_t m, unsigned joint, mat44 M, vec3 *out);
2024-07-25 06:11:55 +00:00
void model_destroy(model_t);
unsigned model_getpass();
unsigned model_setpass(unsigned pass);
vec3 pose(bool forward, float curframe, int minframe, int maxframe, bool loop, float *opt_retframe);
typedef struct anims_t {
int inuse;
float speed;
anim_t* anims;
} anims_t;
anims_t animations(const char *pathfile, int flags);
typedef struct lightmap_t {
struct lm_context *ctx;
bool ready;
int w, h;
int atlas_w, atlas_h;
texture_t atlas;
model_t** models;
unsigned shader;
} lightmap_t;
lightmap_t lightmap(int hmsize , float near, float far, vec3 color , int passes , float threshold , float distmod );
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);
void viewport_color(unsigned color);
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);
void fx_setparam(int pass, const char *name, float value);
void fx_order(int pass, unsigned priority);
unsigned fx_program(int pass);
int ui_fx(int pass);
int ui_fxs();
void* screenshot(int components);
void* screenshot_async(int components);
2024-07-29 13:17:47 +00:00
void ddraw_line_width(float width);
void ddraw_line_width_push(float scale);
void ddraw_line_width_pop();
2024-07-25 06:11:55 +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);
int gizmo(vec3 *pos, vec3 *rot, vec3 *sca);
bool gizmo_active();
bool gizmo_hover();
typedef struct camera_t {
mat44 view, proj;
2024-09-03 22:10:44 +00:00
vec3 position, updir, lookdir, rightdir;
2024-07-25 06:11:55 +00:00
float yaw, pitch, roll;
float speed, fov;
2024-08-30 10:19:50 +00:00
float near_clip, far_clip;
2024-09-03 09:41:33 +00:00
float frustum_fov_multiplier;
2024-07-25 06:11:55 +00:00
float move_friction, move_damping;
float look_friction, look_damping;
vec3 last_look; vec3 last_move;
bool damping;
bool orthographic;
float distance;
} camera_t;
camera_t camera();
void camera_teleport(camera_t *cam, vec3 pos);
void camera_moveby(camera_t *cam, vec3 inc);
void camera_fov(camera_t *cam, float fov);
void camera_fps(camera_t *cam, float yaw, float pitch);
void camera_fps2(camera_t *cam, float yaw, float pitch, float roll);
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);
2024-09-03 09:41:33 +00:00
frustum camera_frustum_build(camera_t *cam);
2024-07-25 06:11:55 +00:00
camera_t *camera_get_active();
int ui_camera(camera_t *cam);
void ddraw_camera(camera_t *cam);
typedef struct object_t {
uint64_t renderbucket;
mat44 transform;
quat rot;
vec3 sca, pos, euler, pivot;
2024-08-24 09:49:16 +00:00
texture_t* textures;
2024-07-25 06:11:55 +00:00
model_t model;
anim_t anim;
float anim_speed;
aabb bounds;
unsigned billboard;
bool disable_frustum_check;
2024-08-30 01:46:46 +00:00
bool cast_shadows;
handle* old_texture_ids;
texture_t* old_textures;
float distance;
bool skip_draw;
2024-07-25 06:11:55 +00:00
bool light_cached;
} 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);
void object_anim(object_t *obj, anim_t anim, float speed);
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);
enum SCENE_FLAGS {
SCENE_WIREFRAME = 1,
SCENE_CULLFACE = 2,
SCENE_BACKGROUND = 4,
SCENE_FOREGROUND = 8,
SCENE_UPDATE_SH_COEF = 16,
2024-08-30 01:46:46 +00:00
SCENE_CAST_SHADOWS = 32,
2024-07-25 06:11:55 +00:00
};
typedef struct scene_t {
object_t* objs;
light_t* lights;
skybox_t skybox;
int u_coefficients_sh;
2024-08-30 01:46:46 +00:00
shadowmap_t shadowmap;
2024-07-25 06:11:55 +00:00
} scene_t;
scene_t* scene_push();
void scene_pop();
scene_t* scene_get_active();
int scene_merge(const char *source);
void scene_render(int flags);
object_t* scene_spawn();
unsigned scene_count();
object_t* scene_index(unsigned index);
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);
const char * strstri(const char *src, const char *sub);
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);
const char * strlerp(unsigned numpairs, const char **pairs, const char *str);
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);
uint32_t* string32( const char *utf8 );
const char* codepoint_to_utf8(unsigned cp);
unsigned intern( const char *string );
const char *quark( unsigned key );
typedef struct quarks_db {
char* blob;
vec2i* entries;
} quarks_db;
unsigned quark_intern( quarks_db*, const char *string );
const char *quark_string( quarks_db*, unsigned key );
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 );
char* kit_translate2( const char *id, const char *langcode_iso639_1 );
void kit_locale( const char *langcode_iso639_1 );
char* kit_translate( const char *id );
typedef enum SPRITE_FLAGS {
SPRITE_PROJECTED = 1,
SPRITE_ADDITIVE = 2,
SPRITE_CENTERED = 4,
SPRITE_RESOLUTION_INDEPENDANT = 128,
} 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 {
texture_t tex;
unsigned tile_w, tile_h;
unsigned cols, rows;
unsigned selected;
} tileset_t;
tileset_t tileset(texture_t tex, unsigned tile_w, unsigned tile_h, unsigned cols, unsigned rows);
int ui_tileset( tileset_t t );
typedef struct tilemap_t {
int blank_chr;
unsigned cols, rows;
int* map;
vec3 position;
float zindex;
float tilt;
unsigned tint;
bool is_additive;
} tilemap_t;
tilemap_t tilemap(const char *map, int blank_chr, int linefeed_chr);
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 );
typedef struct tiled_t {
char *map_name;
unsigned first_gid, tilew, tileh, w, h;
bool parallax;
vec3 position;
bool* visible;
tilemap_t* layers;
tileset_t* sets;
char** names;
} tiled_t;
tiled_t tiled(const char *file_tmx);
void tiled_render(tiled_t tmx, vec3 pos);
void ui_tiled(tiled_t *t);
typedef struct spine_t spine_t;
spine_t*spine(const char *file_json, const char *file_atlas, unsigned flags);
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);
typedef struct atlas_frame_t {
unsigned delay;
vec4 sheet;
vec2 anchor;
vec3i* indices;
vec2* coords;
vec2* uvs;
} atlas_frame_t;
typedef struct atlas_anim_t {
unsigned name;
unsigned* frames;
} atlas_anim_t;
typedef struct atlas_slice_frame_t {
vec4 bounds;
bool has_9slice;
vec4 core;
vec2 pivot;
unsigned color;
char *text;
} atlas_slice_frame_t;
typedef struct atlas_slice_t {
unsigned name;
unsigned* frames;
} atlas_slice_t;
typedef struct atlas_t {
texture_t tex;
atlas_frame_t* frames;
atlas_anim_t* anims;
atlas_slice_t* slices;
atlas_slice_frame_t* slice_frames;
quarks_db db;
} atlas_t;
atlas_t atlas_create(const char *inifile, unsigned flags);
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;
} sprite_t;
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);
sprite_t*sprite_new(const char *ase, int bindings[6]);
void sprite_del(sprite_t *s);
void sprite_setanim(sprite_t *s, unsigned name);
typedef struct guiskin_t {
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;
} guiskin_t;
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();
typedef struct skinned_t {
atlas_t atlas;
float scale;
} skinned_t;
guiskin_t gui_skinned(const char *asefile, float scale);
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);
const char* option(const char *commalist, const char *defaults);
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();
const char* app_exec(const char *command);
int app_spawn(const char *command);
int app_cores();
int app_battery();
const char* app_name();
const char* app_path();
const char* app_cache();
const char* app_temp();
const char* app_cmdline();
void app_beep();
void app_hang();
void app_crash();
void app_singleton(const char *guid);
bool app_open(const char *folder_file_or_url);
const char* app_loadfile();
const char* app_savefile();
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);
const char *trap_name(int signal);
void trap_on_ignore(int signal);
void trap_on_quit(int signal);
void trap_on_abort(int signal);
void trap_on_debug(int signal);
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);
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);
typedef vec3i guid;
guid guid_create();
float ease_zero(float t);
float ease_one(float t);
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 {
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
};
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 {
float t;
vec3 v;
unsigned ease;
} tween_keyframe_t;
typedef struct tween_t {
tween_keyframe_t* keyframes;
vec3 result;
float time;
float duration;
} tween_t;
tween_t tween();
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);
typedef struct curve_t {
float* lengths;
unsigned* colors;
vec3* samples;
vec3* points;
int* indices;
} curve_t;
curve_t curve();
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);
enum PANEL_FLAGS {
PANEL_OPEN = 1,
};
int ui_notify(const char *title, const char *body);
int ui_window(const char *title, int *enabled);
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);
2024-08-31 10:17:59 +00:00
int ui_float_(const char *label, float *value, float step);
int ui_float2_(const char *label, float value[2], float step);
int ui_float3_(const char *label, float value[3], float step);
int ui_float4_(const char *label, float value[4], float step);
2024-07-25 06:11:55 +00:00
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();
2024-08-31 10:17:59 +00:00
int ui_clampf_(const char *label, float *value, float minf, float maxf, float step);
2024-07-25 06:11:55 +00:00
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();
int ui_window_end();
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);
vec2 ui_get_dims();
int ui_enable();
int ui_enabled();
int ui_disable();
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);
void *ui_handle();
enum VIDEO_FLAGS {
VIDEO_YCBCR = 0,
VIDEO_RGB = 2,
VIDEO_AUDIO = 0,
VIDEO_NO_AUDIO = 4,
VIDEO_LOOP = 8,
};
typedef struct video_t video_t;
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);
enum WINDOW_FLAGS {
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-08-15 17:49:41 +00:00
WINDOW_TRUE_BORDERLESS = 0x4000,
2024-07-25 06:11:55 +00:00
WINDOW_VSYNC_DISABLED = 0,
WINDOW_VSYNC_ADAPTIVE = 0x1000,
WINDOW_VSYNC = 0x2000,
};
bool window_create(float scale, unsigned flags);
bool window_create_from_handle(void *handle, float scale, unsigned flags);
2024-08-16 09:27:47 +00:00
void window_destroy();
2024-07-25 06:11:55 +00:00
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);
char window_msaa();
2024-07-25 06:11:55 +00:00
vec2 window_canvas();
void* window_handle();
char* window_stats();
uint64_t window_frame();
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();
void window_debug(int visible);
int window_has_debug();
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();
2024-07-31 11:54:29 +00:00
void window_fps_vsync(int vsync);
2024-07-25 06:11:55 +00:00
void window_screenshot(const char* outfile_png);
int window_record(const char *outfile_mp4);
vec2 window_dpi();
enum CURSOR_SHAPES {
CURSOR_NONE,
CURSOR_HW_ARROW,
CURSOR_HW_IBEAM,
CURSOR_HW_HDRAG,
CURSOR_HW_VDRAG,
CURSOR_HW_HAND,
CURSOR_HW_CROSS,
CURSOR_SW_AUTO,
};
void window_cursor_shape(unsigned shape);
const char *window_clipboard();
void window_setclipboard(const char *text);
typedef struct editor_bind_t {
const char *command;
const char *bindings;
void (*fn)();
} editor_bind_t;
void editor_addbind(editor_bind_t bind);
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);;
void editor_destroy_properties(void *o);
void editor_load_on_boot(void);
void editor_save_on_quit(void);
enum EDITOR_MODE {
EDITOR_PANEL,
EDITOR_WINDOW,
EDITOR_WINDOW_NK,
EDITOR_WINDOW_NK_SMALL,
};
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);
vec3 editor_pick(float mouse_x, float mouse_y);
char* editor_path(const char *path);
void editor_setmouse(int x, int y);
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);
void editor_gizmos(int dim);
int editor_send(const char *cmd);
const char* editor_recv(int jobid, double timeout_ss);
void editor_pump();
void editor_frame( void (*game)(unsigned, float, double) );
float* engine_getf(const char *key);
int* engine_geti(const char *key);
char** engine_gets(const char *key);
int engine_send(const char *cmd, const char *optional_value);
int ui_engine();
]])
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
local v4k = ffi.load("v4k")
return setmetatable( _M, {
__index = function( table, key )
return v4k[ key ]
end
} )