From e0f3985b00841098d17affd5981068f55db53ca6 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Fri, 12 May 2023 18:22:05 +0000 Subject: [PATCH] shaders --- source/engine/2dphysics.c | 760 +- source/engine/2dphysics.h | 66 +- source/engine/3d/3dphysics.h | 1 - source/engine/3d/3pfollow.c | 94 +- source/engine/3d/3pfollow.h | 74 +- source/engine/3d/light.c | 77 +- source/engine/3d/light.h | 16 +- source/engine/3d/mesh.c | 188 +- source/engine/3d/mesh.h | 32 +- source/engine/3d/model.c | 408 +- source/engine/3d/model.h | 12 +- source/engine/3d/skybox.c | 129 +- source/engine/3d/skybox.h | 10 +- source/engine/HandmadeMath.h | 3553 ++++++ source/engine/KHR/khrplatform.h | 311 - source/engine/anim.c | 48 +- source/engine/anim.h | 11 +- source/engine/camera.c | 130 +- source/engine/camera.h | 8 +- source/engine/config.h | 3 +- source/engine/datastream.c | 295 +- source/engine/datastream.h | 22 +- source/engine/debug/debugdraw.c | 305 +- source/engine/debug/debugdraw.h | 4 +- source/engine/editor/editor.h | 2 +- source/engine/engine.c | 57 +- source/engine/ffi.c | 1985 ++- source/engine/font.c | 526 +- source/engine/font.h | 26 +- source/engine/gameobject.c | 440 +- source/engine/gameobject.h | 40 +- source/engine/glad/gl.c | 2254 ++-- source/engine/glad/gl.h | 1997 ++- source/engine/input.c | 710 +- source/engine/input.h | 9 +- source/engine/level.c | 60 +- source/engine/level.h | 3 +- source/engine/mathc.c | 10632 +++++++--------- source/engine/mathc.h | 2677 ++-- source/engine/nuke.c | 134 +- source/engine/nuke.h | 8 + source/engine/openglrender.c | 305 +- source/engine/openglrender.h | 7 + source/engine/parson.c | 3825 +++--- source/engine/parson.h | 161 +- source/engine/particle.c | 88 +- source/engine/resources.c | 162 +- source/engine/resources.h | 2 - source/engine/script.c | 138 +- source/engine/shader.c | 175 +- source/engine/shader.h | 6 +- source/engine/sound.c | 373 +- source/engine/sprite.c | 339 +- source/engine/texture.c | 343 +- source/engine/thirdparty/Nuklear/nuklear.h | 73 +- .../thirdparty/Nuklear/nuklear_glfw_gl3.h | 500 - source/engine/thirdparty/sokol/sokol_color.h | 1148 ++ .../engine/thirdparty/sokol/sokol_debugtext.h | 4644 +++++++ .../engine/thirdparty/sokol/sokol_fontstash.h | 1904 +++ .../engine/thirdparty/sokol/sokol_gfx_imgui.h | 4226 ++++++ source/engine/thirdparty/sokol/sokol_gl.h | 4318 +++++++ source/engine/thirdparty/sokol/sokol_imgui.h | 2457 ++++ .../engine/thirdparty/sokol/sokol_memtrack.h | 167 + .../engine/thirdparty/sokol/sokol_nuklear.h | 2180 ++++ source/engine/thirdparty/sokol/sokol_shape.h | 1437 +++ source/engine/thirdparty/sokol/sokol_spine.h | 5759 +++++++++ source/engine/timer.c | 104 +- source/engine/tinyspline.c | 4668 ++++--- source/engine/transform.c | 56 +- source/engine/window.c | 421 +- source/engine/yugine.c | 305 +- source/shaders/3d/shadowfrag.glsl | 6 - source/shaders/circlefrag.glsl | 19 +- source/shaders/circlevert.glsl | 17 +- source/shaders/crtfrag.glsl | 26 + source/shaders/diffuse_f.glsl | 104 + source/shaders/diffuse_v.glsl | 23 + source/shaders/gridfrag.glsl | 28 +- source/shaders/gridvert.glsl | 11 +- source/shaders/linefrag.glsl | 4 +- source/shaders/linevert.glsl | 8 +- source/shaders/shadowfrag.glsl | 8 + source/shaders/{3d => }/shadowvert.glsl | 0 source/shaders/textfrag.glsl | 7 +- 84 files changed, 49281 insertions(+), 19388 deletions(-) create mode 100644 source/engine/HandmadeMath.h delete mode 100644 source/engine/KHR/khrplatform.h delete mode 100644 source/engine/thirdparty/Nuklear/nuklear_glfw_gl3.h create mode 100644 source/engine/thirdparty/sokol/sokol_color.h create mode 100644 source/engine/thirdparty/sokol/sokol_debugtext.h create mode 100644 source/engine/thirdparty/sokol/sokol_fontstash.h create mode 100644 source/engine/thirdparty/sokol/sokol_gfx_imgui.h create mode 100644 source/engine/thirdparty/sokol/sokol_gl.h create mode 100644 source/engine/thirdparty/sokol/sokol_imgui.h create mode 100644 source/engine/thirdparty/sokol/sokol_memtrack.h create mode 100644 source/engine/thirdparty/sokol/sokol_nuklear.h create mode 100644 source/engine/thirdparty/sokol/sokol_shape.h create mode 100644 source/engine/thirdparty/sokol/sokol_spine.h delete mode 100644 source/shaders/3d/shadowfrag.glsl create mode 100644 source/shaders/crtfrag.glsl create mode 100644 source/shaders/diffuse_f.glsl create mode 100644 source/shaders/diffuse_v.glsl create mode 100644 source/shaders/shadowfrag.glsl rename source/shaders/{3d => }/shadowvert.glsl (100%) diff --git a/source/engine/2dphysics.c b/source/engine/2dphysics.c index a2a7a82..32db9cc 100644 --- a/source/engine/2dphysics.c +++ b/source/engine/2dphysics.c @@ -1,23 +1,23 @@ #include "2dphysics.h" +#include "debug.h" #include "gameobject.h" -#include #include "mathc.h" #include "nuke.h" -#include "debug.h" +#include #include "debugdraw.h" -#include -#include #include "stb_ds.h" #include +#include +#include #include "2dphysics.h" #include "tinyspline.h" -#include "script.h" #include "ffi.h" +#include "script.h" #include "log.h" @@ -27,49 +27,44 @@ float phys2d_gravity = -50.f; float dbg_color[3] = {0.836f, 1.f, 0.45f}; float trigger_color[3] = {0.278f, 0.953f, 1.f}; float disabled_color[3] = {0.58f, 0.58f, 0.58f}; -float dynamic_color[3] = {255/255, 70/255, 46/255}; -float kinematic_color[3] = {255/255, 206/255,71/255}; +float dynamic_color[3] = {255 / 255, 70 / 255, 46 / 255}; +float kinematic_color[3] = {255 / 255, 206 / 255, 71 / 255}; float static_color[3] = {0.22f, 0.271f, 1.f}; unsigned int category_masks[32]; -void set_cat_mask(int cat, unsigned int mask) -{ +void set_cat_mask(int cat, unsigned int mask) { category_masks[cat] = mask; } -void color2float(struct color color, float *fcolor) -{ - fcolor[0] = (float)color.r/255; - fcolor[1] = (float)color.g/255; - fcolor[2] = (float)color.b/255; +void color2float(struct color color, float *fcolor) { + fcolor[0] = (float)color.r / 255; + fcolor[1] = (float)color.g / 255; + fcolor[2] = (float)color.b / 255; } -struct color float2color(float *fcolor) -{ - struct color new; - new.r = fcolor[0]*255; - new.b = fcolor[1]*255; - new.g = fcolor[2]*255; - return new; +struct color float2color(float *fcolor) { + struct color new; + new.r = fcolor[0] * 255; + new.b = fcolor[1] * 255; + new.g = fcolor[2] * 255; + return new; } -cpShape *phys2d_query_pos(cpVect pos) -{ +cpShape *phys2d_query_pos(cpVect pos) { cpShapeFilter filter; filter.group = CP_NO_GROUP; filter.mask = CP_ALL_CATEGORIES; filter.categories = CP_ALL_CATEGORIES; cpShape *find = cpSpacePointQueryNearest(space, pos, 0.f, filter, NULL); -// cpShape *find = cpSpaceSegmentQueryFirst(space, pos, pos, 0.f, filter, NULL); + // cpShape *find = cpSpaceSegmentQueryFirst(space, pos, pos, 0.f, filter, NULL); return find; } int *qhits; -void querylist(cpShape *shape, cpContactPointSet *points, void *data) -{ +void querylist(cpShape *shape, cpContactPointSet *points, void *data) { int go = shape2gameobject(shape); int in = 0; for (int i = 0; i < arrlen(qhits); i++) { @@ -82,27 +77,25 @@ void querylist(cpShape *shape, cpContactPointSet *points, void *data) if (!in) arrput(qhits, go); } -void querylistbodies(cpBody *body, void *data) -{ - cpBB *bbox = data; +void querylistbodies(cpBody *body, void *data) { + cpBB *bbox = data; if (cpBBContainsVect(*bbox, cpBodyGetPosition(body))) { int go = body2id(body); if (go < 0) return; - + int in = 0; for (int i = 0; i < arrlen(qhits); i++) { if (qhits[i] == go) { in = 1; - break; + break; } } - + if (!in) arrput(qhits, go); } } -int *phys2d_query_box_points(cpVect pos, cpVect wh, cpVect *points, int n) -{ +int *phys2d_query_box_points(cpVect pos, cpVect wh, cpVect *points, int n) { cpShape *box = cpBoxShapeNew(NULL, wh.x, wh.y, 0.f); cpTransform T = {0}; T.a = 1; @@ -110,21 +103,20 @@ int *phys2d_query_box_points(cpVect pos, cpVect wh, cpVect *points, int n) T.tx = pos.x; T.ty = pos.y; cpShapeUpdate(box, T); - + cpBB bbox = cpShapeGetBB(box); - + if (qhits) arrfree(qhits); for (int i = 0; i < n; i++) { if (cpBBContainsVect(bbox, points[i])) arrpush(qhits, i); } - + return qhits; } -int *phys2d_query_box(cpVect pos, cpVect wh) -{ +int *phys2d_query_box(cpVect pos, cpVect wh) { cpShape *box = cpBoxShapeNew(NULL, wh.x, wh.y, 0.f); cpTransform T = {0}; T.a = 1; @@ -132,152 +124,138 @@ int *phys2d_query_box(cpVect pos, cpVect wh) T.tx = pos.x; T.ty = pos.y; cpShapeUpdate(box, T); - + cpBB bbox = cpShapeGetBB(box); if (qhits) arrfree(qhits); - + cpSpaceShapeQuery(space, box, querylist, NULL); cpSpaceEachBody(space, querylistbodies, &bbox); - + cpShapeFree(box); - + return qhits; } -int *phys2d_query_shape(struct phys2d_shape *shape) -{ +int *phys2d_query_shape(struct phys2d_shape *shape) { if (qhits) arrfree(qhits); - + cpSpaceShapeQuery(space, shape->shape, querylist, NULL); - + return qhits; } -int cpshape_enabled(cpShape *c) -{ - cpShapeFilter filter = cpShapeGetFilter(c); - if (filter.categories == ~CP_ALL_CATEGORIES && filter.mask == ~CP_ALL_CATEGORIES) - return 0; +int cpshape_enabled(cpShape *c) { + cpShapeFilter filter = cpShapeGetFilter(c); + if (filter.categories == ~CP_ALL_CATEGORIES && filter.mask == ~CP_ALL_CATEGORIES) + return 0; - return 1; + return 1; } -float *shape_outline_color(cpShape *shape) -{ - switch (cpBodyGetType(cpShapeGetBody(shape))) { - case CP_BODY_TYPE_DYNAMIC: - return dynamic_color; +float *shape_outline_color(cpShape *shape) { + switch (cpBodyGetType(cpShapeGetBody(shape))) { + case CP_BODY_TYPE_DYNAMIC: + return dynamic_color; - case CP_BODY_TYPE_KINEMATIC: - return kinematic_color; - - case CP_BODY_TYPE_STATIC: - return static_color; - } + case CP_BODY_TYPE_KINEMATIC: + return kinematic_color; + case CP_BODY_TYPE_STATIC: return static_color; + } + + return static_color; } -float *shape_color(cpShape *shape) -{ - if (!cpshape_enabled(shape)) return disabled_color; +float *shape_color(cpShape *shape) { + if (!cpshape_enabled(shape)) return disabled_color; - if (cpShapeGetSensor(shape)) return trigger_color; + if (cpShapeGetSensor(shape)) return trigger_color; - return dbg_color; + return dbg_color; } -struct color shape_color_s(cpShape *shape) -{ +struct color shape_color_s(cpShape *shape) { float *c = shape_color(shape); struct color col; - col.r = c[0]*255; - col.g = c[1]*255; - col.b = c[2]*255; + col.r = c[0] * 255; + col.g = c[1] * 255; + col.b = c[2] * 255; return col; } -void phys2d_init() -{ - space = cpSpaceNew(); - cpVect grav = {0, phys2d_gravity}; - phys2d_set_gravity(grav); - cpSpaceSetGravity(space, cpv(0, phys2d_gravity)); +void phys2d_init() { + space = cpSpaceNew(); + cpVect grav = {0, phys2d_gravity}; + phys2d_set_gravity(grav); + cpSpaceSetGravity(space, cpv(0, phys2d_gravity)); } void phys2d_set_gravity(cpVect v) { - YughInfo("Set gravity to %g %g", v.x, v.y); - cpSpaceSetGravity(space, v); + YughInfo("Set gravity to %g %g", v.x, v.y); + cpSpaceSetGravity(space, v); } -void phys2d_update(float deltaT) -{ - cpSpaceStep(space, deltaT); +void phys2d_update(float deltaT) { + cpSpaceStep(space, deltaT); } -void init_phys2dshape(struct phys2d_shape *shape, int go, void *data) -{ - shape->go = go; - shape->data = data; - go_shape_apply(id2go(go)->body, shape->shape, id2go(go)); - cpShapeSetCollisionType(shape->shape, go); - cpShapeSetUserData(shape->shape, shape); +void init_phys2dshape(struct phys2d_shape *shape, int go, void *data) { + shape->go = go; + shape->data = data; + go_shape_apply(id2go(go)->body, shape->shape, id2go(go)); + cpShapeSetCollisionType(shape->shape, go); + cpShapeSetUserData(shape->shape, shape); } -void phys2d_shape_del(struct phys2d_shape *shape) -{ - if (!shape->shape) return; - cpSpaceRemoveShape(space, shape->shape); - cpShapeFree(shape->shape); +void phys2d_shape_del(struct phys2d_shape *shape) { + if (!shape->shape) return; + cpSpaceRemoveShape(space, shape->shape); + cpShapeFree(shape->shape); } /***************** CIRCLE2D *****************/ -struct phys2d_circle *Make2DCircle(int go) -{ - struct phys2d_circle *new = malloc(sizeof(struct phys2d_circle)); +struct phys2d_circle *Make2DCircle(int go) { + struct phys2d_circle *new = malloc(sizeof(struct phys2d_circle)); - new->radius = 10.f; - new->offset = cpvzero; + new->radius = 10.f; + new->offset = cpvzero; - new->shape.shape = cpSpaceAddShape(space, cpCircleShapeNew(id2go(go)->body, new->radius, cpvzero)); - new->shape.debugdraw = phys2d_dbgdrawcircle; - new->shape.moi = phys2d_circle_moi; - init_phys2dshape(&new->shape, go, new); + new->shape.shape = cpSpaceAddShape(space, cpCircleShapeNew(id2go(go)->body, new->radius, cpvzero)); + new->shape.debugdraw = phys2d_dbgdrawcircle; + new->shape.moi = phys2d_circle_moi; + init_phys2dshape(&new->shape, go, new); - return new; + return new; } -float phys2d_circle_moi(struct phys2d_circle *c, float m) -{ +float phys2d_circle_moi(struct phys2d_circle *c, float m) { return cpMomentForCircle(m, 0, c->radius, c->offset); } -void phys2d_circledel(struct phys2d_circle *c) -{ - phys2d_shape_del(&c->shape); +void phys2d_circledel(struct phys2d_circle *c) { + phys2d_shape_del(&c->shape); } -cpVect world2go(struct gameobject *go, cpVect worldpos) -{ +cpVect world2go(struct gameobject *go, cpVect worldpos) { cpTransform T = {0}; cpVect pos = cpBodyGetPosition(go->body); worldpos.x -= pos.x; worldpos.y -= pos.y; -// worldpos.x /= go->scale; -// worldpos.y /= go->scale; + // worldpos.x /= go->scale; + // worldpos.y /= go->scale; float angle = cpBodyGetAngle(go->body); T.a = go->flipx * cos(-angle) / go->scale; T.b = sin(-angle) / go->scale; T.c = -sin(-angle) / go->scale; T.d = go->flipy * cos(-angle) / go->scale; - worldpos = cpTransformPoint(T,worldpos); + worldpos = cpTransformPoint(T, worldpos); return worldpos; } -cpVect go2world(struct gameobject *go, cpVect gopos) -{ +cpVect go2world(struct gameobject *go, cpVect gopos) { cpVect pos = cpBodyGetPosition(go->body); float angle = cpBodyGetAngle(go->body); cpTransform T = {0}; @@ -290,72 +268,64 @@ cpVect go2world(struct gameobject *go, cpVect gopos) return cpTransformPoint(T, gopos); } -cpVect gotransformpoint(struct gameobject *go, cpVect point) -{ +cpVect gotransformpoint(struct gameobject *go, cpVect point) { point.x *= go->scale * go->flipx; point.y *= go->scale * go->flipy; return point; } -cpVect bodytransformpoint(cpBody *body, cpVect offset) -{ +cpVect bodytransformpoint(cpBody *body, cpVect offset) { cpVect pos = cpBodyGetPosition(body); float d = sqrt(pow(offset.x, 2.f) + pow(offset.y, 2.f)); float a = atan2(offset.y, offset.x) + cpBodyGetAngle(body); - pos.x += d*cos(a); - pos.y += d*sin(a); + pos.x += d * cos(a); + pos.y += d * sin(a); return pos; } -void phys2d_dbgdrawcpcirc(cpCircleShape *c) -{ - cpVect pos = bodytransformpoint(cpShapeGetBody(c), cpCircleShapeGetOffset(c)); - float radius = cpCircleShapeGetRadius(c); - draw_circle(pos.x, pos.y, radius, 2, shape_color(c), 1); +void phys2d_dbgdrawcpcirc(cpCircleShape *c) { + cpVect pos = bodytransformpoint(cpShapeGetBody(c), cpCircleShapeGetOffset(c)); + float radius = cpCircleShapeGetRadius(c); + draw_circle(pos.x, pos.y, radius, 2, shape_color(c), 1); } -void phys2d_dbgdrawcircle(struct phys2d_circle *circle) -{ - phys2d_dbgdrawcpcirc((cpCircleShape *)circle->shape.shape); +void phys2d_dbgdrawcircle(struct phys2d_circle *circle) { + phys2d_dbgdrawcpcirc((cpCircleShape *)circle->shape.shape); } -void phys2d_applycircle(struct phys2d_circle *circle) -{ - struct gameobject *go = id2go(circle->shape.go); +void phys2d_applycircle(struct phys2d_circle *circle) { + struct gameobject *go = id2go(circle->shape.go); - float radius = circle->radius * go->scale; - cpVect offset = gotransformpoint(go, circle->offset); + float radius = circle->radius * go->scale; + cpVect offset = gotransformpoint(go, circle->offset); - cpCircleShapeSetRadius(circle->shape.shape, radius); - cpCircleShapeSetOffset(circle->shape.shape, offset); + cpCircleShapeSetRadius(circle->shape.shape, radius); + cpCircleShapeSetOffset(circle->shape.shape, offset); } /************* BOX2D ************/ -struct phys2d_box *Make2DBox(int go) -{ - struct phys2d_box *new = malloc(sizeof(struct phys2d_box)); +struct phys2d_box *Make2DBox(int go) { + struct phys2d_box *new = malloc(sizeof(struct phys2d_box)); - new->w = 50.f; - new->h = 50.f; - new->r = 0.f; - new->offset[0] = 0.f; - new->offset[1] = 0.f; - new->shape.go = go; - phys2d_applybox(new); - new->shape.debugdraw = phys2d_dbgdrawbox; - new->shape.moi = phys2d_box_moi; + new->w = 50.f; + new->h = 50.f; + new->r = 0.f; + new->offset[0] = 0.f; + new->offset[1] = 0.f; + new->shape.go = go; + phys2d_applybox(new); + new->shape.debugdraw = phys2d_dbgdrawbox; + new->shape.moi = phys2d_box_moi; - return new; + return new; } -float phys2d_box_moi(struct phys2d_box *box, float m) -{ +float phys2d_box_moi(struct phys2d_box *box, float m) { return cpMomentForBox(m, box->w, box->h); } -cpTransform go2transform(struct gameobject *go, cpVect offset, float angle) -{ +cpTransform go2transform(struct gameobject *go, cpVect offset, float angle) { cpTransform T = {0}; T.a = cos(angle) * go->scale * go->flipx; T.b = -sin(angle) * go->scale * go->flipx; @@ -366,386 +336,344 @@ cpTransform go2transform(struct gameobject *go, cpVect offset, float angle) return T; } -void phys2d_boxdel(struct phys2d_box *box) -{ - phys2d_shape_del(&box->shape); +void phys2d_boxdel(struct phys2d_box *box) { + phys2d_shape_del(&box->shape); } -void phys2d_applybox(struct phys2d_box *box) -{ - phys2d_boxdel(box); - struct gameobject *go = id2go(box->shape.go); - cpVect off; - off.x = box->offset[0]; - off.y = box->offset[1]; - cpTransform T = go2transform(id2go(box->shape.go), off, box->rotation); - float hh = box->h / 2.f; - float hw = box->w / 2.f; - cpVect verts[4] = { { -hw, -hh }, { hw, -hh }, { hw, hh }, { -hw, hh } }; - box->shape.shape = cpSpaceAddShape(space, cpPolyShapeNew(go->body, 4, verts, T, box->r)); - init_phys2dshape(&box->shape, box->shape.go, box); +void phys2d_applybox(struct phys2d_box *box) { + phys2d_boxdel(box); + struct gameobject *go = id2go(box->shape.go); + cpVect off; + off.x = box->offset[0]; + off.y = box->offset[1]; + cpTransform T = go2transform(id2go(box->shape.go), off, box->rotation); + float hh = box->h / 2.f; + float hw = box->w / 2.f; + cpVect verts[4] = {{-hw, -hh}, {hw, -hh}, {hw, hh}, {-hw, hh}}; + box->shape.shape = cpSpaceAddShape(space, cpPolyShapeNew(go->body, 4, verts, T, box->r)); + init_phys2dshape(&box->shape, box->shape.go, box); } -void phys2d_dbgdrawbox(struct phys2d_box *box) -{ - int n = cpPolyShapeGetCount(box->shape.shape); - float points[n * 2]; - - for (int i = 0; i < n; i++) { - cpVect p = bodytransformpoint(cpShapeGetBody(box->shape.shape), cpPolyShapeGetVert(box->shape.shape, i)); - points[i*2] = p.x; - points[i*2+1] = p.y; - } +void phys2d_dbgdrawbox(struct phys2d_box *box) { + int n = cpPolyShapeGetCount(box->shape.shape); + cpVect points[n * 2]; - draw_poly(points, n, shape_color(box->shape.shape)); + for (int i = 0; i < n; i++) + points[i] = bodytransformpoint(cpShapeGetBody(box->shape.shape), cpPolyShapeGetVert(box->shape.shape, i)); + + draw_poly(points, n, shape_color(box->shape.shape)); } /************** POLYGON ************/ -struct phys2d_poly *Make2DPoly(int go) -{ - struct phys2d_poly *new = malloc(sizeof(struct phys2d_poly)); +struct phys2d_poly *Make2DPoly(int go) { + struct phys2d_poly *new = malloc(sizeof(struct phys2d_poly)); - new->points = NULL; - arrsetlen(new->points, 0); - new->radius = 0.f; + new->points = NULL; + arrsetlen(new->points, 0); + new->radius = 0.f; - new->shape.shape = cpSpaceAddShape(space, cpPolyShapeNewRaw(id2go(go)->body, 0, new->points, new->radius)); - new->shape.debugdraw = phys2d_dbgdrawpoly; - new->shape.moi = phys2d_poly_moi; - init_phys2dshape(&new->shape, go, new); - return new; + new->shape.shape = cpSpaceAddShape(space, cpPolyShapeNewRaw(id2go(go)->body, 0, new->points, new->radius)); + new->shape.debugdraw = phys2d_dbgdrawpoly; + new->shape.moi = phys2d_poly_moi; + init_phys2dshape(&new->shape, go, new); + return new; } -float phys2d_poly_moi(struct phys2d_poly *poly, float m) -{ +float phys2d_poly_moi(struct phys2d_poly *poly, float m) { float moi = cpMomentForPoly(m, arrlen(poly->points), poly->points, cpvzero, poly->radius); if (moi <= 0) { YughError("Polygon MOI is negative. Returning one;"); return 1; } - + return moi; } -void phys2d_polydel(struct phys2d_poly *poly) -{ - arrfree(poly->points); - phys2d_shape_del(&poly->shape); +void phys2d_polydel(struct phys2d_poly *poly) { + arrfree(poly->points); + phys2d_shape_del(&poly->shape); } -void phys2d_polyaddvert(struct phys2d_poly *poly) -{ - arrput(poly->points, cpvzero); +void phys2d_polyaddvert(struct phys2d_poly *poly) { + arrput(poly->points, cpvzero); } -void phys2d_poly_setverts(struct phys2d_poly *poly, cpVect *verts) -{ - if (!verts) return; - arrfree(poly->points); - poly->points = verts; - phys2d_applypoly(poly); +void phys2d_poly_setverts(struct phys2d_poly *poly, cpVect *verts) { + if (!verts) return; + arrfree(poly->points); + poly->points = verts; + phys2d_applypoly(poly); } -void phys2d_applypoly(struct phys2d_poly *poly) -{ - if (arrlen(poly->points) <= 0) return; - struct gameobject *go = id2go(poly->shape.go); - - cpTransform T = go2transform(go, cpvzero, 0); +void phys2d_applypoly(struct phys2d_poly *poly) { + if (arrlen(poly->points) <= 0) return; + struct gameobject *go = id2go(poly->shape.go); - cpPolyShapeSetVerts(poly->shape.shape, arrlen(poly->points), poly->points, T); - cpPolyShapeSetRadius(poly->shape.shape, poly->radius); - cpSpaceReindexShapesForBody(space, cpShapeGetBody(poly->shape.shape)); + cpTransform T = go2transform(go, cpvzero, 0); + + cpPolyShapeSetVerts(poly->shape.shape, arrlen(poly->points), poly->points, T); + cpPolyShapeSetRadius(poly->shape.shape, poly->radius); + cpSpaceReindexShapesForBody(space, cpShapeGetBody(poly->shape.shape)); } -void phys2d_dbgdrawpoly(struct phys2d_poly *poly) -{ - float *color = shape_color(poly->shape.shape); +void phys2d_dbgdrawpoly(struct phys2d_poly *poly) { + float *color = shape_color(poly->shape.shape); - if (arrlen(poly->points) >= 3) { - int n = cpPolyShapeGetCount(poly->shape.shape); - float points[n * 2]; + if (arrlen(poly->points) >= 3) { + int n = cpPolyShapeGetCount(poly->shape.shape); + cpVect points[n]; - for (int i = 0; i < n; i++) { - cpVect p = bodytransformpoint(cpShapeGetBody(poly->shape.shape), cpPolyShapeGetVert(poly->shape.shape, i)); - points[i*2] = p.x; - points[i*2+1] = p.y; - } - - draw_poly(points, n, color); - } + for (int i = 0; i < n; i++) + points[i] = bodytransformpoint(cpShapeGetBody(poly->shape.shape), cpPolyShapeGetVert(poly->shape.shape, i)); + draw_poly(points, n, color); + } } /****************** EDGE 2D**************/ -struct phys2d_edge *Make2DEdge(int go) -{ - struct phys2d_edge *new = malloc(sizeof(struct phys2d_edge)); - new->points = NULL; - arrsetlen(new->points, 0); - new->thickness = 0.f; - new->shapes = NULL; - arrsetlen(new->shapes, 0); - new->shape.go = go; - new->shape.data = new; - new->shape.debugdraw = phys2d_dbgdrawedge; - new->shape.moi = phys2d_edge_moi; - new->shape.shape = NULL; - phys2d_applyedge(new); +struct phys2d_edge *Make2DEdge(int go) { + struct phys2d_edge *new = malloc(sizeof(struct phys2d_edge)); + new->points = NULL; + arrsetlen(new->points, 0); + new->thickness = 0.f; + new->shapes = NULL; + arrsetlen(new->shapes, 0); + new->shape.go = go; + new->shape.data = new; + new->shape.debugdraw = phys2d_dbgdrawedge; + new->shape.moi = phys2d_edge_moi; + new->shape.shape = NULL; + phys2d_applyedge(new); - return new; + return new; } -float phys2d_edge_moi(struct phys2d_edge *edge, float m) -{ +float phys2d_edge_moi(struct phys2d_edge *edge, float m) { float moi = 0; - for (int i = 0; i < arrlen(edge->points)-1; i++) - moi += cpMomentForSegment(m, edge->points[i], edge->points[i+1], edge->thickness); + for (int i = 0; i < arrlen(edge->points) - 1; i++) + moi += cpMomentForSegment(m, edge->points[i], edge->points[i + 1], edge->thickness); return moi; } -void phys2d_edgedel(struct phys2d_edge *edge) -{ - phys2d_shape_del(&edge->shape); +void phys2d_edgedel(struct phys2d_edge *edge) { + phys2d_shape_del(&edge->shape); } -void phys2d_edgeaddvert(struct phys2d_edge *edge) -{ - arrput(edge->points, cpvzero); - if (arrlen(edge->points) > 1) - arrput(edge->shapes, cpSpaceAddShape(space, cpSegmentShapeNew(id2go(edge->shape.go)->body, cpvzero, cpvzero, edge->thickness))); +void phys2d_edgeaddvert(struct phys2d_edge *edge) { + arrput(edge->points, cpvzero); + if (arrlen(edge->points) > 1) + arrput(edge->shapes, cpSpaceAddShape(space, cpSegmentShapeNew(id2go(edge->shape.go)->body, cpvzero, cpvzero, edge->thickness))); + phys2d_applyedge(edge); +} + +void phys2d_edge_rmvert(struct phys2d_edge *edge, int index) { + assert(arrlen(edge->points) > index && index >= 0); + + arrdel(edge->points, index); + + if (arrlen(edge->points) == 0) return; + + if (index == 0) { + cpSpaceRemoveShape(space, edge->shapes[index]); + cpShapeFree(edge->shapes[index]); + arrdel(edge->shapes, index); phys2d_applyedge(edge); + return; + } + + if (index != arrlen(edge->points)) { + cpSegmentShapeSetEndpoints(edge->shapes[index - 1], edge->points[index - 1], edge->points[index]); + } + + cpSpaceRemoveShape(space, edge->shapes[index - 1]); + cpShapeFree(edge->shapes[index - 1]); + arrdel(edge->shapes, index - 1); + + phys2d_applyedge(edge); } -void phys2d_edge_rmvert(struct phys2d_edge *edge, int index) -{ - assert(arrlen(edge->points) > index && index >= 0); +void phys2d_edge_setvert(struct phys2d_edge *edge, int index, cpVect val) { + assert(arrlen(edge->points) > index && index >= 0); + edge->points[index] = val; - arrdel(edge->points, index); - - if (arrlen(edge->points) == 0) return; - - - if (index == 0) { - cpSpaceRemoveShape(space, edge->shapes[index]); - cpShapeFree(edge->shapes[index]); - arrdel(edge->shapes, index); - phys2d_applyedge(edge); - return; - } - - if (index != arrlen(edge->points)) { - cpSegmentShapeSetEndpoints(edge->shapes[index-1], edge->points[index-1], edge->points[index]); - } - - cpSpaceRemoveShape(space, edge->shapes[index-1]); - cpShapeFree(edge->shapes[index-1]); - arrdel(edge->shapes, index-1); - - phys2d_applyedge(edge); + phys2d_applyedge(edge); } -void phys2d_edge_setvert(struct phys2d_edge *edge, int index, cpVect val) -{ - assert(arrlen(edge->points) > index && index >= 0); - edge->points[index] = val; - - phys2d_applyedge(edge); -} - -void phys2d_edge_clearverts(struct phys2d_edge *edge) -{ - for (int i = arrlen(edge->points)-1; i>=0; i--) { +void phys2d_edge_clearverts(struct phys2d_edge *edge) { + for (int i = arrlen(edge->points) - 1; i >= 0; i--) { phys2d_edge_rmvert(edge, i); } } -void phys2d_edge_addverts(struct phys2d_edge *edge, cpVect *verts) -{ +void phys2d_edge_addverts(struct phys2d_edge *edge, cpVect *verts) { for (int i = 0; i < arrlen(verts); i++) { phys2d_edgeaddvert(edge); phys2d_edge_setvert(edge, i, verts[i]); } } -void phys2d_applyedge(struct phys2d_edge *edge) -{ - struct gameobject *go = id2go(edge->shape.go); - - for (int i = 0; i < arrlen(edge->shapes); i++) { - cpVect a = gotransformpoint(go, edge->points[i]); - cpVect b = gotransformpoint(go, edge->points[i+1]); - cpSegmentShapeSetEndpoints(edge->shapes[i], a, b); - cpSegmentShapeSetRadius(edge->shapes[i], edge->thickness); - if (i > 0 && i < arrlen(edge->shapes)-1) - cpSegmentShapeSetNeighbors(edge->shapes[i], gotransformpoint(go, edge->points[i-1]), gotransformpoint(go, edge->points[i+2])); - go_shape_apply(NULL, edge->shapes[i], go); - cpShapeSetUserData(edge->shapes[i], &edge->shape); - } +void phys2d_applyedge(struct phys2d_edge *edge) { + struct gameobject *go = id2go(edge->shape.go); - cpSpaceReindexShapesForBody(space, id2go(edge->shape.go)->body); + for (int i = 0; i < arrlen(edge->shapes); i++) { + cpVect a = gotransformpoint(go, edge->points[i]); + cpVect b = gotransformpoint(go, edge->points[i + 1]); + cpSegmentShapeSetEndpoints(edge->shapes[i], a, b); + cpSegmentShapeSetRadius(edge->shapes[i], edge->thickness); + if (i > 0 && i < arrlen(edge->shapes) - 1) + cpSegmentShapeSetNeighbors(edge->shapes[i], gotransformpoint(go, edge->points[i - 1]), gotransformpoint(go, edge->points[i + 2])); + go_shape_apply(NULL, edge->shapes[i], go); + cpShapeSetUserData(edge->shapes[i], &edge->shape); + } + + cpSpaceReindexShapesForBody(space, id2go(edge->shape.go)->body); } -void phys2d_dbgdrawedge(struct phys2d_edge *edge) -{ - edge->draws++; - if (edge->draws > 1) { - if (edge->draws >= arrlen(edge->shapes)) - edge->draws = 0; +void phys2d_dbgdrawedge(struct phys2d_edge *edge) { + edge->draws++; + if (edge->draws > 1) { + if (edge->draws >= arrlen(edge->shapes)) + edge->draws = 0; - return; - } + return; + } - if (arrlen(edge->shapes) < 1) return; + if (arrlen(edge->shapes) < 1) return; - cpVect drawpoints[arrlen(edge->points)]; - struct gameobject *go = id2go(edge->shape.go); + cpVect drawpoints[arrlen(edge->points)]; + struct gameobject *go = id2go(edge->shape.go); - for (int i = 0; i < arrlen(edge->points); i++) { - drawpoints[i] = gotransformpoint(go, edge->points[i]); - drawpoints[i] = bodytransformpoint(cpShapeGetBody(edge->shapes[0]), drawpoints[i]); - } + for (int i = 0; i < arrlen(edge->points); i++) { + drawpoints[i] = gotransformpoint(go, edge->points[i]); + drawpoints[i] = bodytransformpoint(cpShapeGetBody(edge->shapes[0]), drawpoints[i]); + } - draw_edge(drawpoints, arrlen(edge->points), shape_color_s(edge->shapes[0]), edge->thickness*2); - draw_points(drawpoints, arrlen(edge->points), 2, kinematic_color); + draw_edge(drawpoints, arrlen(edge->points), shape_color_s(edge->shapes[0]), edge->thickness * 2); + draw_points(drawpoints, arrlen(edge->points), 2, kinematic_color); } - /************ COLLIDER ****************/ -void shape_enabled(struct phys2d_shape *shape, int enabled) -{ - if (enabled) - cpShapeSetFilter(shape->data, CP_SHAPE_FILTER_ALL); - else - cpShapeSetFilter(shape->data, CP_SHAPE_FILTER_NONE); +void shape_enabled(struct phys2d_shape *shape, int enabled) { + if (enabled) + cpShapeSetFilter(shape->data, CP_SHAPE_FILTER_ALL); + else + cpShapeSetFilter(shape->data, CP_SHAPE_FILTER_NONE); } -int shape_is_enabled(struct phys2d_shape *shape) -{ - if (cpshape_enabled(shape->shape)) - return 1; +int shape_is_enabled(struct phys2d_shape *shape) { + if (cpshape_enabled(shape->shape)) + return 1; - return 0; + return 0; } -void shape_set_sensor(struct phys2d_shape *shape, int sensor) -{ - if (!shape->shape) { - struct phys2d_edge *edge = shape->data; - - for (int i = 0; i < arrlen(edge->shapes); i++) - cpShapeSetSensor(edge->shapes[i], sensor); - } else - cpShapeSetSensor(shape->shape, sensor); +void shape_set_sensor(struct phys2d_shape *shape, int sensor) { + if (!shape->shape) { + struct phys2d_edge *edge = shape->data; + + for (int i = 0; i < arrlen(edge->shapes); i++) + cpShapeSetSensor(edge->shapes[i], sensor); + } else + cpShapeSetSensor(shape->shape, sensor); } -int shape_get_sensor(struct phys2d_shape *shape) -{ - if (!shape->shape) { - return cpShapeGetSensor(((struct phys2d_edge *)(shape->data))->shapes[0]); - } - return cpShapeGetSensor(shape->shape); +int shape_get_sensor(struct phys2d_shape *shape) { + if (!shape->shape) { + return cpShapeGetSensor(((struct phys2d_edge *)(shape->data))->shapes[0]); + } + return cpShapeGetSensor(shape->shape); } void phys2d_reindex_body(cpBody *body) { - cpSpaceReindexShapesForBody(space, body); + cpSpaceReindexShapesForBody(space, body); } -void duk_call_phys_cb(cpVect norm, struct callee c, int hit, cpArbiter *arb) -{ - cpShape *shape1; - cpShape *shape2; - cpArbiterGetShapes(arb, &shape1, &shape2); - - JSValue obj = JS_NewObject(js); - JS_SetPropertyStr(js, obj, "normal", vec2js(norm)); - JS_SetPropertyStr(js, obj, "hit", JS_NewInt32(js, hit)); - JS_SetPropertyStr(js, obj, "sensor", JS_NewBool(js, cpShapeGetSensor(shape2))); - JS_SetPropertyStr(js, obj, "velocity", vec2js(cpArbiterGetSurfaceVelocity(arb))); - script_callee(c, 1, &obj); +void duk_call_phys_cb(cpVect norm, struct callee c, int hit, cpArbiter *arb) { + cpShape *shape1; + cpShape *shape2; + cpArbiterGetShapes(arb, &shape1, &shape2); + + JSValue obj = JS_NewObject(js); + JS_SetPropertyStr(js, obj, "normal", vec2js(norm)); + JS_SetPropertyStr(js, obj, "hit", JS_NewInt32(js, hit)); + JS_SetPropertyStr(js, obj, "sensor", JS_NewBool(js, cpShapeGetSensor(shape2))); + JS_SetPropertyStr(js, obj, "velocity", vec2js(cpArbiterGetSurfaceVelocity(arb))); + script_callee(c, 1, &obj); } #define CTYPE_BEGIN 0 #define CTYPE_SEP 1 -static cpBool handle_collision(cpArbiter *arb, int type) -{ - cpBody *body1; - cpBody *body2; - cpArbiterGetBodies(arb, &body1, &body2); - int g1 = (int)cpBodyGetUserData(body1); - int g2 = (int)cpBodyGetUserData(body2); - struct gameobject *go = id2go(g1); - struct gameobject *go2 = id2go(g2); +static cpBool handle_collision(cpArbiter *arb, int type) { + cpBody *body1; + cpBody *body2; + cpArbiterGetBodies(arb, &body1, &body2); + int g1 = (int)cpBodyGetUserData(body1); + int g2 = (int)cpBodyGetUserData(body2); + struct gameobject *go = id2go(g1); + struct gameobject *go2 = id2go(g2); - cpShape *shape1; - cpShape *shape2; - cpArbiterGetShapes(arb, &shape1, &shape2); - struct phys2d_shape *pshape1 = cpShapeGetUserData(shape1); - struct phys2d_shape *pshape2 = cpShapeGetUserData(shape2); + cpShape *shape1; + cpShape *shape2; + cpArbiterGetShapes(arb, &shape1, &shape2); + struct phys2d_shape *pshape1 = cpShapeGetUserData(shape1); + struct phys2d_shape *pshape2 = cpShapeGetUserData(shape2); - cpVect norm1 = cpArbiterGetNormal(arb); + cpVect norm1 = cpArbiterGetNormal(arb); - switch (type) { - case CTYPE_BEGIN: - for (int i = 0; i < arrlen(go->shape_cbs); i++) - if (go->shape_cbs[i].shape == pshape1) - duk_call_phys_cb(norm1, go->shape_cbs[i].cbs.begin, g2, arb); + switch (type) { + case CTYPE_BEGIN: + for (int i = 0; i < arrlen(go->shape_cbs); i++) + if (go->shape_cbs[i].shape == pshape1) + duk_call_phys_cb(norm1, go->shape_cbs[i].cbs.begin, g2, arb); - if (JS_IsObject(go->cbs.begin.obj)) - duk_call_phys_cb(norm1, go->cbs.begin, g2, arb); + if (JS_IsObject(go->cbs.begin.obj)) + duk_call_phys_cb(norm1, go->cbs.begin, g2, arb); - break; + break; - case CTYPE_SEP: - if (JS_IsObject(go->cbs.separate.obj)) { - YughWarn("Made it here; separate."); - duk_call_phys_cb(norm1, go->cbs.separate, g2, arb); - } - - break; - + case CTYPE_SEP: + if (JS_IsObject(go->cbs.separate.obj)) { + YughWarn("Made it here; separate."); + duk_call_phys_cb(norm1, go->cbs.separate, g2, arb); } - return 1; + break; + } + + return 1; } -static cpBool script_phys_cb_begin(cpArbiter *arb, cpSpace *space, void *data) -{ +static cpBool script_phys_cb_begin(cpArbiter *arb, cpSpace *space, void *data) { return handle_collision(arb, CTYPE_BEGIN); } -static cpBool script_phys_cb_separate(cpArbiter *arb, cpSpace *space, void *data) -{ +static cpBool script_phys_cb_separate(cpArbiter *arb, cpSpace *space, void *data) { return handle_collision(arb, CTYPE_SEP); } -void phys2d_rm_go_handlers(int go) -{ +void phys2d_rm_go_handlers(int go) { cpCollisionHandler *handler = cpSpaceAddWildcardHandler(space, go); handler->userData = NULL; handler->beginFunc = NULL; handler->separateFunc = NULL; } -void phys2d_setup_handlers(int go) -{ +void phys2d_setup_handlers(int go) { cpCollisionHandler *handler = cpSpaceAddWildcardHandler(space, go); - handler->userData = (void*)go; + handler->userData = (void *)go; handler->beginFunc = script_phys_cb_begin; handler->separateFunc = script_phys_cb_separate; } static int airborne = 0; -void inair(cpBody *body, cpArbiter *arbiter, void *data) -{ +void inair(cpBody *body, cpArbiter *arbiter, void *data) { airborne = 0; } -int phys2d_in_air(cpBody *body) -{ +int phys2d_in_air(cpBody *body) { airborne = 1; cpBodyEachArbiter(body, inair, NULL); diff --git a/source/engine/2dphysics.h b/source/engine/2dphysics.h index 50650b2..120b7c4 100644 --- a/source/engine/2dphysics.h +++ b/source/engine/2dphysics.h @@ -1,8 +1,8 @@ #ifndef TWODPHYSICS_H #define TWODPHYSICS_H -#include #include "script.h" +#include struct gameobject; @@ -18,53 +18,53 @@ extern float kinematic_color[3]; extern float static_color[3]; struct phys2d_shape { - cpShape *shape; - int go; - void *data; - void (*debugdraw)(void *data); - float (*moi)(void *data, float mass); + cpShape *shape; + int go; + void *data; + void (*debugdraw)(void *data); + float (*moi)(void *data, float mass); }; /* Circles are the fastest collier type */ struct phys2d_circle { - float radius; - cpVect offset; - struct phys2d_shape shape; + float radius; + cpVect offset; + struct phys2d_shape shape; }; /* A single segment */ struct phys2d_segment { - float a[2]; - float b[2]; - float thickness; - struct phys2d_shape shape; + float a[2]; + float b[2]; + float thickness; + struct phys2d_shape shape; }; /* A convex polygon; defined as the convex hull around the given set of points */ struct phys2d_poly { - cpVect *points; - float radius; - struct phys2d_shape shape; + cpVect *points; + float radius; + struct phys2d_shape shape; }; /* A box shape; a type of a polygon collider */ struct phys2d_box { - float w; - float h; - float offset[2]; - float rotation; - float r; - struct phys2d_shape shape; + float w; + float h; + float offset[2]; + float rotation; + float r; + struct phys2d_shape shape; }; /* An edge with no volume. Cannot collide with each other. Join to make levels. Static only. */ struct phys2d_edge { - cpVect *points; - float thickness; - cpShape **shapes; - int closed; /* True if the first and last points should be connected */ - struct phys2d_shape shape; - int draws; + cpVect *points; + float thickness; + cpShape **shapes; + int closed; /* True if the first and last points should be connected */ + struct phys2d_shape shape; + int draws; }; struct phys2d_circle *Make2DCircle(int go); @@ -107,8 +107,8 @@ cpShape *phys2d_query_pos(cpVect pos); int *phys2d_query_box(cpVect pos, cpVect wh); struct phys_cbs { - struct callee begin; - struct callee separate; + struct callee begin; + struct callee separate; }; struct shape_cb { @@ -127,9 +127,9 @@ void shape_set_sensor(struct phys2d_shape *shape, int sensor); int shape_get_sensor(struct phys2d_shape *shape); struct color { - unsigned char r; - unsigned char g; - unsigned char b; + unsigned char r; + unsigned char g; + unsigned char b; }; void color2float(struct color, float *fcolor); diff --git a/source/engine/3d/3dphysics.h b/source/engine/3d/3dphysics.h index 3097c22..3d6a394 100644 --- a/source/engine/3d/3dphysics.h +++ b/source/engine/3d/3dphysics.h @@ -1,5 +1,4 @@ #ifndef THREEDPHYSICS_H #define THREEDPHYSICS_H - #endif diff --git a/source/engine/3d/3pfollow.c b/source/engine/3d/3pfollow.c index d04e5fa..f360876 100644 --- a/source/engine/3d/3pfollow.c +++ b/source/engine/3d/3pfollow.c @@ -42,26 +42,26 @@ glm::vec3 ThirdPersonFollow::CalculatePosition() glm::vec3 p1 = CalculateCenter(); glm::vec3 p2 = - XDirPosts ? GetPostsOffset(TFOR.Right(), - FloatWidths. - x) : GetExtentsOffset(TFOR.Right(), - FloatWidths.x, - TargetOffset.x, - AnchorWidths.x); + XDirPosts ? GetPostsOffset(TFOR.Right(), + FloatWidths. + x) : GetExtentsOffset(TFOR.Right(), + FloatWidths.x, + TargetOffset.x, + AnchorWidths.x); glm::vec3 p3 = - YDirPosts ? GetPostsOffset(TFOR.Up(), - FloatWidths. - y) : GetExtentsOffset(TFOR.Up(), - FloatWidths.y, - TargetOffset.y, - AnchorWidths.y); + YDirPosts ? GetPostsOffset(TFOR.Up(), + FloatWidths. + y) : GetExtentsOffset(TFOR.Up(), + FloatWidths.y, + TargetOffset.y, + AnchorWidths.y); glm::vec3 p4 = - ZDirPosts ? GetPostsOffset(TFOR.Back(), - FloatWidths. - z) : GetExtentsOffset(TFOR.Back(), - FloatWidths.z, - TargetOffset.z, - AnchorWidths.z); + ZDirPosts ? GetPostsOffset(TFOR.Back(), + FloatWidths. + z) : GetExtentsOffset(TFOR.Back(), + FloatWidths.z, + TargetOffset.z, + AnchorWidths.z); return p1 + p2 + p3 + p4; } @@ -69,7 +69,7 @@ glm::vec3 ThirdPersonFollow::CalculatePosition() glm::vec3 ThirdPersonFollow::CalculateCenter() { return Target->get_global_translation() + - TFOR.TransformDirection(Offset) + (mytransform->Back() * Distance); + TFOR.TransformDirection(Offset) + (mytransform->Back() * Distance); } glm::vec3 ThirdPersonFollow:: @@ -82,37 +82,37 @@ GetPostsOffset(const glm::vec3 & DirectionVector, float AnchorWidth) glm::vec3 ThirdPersonFollow:: GetExtentsOffset(const glm::vec3 & DirectionVector, float AnchorWidth, - float TOffset, float Width) + float TOffset, float Width) { float negated_offset_sign = ((0 <= TOffset) - (TOffset < 0)) * -1.f; float TotalWidth = AnchorWidth + Width; if (glm::abs(TOffset) > TotalWidth - && !glm::epsilonEqual(glm::abs(TOffset), TotalWidth, 0.5f)) - return DirectionVector * TotalWidth * negated_offset_sign; + && !glm::epsilonEqual(glm::abs(TOffset), TotalWidth, 0.5f)) + return DirectionVector * TotalWidth * negated_offset_sign; else { - if (glm::abs(TOffset) >= AnchorWidth) - return DirectionVector * AnchorWidth * negated_offset_sign; - else - return DirectionVector * TOffset * -1.f; + if (glm::abs(TOffset) >= AnchorWidth) + return DirectionVector * AnchorWidth * negated_offset_sign; + else + return DirectionVector * TOffset * -1.f; } return glm::vec3(0.f); } glm::vec3 ThirdPersonFollow::FrameBasedVectorLerp(const glm::vec3 & From, - const glm::vec3 & To, - const glm::vec3 & Speeds, - float Tick) + const glm::vec3 & To, + const glm::vec3 & Speeds, + float Tick) { // Previously "FORTransform.TransformVector(Speeds) glm::vec3 TSpeed = glm::abs(TFOR.TransformDirection(Speeds)); glm::vec3 TOffset = glm::abs(TFOR.TransformDirection(TargetOffset)); glm::vec3 TAnchorWidths = - glm::abs(TFOR.TransformDirection(AnchorWidths)); + glm::abs(TFOR.TransformDirection(AnchorWidths)); glm::vec3 TFloatWidths = - glm::abs(TFOR.TransformDirection(FloatWidths)); + glm::abs(TFOR.TransformDirection(FloatWidths)); @@ -124,14 +124,14 @@ glm::vec3 ThirdPersonFollow::FrameBasedVectorLerp(const glm::vec3 & From, float xAlpha = - glm::clamp((bUseX ? AnchorSpeed : TSpeed.x) * Tick, 0.f, 1.f); + glm::clamp((bUseX ? AnchorSpeed : TSpeed.x) * Tick, 0.f, 1.f); float yAlpha = - glm::clamp((bUseY ? AnchorSpeed : TSpeed.y) * Tick, 0.f, 1.f); + glm::clamp((bUseY ? AnchorSpeed : TSpeed.y) * Tick, 0.f, 1.f); float zAlpha = - glm::clamp((bUseZ ? AnchorSpeed : TSpeed.z) * Tick, 0.f, 1.f); + glm::clamp((bUseZ ? AnchorSpeed : TSpeed.z) * Tick, 0.f, 1.f); return VectorLerpPiecewise(From, To, - glm::vec3(xAlpha, yAlpha, zAlpha)); + glm::vec3(xAlpha, yAlpha, zAlpha)); } int float_epsilon(mfloat_t a, mfloat_t b, mfloat_t e) @@ -165,11 +165,11 @@ void ThirdPersonFollow::CalculateTargets() // For rotation // TODO: Check of this implementation is the same as UKismetMath FindLookAtRotation TargetRotation = - RemoveLockedRotation(glm::quat - (mytransform-> - get_global_transform()->get_origin() - - Target-> - get_global_transform()->get_origin())); + RemoveLockedRotation(glm::quat + (mytransform-> + get_global_transform()->get_origin() - + Target-> + get_global_transform()->get_origin())); } follow_removelockedrot() @@ -185,11 +185,11 @@ RemoveLockedRotation(const glm::quat & CurrentRotation) // NewRotator.x = - LockRoll ? mytransform->get_rotation().x : CurrentRotator.x; + LockRoll ? mytransform->get_rotation().x : CurrentRotator.x; NewRotator.y = - LockPitch ? mytransform->get_rotation().y : CurrentRotator.y; + LockPitch ? mytransform->get_rotation().y : CurrentRotator.y; NewRotator.z = - LockYaw ? mytransform->get_rotation().z : CurrentRotator.z; + LockYaw ? mytransform->get_rotation().z : CurrentRotator.z; return glm::quat(NewRotator); } @@ -199,11 +199,11 @@ RemoveLockedRotation(const glm::quat & CurrentRotation) void ThirdPersonFollow::CalculateTargetOffset() { glm::vec3 p1 = - (mytransform->Forward() * Distance) + - TFOR.TransformDirection(Offset) + - mytransform->get_global_translation(); + (mytransform->Forward() * Distance) + + TFOR.TransformDirection(Offset) + + mytransform->get_global_translation(); glm::vec3 p2 = - TFOR.InverseTransformDirection(Target->get_global_translation()); + TFOR.InverseTransformDirection(Target->get_global_translation()); glm::vec3 p3 = TFOR.InverseTransformDirection(p1); TargetOffset = p2 - p3; diff --git a/source/engine/3d/3pfollow.h b/source/engine/3d/3pfollow.h index ac671bf..5daa61e 100644 --- a/source/engine/3d/3pfollow.h +++ b/source/engine/3d/3pfollow.h @@ -6,8 +6,8 @@ #include "transform.h" struct follow { - float distance; - mfloat_t target_rot[4]; + float distance; + mfloat_t target_rot[4]; }; mfloat_t *follow_calccenter(); @@ -31,45 +31,45 @@ class ThirdPersonFollow { public: enum CameraType { - STATIONARY, - TRANSLATING, - ROTATING, - SPLINE + STATIONARY, + TRANSLATING, + ROTATING, + SPLINE }; enum CameraTransition { - NONE, - CROSSDISSOLVE, - WIPE, - DIP + NONE, + CROSSDISSOLVE, + WIPE, + DIP }; enum FrameOfReference { - LOCAL, - WORLD, - EXTERNAL + LOCAL, + WORLD, + EXTERNAL }; ThirdPersonFollow() { - // Rotation - RotationSpeed = 10.0f; - LockPitch = LockYaw = LockRoll = true; + // Rotation + RotationSpeed = 10.0f; + LockPitch = LockYaw = LockRoll = true; - XDirPosts = false; - YDirPosts = false; - ZDirPosts = false; + XDirPosts = false; + YDirPosts = false; + ZDirPosts = false; - // Translation - //FloatWidths = AnchorWidths = CenterVector = glm::vec3(0, 0, 0); - PositionSpeeds = glm::vec3(2.f, 2.f, 2.f); - //TranslationScales = glm::vec3(1, 1, 1); + // Translation + //FloatWidths = AnchorWidths = CenterVector = glm::vec3(0, 0, 0); + PositionSpeeds = glm::vec3(2.f, 2.f, 2.f); + //TranslationScales = glm::vec3(1, 1, 1); - // Frame settings - Offset = glm::vec3(0.f, 0.f, 0.f); - Distance = 10; + // Frame settings + Offset = glm::vec3(0.f, 0.f, 0.f); + Distance = 10; - AnchorSpeed = 80; + AnchorSpeed = 80; } ~ThirdPersonFollow() { } @@ -81,14 +81,14 @@ class ThirdPersonFollow { void SetExternalFrame(Transform * val) { - ExternalFrame = val; + ExternalFrame = val; } // The target the camera "looks" at, used for calculations Transform *Target = nullptr; void SetTarget(Transform * val) { - Target = val; + Target = val; } // Offset from the target @@ -158,25 +158,25 @@ class ThirdPersonFollow { /// Given a direction and width, find the offsets. glm::vec3 GetPostsOffset(const glm::vec3 & DirectionVector, - float AnchorWidth); + float AnchorWidth); /// Given anchors, what's the anchor width? glm::vec3 GetExtentsOffset(const glm::vec3 & DirectionVector, - float AnchorWidth, float TOffset, - float Width); + float AnchorWidth, float TOffset, + float Width); glm::quat RemoveLockedRotation(const glm::quat & CurrentRotation); glm::vec3 FrameBasedVectorLerp(const glm::vec3 & From, - const glm::vec3 & To, - const glm::vec3 & Speeds, float Tick); + const glm::vec3 & To, + const glm::vec3 & Speeds, float Tick); glm::vec3 VectorLerpPiecewise(const glm::vec3 & From, - const glm::vec3 & To, - const glm::vec3 & Alpha); + const glm::vec3 & To, + const glm::vec3 & Alpha); bool GetLerpParam(const float Offst, const float AnchorWidth, - const float FloatWidth); + const float FloatWidth); /// Set to a value that gives good clamping, smoothly. Activates when /// the target is out of range. diff --git a/source/engine/3d/light.c b/source/engine/3d/light.c index 4a2755f..2b67644 100644 --- a/source/engine/3d/light.c +++ b/source/engine/3d/light.c @@ -1,7 +1,6 @@ #include "light.h" #include - /* void Light::serialize(FILE * file) { @@ -30,20 +29,20 @@ struct mDirectionalLight *dLight = NULL; struct mDirectionalLight *MakeDLight() { if (dLight != NULL) { - dLight = - (struct mDirectionalLight *) - malloc(sizeof(struct mDirectionalLight)); - quat_from_euler(dLight->light.obj.transform.rotation, - dlight_init_rot); + dLight = + (struct mDirectionalLight *) + malloc(sizeof(struct mDirectionalLight)); + quat_from_euler(dLight->light.obj.transform.rotation, + dlight_init_rot); - return dLight; + return dLight; } return dLight; } void dlight_prepshader(struct mDirectionalLight *light, - struct shader *shader) + struct shader *shader) { mfloat_t fwd[3] = { 0.f }; trans_forward(fwd, &light->light.obj.transform); @@ -61,14 +60,14 @@ static int numLights = 0; struct mPointLight *MakePointlight() { if (numLights < 4) { - struct mPointLight *light = - (struct mPointLight *) malloc(sizeof(struct mPointLight)); - pointLights[numLights++] = light; - light->light.strength = 0.2f; - light->constant = 1.f; - light->linear = 0.9f; - light->quadratic = 0.032f; - return light; + struct mPointLight *light = + (struct mPointLight *) malloc(sizeof(struct mPointLight)); + pointLights[numLights++] = light; + light->light.strength = 0.2f; + light->constant = 1.f; + light->linear = 0.9f; + light->quadratic = 0.032f; + return light; } return NULL; @@ -82,11 +81,11 @@ static void prepstring(char *buffer, char *prepend, const char *append) void pointlights_prepshader(struct shader *shader) { for (int i = 0; i < numLights; i++) - pointlight_prepshader(pointLights[i], shader, i); + pointlight_prepshader(pointLights[i], shader, i); } void pointlight_prepshader(struct mPointLight *light, - struct shader *shader, int num) + struct shader *shader, int num) { shader_use(shader); char prepend[100] = { '\0' }; @@ -121,10 +120,10 @@ static int numSpots = 0; struct mSpotLight *MakeSpotlight() { if (numSpots < 4) { - struct mSpotLight *light = - (struct mSpotLight *) malloc(sizeof(struct mSpotLight)); - spotLights[numSpots++] = light; - return light; + struct mSpotLight *light = + (struct mSpotLight *) malloc(sizeof(struct mSpotLight)); + spotLights[numSpots++] = light; + return light; } return NULL; @@ -135,17 +134,17 @@ struct mSpotLight *MakeSpotlight() void spotlights_prepshader(struct shader *shader) { for (int i = 0; i < numSpots; i++) - spotlight_prepshader(spotLights[i], shader, i); + spotlight_prepshader(spotLights[i], shader, i); } void spotlight_prepshader(struct mSpotLight *light, struct shader *shader, - int num) + int num) { mfloat_t fwd[3] = { 0.f }; trans_forward(fwd, &light->light.obj.transform); shader_use(shader); shader_setvec3(shader, "spotLight.position", - light->light.obj.transform.position); + light->light.obj.transform.position); shader_setvec3(shader, "spotLight.direction", fwd); shader_setvec3(shader, "spotLight.color", light->light.color); shader_setfloat(shader, "spotLight.strength", light->light.strength); @@ -165,10 +164,10 @@ void light_gui(struct mLight *light) object_gui(&light->obj); if (nk_tree_push(ctx, NK_TREE_NODE, "Light", NK_MINIMIZED)) { - nk_property_float(ctx, "Strength", 0.f, &light->strength, 1.f, 0.01f, 0.001f); - // ImGui::ColorEdit3("Color", &light->color[0]); - nk_checkbox_label(ctx, "Dynamic", (bool *) &light->dynamic); - nk_tree_pop(ctx); + nk_property_float(ctx, "Strength", 0.f, &light->strength, 1.f, 0.01f, 0.001f); + // ImGui::ColorEdit3("Color", &light->color[0]); + nk_checkbox_label(ctx, "Dynamic", (bool *) &light->dynamic); + nk_tree_pop(ctx); } } @@ -178,10 +177,10 @@ void pointlight_gui(struct mPointLight *light) light_gui(&light->light); if (nk_tree_push(ctx, NK_TREE_NODE, "Point Light", NK_MINIMIZED)) { - nk_property_float(ctx, "Constant", 0.f, &light->constant, 1.f, 0.01f, 0.001f); - nk_property_float(ctx, "Linear", 0.f, &light->linear, 0.3f, 0.01f, 0.001f); - nk_property_float(ctx, "Quadratic", 0.f, &light->quadratic, 0.3f, 0.01f, 0.001f); - nk_tree_pop(ctx); + nk_property_float(ctx, "Constant", 0.f, &light->constant, 1.f, 0.01f, 0.001f); + nk_property_float(ctx, "Linear", 0.f, &light->linear, 0.3f, 0.01f, 0.001f); + nk_property_float(ctx, "Quadratic", 0.f, &light->quadratic, 0.3f, 0.01f, 0.001f); + nk_tree_pop(ctx); } } @@ -191,12 +190,12 @@ void spotlight_gui(struct mSpotLight *spot) light_gui(&spot->light); if (nk_tree_push(ctx, NK_TREE_NODE, "Spotlight", NK_MINIMIZED)) { - nk_property_float(ctx, "Linear", 0.f, &spot->linear, 1.f, 0.01f, 0.001f); - nk_property_float(ctx, "Quadratic", 0.f, &spot->quadratic, 1.f, 0.01f, 0.001f); - nk_property_float(ctx, "Distance", 0.f, &spot->distance, 200.f, 1.f, 0.1f, 200.f); - nk_property_float(ctx, "Cutoff Degrees", 0.f, &spot->cutoff, 0.7f, 0.01f, 0.001f); - nk_property_float(ctx, "Outer Cutoff Degrees", 0.f, &spot->outerCutoff, 0.7f, 0.01f, 0.001f); - nk_tree_pop(ctx); + nk_property_float(ctx, "Linear", 0.f, &spot->linear, 1.f, 0.01f, 0.001f); + nk_property_float(ctx, "Quadratic", 0.f, &spot->quadratic, 1.f, 0.01f, 0.001f); + nk_property_float(ctx, "Distance", 0.f, &spot->distance, 200.f, 1.f, 0.1f, 200.f); + nk_property_float(ctx, "Cutoff Degrees", 0.f, &spot->cutoff, 0.7f, 0.01f, 0.001f); + nk_property_float(ctx, "Outer Cutoff Degrees", 0.f, &spot->outerCutoff, 0.7f, 0.01f, 0.001f); + nk_tree_pop(ctx); } } */ diff --git a/source/engine/3d/light.h b/source/engine/3d/light.h index c6ceba8..f339871 100644 --- a/source/engine/3d/light.h +++ b/source/engine/3d/light.h @@ -4,11 +4,11 @@ #include struct mLight { - struct gameobject *go; - uint8_t color[3]; - float strength; - int dynamic; - int on; + struct gameobject *go; + uint8_t color[3]; + float strength; + int dynamic; + int on; }; /* @@ -21,7 +21,7 @@ struct mPointLight { struct mPointLight *MakePointlight(); void pointlight_prepshader(struct mPointLight *light, - struct shader *shader, int num); + struct shader *shader, int num); void pointlights_prepshader(struct shader *shader); @@ -39,7 +39,7 @@ struct mSpotLight { struct mSpotLight *MakeSpotlight(); void spotlight_gui(struct mSpotLight *light); void spotlight_prepshader(struct mSpotLight *light, struct shader *shader, - int num); + int num); void spotlights_prepshader(struct shader *shader); @@ -49,7 +49,7 @@ struct mDirectionalLight { }; void dlight_prepshader(struct mDirectionalLight *light, - struct shader *shader); + struct shader *shader); struct mDirectionalLight *MakeDLight(); extern struct mDirectionalLight *dLight; diff --git a/source/engine/3d/mesh.c b/source/engine/3d/mesh.c index 157a952..c095b84 100644 --- a/source/engine/3d/mesh.c +++ b/source/engine/3d/mesh.c @@ -4,122 +4,94 @@ #include "shader.h" #include "texture.h" #include -#include #include +#include -void DrawMesh(struct mesh *mesh, struct shader *shader) -{ - // bind appropriate textures - uint32_t diffuseNr = 1; - uint32_t specularNr = 1; - uint32_t normalNr = 1; - uint32_t heightNr = 1; +void DrawMesh(struct mesh *mesh, struct shader *shader) { + // bind appropriate textures + uint32_t diffuseNr = 1; + uint32_t specularNr = 1; + uint32_t normalNr = 1; + uint32_t heightNr = 1; - for (int i = 0; i < (mesh->te - mesh->textures); i++) { -// glActiveTexture(GL_TEXTURE0 + i); // active proper texture unit before binding - // retrieve texture number (the N in diffuse_textureN) - char number = 0; - // TODO: malloc every single frame ... nope! Change to stack - /*char *name = malloc(sizeof(char) *(strlen(mesh->textures[i].type) + 2));*/ - /* - if (mesh->textures[i].type == TEX_DIFF) - number = diffuseNr++; - else if (mesh->textures[i].type == TEX_SPEC) - number = specularNr++; - else if (mesh->textures[i].type == TEX_NORM) - number = normalNr++; - else if (mesh->textures[i].type == TEX_HEIGHT) - number = heightNr++; + // for (int i = 0; i < (mesh->te - mesh->textures); i++) { + // glActiveTexture(GL_TEXTURE0 + i); // active proper texture unit before binding + // retrieve texture number (the N in diffuse_textureN) + // char number = 0; + // TODO: malloc every single frame ... nope! Change to stack + /*char *name = malloc(sizeof(char) *(strlen(mesh->textures[i].type) + 2));*/ + /* +// if (mesh->textures[i].type == TEX_DIFF) +// number = diffuseNr++; +// else if (mesh->textures[i].type == TEX_SPEC) +// number = specularNr++; +// else if (mesh->textures[i].type == TEX_NORM) +// number = normalNr++; +// else if (mesh->textures[i].type == TEX_HEIGHT) +// number = heightNr++; */ -/* - glUniform1i(glGetUniformLocation(shader->id, name), i); - glBindTexture(GL_TEXTURE_2D, mesh->textures[i].id); - free(name); - */ - } - - // draw mesh - glBindVertexArray(mesh->VAO); - DrawMeshAgain(mesh); - - // DEBUG - // triCount += indices.size() / 3; + /* + glUniform1i(glGetUniformLocation(shader->id, name), i); + glBindTexture(GL_TEXTURE_2D, mesh->textures[i].id); + free(name); + */ } - -void DrawMeshAgain(struct mesh *mesh) -{ +void DrawMeshAgain(struct mesh *mesh) { } -struct mesh *MakeMesh(struct Vertex *vertices, struct Vertex *ve, - uint32_t * indices, uint32_t * ie, - struct Texture *textures, struct Texture *te) -{ - struct mesh *newmesh = (struct mesh *) malloc(sizeof(struct mesh)); - newmesh->vertices = vertices; - newmesh->ve = ve; - newmesh->indices = indices; - newmesh->ie = ie; - newmesh->textures = textures; - newmesh->te = te; +void setupmesh(struct mesh *mesh) { + /* + // create buffers/arrays + glGenVertexArrays(1, &mesh->VAO); + glGenBuffers(1, &mesh->VBO); + glGenBuffers(1, &mesh->EBO); - setupmesh(newmesh); - return newmesh; -} - -void setupmesh(struct mesh *mesh) -{ -/* - // create buffers/arrays - glGenVertexArrays(1, &mesh->VAO); - glGenBuffers(1, &mesh->VBO); - glGenBuffers(1, &mesh->EBO); - - glBindVertexArray(mesh->VAO); - // load data into vertex buffers - glBindBuffer(GL_ARRAY_BUFFER, mesh->VBO); - - - // The effect is that we can simply pass a pointer to the struct and it translates perfectly to vevc array which - // again translates to 3/2 floats which translates to a byte array. - glBufferData(GL_ARRAY_BUFFER, - (mesh->ve - mesh->vertices) * sizeof(struct Vertex), - &mesh->vertices[0], GL_STATIC_DRAW); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->EBO); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, - (mesh->ie - mesh->indices) * sizeof(uint32_t), - &mesh->indices[0], GL_STATIC_DRAW); - - // set the vertex attribute pointers - // vertex Positions - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), NULL); - // vertex normals - glEnableVertexAttribArray(1); -// glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Normal[3])); - // vertex texture coords - glEnableVertexAttribArray(2); -// glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, TexCoords[2])); - // vertex tangent - glEnableVertexAttribArray(3); -// glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Tangent[3])); - // vertex bitangent - glEnableVertexAttribArray(4); -// glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Bitangent[3])); - - // Bone ids - glEnableVertexAttribArray(5); - glVertexAttribPointer(5, 4, GL_INT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, - m_BoneIDs - [MAX_BONE_INFLUENCE])); - - // Weights - glEnableVertexAttribArray(6); -// glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, m_Weights)); - - glBindVertexArray(0); - -*/ + glBindVertexArray(mesh->VAO); + // load data into vertex buffers + glBindBuffer(GL_ARRAY_BUFFER, mesh->VBO); + + + // The effect is that we can simply pass a pointer to the struct and it translates perfectly to vevc array which + // again translates to 3/2 floats which translates to a byte array. + glBufferData(GL_ARRAY_BUFFER, + (mesh->ve - mesh->vertices) * sizeof(struct Vertex), + &mesh->vertices[0], GL_STATIC_DRAW); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->EBO); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, + (mesh->ie - mesh->indices) * sizeof(uint32_t), + &mesh->indices[0], GL_STATIC_DRAW); + + // set the vertex attribute pointers + // vertex Positions + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), NULL); + // vertex normals + glEnableVertexAttribArray(1); + // glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Normal[3])); + // vertex texture coords + glEnableVertexAttribArray(2); + // glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, TexCoords[2])); + // vertex tangent + glEnableVertexAttribArray(3); + // glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Tangent[3])); + // vertex bitangent + glEnableVertexAttribArray(4); + // glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Bitangent[3])); + + // Bone ids + glEnableVertexAttribArray(5); + glVertexAttribPointer(5, 4, GL_INT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, + m_BoneIDs + [MAX_BONE_INFLUENCE])); + + // Weights + glEnableVertexAttribArray(6); + // glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, m_Weights)); + + glBindVertexArray(0); + + */ } diff --git a/source/engine/3d/mesh.h b/source/engine/3d/mesh.h index 4d30abe..2c7cb32 100644 --- a/source/engine/3d/mesh.h +++ b/source/engine/3d/mesh.h @@ -2,40 +2,20 @@ #define MESH_H #include "mathc.h" +#include "sokol/sokol_gfx.h" #include struct shader; struct Texture; -#define MAX_BONE_INFLUENCE 4 - -struct Vertex { - mfloat_t Position[3]; - mfloat_t Normal[3]; - mfloat_t TexCoords[2]; - mfloat_t Tangent[3]; - mfloat_t Bitangent[3]; - - int m_BoneIDs[MAX_BONE_INFLUENCE]; - - float m_Weights[MAX_BONE_INFLUENCE]; -}; - struct mesh { - struct Vertex *vertices; - struct Vertex *ve; - uint32_t *indices; - uint32_t *ie; - struct Texture *textures; - struct Texture *te; - uint32_t VAO, VBO, EBO; + sg_bindings bind; + uint32_t face_count; }; -struct mesh *MakeMesh(struct Vertex *vertices, struct Vertex *ve, - uint32_t * indices, uint32_t * ie, - struct Texture *textures, struct Texture *te); -void setupmesh(struct mesh *mesh); /* Loads mesh into the GPU */ +struct mesh *MakeMesh(struct Vertex *vertices, struct Vertex *ve, uint32_t *indices, uint32_t *ie, struct Texture *textures, struct Texture *te); +void setupmesh(struct mesh *mesh); /* Loads mesh into the GPU */ void DrawMesh(struct mesh *mesh, struct shader *shader); -void DrawMeshAgain(struct mesh *mesh); /* Draws whatever mesh was drawn last */ +void DrawMeshAgain(struct mesh *mesh); /* Draws whatever mesh was drawn last */ #endif diff --git a/source/engine/3d/model.c b/source/engine/3d/model.c index 75abcaf..5623dce 100644 --- a/source/engine/3d/model.c +++ b/source/engine/3d/model.c @@ -5,10 +5,27 @@ #include "resources.h" #include "shader.h" #include "stb_ds.h" +#include "font.h" + +#include "openglrender.h" + +// #define HANDMADE_MATH_USE_TURNS +#include "HandmadeMath.h" + +#include "math.h" +#include "time.h" + +#define CGLTF_IMPLEMENTATION #include #include #include +#include "texture.h" + +#include "mathc.h" + +#include "sokol/sokol_gfx.h" + static struct { char *key; struct Texture *value; @@ -18,6 +35,59 @@ static void processnode(); static void processmesh(); static void processtexture(); +static sg_shader model_shader; +static sg_pipeline model_pipe; + +void model_init() { + YughWarn("Creating model"); + model_shader = sg_make_shader(&(sg_shader_desc){ + .vs.source = slurp_text("shaders/diffuse_v.glsl"), + .fs.source = slurp_text("shaders/diffuse_f.glsl"), + .vs.uniform_blocks[0] = { + .size = sizeof(float) * 16 * 4, + .uniforms = { + [0] = {.name = "vp", .type = SG_UNIFORMTYPE_MAT4}, + [1] = {.name = "model", .type = SG_UNIFORMTYPE_MAT4}, + [2] = {.name = "proj", .type = SG_UNIFORMTYPE_MAT4}, + [3] = {.name = "lsm", .type = SG_UNIFORMTYPE_MAT4}, + }}, + + .fs.uniform_blocks[0] = { + .size = sizeof(float) * 3 * 5, + .uniforms = { + [0] = {.name = "point_pos", .type = SG_UNIFORMTYPE_FLOAT3}, + [1] = {.name = "dir_dir", .type = SG_UNIFORMTYPE_FLOAT3}, + [2] = {.name = "view_pos", .type = SG_UNIFORMTYPE_FLOAT3}, + [3] = {.name = "spot_pos", .type = SG_UNIFORMTYPE_FLOAT3}, + [4] = {.name = "spot_dir", .type = SG_UNIFORMTYPE_FLOAT3}, + }, + }, + + .fs.images[0] = {.name = "diffuse", .image_type = SG_IMAGETYPE_2D, .sampler_type = SG_SAMPLERTYPE_FLOAT}, + .fs.images[1] = { .name = "normmap", .image_type = SG_IMAGETYPE_2D, .sampler_type = SG_SAMPLERTYPE_FLOAT}, + .fs.images[2] = {.name = "shadow_map", .image_type = SG_IMAGETYPE_2D, .sampler_type = SG_SAMPLERTYPE_FLOAT}, + + }); + + model_pipe = sg_make_pipeline(&(sg_pipeline_desc){ + .shader = model_shader, + .layout = { + .attrs = { + [0].format = SG_VERTEXFORMAT_FLOAT3, + [0].buffer_index = 0, /* position */ + [1].format = SG_VERTEXFORMAT_FLOAT2, + [1].buffer_index = 1, /* tex coords */ + [2].format = SG_VERTEXFORMAT_FLOAT3, + [2].buffer_index = 2, /* normal */ + }, + }, + .index_type = SG_INDEXTYPE_UINT16, + .cull_mode = SG_CULLMODE_FRONT, + .depth.write_enabled = true, + .depth.compare = SG_COMPAREFUNC_LESS_EQUAL + }); +} + struct model *GetExistingModel(const char *path) { if (!path || path[0] == '\0') return NULL; @@ -27,8 +97,18 @@ struct model *GetExistingModel(const char *path) { return MakeModel(path); } -/* TODO: Make this a hash compare for speedup */ +cgltf_attribute *get_attr_type(cgltf_primitive p, cgltf_attribute_type t) +{ + for (int i = 0; i < p.attributes_count; i++) { + if (p.attributes[i].type == t) + return &p.attributes[i]; + } + + return NULL; +} + struct model *MakeModel(const char *path) { + YughWarn("Making the model from %s.", path); cgltf_options options = {0}; cgltf_data *data = NULL; cgltf_result result = cgltf_parse_file(&options, path, &data); @@ -45,188 +125,166 @@ struct model *MakeModel(const char *path) { return NULL; } - struct model *model = malloc(sizeof(struct model)); + struct model *model = calloc(1, sizeof(*model)); + /* TODO: Optimize by grouping by material. One material per draw. */ + YughWarn("Model has %d materials.", data->materials_count); - model->meshes = malloc(sizeof(struct mesh) * data->meshes_count); + float vs[65535*3]; + uint16_t idxs[65535]; - for (int i = 0; i < data->nodes_count; i++) { - - if (data->nodes[i].mesh) { - cgltf_mesh *mesh = data->nodes[i].mesh; - - for (int j = 0; j < mesh->primitives_count; j++) { - cgltf_primitive primitive = mesh->primitives[j]; - - for (int k = 0; k < primitive.attributes_count; k++) { - cgltf_attribute attribute = primitive.attributes[k]; - - switch (attribute.type) { - - case cgltf_attribute_type_position: -// float *vs = malloc(sizeof(float) * cgltf_accessor_unpack_floats(attribute.accessor, NULL, attribute.accessor.count); -// cgltf_accessor_unpack_floats(attribute.accessor, vs, attribute.accessor.count); + for (int i = 0; i < data->meshes_count; i++) { + cgltf_mesh *mesh = &data->meshes[i]; + struct mesh newmesh = {0}; + arrput(model->meshes,newmesh); + + YughWarn("Making mesh %d. It has %d primitives.", i, mesh->primitives_count); + + for (int j = 0; j < mesh->primitives_count; j++) { + cgltf_primitive primitive = mesh->primitives[j]; + + if (primitive.indices) { + int c = primitive.indices->count; + memcpy(idxs, cgltf_buffer_view_data(primitive.indices->buffer_view), sizeof(uint16_t) * c); + + model->meshes[j].bind.index_buffer = sg_make_buffer(&(sg_buffer_desc){ + .data.ptr = idxs, + .data.size = sizeof(uint16_t) * c, + .type = SG_BUFFERTYPE_INDEXBUFFER}); + + model->meshes[j].face_count = c; + } else { + YughWarn("Model does not have indices. Generating them."); + int c = primitive.attributes[0].data->count; + model->meshes[j].face_count = c; + for (int z = 0; z < c; z++) + idxs[z] = z; + + model->meshes[j].bind.index_buffer = sg_make_buffer(&(sg_buffer_desc){ + .data.ptr = idxs, + .data.size = sizeof(uint16_t) * c, + .type = SG_BUFFERTYPE_INDEXBUFFER}); + } + + if (primitive.material->has_pbr_metallic_roughness && primitive.material->pbr_metallic_roughness.base_color_texture.texture) { +// YughWarn("Texture is %s.", primitive.material->pbr_metallic_roughness.base_color_texture.texture->image->uri); + + model->meshes[j].bind.fs_images[0] = texture_pullfromfile(primitive.material->pbr_metallic_roughness.base_color_texture.texture->image->uri)->id; + } else + model->meshes[j].bind.fs_images[0] = texture_pullfromfile("k")->id; + + cgltf_texture *tex; + if (tex = primitive.material->normal_texture.texture) { + model->meshes[j].bind.fs_images[1] = texture_pullfromfile(tex->image->uri)->id; + } else + model->meshes[j].bind.fs_images[1] = texture_pullfromfile("k")->id; + + model->meshes[j].bind.fs_images[2] = ddimg; + + int has_norm = 0; + + for (int k = 0; k < primitive.attributes_count; k++) { + cgltf_attribute attribute = primitive.attributes[k]; + + int n = cgltf_accessor_unpack_floats(attribute.data, NULL, 0); /* floats per element x num elements */ + + cgltf_accessor_unpack_floats(attribute.data, vs, n); + + switch (attribute.type) { + case cgltf_attribute_type_position: + model->meshes[j].bind.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ + .data.ptr = vs, + .data.size = sizeof(float) * n}); break; - case cgltf_attribute_type_normal: - break; + case cgltf_attribute_type_normal: + has_norm = 1; + model->meshes[j].bind.vertex_buffers[2] = sg_make_buffer(&(sg_buffer_desc){ + .data.ptr = vs, + .data.size = sizeof(float) * n}); + break; + case cgltf_attribute_type_tangent: + break; - case cgltf_attribute_type_tangent: - break; - - case cgltf_attribute_type_texcoord: - break; - } + case cgltf_attribute_type_texcoord: + model->meshes[j].bind.vertex_buffers[1] = sg_make_buffer(&(sg_buffer_desc){ + .data.ptr = vs, + .data.size = sizeof(float) * n}); + break; } } - } + + if (!has_norm) { + YughWarn("Model does not have normals. Generating them."); + float norms[3 * model->meshes[j].face_count]; + + + cgltf_attribute *pa = get_attr_type(primitive, cgltf_attribute_type_position); + int n = cgltf_accessor_unpack_floats(pa->data, NULL,0); + float ps[n]; + cgltf_accessor_unpack_floats(pa->data,ps,n); + + for (int i = 0; i < model->meshes[j].face_count/3; i++) { + int o = i*9; + HMM_Vec3 a = {ps[o], ps[o+1],ps[o+2]}; + o += 3; + HMM_Vec3 b = {ps[o], ps[o+1],ps[o+2]}; + o += 3; + HMM_Vec3 c = {ps[o], ps[o+1],ps[o+2]}; + HMM_Vec3 norm = HMM_NormV3(HMM_Cross(HMM_SubV3(b,a), HMM_SubV3(c,a))); + for (int j = 0; j < 3; j++) { + norms[i*9+j*3+0] = norm.X; + norms[i*9+j*3+1] = norm.Y; + norms[i*9+j*3+2] = norm.Z; + } + } + + model->meshes[j].bind.vertex_buffers[2] = sg_make_buffer(&(sg_buffer_desc){ + .data.ptr = norms, + .data.size = sizeof(float) * model->meshes[j].face_count * 3 + }); + } + } + } + + return model; +} + +HMM_Vec3 eye = {50,10,5}; + +void draw_model(struct model *model, HMM_Mat4 amodel, HMM_Mat4 lsm) { + HMM_Mat4 proj = HMM_Perspective_RH_ZO(45, 1200.f / 720, 0.1, 10000); + HMM_Vec3 center = {0.f, 0.f, 0.f}; + HMM_Vec3 up = {0.f, 1.f, 0.f}; + HMM_Mat4 view = HMM_LookAt_RH(eye, center, up); + + HMM_Mat4 vp = HMM_MulM4(proj, view); + HMM_Mat4 mvp = HMM_MulM4(vp, amodel); + + HMM_Vec3 lp = {1, 1, 1}; + HMM_Vec3 dir_dir = HMM_NormV3(HMM_SubV3(center, dirl_pos)); + + HMM_Mat4 m2[4]; + m2[0] = view; + m2[1] = amodel; + m2[2] = proj; + m2[3] = lsm; + + HMM_Vec3 f_ubo[5]; + f_ubo[0] = lp; + f_ubo[1] = dir_dir; + f_ubo[2] = eye; + f_ubo[3] = eye; + f_ubo[4] = eye; + + sg_apply_pipeline(model_pipe); + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(m2)); + sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, SG_RANGE_REF(f_ubo)); + + + for (int i = 0; i < arrlen(model->meshes); i++) { + sg_apply_bindings(&model->meshes[i].bind); + sg_draw(0, model->meshes[i].face_count, 1); } } -/* TODO: DELETE -static void processnode() { - - for (uint32_t i = 0; i < node->mNumMeshes; i++) { - aiMesh *mesh = scene->mMeshes[node->mMeshes[i]]; - *mp = processMesh(mesh, scene); - mp++; - } - - for (uint32_t i = 0; i < node->mNumChildren; i++) { - processnode(node->mChildren[i], scene); - } - -} -*/ -static void processmesh() { - /* - Vertex *vertices = - (Vertex *) malloc(sizeof(Vertex) * mesh->mNumVertices); - Vertex *vp = vertices + mesh->mNumVertices; - Vertex *p = vertices; - for (int i = 0; i < mesh->mNumVertices; i++) { - // positions - (p + i)->Position.x = mesh->mVertices[i][0]; - (p + i)->Position.y = mesh->mVertices[i][1]; - (p + i)->Position.z = mesh->mVertices[i][2]; - - - // normals - if (mesh->HasNormals()) { - (p + i)->Normal.x = mesh->mNormals[i][0]; - (p + i)->Normal.y = mesh->mNormals[i].y; - (p + i)->Normal.z = mesh->mNormals[i].z; - } - - // texture coordinates - if (mesh->mTextureCoords[0]) { - glm::vec2 vec; - // a vertex can contain up to 8 different texture coordinates. We thus make the assumption that we won't - // use models where a vertex can have multiple texture coordinates so we always take the first set (0). - (p + i)->TexCoords.x = mesh->mTextureCoords[0][i].x; - (p + i)->TexCoords.y = mesh->mTextureCoords[0][i].y; - - // tangent - (p + i)->Tangent.x = mesh->mTangents[i].x; - (p + i)->Tangent.y = mesh->mTangents[i].y; - (p + i)->Tangent.z = mesh->mTangents[i].z; - - // bitangent - (p + i)->Bitangent.x = mesh->mBitangents[i].x; - (p + i)->Bitangent.y = mesh->mBitangents[i].y; - (p + i)->Bitangent.z = mesh->mBitangents[i].z; - - } else - (p + i)->TexCoords = glm::vec2(0.0f, 0.0f); - } - - - - // TODO: Done quickly, find better way. Go through for loop twice! - int numindices = 0; - // now walk through each of the mesh's faces (a face is a mesh its triangle) and retrieve the corresponding vertex indices. - for (uint32_t i = 0; i < mesh->mNumFaces; i++) { - numindices += mesh->mFaces[i].mNumIndices; - } - - uint32_t *indices = (uint32_t *) malloc(sizeof(uint32_t) * numindices); - uint32_t *ip = indices; - - for (uint32_t i = 0; i < mesh->mNumFaces; i++) { - for (uint32_t j = 0; j < mesh->mFaces[i].mNumIndices; j++) { - *ip = mesh->mFaces[i].mIndices[j]; - ip++; - } - } - - - // std::vector textures; - aiMaterial *material = scene->mMaterials[mesh->mMaterialIndex]; - - // TODO: Allocating 100 to be safe, can probably be way less - textures_loaded = (Texture *) malloc(sizeof(Texture) * 100); - tp = textures_loaded; - // we assume a convention for sampler names in the shaders. Each diffuse texture should be named - // as 'texture_diffuseN' where N is a sequential number ranging from 1 to MAX_SAMPLER_NUMBER. - // Same applies to other texture as the following list summarizes: - // diffuse: texture_diffuseN - // specular: texture_specularN - // normal: texture_normalN - - // 1. diffuse maps - loadMaterialTextures(material, aiTextureType_DIFFUSE, - "texture_diffuse"); - - // 2. specular maps - loadMaterialTextures(material, aiTextureType_SPECULAR, - "texture_specular"); - - // 3. normal maps - loadMaterialTextures(material, aiTextureType_NORMALS, - "texture_normal"); - - // 4. height maps - loadMaterialTextures(material, aiTextureType_AMBIENT, - "texture_height"); - - - // return a mesh object created from the extracted mesh data - return Mesh(vertices, vp, indices, ip, textures_loaded, tp); - - */ -} - -// TODO: This routine mallocs inside the function -static void processtexture() { - /* - for (uint32_t i = 0; i < mat->GetTextureCount(type); i++) { - aiString str; - mat->GetTexture(type, i, &str); - for (Texture * tpp = textures_loaded; tpp != tp; tpp++) { - if (strcmp(tpp->path, str.data) == 0) - goto next; // Check if we already have this texture - } - - tp->id = TextureFromFile(str.data, this->directory); - tp->type = (char *) malloc(sizeof(char) * strlen(typeName)); - strcpy(tp->type, typeName); - tp->path = (char *) malloc(sizeof(char) * strlen(str.data)); - strcpy(tp->path, str.data); - - tp++; - - next:; - - } - */ -} - -void draw_models(struct model *model, struct shader *shader) -{ - -} - -// TODO: Come back to this; simple optimization -void draw_model(struct model *model, struct shader *shader) { - -} diff --git a/source/engine/3d/model.h b/source/engine/3d/model.h index 8ca61da..2f2c8f6 100644 --- a/source/engine/3d/model.h +++ b/source/engine/3d/model.h @@ -1,12 +1,14 @@ #ifndef MODEL_H #define MODEL_H -struct mesh; +#include "mesh.h" +#include "HandmadeMath.h" + +extern HMM_Vec3 eye; struct shader; struct model { - struct mesh *meshes; - struct mesh *mp; + struct mesh *meshes; }; /* Get the model at a path, or create and return if it doesn't exist */ @@ -18,7 +20,9 @@ struct model *MakeModel(const char *path); /* Load a model from memory into the GPU */ void loadmodel(struct model *model); -void draw_model(struct model *model, struct shader *shader); +void model_init(); + +void draw_model(struct model *model, HMM_Mat4 amodel, HMM_Mat4 lsm); void draw_models(struct model *model, struct shader *shader); #endif diff --git a/source/engine/3d/skybox.c b/source/engine/3d/skybox.c index 95ed2b8..7f752d0 100644 --- a/source/engine/3d/skybox.c +++ b/source/engine/3d/skybox.c @@ -1,9 +1,9 @@ #include "skybox.h" -#include "shader.h" #include "camera.h" -#include +#include "shader.h" #include +#include #include "openglrender.h" @@ -48,82 +48,79 @@ static const float skyboxVertices[216] = { 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, 1.0f -}; + 1.0f, -1.0f, 1.0f}; -struct mSkybox *MakeSkybox(const char *cubemap) -{ -/* - struct mSkybox *newskybox = malloc(sizeof(struct mSkybox)); +struct mSkybox *MakeSkybox(const char *cubemap) { + /* + struct mSkybox *newskybox = malloc(sizeof(struct mSkybox)); - newskybox->shader = MakeShader("skyvert.glsl", "skyfrag.glsl"); - shader_compile(newskybox->shader); + newskybox->shader = MakeShader("skyvert.glsl", "skyfrag.glsl"); + shader_compile(newskybox->shader); - glGenVertexArrays(1, &newskybox->VAO); - glGenBuffers(1, &newskybox->VBO); - glBindVertexArray(newskybox->VAO); - glBindBuffer(GL_ARRAY_BUFFER, newskybox->VBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(skyboxVertices), &skyboxVertices, GL_STATIC_DRAW); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), - (void *) 0); + glGenVertexArrays(1, &newskybox->VAO); + glGenBuffers(1, &newskybox->VBO); + glBindVertexArray(newskybox->VAO); + glBindBuffer(GL_ARRAY_BUFFER, newskybox->VBO); + glBufferData(GL_ARRAY_BUFFER, sizeof(skyboxVertices), &skyboxVertices, GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), + (void *) 0); - shader_use(newskybox->shader); - shader_setint(newskybox->shader, "skybox", 0); -*/ -/* - const char *faces[6] = - { "right.jpg", "left.jpg", "top.jpg", "bottom.jpg", "front.jpg", - "back.jpg" - }; -*/ -/* - glGenTextures(1, &newskybox->id); - glBindTexture(GL_TEXTURE_CUBE_MAP, newskybox->id); -*/ - /*char buf[100] = { '\0' };*/ + shader_use(newskybox->shader); + shader_setint(newskybox->shader, "skybox", 0); + */ + /* + const char *faces[6] = + { "right.jpg", "left.jpg", "top.jpg", "bottom.jpg", "front.jpg", + "back.jpg" + }; + */ + /* + glGenTextures(1, &newskybox->id); + glBindTexture(GL_TEXTURE_CUBE_MAP, newskybox->id); + */ + /*char buf[100] = { '\0' };*/ - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) { /* - buf[0] = '\0'; - strcat(buf, cubemap); - strcat(buf, "/"); - strcat(buf, faces[i]); - IMG_Load(buf); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, 2048, - 2048, 0, GL_RGB, GL_UNSIGNED_BYTE, data->pixels); + buf[0] = '\0'; + strcat(buf, cubemap); + strcat(buf, "/"); + strcat(buf, faces[i]); + IMG_Load(buf); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, 2048, + 2048, 0, GL_RGB, GL_UNSIGNED_BYTE, data->pixels); */ - } -/* - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, - GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, - GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, - GL_CLAMP_TO_EDGE); + } + /* + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, + GL_CLAMP_TO_EDGE); - return newskybox; -*/ + return newskybox; + */ } void skybox_draw(const struct mSkybox *skybox, - const struct mCamera *camera) -{ -/* - shader_use(skybox->shader); + const struct mCamera *camera) { + /* + shader_use(skybox->shader); - mfloat_t view[16] = { 0.f }; - getviewmatrix(view, camera); - shader_setmat4(skybox->shader, "skyview", view); + mfloat_t view[16] = { 0.f }; + getviewmatrix(view, camera); + shader_setmat4(skybox->shader, "skyview", view); - // skybox cube - glBindVertexArray(skybox->VAO); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_CUBE_MAP, skybox->id); - glDrawArrays(GL_TRIANGLES, 0, 36); - glBindVertexArray(0); -*/ + // skybox cube + glBindVertexArray(skybox->VAO); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_CUBE_MAP, skybox->id); + glDrawArrays(GL_TRIANGLES, 0, 36); + glBindVertexArray(0); + */ } diff --git a/source/engine/3d/skybox.h b/source/engine/3d/skybox.h index ae9d018..2b8b2c7 100644 --- a/source/engine/3d/skybox.h +++ b/source/engine/3d/skybox.h @@ -4,14 +4,14 @@ struct mCamera; struct mSkybox { - unsigned int VAO; - unsigned int VBO; - unsigned int id; - struct shader *shader; + unsigned int VAO; + unsigned int VBO; + unsigned int id; + struct shader *shader; }; struct mSkybox *MakeSkybox(const char *cubemap); void skybox_draw(const struct mSkybox *skybox, - const struct mCamera *camera); + const struct mCamera *camera); #endif diff --git a/source/engine/HandmadeMath.h b/source/engine/HandmadeMath.h new file mode 100644 index 0000000..b0e8ce2 --- /dev/null +++ b/source/engine/HandmadeMath.h @@ -0,0 +1,3553 @@ +/* + HandmadeMath.h v2.0.0 + + This is a single header file with a bunch of useful types and functions for + games and graphics. Consider it a lightweight alternative to GLM that works + both C and C++. + + ============================================================================= + CONFIG + ============================================================================= + + By default, all angles in Handmade Math are specified in radians. However, it + can be configured to use degrees or turns instead. Use one of the following + defines to specify the default unit for angles: + + #define HANDMADE_MATH_USE_RADIANS + #define HANDMADE_MATH_USE_DEGREES + #define HANDMADE_MATH_USE_TURNS + + Regardless of the default angle, you can use the following functions to + specify an angle in a particular unit: + + HMM_AngleRad(radians) + HMM_AngleDeg(degrees) + HMM_AngleTurn(turns) + + The definitions of these functions change depending on the default unit. + + ----------------------------------------------------------------------------- + + Handmade Math ships with SSE (SIMD) implementations of several common + operations. To disable the use of SSE intrinsics, you must define + HANDMADE_MATH_NO_SSE before including this file: + + #define HANDMADE_MATH_NO_SSE + #include "HandmadeMath.h" + + ----------------------------------------------------------------------------- + + To use Handmade Math without the C runtime library, you must provide your own + implementations of basic math functions. Otherwise, HandmadeMath.h will use + the runtime library implementation of these functions. + + Define HANDMADE_MATH_PROVIDE_MATH_FUNCTIONS and provide your own + implementations of HMM_SINF, HMM_COSF, HMM_TANF, HMM_ACOSF, and HMM_SQRTF + before including HandmadeMath.h, like so: + + #define HANDMADE_MATH_PROVIDE_MATH_FUNCTIONS + #define HMM_SINF MySinF + #define HMM_COSF MyCosF + #define HMM_TANF MyTanF + #define HMM_ACOSF MyACosF + #define HMM_SQRTF MySqrtF + #include "HandmadeMath.h" + + By default, it is assumed that your math functions take radians. To use + different units, you must define HMM_ANGLE_USER_TO_INTERNAL and + HMM_ANGLE_INTERNAL_TO_USER. For example, if you want to use degrees in your + code but your math functions use turns: + + #define HMM_ANGLE_USER_TO_INTERNAL(a) ((a)*HMM_DegToTurn) + #define HMM_ANGLE_INTERNAL_TO_USER(a) ((a)*HMM_TurnToDeg) + + ============================================================================= + + LICENSE + + This software is in the public domain. Where that dedication is not + recognized, you are granted a perpetual, irrevocable license to copy, + distribute, and modify this file as you see fit. + + ============================================================================= + + CREDITS + + Originally written by Zakary Strange. + + Functionality: + Zakary Strange (strangezak@protonmail.com && @strangezak) + Matt Mascarenhas (@miblo_) + Aleph + FieryDrake (@fierydrake) + Gingerbill (@TheGingerBill) + Ben Visness (@bvisness) + Trinton Bullard (@Peliex_Dev) + @AntonDan + Logan Forman (@dev_dwarf) + + Fixes: + Jeroen van Rijn (@J_vanRijn) + Kiljacken (@Kiljacken) + Insofaras (@insofaras) + Daniel Gibson (@DanielGibson) +*/ + +#ifndef HANDMADE_MATH_H +#define HANDMADE_MATH_H + +// Dummy macros for when test framework is not present. +#ifndef COVERAGE +#define COVERAGE(a, b) +#endif + +#ifndef ASSERT_COVERED +#define ASSERT_COVERED(a) +#endif + +/* let's figure out if SSE is really available (unless disabled anyway) + (it isn't on non-x86/x86_64 platforms or even x86 without explicit SSE support) + => only use "#ifdef HANDMADE_MATH__USE_SSE" to check for SSE support below this block! */ +#ifndef HANDMADE_MATH_NO_SSE +#ifdef _MSC_VER /* MSVC supports SSE in amd64 mode or _M_IX86_FP >= 1 (2 means SSE2) */ +#if defined(_M_AMD64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1) +#define HANDMADE_MATH__USE_SSE 1 +#endif +#else /* not MSVC, probably GCC, clang, icc or something that doesn't support SSE anyway */ +#ifdef __SSE__ /* they #define __SSE__ if it's supported */ +#define HANDMADE_MATH__USE_SSE 1 +#endif /* __SSE__ */ +#endif /* not _MSC_VER */ +#endif /* #ifndef HANDMADE_MATH_NO_SSE */ + +#if (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) +#define HANDMADE_MATH__USE_C11_GENERICS 1 +#endif + +#ifdef HANDMADE_MATH__USE_SSE +#include +#endif + +#ifdef _MSC_VER +#pragma warning(disable : 4201) +#endif + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" +#if (defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 8)) || defined(__clang__) +#pragma GCC diagnostic ignored "-Wmissing-braces" +#endif +#ifdef __clang__ +#pragma GCC diagnostic ignored "-Wgnu-anonymous-struct" +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif +#endif + +#if defined(__GNUC__) || defined(__clang__) +#define HMM_DEPRECATED(msg) __attribute__((deprecated(msg))) +#elif defined(_MSC_VER) +#define HMM_DEPRECATED(msg) __declspec(deprecated(msg)) +#else +#define HMM_DEPRECATED(msg) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(HANDMADE_MATH_USE_DEGREES) && !defined(HANDMADE_MATH_USE_TURNS) && !defined(HANDMADE_MATH_USE_RADIANS) +#define HANDMADE_MATH_USE_RADIANS +#endif + +#define HMM_PI 3.14159265358979323846 +#define HMM_PI32 3.14159265359f +#define HMM_DEG180 180.0 +#define HMM_DEG18032 180.0f +#define HMM_TURNHALF 0.5 +#define HMM_TURNHALF32 0.5f +#define HMM_RadToDeg ((float)(HMM_DEG180 / HMM_PI)) +#define HMM_RadToTurn ((float)(HMM_TURNHALF / HMM_PI)) +#define HMM_DegToRad ((float)(HMM_PI / HMM_DEG180)) +#define HMM_DegToTurn ((float)(HMM_TURNHALF / HMM_DEG180)) +#define HMM_TurnToRad ((float)(HMM_PI / HMM_TURNHALF)) +#define HMM_TurnToDeg ((float)(HMM_DEG180 / HMM_TURNHALF)) + +#if defined(HANDMADE_MATH_USE_RADIANS) +#define HMM_AngleRad(a) (a) +#define HMM_AngleDeg(a) ((a)*HMM_DegToRad) +#define HMM_AngleTurn(a) ((a)*HMM_TurnToRad) +#elif defined(HANDMADE_MATH_USE_DEGREES) +#define HMM_AngleRad(a) ((a)*HMM_RadToDeg) +#define HMM_AngleDeg(a) (a) +#define HMM_AngleTurn(a) ((a)*HMM_TurnToDeg) +#elif defined(HANDMADE_MATH_USE_TURNS) +#define HMM_AngleRad(a) ((a)*HMM_RadToTurn) +#define HMM_AngleDeg(a) ((a)*HMM_DegToTurn) +#define HMM_AngleTurn(a) (a) +#endif + +#if !defined(HANDMADE_MATH_PROVIDE_MATH_FUNCTIONS) +#include +#define HMM_SINF sinf +#define HMM_COSF cosf +#define HMM_TANF tanf +#define HMM_SQRTF sqrtf +#define HMM_ACOSF acosf +#endif + +#if !defined(HMM_ANGLE_USER_TO_INTERNAL) +#define HMM_ANGLE_USER_TO_INTERNAL(a) (HMM_ToRad(a)) +#endif + +#if !defined(HMM_ANGLE_INTERNAL_TO_USER) +#if defined(HANDMADE_MATH_USE_RADIANS) +#define HMM_ANGLE_INTERNAL_TO_USER(a) (a) +#elif defined(HANDMADE_MATH_USE_DEGREES) +#define HMM_ANGLE_INTERNAL_TO_USER(a) ((a)*HMM_RadToDeg) +#elif defined(HANDMADE_MATH_USE_TURNS) +#define HMM_ANGLE_INTERNAL_TO_USER(a) ((a)*HMM_RadToTurn) +#endif +#endif + +#define HMM_MIN(a, b) ((a) > (b) ? (b) : (a)) +#define HMM_MAX(a, b) ((a) < (b) ? (b) : (a)) +#define HMM_ABS(a) ((a) > 0 ? (a) : -(a)) +#define HMM_MOD(a, m) (((a) % (m)) >= 0 ? ((a) % (m)) : (((a) % (m)) + (m))) +#define HMM_SQUARE(x) ((x) * (x)) + +typedef union HMM_Vec2 { + struct + { + float X, Y; + }; + + struct + { + float U, V; + }; + + struct + { + float Left, Right; + }; + + struct + { + float Width, Height; + }; + + float Elements[2]; + +#ifdef __cplusplus + inline float &operator[](const int &Index) { + return Elements[Index]; + } +#endif +} HMM_Vec2; + +typedef union HMM_Vec3 { + struct + { + float X, Y, Z; + }; + + struct + { + float U, V, W; + }; + + struct + { + float R, G, B; + }; + + struct + { + HMM_Vec2 XY; + float _Ignored0; + }; + + struct + { + float _Ignored1; + HMM_Vec2 YZ; + }; + + struct + { + HMM_Vec2 UV; + float _Ignored2; + }; + + struct + { + float _Ignored3; + HMM_Vec2 VW; + }; + + float Elements[3]; + +#ifdef __cplusplus + inline float &operator[](const int &Index) { + return Elements[Index]; + } +#endif +} HMM_Vec3; + +typedef union HMM_Vec4 { + struct + { + union { + HMM_Vec3 XYZ; + struct + { + float X, Y, Z; + }; + }; + + float W; + }; + struct + { + union { + HMM_Vec3 RGB; + struct + { + float R, G, B; + }; + }; + + float A; + }; + + struct + { + HMM_Vec2 XY; + float _Ignored0; + float _Ignored1; + }; + + struct + { + float _Ignored2; + HMM_Vec2 YZ; + float _Ignored3; + }; + + struct + { + float _Ignored4; + float _Ignored5; + HMM_Vec2 ZW; + }; + + float Elements[4]; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 SSE; +#endif + +#ifdef __cplusplus + inline float &operator[](const int &Index) { + return Elements[Index]; + } +#endif +} HMM_Vec4; + +typedef union HMM_Mat2 { + float Elements[2][2]; + HMM_Vec2 Columns[2]; + +#ifdef __cplusplus + inline HMM_Vec2 &operator[](const int &Index) { + return Columns[Index]; + } +#endif +} HMM_Mat2; + +typedef union HMM_Mat3 { + float Elements[3][3]; + HMM_Vec3 Columns[3]; + +#ifdef __cplusplus + inline HMM_Vec3 &operator[](const int &Index) { + return Columns[Index]; + } +#endif +} HMM_Mat3; + +typedef union HMM_Mat4 { + float Elements[4][4]; + HMM_Vec4 Columns[4]; + +#ifdef __cplusplus + inline HMM_Vec4 &operator[](const int &Index) { + return Columns[Index]; + } +#endif +} HMM_Mat4; + +typedef union HMM_Quat { + struct + { + union { + HMM_Vec3 XYZ; + struct + { + float X, Y, Z; + }; + }; + + float W; + }; + + float Elements[4]; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 SSE; +#endif +} HMM_Quat; + +typedef signed int HMM_Bool; + +/* + * Angle unit conversion functions + */ +static inline float HMM_ToRad(float Angle) { +#if defined(HANDMADE_MATH_USE_RADIANS) + float Result = Angle; +#elif defined(HANDMADE_MATH_USE_DEGREES) + float Result = Angle * HMM_DegToRad; +#elif defined(HANDMADE_MATH_USE_TURNS) + float Result = Angle * HMM_TurnToRad; +#endif + + return Result; +} + +static inline float HMM_ToDeg(float Angle) { +#if defined(HANDMADE_MATH_USE_RADIANS) + float Result = Angle * HMM_RadToDeg; +#elif defined(HANDMADE_MATH_USE_DEGREES) + float Result = Angle; +#elif defined(HANDMADE_MATH_USE_TURNS) + float Result = Angle * HMM_TurnToDeg; +#endif + + return Result; +} + +static inline float HMM_ToTurn(float Angle) { +#if defined(HANDMADE_MATH_USE_RADIANS) + float Result = Angle * HMM_RadToTurn; +#elif defined(HANDMADE_MATH_USE_DEGREES) + float Result = Angle * HMM_DegToTurn; +#elif defined(HANDMADE_MATH_USE_TURNS) + float Result = Angle; +#endif + + return Result; +} + +/* + * Floating-point math functions + */ + +COVERAGE(HMM_SinF, 1) +static inline float HMM_SinF(float Angle) { + ASSERT_COVERED(HMM_SinF); + return HMM_SINF(HMM_ANGLE_USER_TO_INTERNAL(Angle)); +} + +COVERAGE(HMM_CosF, 1) +static inline float HMM_CosF(float Angle) { + ASSERT_COVERED(HMM_CosF); + return HMM_COSF(HMM_ANGLE_USER_TO_INTERNAL(Angle)); +} + +COVERAGE(HMM_TanF, 1) +static inline float HMM_TanF(float Angle) { + ASSERT_COVERED(HMM_TanF); + return HMM_TANF(HMM_ANGLE_USER_TO_INTERNAL(Angle)); +} + +COVERAGE(HMM_ACosF, 1) +static inline float HMM_ACosF(float Arg) { + ASSERT_COVERED(HMM_ACosF); + return HMM_ANGLE_INTERNAL_TO_USER(HMM_ACOSF(Arg)); +} + +COVERAGE(HMM_SqrtF, 1) +static inline float HMM_SqrtF(float Float) { + ASSERT_COVERED(HMM_SqrtF); + + float Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 In = _mm_set_ss(Float); + __m128 Out = _mm_sqrt_ss(In); + Result = _mm_cvtss_f32(Out); +#else + Result = HMM_SQRTF(Float); +#endif + + return Result; +} + +COVERAGE(HMM_InvSqrtF, 1) +static inline float HMM_InvSqrtF(float Float) { + ASSERT_COVERED(HMM_InvSqrtF); + + float Result; + + Result = 1.0f / HMM_SqrtF(Float); + + return Result; +} + +/* + * Utility functions + */ + +COVERAGE(HMM_Lerp, 1) +static inline float HMM_Lerp(float A, float Time, float B) { + ASSERT_COVERED(HMM_Lerp); + return (1.0f - Time) * A + Time * B; +} + +COVERAGE(HMM_Clamp, 1) +static inline float HMM_Clamp(float Min, float Value, float Max) { + ASSERT_COVERED(HMM_Clamp); + + float Result = Value; + + if (Result < Min) { + Result = Min; + } + + if (Result > Max) { + Result = Max; + } + + return Result; +} + +/* + * Vector initialization + */ + +COVERAGE(HMM_V2, 1) +static inline HMM_Vec2 HMM_V2(float X, float Y) { + ASSERT_COVERED(HMM_V2); + + HMM_Vec2 Result; + Result.X = X; + Result.Y = Y; + + return Result; +} + +COVERAGE(HMM_V3, 1) +static inline HMM_Vec3 HMM_V3(float X, float Y, float Z) { + ASSERT_COVERED(HMM_V3); + + HMM_Vec3 Result; + Result.X = X; + Result.Y = Y; + Result.Z = Z; + + return Result; +} + +COVERAGE(HMM_V4, 1) +static inline HMM_Vec4 HMM_V4(float X, float Y, float Z, float W) { + ASSERT_COVERED(HMM_V4); + + HMM_Vec4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_setr_ps(X, Y, Z, W); +#else + Result.X = X; + Result.Y = Y; + Result.Z = Z; + Result.W = W; +#endif + + return Result; +} + +COVERAGE(HMM_V4V, 1) +static inline HMM_Vec4 HMM_V4V(HMM_Vec3 Vector, float W) { + ASSERT_COVERED(HMM_V4V); + + HMM_Vec4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_setr_ps(Vector.X, Vector.Y, Vector.Z, W); +#else + Result.XYZ = Vector; + Result.W = W; +#endif + + return Result; +} + +/* + * Binary vector operations + */ + +COVERAGE(HMM_AddV2, 1) +static inline HMM_Vec2 HMM_AddV2(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_AddV2); + + HMM_Vec2 Result; + Result.X = Left.X + Right.X; + Result.Y = Left.Y + Right.Y; + + return Result; +} + +COVERAGE(HMM_AddV3, 1) +static inline HMM_Vec3 HMM_AddV3(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_AddV3); + + HMM_Vec3 Result; + Result.X = Left.X + Right.X; + Result.Y = Left.Y + Right.Y; + Result.Z = Left.Z + Right.Z; + + return Result; +} + +COVERAGE(HMM_AddV4, 1) +static inline HMM_Vec4 HMM_AddV4(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_AddV4); + + HMM_Vec4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_add_ps(Left.SSE, Right.SSE); +#else + Result.X = Left.X + Right.X; + Result.Y = Left.Y + Right.Y; + Result.Z = Left.Z + Right.Z; + Result.W = Left.W + Right.W; +#endif + + return Result; +} + +COVERAGE(HMM_SubV2, 1) +static inline HMM_Vec2 HMM_SubV2(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_SubV2); + + HMM_Vec2 Result; + Result.X = Left.X - Right.X; + Result.Y = Left.Y - Right.Y; + + return Result; +} + +COVERAGE(HMM_SubV3, 1) +static inline HMM_Vec3 HMM_SubV3(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_SubV3); + + HMM_Vec3 Result; + Result.X = Left.X - Right.X; + Result.Y = Left.Y - Right.Y; + Result.Z = Left.Z - Right.Z; + + return Result; +} + +COVERAGE(HMM_SubV4, 1) +static inline HMM_Vec4 HMM_SubV4(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_SubV4); + + HMM_Vec4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_sub_ps(Left.SSE, Right.SSE); +#else + Result.X = Left.X - Right.X; + Result.Y = Left.Y - Right.Y; + Result.Z = Left.Z - Right.Z; + Result.W = Left.W - Right.W; +#endif + + return Result; +} + +COVERAGE(HMM_MulV2, 1) +static inline HMM_Vec2 HMM_MulV2(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_MulV2); + + HMM_Vec2 Result; + Result.X = Left.X * Right.X; + Result.Y = Left.Y * Right.Y; + + return Result; +} + +COVERAGE(HMM_MulV2F, 1) +static inline HMM_Vec2 HMM_MulV2F(HMM_Vec2 Left, float Right) { + ASSERT_COVERED(HMM_MulV2F); + + HMM_Vec2 Result; + Result.X = Left.X * Right; + Result.Y = Left.Y * Right; + + return Result; +} + +COVERAGE(HMM_MulV3, 1) +static inline HMM_Vec3 HMM_MulV3(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_MulV3); + + HMM_Vec3 Result; + Result.X = Left.X * Right.X; + Result.Y = Left.Y * Right.Y; + Result.Z = Left.Z * Right.Z; + + return Result; +} + +COVERAGE(HMM_MulV3F, 1) +static inline HMM_Vec3 HMM_MulV3F(HMM_Vec3 Left, float Right) { + ASSERT_COVERED(HMM_MulV3F); + + HMM_Vec3 Result; + Result.X = Left.X * Right; + Result.Y = Left.Y * Right; + Result.Z = Left.Z * Right; + + return Result; +} + +COVERAGE(HMM_MulV4, 1) +static inline HMM_Vec4 HMM_MulV4(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_MulV4); + + HMM_Vec4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_mul_ps(Left.SSE, Right.SSE); +#else + Result.X = Left.X * Right.X; + Result.Y = Left.Y * Right.Y; + Result.Z = Left.Z * Right.Z; + Result.W = Left.W * Right.W; +#endif + + return Result; +} + +COVERAGE(HMM_MulV4F, 1) +static inline HMM_Vec4 HMM_MulV4F(HMM_Vec4 Left, float Right) { + ASSERT_COVERED(HMM_MulV4F); + + HMM_Vec4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 Scalar = _mm_set1_ps(Right); + Result.SSE = _mm_mul_ps(Left.SSE, Scalar); +#else + Result.X = Left.X * Right; + Result.Y = Left.Y * Right; + Result.Z = Left.Z * Right; + Result.W = Left.W * Right; +#endif + + return Result; +} + +COVERAGE(HMM_DivV2, 1) +static inline HMM_Vec2 HMM_DivV2(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_DivV2); + + HMM_Vec2 Result; + Result.X = Left.X / Right.X; + Result.Y = Left.Y / Right.Y; + + return Result; +} + +COVERAGE(HMM_DivV2F, 1) +static inline HMM_Vec2 HMM_DivV2F(HMM_Vec2 Left, float Right) { + ASSERT_COVERED(HMM_DivV2F); + + HMM_Vec2 Result; + Result.X = Left.X / Right; + Result.Y = Left.Y / Right; + + return Result; +} + +COVERAGE(HMM_DivV3, 1) +static inline HMM_Vec3 HMM_DivV3(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_DivV3); + + HMM_Vec3 Result; + Result.X = Left.X / Right.X; + Result.Y = Left.Y / Right.Y; + Result.Z = Left.Z / Right.Z; + + return Result; +} + +COVERAGE(HMM_DivV3F, 1) +static inline HMM_Vec3 HMM_DivV3F(HMM_Vec3 Left, float Right) { + ASSERT_COVERED(HMM_DivV3F); + + HMM_Vec3 Result; + Result.X = Left.X / Right; + Result.Y = Left.Y / Right; + Result.Z = Left.Z / Right; + + return Result; +} + +COVERAGE(HMM_DivV4, 1) +static inline HMM_Vec4 HMM_DivV4(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_DivV4); + + HMM_Vec4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_div_ps(Left.SSE, Right.SSE); +#else + Result.X = Left.X / Right.X; + Result.Y = Left.Y / Right.Y; + Result.Z = Left.Z / Right.Z; + Result.W = Left.W / Right.W; +#endif + + return Result; +} + +COVERAGE(HMM_DivV4F, 1) +static inline HMM_Vec4 HMM_DivV4F(HMM_Vec4 Left, float Right) { + ASSERT_COVERED(HMM_DivV4F); + + HMM_Vec4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 Scalar = _mm_set1_ps(Right); + Result.SSE = _mm_div_ps(Left.SSE, Scalar); +#else + Result.X = Left.X / Right; + Result.Y = Left.Y / Right; + Result.Z = Left.Z / Right; + Result.W = Left.W / Right; +#endif + + return Result; +} + +COVERAGE(HMM_EqV2, 1) +static inline HMM_Bool HMM_EqV2(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_EqV2); + return Left.X == Right.X && Left.Y == Right.Y; +} + +COVERAGE(HMM_EqV3, 1) +static inline HMM_Bool HMM_EqV3(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_EqV3); + return Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z; +} + +COVERAGE(HMM_EqV4, 1) +static inline HMM_Bool HMM_EqV4(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_EqV4); + return Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z && Left.W == Right.W; +} + +COVERAGE(HMM_DotV2, 1) +static inline float HMM_DotV2(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_DotV2); + return (Left.X * Right.X) + (Left.Y * Right.Y); +} + +COVERAGE(HMM_DotV3, 1) +static inline float HMM_DotV3(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_DotV3); + return (Left.X * Right.X) + (Left.Y * Right.Y) + (Left.Z * Right.Z); +} + +COVERAGE(HMM_DotV4, 1) +static inline float HMM_DotV4(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_DotV4); + + float Result; + + // NOTE(zak): IN the future if we wanna check what version SSE is support + // we can use _mm_dp_ps (4.3) but for now we will use the old way. + // Or a r = _mm_mul_ps(v1, v2), r = _mm_hadd_ps(r, r), r = _mm_hadd_ps(r, r) for SSE3 +#ifdef HANDMADE_MATH__USE_SSE + __m128 SSEResultOne = _mm_mul_ps(Left.SSE, Right.SSE); + __m128 SSEResultTwo = _mm_shuffle_ps(SSEResultOne, SSEResultOne, _MM_SHUFFLE(2, 3, 0, 1)); + SSEResultOne = _mm_add_ps(SSEResultOne, SSEResultTwo); + SSEResultTwo = _mm_shuffle_ps(SSEResultOne, SSEResultOne, _MM_SHUFFLE(0, 1, 2, 3)); + SSEResultOne = _mm_add_ps(SSEResultOne, SSEResultTwo); + _mm_store_ss(&Result, SSEResultOne); +#else + Result = ((Left.X * Right.X) + (Left.Z * Right.Z)) + ((Left.Y * Right.Y) + (Left.W * Right.W)); +#endif + + return Result; +} + +COVERAGE(HMM_Cross, 1) +static inline HMM_Vec3 HMM_Cross(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_Cross); + + HMM_Vec3 Result; + Result.X = (Left.Y * Right.Z) - (Left.Z * Right.Y); + Result.Y = (Left.Z * Right.X) - (Left.X * Right.Z); + Result.Z = (Left.X * Right.Y) - (Left.Y * Right.X); + + return Result; +} + +/* + * Unary vector operations + */ + +COVERAGE(HMM_LenSqrV2, 1) +static inline float HMM_LenSqrV2(HMM_Vec2 A) { + ASSERT_COVERED(HMM_LenSqrV2); + return HMM_DotV2(A, A); +} + +COVERAGE(HMM_LenSqrV3, 1) +static inline float HMM_LenSqrV3(HMM_Vec3 A) { + ASSERT_COVERED(HMM_LenSqrV3); + return HMM_DotV3(A, A); +} + +COVERAGE(HMM_LenSqrV4, 1) +static inline float HMM_LenSqrV4(HMM_Vec4 A) { + ASSERT_COVERED(HMM_LenSqrV4); + return HMM_DotV4(A, A); +} + +COVERAGE(HMM_LenV2, 1) +static inline float HMM_LenV2(HMM_Vec2 A) { + ASSERT_COVERED(HMM_LenV2); + return HMM_SqrtF(HMM_LenSqrV2(A)); +} + +COVERAGE(HMM_LenV3, 1) +static inline float HMM_LenV3(HMM_Vec3 A) { + ASSERT_COVERED(HMM_LenV3); + return HMM_SqrtF(HMM_LenSqrV3(A)); +} + +COVERAGE(HMM_LenV4, 1) +static inline float HMM_LenV4(HMM_Vec4 A) { + ASSERT_COVERED(HMM_LenV4); + return HMM_SqrtF(HMM_LenSqrV4(A)); +} + +COVERAGE(HMM_NormV2, 1) +static inline HMM_Vec2 HMM_NormV2(HMM_Vec2 A) { + ASSERT_COVERED(HMM_NormV2); + return HMM_MulV2F(A, HMM_InvSqrtF(HMM_DotV2(A, A))); +} + +COVERAGE(HMM_NormV3, 1) +static inline HMM_Vec3 HMM_NormV3(HMM_Vec3 A) { + ASSERT_COVERED(HMM_NormV3); + return HMM_MulV3F(A, HMM_InvSqrtF(HMM_DotV3(A, A))); +} + +COVERAGE(HMM_NormV4, 1) +static inline HMM_Vec4 HMM_NormV4(HMM_Vec4 A) { + ASSERT_COVERED(HMM_NormV4); + return HMM_MulV4F(A, HMM_InvSqrtF(HMM_DotV4(A, A))); +} + +/* + * Utility vector functions + */ + +COVERAGE(HMM_LerpV2, 1) +static inline HMM_Vec2 HMM_LerpV2(HMM_Vec2 A, float Time, HMM_Vec2 B) { + ASSERT_COVERED(HMM_LerpV2); + return HMM_AddV2(HMM_MulV2F(A, 1.0f - Time), HMM_MulV2F(B, Time)); +} + +COVERAGE(HMM_LerpV3, 1) +static inline HMM_Vec3 HMM_LerpV3(HMM_Vec3 A, float Time, HMM_Vec3 B) { + ASSERT_COVERED(HMM_LerpV3); + return HMM_AddV3(HMM_MulV3F(A, 1.0f - Time), HMM_MulV3F(B, Time)); +} + +COVERAGE(HMM_LerpV4, 1) +static inline HMM_Vec4 HMM_LerpV4(HMM_Vec4 A, float Time, HMM_Vec4 B) { + ASSERT_COVERED(HMM_LerpV4); + return HMM_AddV4(HMM_MulV4F(A, 1.0f - Time), HMM_MulV4F(B, Time)); +} + +/* + * SSE stuff + */ + +COVERAGE(HMM_LinearCombineV4M4, 1) +static inline HMM_Vec4 HMM_LinearCombineV4M4(HMM_Vec4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_LinearCombineV4M4); + + HMM_Vec4 Result; +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_mul_ps(_mm_shuffle_ps(Left.SSE, Left.SSE, 0x00), Right.Columns[0].SSE); + Result.SSE = _mm_add_ps(Result.SSE, _mm_mul_ps(_mm_shuffle_ps(Left.SSE, Left.SSE, 0x55), Right.Columns[1].SSE)); + Result.SSE = _mm_add_ps(Result.SSE, _mm_mul_ps(_mm_shuffle_ps(Left.SSE, Left.SSE, 0xaa), Right.Columns[2].SSE)); + Result.SSE = _mm_add_ps(Result.SSE, _mm_mul_ps(_mm_shuffle_ps(Left.SSE, Left.SSE, 0xff), Right.Columns[3].SSE)); +#else + Result.X = Left.Elements[0] * Right.Columns[0].X; + Result.Y = Left.Elements[0] * Right.Columns[0].Y; + Result.Z = Left.Elements[0] * Right.Columns[0].Z; + Result.W = Left.Elements[0] * Right.Columns[0].W; + + Result.X += Left.Elements[1] * Right.Columns[1].X; + Result.Y += Left.Elements[1] * Right.Columns[1].Y; + Result.Z += Left.Elements[1] * Right.Columns[1].Z; + Result.W += Left.Elements[1] * Right.Columns[1].W; + + Result.X += Left.Elements[2] * Right.Columns[2].X; + Result.Y += Left.Elements[2] * Right.Columns[2].Y; + Result.Z += Left.Elements[2] * Right.Columns[2].Z; + Result.W += Left.Elements[2] * Right.Columns[2].W; + + Result.X += Left.Elements[3] * Right.Columns[3].X; + Result.Y += Left.Elements[3] * Right.Columns[3].Y; + Result.Z += Left.Elements[3] * Right.Columns[3].Z; + Result.W += Left.Elements[3] * Right.Columns[3].W; +#endif + + return Result; +} + +/* + * 2x2 Matrices + */ + +COVERAGE(HMM_M2, 1) +static inline HMM_Mat2 HMM_M2(void) { + ASSERT_COVERED(HMM_M2); + HMM_Mat2 Result = {0}; + return Result; +} + +COVERAGE(HMM_M2D, 1) +static inline HMM_Mat2 HMM_M2D(float Diagonal) { + ASSERT_COVERED(HMM_M2D); + + HMM_Mat2 Result = {0}; + Result.Elements[0][0] = Diagonal; + Result.Elements[1][1] = Diagonal; + + return Result; +} + +COVERAGE(HMM_TransposeM2, 1) +static inline HMM_Mat2 HMM_TransposeM2(HMM_Mat2 Matrix) { + ASSERT_COVERED(HMM_TransposeM2); + + HMM_Mat2 Result = Matrix; + + Result.Elements[0][1] = Matrix.Elements[1][0]; + Result.Elements[1][0] = Matrix.Elements[0][1]; + + return Result; +} + +COVERAGE(HMM_AddM2, 1) +static inline HMM_Mat2 HMM_AddM2(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_AddM2); + + HMM_Mat2 Result; + + Result.Elements[0][0] = Left.Elements[0][0] + Right.Elements[0][0]; + Result.Elements[0][1] = Left.Elements[0][1] + Right.Elements[0][1]; + Result.Elements[1][0] = Left.Elements[1][0] + Right.Elements[1][0]; + Result.Elements[1][1] = Left.Elements[1][1] + Right.Elements[1][1]; + + return Result; +} + +COVERAGE(HMM_SubM2, 1) +static inline HMM_Mat2 HMM_SubM2(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_SubM2); + + HMM_Mat2 Result; + + Result.Elements[0][0] = Left.Elements[0][0] - Right.Elements[0][0]; + Result.Elements[0][1] = Left.Elements[0][1] - Right.Elements[0][1]; + Result.Elements[1][0] = Left.Elements[1][0] - Right.Elements[1][0]; + Result.Elements[1][1] = Left.Elements[1][1] - Right.Elements[1][1]; + + return Result; +} + +COVERAGE(HMM_MulM2V2, 1) +static inline HMM_Vec2 HMM_MulM2V2(HMM_Mat2 Matrix, HMM_Vec2 Vector) { + ASSERT_COVERED(HMM_MulM2V2); + + HMM_Vec2 Result; + + Result.X = Vector.Elements[0] * Matrix.Columns[0].X; + Result.Y = Vector.Elements[0] * Matrix.Columns[0].Y; + + Result.X += Vector.Elements[1] * Matrix.Columns[1].X; + Result.Y += Vector.Elements[1] * Matrix.Columns[1].Y; + + return Result; +} + +COVERAGE(HMM_MulM2, 1) +static inline HMM_Mat2 HMM_MulM2(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_MulM2); + + HMM_Mat2 Result; + Result.Columns[0] = HMM_MulM2V2(Left, Right.Columns[0]); + Result.Columns[1] = HMM_MulM2V2(Left, Right.Columns[1]); + + return Result; +} + +COVERAGE(HMM_MulM2F, 1) +static inline HMM_Mat2 HMM_MulM2F(HMM_Mat2 Matrix, float Scalar) { + ASSERT_COVERED(HMM_MulM2F); + + HMM_Mat2 Result; + + Result.Elements[0][0] = Matrix.Elements[0][0] * Scalar; + Result.Elements[0][1] = Matrix.Elements[0][1] * Scalar; + Result.Elements[1][0] = Matrix.Elements[1][0] * Scalar; + Result.Elements[1][1] = Matrix.Elements[1][1] * Scalar; + + return Result; +} + +COVERAGE(HMM_DivM2F, 1) +static inline HMM_Mat2 HMM_DivM2F(HMM_Mat2 Matrix, float Scalar) { + ASSERT_COVERED(HMM_DivM2F); + + HMM_Mat2 Result; + + Result.Elements[0][0] = Matrix.Elements[0][0] / Scalar; + Result.Elements[0][1] = Matrix.Elements[0][1] / Scalar; + Result.Elements[1][0] = Matrix.Elements[1][0] / Scalar; + Result.Elements[1][1] = Matrix.Elements[1][1] / Scalar; + + return Result; +} + +COVERAGE(HMM_DeterminantM2, 1) +static inline float HMM_DeterminantM2(HMM_Mat2 Matrix) { + ASSERT_COVERED(HMM_DeterminantM2); + return Matrix.Elements[0][0] * Matrix.Elements[1][1] - Matrix.Elements[0][1] * Matrix.Elements[1][0]; +} + +COVERAGE(HMM_InvGeneralM2, 1) +static inline HMM_Mat2 HMM_InvGeneralM2(HMM_Mat2 Matrix) { + ASSERT_COVERED(HMM_InvGeneralM2); + + HMM_Mat2 Result; + float InvDeterminant = 1.0f / HMM_DeterminantM2(Matrix); + Result.Elements[0][0] = InvDeterminant * +Matrix.Elements[1][1]; + Result.Elements[1][1] = InvDeterminant * +Matrix.Elements[0][0]; + Result.Elements[0][1] = InvDeterminant * -Matrix.Elements[0][1]; + Result.Elements[1][0] = InvDeterminant * -Matrix.Elements[1][0]; + + return Result; +} + +/* + * 3x3 Matrices + */ + +COVERAGE(HMM_M3, 1) +static inline HMM_Mat3 HMM_M3(void) { + ASSERT_COVERED(HMM_M3); + HMM_Mat3 Result = {0}; + return Result; +} + +COVERAGE(HMM_M3D, 1) +static inline HMM_Mat3 HMM_M3D(float Diagonal) { + ASSERT_COVERED(HMM_M3D); + + HMM_Mat3 Result = {0}; + Result.Elements[0][0] = Diagonal; + Result.Elements[1][1] = Diagonal; + Result.Elements[2][2] = Diagonal; + + return Result; +} + +COVERAGE(HMM_TransposeM3, 1) +static inline HMM_Mat3 HMM_TransposeM3(HMM_Mat3 Matrix) { + ASSERT_COVERED(HMM_TransposeM3); + + HMM_Mat3 Result = Matrix; + + Result.Elements[0][1] = Matrix.Elements[1][0]; + Result.Elements[0][2] = Matrix.Elements[2][0]; + Result.Elements[1][0] = Matrix.Elements[0][1]; + Result.Elements[1][2] = Matrix.Elements[2][1]; + Result.Elements[2][1] = Matrix.Elements[1][2]; + Result.Elements[2][0] = Matrix.Elements[0][2]; + + return Result; +} + +COVERAGE(HMM_AddM3, 1) +static inline HMM_Mat3 HMM_AddM3(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_AddM3); + + HMM_Mat3 Result; + + Result.Elements[0][0] = Left.Elements[0][0] + Right.Elements[0][0]; + Result.Elements[0][1] = Left.Elements[0][1] + Right.Elements[0][1]; + Result.Elements[0][2] = Left.Elements[0][2] + Right.Elements[0][2]; + Result.Elements[1][0] = Left.Elements[1][0] + Right.Elements[1][0]; + Result.Elements[1][1] = Left.Elements[1][1] + Right.Elements[1][1]; + Result.Elements[1][2] = Left.Elements[1][2] + Right.Elements[1][2]; + Result.Elements[2][0] = Left.Elements[2][0] + Right.Elements[2][0]; + Result.Elements[2][1] = Left.Elements[2][1] + Right.Elements[2][1]; + Result.Elements[2][2] = Left.Elements[2][2] + Right.Elements[2][2]; + + return Result; +} + +COVERAGE(HMM_SubM3, 1) +static inline HMM_Mat3 HMM_SubM3(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_SubM3); + + HMM_Mat3 Result; + + Result.Elements[0][0] = Left.Elements[0][0] - Right.Elements[0][0]; + Result.Elements[0][1] = Left.Elements[0][1] - Right.Elements[0][1]; + Result.Elements[0][2] = Left.Elements[0][2] - Right.Elements[0][2]; + Result.Elements[1][0] = Left.Elements[1][0] - Right.Elements[1][0]; + Result.Elements[1][1] = Left.Elements[1][1] - Right.Elements[1][1]; + Result.Elements[1][2] = Left.Elements[1][2] - Right.Elements[1][2]; + Result.Elements[2][0] = Left.Elements[2][0] - Right.Elements[2][0]; + Result.Elements[2][1] = Left.Elements[2][1] - Right.Elements[2][1]; + Result.Elements[2][2] = Left.Elements[2][2] - Right.Elements[2][2]; + + return Result; +} + +COVERAGE(HMM_MulM3V3, 1) +static inline HMM_Vec3 HMM_MulM3V3(HMM_Mat3 Matrix, HMM_Vec3 Vector) { + ASSERT_COVERED(HMM_MulM3V3); + + HMM_Vec3 Result; + + Result.X = Vector.Elements[0] * Matrix.Columns[0].X; + Result.Y = Vector.Elements[0] * Matrix.Columns[0].Y; + Result.Z = Vector.Elements[0] * Matrix.Columns[0].Z; + + Result.X += Vector.Elements[1] * Matrix.Columns[1].X; + Result.Y += Vector.Elements[1] * Matrix.Columns[1].Y; + Result.Z += Vector.Elements[1] * Matrix.Columns[1].Z; + + Result.X += Vector.Elements[2] * Matrix.Columns[2].X; + Result.Y += Vector.Elements[2] * Matrix.Columns[2].Y; + Result.Z += Vector.Elements[2] * Matrix.Columns[2].Z; + + return Result; +} + +COVERAGE(HMM_MulM3, 1) +static inline HMM_Mat3 HMM_MulM3(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_MulM3); + + HMM_Mat3 Result; + Result.Columns[0] = HMM_MulM3V3(Left, Right.Columns[0]); + Result.Columns[1] = HMM_MulM3V3(Left, Right.Columns[1]); + Result.Columns[2] = HMM_MulM3V3(Left, Right.Columns[2]); + + return Result; +} + +COVERAGE(HMM_MulM3F, 1) +static inline HMM_Mat3 HMM_MulM3F(HMM_Mat3 Matrix, float Scalar) { + ASSERT_COVERED(HMM_MulM3F); + + HMM_Mat3 Result; + + Result.Elements[0][0] = Matrix.Elements[0][0] * Scalar; + Result.Elements[0][1] = Matrix.Elements[0][1] * Scalar; + Result.Elements[0][2] = Matrix.Elements[0][2] * Scalar; + Result.Elements[1][0] = Matrix.Elements[1][0] * Scalar; + Result.Elements[1][1] = Matrix.Elements[1][1] * Scalar; + Result.Elements[1][2] = Matrix.Elements[1][2] * Scalar; + Result.Elements[2][0] = Matrix.Elements[2][0] * Scalar; + Result.Elements[2][1] = Matrix.Elements[2][1] * Scalar; + Result.Elements[2][2] = Matrix.Elements[2][2] * Scalar; + + return Result; +} + +COVERAGE(HMM_DivM3, 1) +static inline HMM_Mat3 HMM_DivM3F(HMM_Mat3 Matrix, float Scalar) { + ASSERT_COVERED(HMM_DivM3); + + HMM_Mat3 Result; + + Result.Elements[0][0] = Matrix.Elements[0][0] / Scalar; + Result.Elements[0][1] = Matrix.Elements[0][1] / Scalar; + Result.Elements[0][2] = Matrix.Elements[0][2] / Scalar; + Result.Elements[1][0] = Matrix.Elements[1][0] / Scalar; + Result.Elements[1][1] = Matrix.Elements[1][1] / Scalar; + Result.Elements[1][2] = Matrix.Elements[1][2] / Scalar; + Result.Elements[2][0] = Matrix.Elements[2][0] / Scalar; + Result.Elements[2][1] = Matrix.Elements[2][1] / Scalar; + Result.Elements[2][2] = Matrix.Elements[2][2] / Scalar; + + return Result; +} + +COVERAGE(HMM_DeterminantM3, 1) +static inline float HMM_DeterminantM3(HMM_Mat3 Matrix) { + ASSERT_COVERED(HMM_DeterminantM3); + + HMM_Mat3 Cross; + Cross.Columns[0] = HMM_Cross(Matrix.Columns[1], Matrix.Columns[2]); + Cross.Columns[1] = HMM_Cross(Matrix.Columns[2], Matrix.Columns[0]); + Cross.Columns[2] = HMM_Cross(Matrix.Columns[0], Matrix.Columns[1]); + + return HMM_DotV3(Cross.Columns[2], Matrix.Columns[2]); +} + +COVERAGE(HMM_InvGeneralM3, 1) +static inline HMM_Mat3 HMM_InvGeneralM3(HMM_Mat3 Matrix) { + ASSERT_COVERED(HMM_InvGeneralM3); + + HMM_Mat3 Cross; + Cross.Columns[0] = HMM_Cross(Matrix.Columns[1], Matrix.Columns[2]); + Cross.Columns[1] = HMM_Cross(Matrix.Columns[2], Matrix.Columns[0]); + Cross.Columns[2] = HMM_Cross(Matrix.Columns[0], Matrix.Columns[1]); + + float InvDeterminant = 1.0f / HMM_DotV3(Cross.Columns[2], Matrix.Columns[2]); + + HMM_Mat3 Result; + Result.Columns[0] = HMM_MulV3F(Cross.Columns[0], InvDeterminant); + Result.Columns[1] = HMM_MulV3F(Cross.Columns[1], InvDeterminant); + Result.Columns[2] = HMM_MulV3F(Cross.Columns[2], InvDeterminant); + + return HMM_TransposeM3(Result); +} + +/* + * 4x4 Matrices + */ + +COVERAGE(HMM_M4, 1) +static inline HMM_Mat4 HMM_M4(void) { + ASSERT_COVERED(HMM_M4); + HMM_Mat4 Result = {0}; + return Result; +} + +COVERAGE(HMM_M4D, 1) +static inline HMM_Mat4 HMM_M4D(float Diagonal) { + ASSERT_COVERED(HMM_M4D); + + HMM_Mat4 Result = {0}; + Result.Elements[0][0] = Diagonal; + Result.Elements[1][1] = Diagonal; + Result.Elements[2][2] = Diagonal; + Result.Elements[3][3] = Diagonal; + + return Result; +} + +COVERAGE(HMM_TransposeM4, 1) +static inline HMM_Mat4 HMM_TransposeM4(HMM_Mat4 Matrix) { + ASSERT_COVERED(HMM_TransposeM4); + + HMM_Mat4 Result = Matrix; +#ifdef HANDMADE_MATH__USE_SSE + _MM_TRANSPOSE4_PS(Result.Columns[0].SSE, Result.Columns[1].SSE, Result.Columns[2].SSE, Result.Columns[3].SSE); +#else + Result.Elements[0][1] = Matrix.Elements[1][0]; + Result.Elements[0][2] = Matrix.Elements[2][0]; + Result.Elements[0][3] = Matrix.Elements[3][0]; + Result.Elements[1][0] = Matrix.Elements[0][1]; + Result.Elements[1][2] = Matrix.Elements[2][1]; + Result.Elements[1][3] = Matrix.Elements[3][1]; + Result.Elements[2][1] = Matrix.Elements[1][2]; + Result.Elements[2][0] = Matrix.Elements[0][2]; + Result.Elements[2][3] = Matrix.Elements[3][2]; + Result.Elements[3][1] = Matrix.Elements[1][3]; + Result.Elements[3][2] = Matrix.Elements[2][3]; + Result.Elements[3][0] = Matrix.Elements[0][3]; +#endif + + return Result; +} + +COVERAGE(HMM_AddM4, 1) +static inline HMM_Mat4 HMM_AddM4(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_AddM4); + + HMM_Mat4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.Columns[0].SSE = _mm_add_ps(Left.Columns[0].SSE, Right.Columns[0].SSE); + Result.Columns[1].SSE = _mm_add_ps(Left.Columns[1].SSE, Right.Columns[1].SSE); + Result.Columns[2].SSE = _mm_add_ps(Left.Columns[2].SSE, Right.Columns[2].SSE); + Result.Columns[3].SSE = _mm_add_ps(Left.Columns[3].SSE, Right.Columns[3].SSE); +#else + Result.Elements[0][0] = Left.Elements[0][0] + Right.Elements[0][0]; + Result.Elements[0][1] = Left.Elements[0][1] + Right.Elements[0][1]; + Result.Elements[0][2] = Left.Elements[0][2] + Right.Elements[0][2]; + Result.Elements[0][3] = Left.Elements[0][3] + Right.Elements[0][3]; + Result.Elements[1][0] = Left.Elements[1][0] + Right.Elements[1][0]; + Result.Elements[1][1] = Left.Elements[1][1] + Right.Elements[1][1]; + Result.Elements[1][2] = Left.Elements[1][2] + Right.Elements[1][2]; + Result.Elements[1][3] = Left.Elements[1][3] + Right.Elements[1][3]; + Result.Elements[2][0] = Left.Elements[2][0] + Right.Elements[2][0]; + Result.Elements[2][1] = Left.Elements[2][1] + Right.Elements[2][1]; + Result.Elements[2][2] = Left.Elements[2][2] + Right.Elements[2][2]; + Result.Elements[2][3] = Left.Elements[2][3] + Right.Elements[2][3]; + Result.Elements[3][0] = Left.Elements[3][0] + Right.Elements[3][0]; + Result.Elements[3][1] = Left.Elements[3][1] + Right.Elements[3][1]; + Result.Elements[3][2] = Left.Elements[3][2] + Right.Elements[3][2]; + Result.Elements[3][3] = Left.Elements[3][3] + Right.Elements[3][3]; +#endif + + return Result; +} + +COVERAGE(HMM_SubM4, 1) +static inline HMM_Mat4 HMM_SubM4(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_SubM4); + + HMM_Mat4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.Columns[0].SSE = _mm_sub_ps(Left.Columns[0].SSE, Right.Columns[0].SSE); + Result.Columns[1].SSE = _mm_sub_ps(Left.Columns[1].SSE, Right.Columns[1].SSE); + Result.Columns[2].SSE = _mm_sub_ps(Left.Columns[2].SSE, Right.Columns[2].SSE); + Result.Columns[3].SSE = _mm_sub_ps(Left.Columns[3].SSE, Right.Columns[3].SSE); +#else + Result.Elements[0][0] = Left.Elements[0][0] - Right.Elements[0][0]; + Result.Elements[0][1] = Left.Elements[0][1] - Right.Elements[0][1]; + Result.Elements[0][2] = Left.Elements[0][2] - Right.Elements[0][2]; + Result.Elements[0][3] = Left.Elements[0][3] - Right.Elements[0][3]; + Result.Elements[1][0] = Left.Elements[1][0] - Right.Elements[1][0]; + Result.Elements[1][1] = Left.Elements[1][1] - Right.Elements[1][1]; + Result.Elements[1][2] = Left.Elements[1][2] - Right.Elements[1][2]; + Result.Elements[1][3] = Left.Elements[1][3] - Right.Elements[1][3]; + Result.Elements[2][0] = Left.Elements[2][0] - Right.Elements[2][0]; + Result.Elements[2][1] = Left.Elements[2][1] - Right.Elements[2][1]; + Result.Elements[2][2] = Left.Elements[2][2] - Right.Elements[2][2]; + Result.Elements[2][3] = Left.Elements[2][3] - Right.Elements[2][3]; + Result.Elements[3][0] = Left.Elements[3][0] - Right.Elements[3][0]; + Result.Elements[3][1] = Left.Elements[3][1] - Right.Elements[3][1]; + Result.Elements[3][2] = Left.Elements[3][2] - Right.Elements[3][2]; + Result.Elements[3][3] = Left.Elements[3][3] - Right.Elements[3][3]; +#endif + + return Result; +} + +COVERAGE(HMM_MulM4, 1) +static inline HMM_Mat4 HMM_MulM4(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_MulM4); + + HMM_Mat4 Result; + Result.Columns[0] = HMM_LinearCombineV4M4(Right.Columns[0], Left); + Result.Columns[1] = HMM_LinearCombineV4M4(Right.Columns[1], Left); + Result.Columns[2] = HMM_LinearCombineV4M4(Right.Columns[2], Left); + Result.Columns[3] = HMM_LinearCombineV4M4(Right.Columns[3], Left); + + return Result; +} + +COVERAGE(HMM_MulM4F, 1) +static inline HMM_Mat4 HMM_MulM4F(HMM_Mat4 Matrix, float Scalar) { + ASSERT_COVERED(HMM_MulM4F); + + HMM_Mat4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 SSEScalar = _mm_set1_ps(Scalar); + Result.Columns[0].SSE = _mm_mul_ps(Matrix.Columns[0].SSE, SSEScalar); + Result.Columns[1].SSE = _mm_mul_ps(Matrix.Columns[1].SSE, SSEScalar); + Result.Columns[2].SSE = _mm_mul_ps(Matrix.Columns[2].SSE, SSEScalar); + Result.Columns[3].SSE = _mm_mul_ps(Matrix.Columns[3].SSE, SSEScalar); +#else + Result.Elements[0][0] = Matrix.Elements[0][0] * Scalar; + Result.Elements[0][1] = Matrix.Elements[0][1] * Scalar; + Result.Elements[0][2] = Matrix.Elements[0][2] * Scalar; + Result.Elements[0][3] = Matrix.Elements[0][3] * Scalar; + Result.Elements[1][0] = Matrix.Elements[1][0] * Scalar; + Result.Elements[1][1] = Matrix.Elements[1][1] * Scalar; + Result.Elements[1][2] = Matrix.Elements[1][2] * Scalar; + Result.Elements[1][3] = Matrix.Elements[1][3] * Scalar; + Result.Elements[2][0] = Matrix.Elements[2][0] * Scalar; + Result.Elements[2][1] = Matrix.Elements[2][1] * Scalar; + Result.Elements[2][2] = Matrix.Elements[2][2] * Scalar; + Result.Elements[2][3] = Matrix.Elements[2][3] * Scalar; + Result.Elements[3][0] = Matrix.Elements[3][0] * Scalar; + Result.Elements[3][1] = Matrix.Elements[3][1] * Scalar; + Result.Elements[3][2] = Matrix.Elements[3][2] * Scalar; + Result.Elements[3][3] = Matrix.Elements[3][3] * Scalar; +#endif + + return Result; +} + +COVERAGE(HMM_MulM4V4, 1) +static inline HMM_Vec4 HMM_MulM4V4(HMM_Mat4 Matrix, HMM_Vec4 Vector) { + ASSERT_COVERED(HMM_MulM4V4); + return HMM_LinearCombineV4M4(Vector, Matrix); +} + +COVERAGE(HMM_DivM4F, 1) +static inline HMM_Mat4 HMM_DivM4F(HMM_Mat4 Matrix, float Scalar) { + ASSERT_COVERED(HMM_DivM4F); + + HMM_Mat4 Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 SSEScalar = _mm_set1_ps(Scalar); + Result.Columns[0].SSE = _mm_div_ps(Matrix.Columns[0].SSE, SSEScalar); + Result.Columns[1].SSE = _mm_div_ps(Matrix.Columns[1].SSE, SSEScalar); + Result.Columns[2].SSE = _mm_div_ps(Matrix.Columns[2].SSE, SSEScalar); + Result.Columns[3].SSE = _mm_div_ps(Matrix.Columns[3].SSE, SSEScalar); +#else + Result.Elements[0][0] = Matrix.Elements[0][0] / Scalar; + Result.Elements[0][1] = Matrix.Elements[0][1] / Scalar; + Result.Elements[0][2] = Matrix.Elements[0][2] / Scalar; + Result.Elements[0][3] = Matrix.Elements[0][3] / Scalar; + Result.Elements[1][0] = Matrix.Elements[1][0] / Scalar; + Result.Elements[1][1] = Matrix.Elements[1][1] / Scalar; + Result.Elements[1][2] = Matrix.Elements[1][2] / Scalar; + Result.Elements[1][3] = Matrix.Elements[1][3] / Scalar; + Result.Elements[2][0] = Matrix.Elements[2][0] / Scalar; + Result.Elements[2][1] = Matrix.Elements[2][1] / Scalar; + Result.Elements[2][2] = Matrix.Elements[2][2] / Scalar; + Result.Elements[2][3] = Matrix.Elements[2][3] / Scalar; + Result.Elements[3][0] = Matrix.Elements[3][0] / Scalar; + Result.Elements[3][1] = Matrix.Elements[3][1] / Scalar; + Result.Elements[3][2] = Matrix.Elements[3][2] / Scalar; + Result.Elements[3][3] = Matrix.Elements[3][3] / Scalar; +#endif + + return Result; +} + +COVERAGE(HMM_DeterminantM4, 1) +static inline float HMM_DeterminantM4(HMM_Mat4 Matrix) { + ASSERT_COVERED(HMM_DeterminantM4); + + HMM_Vec3 C01 = HMM_Cross(Matrix.Columns[0].XYZ, Matrix.Columns[1].XYZ); + HMM_Vec3 C23 = HMM_Cross(Matrix.Columns[2].XYZ, Matrix.Columns[3].XYZ); + HMM_Vec3 B10 = HMM_SubV3(HMM_MulV3F(Matrix.Columns[0].XYZ, Matrix.Columns[1].W), HMM_MulV3F(Matrix.Columns[1].XYZ, Matrix.Columns[0].W)); + HMM_Vec3 B32 = HMM_SubV3(HMM_MulV3F(Matrix.Columns[2].XYZ, Matrix.Columns[3].W), HMM_MulV3F(Matrix.Columns[3].XYZ, Matrix.Columns[2].W)); + + return HMM_DotV3(C01, B32) + HMM_DotV3(C23, B10); +} + +COVERAGE(HMM_InvGeneralM4, 1) +// Returns a general-purpose inverse of an HMM_Mat4. Note that special-purpose inverses of many transformations +// are available and will be more efficient. +static inline HMM_Mat4 HMM_InvGeneralM4(HMM_Mat4 Matrix) { + ASSERT_COVERED(HMM_InvGeneralM4); + + HMM_Vec3 C01 = HMM_Cross(Matrix.Columns[0].XYZ, Matrix.Columns[1].XYZ); + HMM_Vec3 C23 = HMM_Cross(Matrix.Columns[2].XYZ, Matrix.Columns[3].XYZ); + HMM_Vec3 B10 = HMM_SubV3(HMM_MulV3F(Matrix.Columns[0].XYZ, Matrix.Columns[1].W), HMM_MulV3F(Matrix.Columns[1].XYZ, Matrix.Columns[0].W)); + HMM_Vec3 B32 = HMM_SubV3(HMM_MulV3F(Matrix.Columns[2].XYZ, Matrix.Columns[3].W), HMM_MulV3F(Matrix.Columns[3].XYZ, Matrix.Columns[2].W)); + + float InvDeterminant = 1.0f / (HMM_DotV3(C01, B32) + HMM_DotV3(C23, B10)); + C01 = HMM_MulV3F(C01, InvDeterminant); + C23 = HMM_MulV3F(C23, InvDeterminant); + B10 = HMM_MulV3F(B10, InvDeterminant); + B32 = HMM_MulV3F(B32, InvDeterminant); + + HMM_Mat4 Result; + Result.Columns[0] = HMM_V4V(HMM_AddV3(HMM_Cross(Matrix.Columns[1].XYZ, B32), HMM_MulV3F(C23, Matrix.Columns[1].W)), -HMM_DotV3(Matrix.Columns[1].XYZ, C23)); + Result.Columns[1] = HMM_V4V(HMM_SubV3(HMM_Cross(B32, Matrix.Columns[0].XYZ), HMM_MulV3F(C23, Matrix.Columns[0].W)), +HMM_DotV3(Matrix.Columns[0].XYZ, C23)); + Result.Columns[2] = HMM_V4V(HMM_AddV3(HMM_Cross(Matrix.Columns[3].XYZ, B10), HMM_MulV3F(C01, Matrix.Columns[3].W)), -HMM_DotV3(Matrix.Columns[3].XYZ, C01)); + Result.Columns[3] = HMM_V4V(HMM_SubV3(HMM_Cross(B10, Matrix.Columns[2].XYZ), HMM_MulV3F(C01, Matrix.Columns[2].W)), +HMM_DotV3(Matrix.Columns[2].XYZ, C01)); + + return HMM_TransposeM4(Result); +} + +/* + * Common graphics transformations + */ + +COVERAGE(HMM_Orthographic_RH_NO, 1) +// Produces a right-handed orthographic projection matrix with Z ranging from -1 to 1 (the GL convention). +// Left, Right, Bottom, and Top specify the coordinates of their respective clipping planes. +// Near and Far specify the distances to the near and far clipping planes. +static inline HMM_Mat4 HMM_Orthographic_RH_NO(float Left, float Right, float Bottom, float Top, float Near, float Far) { + ASSERT_COVERED(HMM_Orthographic_RH_NO); + + HMM_Mat4 Result = {0}; + + Result.Elements[0][0] = 2.0f / (Right - Left); + Result.Elements[1][1] = 2.0f / (Top - Bottom); + Result.Elements[2][2] = 2.0f / (Near - Far); + Result.Elements[3][3] = 1.0f; + + Result.Elements[3][0] = (Left + Right) / (Left - Right); + Result.Elements[3][1] = (Bottom + Top) / (Bottom - Top); + Result.Elements[3][2] = (Near + Far) / (Near - Far); + + return Result; +} + +COVERAGE(HMM_Orthographic_RH_ZO, 1) +// Produces a right-handed orthographic projection matrix with Z ranging from 0 to 1 (the DirectX convention). +// Left, Right, Bottom, and Top specify the coordinates of their respective clipping planes. +// Near and Far specify the distances to the near and far clipping planes. +static inline HMM_Mat4 HMM_Orthographic_RH_ZO(float Left, float Right, float Bottom, float Top, float Near, float Far) { + ASSERT_COVERED(HMM_Orthographic_RH_ZO); + + HMM_Mat4 Result = {0}; + + Result.Elements[0][0] = 2.0f / (Right - Left); + Result.Elements[1][1] = 2.0f / (Top - Bottom); + Result.Elements[2][2] = 1.0f / (Near - Far); + Result.Elements[3][3] = 1.0f; + + Result.Elements[3][0] = (Left + Right) / (Left - Right); + Result.Elements[3][1] = (Bottom + Top) / (Bottom - Top); + Result.Elements[3][2] = (Near) / (Near - Far); + + return Result; +} + +COVERAGE(HMM_Orthographic_LH_NO, 1) +// Produces a left-handed orthographic projection matrix with Z ranging from -1 to 1 (the GL convention). +// Left, Right, Bottom, and Top specify the coordinates of their respective clipping planes. +// Near and Far specify the distances to the near and far clipping planes. +static inline HMM_Mat4 HMM_Orthographic_LH_NO(float Left, float Right, float Bottom, float Top, float Near, float Far) { + ASSERT_COVERED(HMM_Orthographic_LH_NO); + + HMM_Mat4 Result = HMM_Orthographic_RH_NO(Left, Right, Bottom, Top, Near, Far); + Result.Elements[2][2] = -Result.Elements[2][2]; + + return Result; +} + +COVERAGE(HMM_Orthographic_LH_ZO, 1) +// Produces a left-handed orthographic projection matrix with Z ranging from 0 to 1 (the DirectX convention). +// Left, Right, Bottom, and Top specify the coordinates of their respective clipping planes. +// Near and Far specify the distances to the near and far clipping planes. +static inline HMM_Mat4 HMM_Orthographic_LH_ZO(float Left, float Right, float Bottom, float Top, float Near, float Far) { + ASSERT_COVERED(HMM_Orthographic_LH_ZO); + + HMM_Mat4 Result = HMM_Orthographic_RH_ZO(Left, Right, Bottom, Top, Near, Far); + Result.Elements[2][2] = -Result.Elements[2][2]; + + return Result; +} + +COVERAGE(HMM_InvOrthographic, 1) +// Returns an inverse for the given orthographic projection matrix. Works for all orthographic +// projection matrices, regardless of handedness or NDC convention. +static inline HMM_Mat4 HMM_InvOrthographic(HMM_Mat4 OrthoMatrix) { + ASSERT_COVERED(HMM_InvOrthographic); + + HMM_Mat4 Result = {0}; + Result.Elements[0][0] = 1.0f / OrthoMatrix.Elements[0][0]; + Result.Elements[1][1] = 1.0f / OrthoMatrix.Elements[1][1]; + Result.Elements[2][2] = 1.0f / OrthoMatrix.Elements[2][2]; + Result.Elements[3][3] = 1.0f; + + Result.Elements[3][0] = -OrthoMatrix.Elements[3][0] * Result.Elements[0][0]; + Result.Elements[3][1] = -OrthoMatrix.Elements[3][1] * Result.Elements[1][1]; + Result.Elements[3][2] = -OrthoMatrix.Elements[3][2] * Result.Elements[2][2]; + + return Result; +} + +COVERAGE(HMM_Perspective_RH_NO, 1) +static inline HMM_Mat4 HMM_Perspective_RH_NO(float FOV, float AspectRatio, float Near, float Far) { + ASSERT_COVERED(HMM_Perspective_RH_NO); + + HMM_Mat4 Result = {0}; + + // See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml + + float Cotangent = 1.0f / HMM_TanF(FOV / 2.0f); + Result.Elements[0][0] = Cotangent / AspectRatio; + Result.Elements[1][1] = Cotangent; + Result.Elements[2][3] = -1.0f; + + Result.Elements[2][2] = (Near + Far) / (Near - Far); + Result.Elements[3][2] = (2.0f * Near * Far) / (Near - Far); + + return Result; +} + +COVERAGE(HMM_Perspective_RH_ZO, 1) +static inline HMM_Mat4 HMM_Perspective_RH_ZO(float FOV, float AspectRatio, float Near, float Far) { + ASSERT_COVERED(HMM_Perspective_RH_ZO); + + HMM_Mat4 Result = {0}; + + // See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml + + float Cotangent = 1.0f / HMM_TanF(FOV / 2.0f); + Result.Elements[0][0] = Cotangent / AspectRatio; + Result.Elements[1][1] = Cotangent; + Result.Elements[2][3] = -1.0f; + + Result.Elements[2][2] = (Far) / (Near - Far); + Result.Elements[3][2] = (Near * Far) / (Near - Far); + + return Result; +} + +COVERAGE(HMM_Perspective_LH_NO, 1) +static inline HMM_Mat4 HMM_Perspective_LH_NO(float FOV, float AspectRatio, float Near, float Far) { + ASSERT_COVERED(HMM_Perspective_LH_NO); + + HMM_Mat4 Result = HMM_Perspective_RH_NO(FOV, AspectRatio, Near, Far); + Result.Elements[2][2] = -Result.Elements[2][2]; + Result.Elements[2][3] = -Result.Elements[2][3]; + + return Result; +} + +COVERAGE(HMM_Perspective_LH_ZO, 1) +static inline HMM_Mat4 HMM_Perspective_LH_ZO(float FOV, float AspectRatio, float Near, float Far) { + ASSERT_COVERED(HMM_Perspective_LH_ZO); + + HMM_Mat4 Result = HMM_Perspective_RH_ZO(FOV, AspectRatio, Near, Far); + Result.Elements[2][2] = -Result.Elements[2][2]; + Result.Elements[2][3] = -Result.Elements[2][3]; + + return Result; +} + +COVERAGE(HMM_InvPerspective_RH, 1) +static inline HMM_Mat4 HMM_InvPerspective_RH(HMM_Mat4 PerspectiveMatrix) { + ASSERT_COVERED(HMM_InvPerspective_RH); + + HMM_Mat4 Result = {0}; + Result.Elements[0][0] = 1.0f / PerspectiveMatrix.Elements[0][0]; + Result.Elements[1][1] = 1.0f / PerspectiveMatrix.Elements[1][1]; + Result.Elements[2][2] = 0.0f; + + Result.Elements[2][3] = 1.0f / PerspectiveMatrix.Elements[3][2]; + Result.Elements[3][3] = PerspectiveMatrix.Elements[2][2] * Result.Elements[2][3]; + Result.Elements[3][2] = PerspectiveMatrix.Elements[2][3]; + + return Result; +} + +COVERAGE(HMM_InvPerspective_LH, 1) +static inline HMM_Mat4 HMM_InvPerspective_LH(HMM_Mat4 PerspectiveMatrix) { + ASSERT_COVERED(HMM_InvPerspective_LH); + + HMM_Mat4 Result = {0}; + Result.Elements[0][0] = 1.0f / PerspectiveMatrix.Elements[0][0]; + Result.Elements[1][1] = 1.0f / PerspectiveMatrix.Elements[1][1]; + Result.Elements[2][2] = 0.0f; + + Result.Elements[2][3] = 1.0f / PerspectiveMatrix.Elements[3][2]; + Result.Elements[3][3] = PerspectiveMatrix.Elements[2][2] * -Result.Elements[2][3]; + Result.Elements[3][2] = PerspectiveMatrix.Elements[2][3]; + + return Result; +} + +COVERAGE(HMM_Translate, 1) +static inline HMM_Mat4 HMM_Translate(HMM_Vec3 Translation) { + ASSERT_COVERED(HMM_Translate); + + HMM_Mat4 Result = HMM_M4D(1.0f); + Result.Elements[3][0] = Translation.X; + Result.Elements[3][1] = Translation.Y; + Result.Elements[3][2] = Translation.Z; + + return Result; +} + +COVERAGE(HMM_InvTranslate, 1) +static inline HMM_Mat4 HMM_InvTranslate(HMM_Mat4 TranslationMatrix) { + ASSERT_COVERED(HMM_InvTranslate); + + HMM_Mat4 Result = TranslationMatrix; + Result.Elements[3][0] = -Result.Elements[3][0]; + Result.Elements[3][1] = -Result.Elements[3][1]; + Result.Elements[3][2] = -Result.Elements[3][2]; + + return Result; +} + +COVERAGE(HMM_Rotate_RH, 1) +static inline HMM_Mat4 HMM_Rotate_RH(float Angle, HMM_Vec3 Axis) { + ASSERT_COVERED(HMM_Rotate_RH); + + HMM_Mat4 Result = HMM_M4D(1.0f); + + Axis = HMM_NormV3(Axis); + + float SinTheta = HMM_SinF(Angle); + float CosTheta = HMM_CosF(Angle); + float CosValue = 1.0f - CosTheta; + + Result.Elements[0][0] = (Axis.X * Axis.X * CosValue) + CosTheta; + Result.Elements[0][1] = (Axis.X * Axis.Y * CosValue) + (Axis.Z * SinTheta); + Result.Elements[0][2] = (Axis.X * Axis.Z * CosValue) - (Axis.Y * SinTheta); + + Result.Elements[1][0] = (Axis.Y * Axis.X * CosValue) - (Axis.Z * SinTheta); + Result.Elements[1][1] = (Axis.Y * Axis.Y * CosValue) + CosTheta; + Result.Elements[1][2] = (Axis.Y * Axis.Z * CosValue) + (Axis.X * SinTheta); + + Result.Elements[2][0] = (Axis.Z * Axis.X * CosValue) + (Axis.Y * SinTheta); + Result.Elements[2][1] = (Axis.Z * Axis.Y * CosValue) - (Axis.X * SinTheta); + Result.Elements[2][2] = (Axis.Z * Axis.Z * CosValue) + CosTheta; + + return Result; +} + +COVERAGE(HMM_Rotate_LH, 1) +static inline HMM_Mat4 HMM_Rotate_LH(float Angle, HMM_Vec3 Axis) { + ASSERT_COVERED(HMM_Rotate_LH); + /* NOTE(lcf): Matrix will be inverse/transpose of RH. */ + return HMM_Rotate_RH(-Angle, Axis); +} + +COVERAGE(HMM_InvRotate, 1) +static inline HMM_Mat4 HMM_InvRotate(HMM_Mat4 RotationMatrix) { + ASSERT_COVERED(HMM_InvRotate); + return HMM_TransposeM4(RotationMatrix); +} + +COVERAGE(HMM_Scale, 1) +static inline HMM_Mat4 HMM_Scale(HMM_Vec3 Scale) { + ASSERT_COVERED(HMM_Scale); + + HMM_Mat4 Result = HMM_M4D(1.0f); + Result.Elements[0][0] = Scale.X; + Result.Elements[1][1] = Scale.Y; + Result.Elements[2][2] = Scale.Z; + + return Result; +} + +COVERAGE(HMM_InvScale, 1) +static inline HMM_Mat4 HMM_InvScale(HMM_Mat4 ScaleMatrix) { + ASSERT_COVERED(HMM_InvScale); + + HMM_Mat4 Result = ScaleMatrix; + Result.Elements[0][0] = 1.0f / Result.Elements[0][0]; + Result.Elements[1][1] = 1.0f / Result.Elements[1][1]; + Result.Elements[2][2] = 1.0f / Result.Elements[2][2]; + + return Result; +} + +static inline HMM_Mat4 _HMM_LookAt(HMM_Vec3 F, HMM_Vec3 S, HMM_Vec3 U, HMM_Vec3 Eye) { + HMM_Mat4 Result; + + Result.Elements[0][0] = S.X; + Result.Elements[0][1] = U.X; + Result.Elements[0][2] = -F.X; + Result.Elements[0][3] = 0.0f; + + Result.Elements[1][0] = S.Y; + Result.Elements[1][1] = U.Y; + Result.Elements[1][2] = -F.Y; + Result.Elements[1][3] = 0.0f; + + Result.Elements[2][0] = S.Z; + Result.Elements[2][1] = U.Z; + Result.Elements[2][2] = -F.Z; + Result.Elements[2][3] = 0.0f; + + Result.Elements[3][0] = -HMM_DotV3(S, Eye); + Result.Elements[3][1] = -HMM_DotV3(U, Eye); + Result.Elements[3][2] = HMM_DotV3(F, Eye); + Result.Elements[3][3] = 1.0f; + + return Result; +} + +COVERAGE(HMM_LookAt_RH, 1) +static inline HMM_Mat4 HMM_LookAt_RH(HMM_Vec3 Eye, HMM_Vec3 Center, HMM_Vec3 Up) { + ASSERT_COVERED(HMM_LookAt_RH); + + HMM_Vec3 F = HMM_NormV3(HMM_SubV3(Center, Eye)); + HMM_Vec3 S = HMM_NormV3(HMM_Cross(F, Up)); + HMM_Vec3 U = HMM_Cross(S, F); + + return _HMM_LookAt(F, S, U, Eye); +} + +COVERAGE(HMM_LookAt_LH, 1) +static inline HMM_Mat4 HMM_LookAt_LH(HMM_Vec3 Eye, HMM_Vec3 Center, HMM_Vec3 Up) { + ASSERT_COVERED(HMM_LookAt_LH); + + HMM_Vec3 F = HMM_NormV3(HMM_SubV3(Eye, Center)); + HMM_Vec3 S = HMM_NormV3(HMM_Cross(F, Up)); + HMM_Vec3 U = HMM_Cross(S, F); + + return _HMM_LookAt(F, S, U, Eye); +} + +COVERAGE(HMM_InvLookAt, 1) +static inline HMM_Mat4 HMM_InvLookAt(HMM_Mat4 Matrix) { + ASSERT_COVERED(HMM_InvLookAt); + HMM_Mat4 Result; + + HMM_Mat3 Rotation = {0}; + Rotation.Columns[0] = Matrix.Columns[0].XYZ; + Rotation.Columns[1] = Matrix.Columns[1].XYZ; + Rotation.Columns[2] = Matrix.Columns[2].XYZ; + Rotation = HMM_TransposeM3(Rotation); + + Result.Columns[0] = HMM_V4V(Rotation.Columns[0], 0.0f); + Result.Columns[1] = HMM_V4V(Rotation.Columns[1], 0.0f); + Result.Columns[2] = HMM_V4V(Rotation.Columns[2], 0.0f); + Result.Columns[3] = HMM_MulV4F(Matrix.Columns[3], -1.0f); + Result.Elements[3][0] = -1.0f * Matrix.Elements[3][0] / + (Rotation.Elements[0][0] + Rotation.Elements[0][1] + Rotation.Elements[0][2]); + Result.Elements[3][1] = -1.0f * Matrix.Elements[3][1] / + (Rotation.Elements[1][0] + Rotation.Elements[1][1] + Rotation.Elements[1][2]); + Result.Elements[3][2] = -1.0f * Matrix.Elements[3][2] / + (Rotation.Elements[2][0] + Rotation.Elements[2][1] + Rotation.Elements[2][2]); + Result.Elements[3][3] = 1.0f; + + return Result; +} + +/* + * Quaternion operations + */ + +COVERAGE(HMM_Q, 1) +static inline HMM_Quat HMM_Q(float X, float Y, float Z, float W) { + ASSERT_COVERED(HMM_Q); + + HMM_Quat Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_setr_ps(X, Y, Z, W); +#else + Result.X = X; + Result.Y = Y; + Result.Z = Z; + Result.W = W; +#endif + + return Result; +} + +COVERAGE(HMM_QV4, 1) +static inline HMM_Quat HMM_QV4(HMM_Vec4 Vector) { + ASSERT_COVERED(HMM_QV4); + + HMM_Quat Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = Vector.SSE; +#else + Result.X = Vector.X; + Result.Y = Vector.Y; + Result.Z = Vector.Z; + Result.W = Vector.W; +#endif + + return Result; +} + +COVERAGE(HMM_AddQ, 1) +static inline HMM_Quat HMM_AddQ(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_AddQ); + + HMM_Quat Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_add_ps(Left.SSE, Right.SSE); +#else + + Result.X = Left.X + Right.X; + Result.Y = Left.Y + Right.Y; + Result.Z = Left.Z + Right.Z; + Result.W = Left.W + Right.W; +#endif + + return Result; +} + +COVERAGE(HMM_SubQ, 1) +static inline HMM_Quat HMM_SubQ(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_SubQ); + + HMM_Quat Result; + +#ifdef HANDMADE_MATH__USE_SSE + Result.SSE = _mm_sub_ps(Left.SSE, Right.SSE); +#else + Result.X = Left.X - Right.X; + Result.Y = Left.Y - Right.Y; + Result.Z = Left.Z - Right.Z; + Result.W = Left.W - Right.W; +#endif + + return Result; +} + +COVERAGE(HMM_MulQ, 1) +static inline HMM_Quat HMM_MulQ(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_MulQ); + + HMM_Quat Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 SSEResultOne = _mm_xor_ps(_mm_shuffle_ps(Left.SSE, Left.SSE, _MM_SHUFFLE(0, 0, 0, 0)), _mm_setr_ps(0.f, -0.f, 0.f, -0.f)); + __m128 SSEResultTwo = _mm_shuffle_ps(Right.SSE, Right.SSE, _MM_SHUFFLE(0, 1, 2, 3)); + __m128 SSEResultThree = _mm_mul_ps(SSEResultTwo, SSEResultOne); + + SSEResultOne = _mm_xor_ps(_mm_shuffle_ps(Left.SSE, Left.SSE, _MM_SHUFFLE(1, 1, 1, 1)), _mm_setr_ps(0.f, 0.f, -0.f, -0.f)); + SSEResultTwo = _mm_shuffle_ps(Right.SSE, Right.SSE, _MM_SHUFFLE(1, 0, 3, 2)); + SSEResultThree = _mm_add_ps(SSEResultThree, _mm_mul_ps(SSEResultTwo, SSEResultOne)); + + SSEResultOne = _mm_xor_ps(_mm_shuffle_ps(Left.SSE, Left.SSE, _MM_SHUFFLE(2, 2, 2, 2)), _mm_setr_ps(-0.f, 0.f, 0.f, -0.f)); + SSEResultTwo = _mm_shuffle_ps(Right.SSE, Right.SSE, _MM_SHUFFLE(2, 3, 0, 1)); + SSEResultThree = _mm_add_ps(SSEResultThree, _mm_mul_ps(SSEResultTwo, SSEResultOne)); + + SSEResultOne = _mm_shuffle_ps(Left.SSE, Left.SSE, _MM_SHUFFLE(3, 3, 3, 3)); + SSEResultTwo = _mm_shuffle_ps(Right.SSE, Right.SSE, _MM_SHUFFLE(3, 2, 1, 0)); + Result.SSE = _mm_add_ps(SSEResultThree, _mm_mul_ps(SSEResultTwo, SSEResultOne)); +#else + Result.X = Right.Elements[3] * +Left.Elements[0]; + Result.Y = Right.Elements[2] * -Left.Elements[0]; + Result.Z = Right.Elements[1] * +Left.Elements[0]; + Result.W = Right.Elements[0] * -Left.Elements[0]; + + Result.X += Right.Elements[2] * +Left.Elements[1]; + Result.Y += Right.Elements[3] * +Left.Elements[1]; + Result.Z += Right.Elements[0] * -Left.Elements[1]; + Result.W += Right.Elements[1] * -Left.Elements[1]; + + Result.X += Right.Elements[1] * -Left.Elements[2]; + Result.Y += Right.Elements[0] * +Left.Elements[2]; + Result.Z += Right.Elements[3] * +Left.Elements[2]; + Result.W += Right.Elements[2] * -Left.Elements[2]; + + Result.X += Right.Elements[0] * +Left.Elements[3]; + Result.Y += Right.Elements[1] * +Left.Elements[3]; + Result.Z += Right.Elements[2] * +Left.Elements[3]; + Result.W += Right.Elements[3] * +Left.Elements[3]; +#endif + + return Result; +} + +COVERAGE(HMM_MulQF, 1) +static inline HMM_Quat HMM_MulQF(HMM_Quat Left, float Multiplicative) { + ASSERT_COVERED(HMM_MulQF); + + HMM_Quat Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 Scalar = _mm_set1_ps(Multiplicative); + Result.SSE = _mm_mul_ps(Left.SSE, Scalar); +#else + Result.X = Left.X * Multiplicative; + Result.Y = Left.Y * Multiplicative; + Result.Z = Left.Z * Multiplicative; + Result.W = Left.W * Multiplicative; +#endif + + return Result; +} + +COVERAGE(HMM_DivQF, 1) +static inline HMM_Quat HMM_DivQF(HMM_Quat Left, float Divnd) { + ASSERT_COVERED(HMM_DivQF); + + HMM_Quat Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 Scalar = _mm_set1_ps(Divnd); + Result.SSE = _mm_div_ps(Left.SSE, Scalar); +#else + Result.X = Left.X / Divnd; + Result.Y = Left.Y / Divnd; + Result.Z = Left.Z / Divnd; + Result.W = Left.W / Divnd; +#endif + + return Result; +} + +COVERAGE(HMM_DotQ, 1) +static inline float HMM_DotQ(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_DotQ); + + float Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 SSEResultOne = _mm_mul_ps(Left.SSE, Right.SSE); + __m128 SSEResultTwo = _mm_shuffle_ps(SSEResultOne, SSEResultOne, _MM_SHUFFLE(2, 3, 0, 1)); + SSEResultOne = _mm_add_ps(SSEResultOne, SSEResultTwo); + SSEResultTwo = _mm_shuffle_ps(SSEResultOne, SSEResultOne, _MM_SHUFFLE(0, 1, 2, 3)); + SSEResultOne = _mm_add_ps(SSEResultOne, SSEResultTwo); + _mm_store_ss(&Result, SSEResultOne); +#else + Result = ((Left.X * Right.X) + (Left.Z * Right.Z)) + ((Left.Y * Right.Y) + (Left.W * Right.W)); +#endif + + return Result; +} + +COVERAGE(HMM_InvQ, 1) +static inline HMM_Quat HMM_InvQ(HMM_Quat Left) { + ASSERT_COVERED(HMM_InvQ); + + HMM_Quat Result; + Result.X = -Left.X; + Result.Y = -Left.Y; + Result.Z = -Left.Z; + Result.W = Left.W; + + return HMM_DivQF(Result, (HMM_DotQ(Left, Left))); +} + +COVERAGE(HMM_NormQ, 1) +static inline HMM_Quat HMM_NormQ(HMM_Quat Quat) { + ASSERT_COVERED(HMM_NormQ); + + /* NOTE(lcf): Take advantage of SSE implementation in HMM_NormV4 */ + HMM_Vec4 Vec = {Quat.X, Quat.Y, Quat.Z, Quat.W}; + Vec = HMM_NormV4(Vec); + HMM_Quat Result = {Vec.X, Vec.Y, Vec.Z, Vec.W}; + + return Result; +} + +static inline HMM_Quat _HMM_MixQ(HMM_Quat Left, float MixLeft, HMM_Quat Right, float MixRight) { + HMM_Quat Result; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 ScalarLeft = _mm_set1_ps(MixLeft); + __m128 ScalarRight = _mm_set1_ps(MixRight); + __m128 SSEResultOne = _mm_mul_ps(Left.SSE, ScalarLeft); + __m128 SSEResultTwo = _mm_mul_ps(Right.SSE, ScalarRight); + Result.SSE = _mm_add_ps(SSEResultOne, SSEResultTwo); +#else + Result.X = Left.X * MixLeft + Right.X * MixRight; + Result.Y = Left.Y * MixLeft + Right.Y * MixRight; + Result.Z = Left.Z * MixLeft + Right.Z * MixRight; + Result.W = Left.W * MixLeft + Right.W * MixRight; +#endif + + return Result; +} + +COVERAGE(HMM_NLerp, 1) +static inline HMM_Quat HMM_NLerp(HMM_Quat Left, float Time, HMM_Quat Right) { + ASSERT_COVERED(HMM_NLerp); + + HMM_Quat Result = _HMM_MixQ(Left, 1.0f - Time, Right, Time); + Result = HMM_NormQ(Result); + + return Result; +} + +COVERAGE(HMM_SLerp, 1) +static inline HMM_Quat HMM_SLerp(HMM_Quat Left, float Time, HMM_Quat Right) { + ASSERT_COVERED(HMM_SLerp); + + HMM_Quat Result; + + float Cos_Theta = HMM_DotQ(Left, Right); + + if (Cos_Theta < 0.0f) { /* NOTE(lcf): Take shortest path on Hyper-sphere */ + Cos_Theta = -Cos_Theta; + Right = HMM_Q(-Right.X, -Right.Y, -Right.Z, -Right.W); + } + + /* NOTE(lcf): Use Normalized Linear interpolation when vectors are roughly not L.I. */ + if (Cos_Theta > 0.9995f) { + Result = HMM_NLerp(Left, Time, Right); + } else { + float Angle = HMM_ACosF(Cos_Theta); + float MixLeft = HMM_SinF((1.0f - Time) * Angle); + float MixRight = HMM_SinF(Time * Angle); + + Result = _HMM_MixQ(Left, MixLeft, Right, MixRight); + Result = HMM_NormQ(Result); + } + + return Result; +} + +COVERAGE(HMM_QToM4, 1) +static inline HMM_Mat4 HMM_QToM4(HMM_Quat Left) { + ASSERT_COVERED(HMM_QToM4); + + HMM_Mat4 Result; + + HMM_Quat NormalizedQ = HMM_NormQ(Left); + + float XX, YY, ZZ, + XY, XZ, YZ, + WX, WY, WZ; + + XX = NormalizedQ.X * NormalizedQ.X; + YY = NormalizedQ.Y * NormalizedQ.Y; + ZZ = NormalizedQ.Z * NormalizedQ.Z; + XY = NormalizedQ.X * NormalizedQ.Y; + XZ = NormalizedQ.X * NormalizedQ.Z; + YZ = NormalizedQ.Y * NormalizedQ.Z; + WX = NormalizedQ.W * NormalizedQ.X; + WY = NormalizedQ.W * NormalizedQ.Y; + WZ = NormalizedQ.W * NormalizedQ.Z; + + Result.Elements[0][0] = 1.0f - 2.0f * (YY + ZZ); + Result.Elements[0][1] = 2.0f * (XY + WZ); + Result.Elements[0][2] = 2.0f * (XZ - WY); + Result.Elements[0][3] = 0.0f; + + Result.Elements[1][0] = 2.0f * (XY - WZ); + Result.Elements[1][1] = 1.0f - 2.0f * (XX + ZZ); + Result.Elements[1][2] = 2.0f * (YZ + WX); + Result.Elements[1][3] = 0.0f; + + Result.Elements[2][0] = 2.0f * (XZ + WY); + Result.Elements[2][1] = 2.0f * (YZ - WX); + Result.Elements[2][2] = 1.0f - 2.0f * (XX + YY); + Result.Elements[2][3] = 0.0f; + + Result.Elements[3][0] = 0.0f; + Result.Elements[3][1] = 0.0f; + Result.Elements[3][2] = 0.0f; + Result.Elements[3][3] = 1.0f; + + return Result; +} + +// This method taken from Mike Day at Insomniac Games. +// https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2015/01/matrix-to-quat.pdf +// +// Note that as mentioned at the top of the paper, the paper assumes the matrix +// would be *post*-multiplied to a vector to rotate it, meaning the matrix is +// the transpose of what we're dealing with. But, because our matrices are +// stored in column-major order, the indices *appear* to match the paper. +// +// For example, m12 in the paper is row 1, column 2. We need to transpose it to +// row 2, column 1. But, because the column comes first when referencing +// elements, it looks like M.Elements[1][2]. +// +// Don't be confused! Or if you must be confused, at least trust this +// comment. :) +COVERAGE(HMM_M4ToQ_RH, 4) +static inline HMM_Quat HMM_M4ToQ_RH(HMM_Mat4 M) { + float T; + HMM_Quat Q; + + if (M.Elements[2][2] < 0.0f) { + if (M.Elements[0][0] > M.Elements[1][1]) { + ASSERT_COVERED(HMM_M4ToQ_RH); + + T = 1 + M.Elements[0][0] - M.Elements[1][1] - M.Elements[2][2]; + Q = HMM_Q( + T, + M.Elements[0][1] + M.Elements[1][0], + M.Elements[2][0] + M.Elements[0][2], + M.Elements[1][2] - M.Elements[2][1]); + } else { + ASSERT_COVERED(HMM_M4ToQ_RH); + + T = 1 - M.Elements[0][0] + M.Elements[1][1] - M.Elements[2][2]; + Q = HMM_Q( + M.Elements[0][1] + M.Elements[1][0], + T, + M.Elements[1][2] + M.Elements[2][1], + M.Elements[2][0] - M.Elements[0][2]); + } + } else { + if (M.Elements[0][0] < -M.Elements[1][1]) { + ASSERT_COVERED(HMM_M4ToQ_RH); + + T = 1 - M.Elements[0][0] - M.Elements[1][1] + M.Elements[2][2]; + Q = HMM_Q( + M.Elements[2][0] + M.Elements[0][2], + M.Elements[1][2] + M.Elements[2][1], + T, + M.Elements[0][1] - M.Elements[1][0]); + } else { + ASSERT_COVERED(HMM_M4ToQ_RH); + + T = 1 + M.Elements[0][0] + M.Elements[1][1] + M.Elements[2][2]; + Q = HMM_Q( + M.Elements[1][2] - M.Elements[2][1], + M.Elements[2][0] - M.Elements[0][2], + M.Elements[0][1] - M.Elements[1][0], + T); + } + } + + Q = HMM_MulQF(Q, 0.5f / HMM_SqrtF(T)); + + return Q; +} + +COVERAGE(HMM_M4ToQ_LH, 4) +static inline HMM_Quat HMM_M4ToQ_LH(HMM_Mat4 M) { + float T; + HMM_Quat Q; + + if (M.Elements[2][2] < 0.0f) { + if (M.Elements[0][0] > M.Elements[1][1]) { + ASSERT_COVERED(HMM_M4ToQ_LH); + + T = 1 + M.Elements[0][0] - M.Elements[1][1] - M.Elements[2][2]; + Q = HMM_Q( + T, + M.Elements[0][1] + M.Elements[1][0], + M.Elements[2][0] + M.Elements[0][2], + M.Elements[2][1] - M.Elements[1][2]); + } else { + ASSERT_COVERED(HMM_M4ToQ_LH); + + T = 1 - M.Elements[0][0] + M.Elements[1][1] - M.Elements[2][2]; + Q = HMM_Q( + M.Elements[0][1] + M.Elements[1][0], + T, + M.Elements[1][2] + M.Elements[2][1], + M.Elements[0][2] - M.Elements[2][0]); + } + } else { + if (M.Elements[0][0] < -M.Elements[1][1]) { + ASSERT_COVERED(HMM_M4ToQ_LH); + + T = 1 - M.Elements[0][0] - M.Elements[1][1] + M.Elements[2][2]; + Q = HMM_Q( + M.Elements[2][0] + M.Elements[0][2], + M.Elements[1][2] + M.Elements[2][1], + T, + M.Elements[1][0] - M.Elements[0][1]); + } else { + ASSERT_COVERED(HMM_M4ToQ_LH); + + T = 1 + M.Elements[0][0] + M.Elements[1][1] + M.Elements[2][2]; + Q = HMM_Q( + M.Elements[2][1] - M.Elements[1][2], + M.Elements[0][2] - M.Elements[2][0], + M.Elements[1][0] - M.Elements[0][2], + T); + } + } + + Q = HMM_MulQF(Q, 0.5f / HMM_SqrtF(T)); + + return Q; +} + +COVERAGE(HMM_QFromAxisAngle_RH, 1) +static inline HMM_Quat HMM_QFromAxisAngle_RH(HMM_Vec3 Axis, float AngleOfRotation) { + ASSERT_COVERED(HMM_QFromAxisAngle_RH); + + HMM_Quat Result; + + HMM_Vec3 AxisNormalized = HMM_NormV3(Axis); + float SineOfRotation = HMM_SinF(AngleOfRotation / 2.0f); + + Result.XYZ = HMM_MulV3F(AxisNormalized, SineOfRotation); + Result.W = HMM_CosF(AngleOfRotation / 2.0f); + + return Result; +} + +COVERAGE(HMM_QFromAxisAngle_LH, 1) +static inline HMM_Quat HMM_QFromAxisAngle_LH(HMM_Vec3 Axis, float AngleOfRotation) { + ASSERT_COVERED(HMM_QFromAxisAngle_LH); + + return HMM_QFromAxisAngle_RH(Axis, -AngleOfRotation); +} + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus + +COVERAGE(HMM_LenV2CPP, 1) +static inline float HMM_Len(HMM_Vec2 A) { + ASSERT_COVERED(HMM_LenV2CPP); + return HMM_LenV2(A); +} + +COVERAGE(HMM_LenV3CPP, 1) +static inline float HMM_Len(HMM_Vec3 A) { + ASSERT_COVERED(HMM_LenV3CPP); + return HMM_LenV3(A); +} + +COVERAGE(HMM_LenV4CPP, 1) +static inline float HMM_Len(HMM_Vec4 A) { + ASSERT_COVERED(HMM_LenV4CPP); + return HMM_LenV4(A); +} + +COVERAGE(HMM_LenSqrV2CPP, 1) +static inline float HMM_LenSqr(HMM_Vec2 A) { + ASSERT_COVERED(HMM_LenSqrV2CPP); + return HMM_LenSqrV2(A); +} + +COVERAGE(HMM_LenSqrV3CPP, 1) +static inline float HMM_LenSqr(HMM_Vec3 A) { + ASSERT_COVERED(HMM_LenSqrV3CPP); + return HMM_LenSqrV3(A); +} + +COVERAGE(HMM_LenSqrV4CPP, 1) +static inline float HMM_LenSqr(HMM_Vec4 A) { + ASSERT_COVERED(HMM_LenSqrV4CPP); + return HMM_LenSqrV4(A); +} + +COVERAGE(HMM_NormV2CPP, 1) +static inline HMM_Vec2 HMM_Norm(HMM_Vec2 A) { + ASSERT_COVERED(HMM_NormV2CPP); + return HMM_NormV2(A); +} + +COVERAGE(HMM_NormV3CPP, 1) +static inline HMM_Vec3 HMM_Norm(HMM_Vec3 A) { + ASSERT_COVERED(HMM_NormV3CPP); + return HMM_NormV3(A); +} + +COVERAGE(HMM_NormV4CPP, 1) +static inline HMM_Vec4 HMM_Norm(HMM_Vec4 A) { + ASSERT_COVERED(HMM_NormV4CPP); + return HMM_NormV4(A); +} + +COVERAGE(HMM_NormQCPP, 1) +static inline HMM_Quat HMM_Norm(HMM_Quat A) { + ASSERT_COVERED(HMM_NormQCPP); + return HMM_NormQ(A); +} + +COVERAGE(HMM_DotV2CPP, 1) +static inline float HMM_Dot(HMM_Vec2 Left, HMM_Vec2 VecTwo) { + ASSERT_COVERED(HMM_DotV2CPP); + return HMM_DotV2(Left, VecTwo); +} + +COVERAGE(HMM_DotV3CPP, 1) +static inline float HMM_Dot(HMM_Vec3 Left, HMM_Vec3 VecTwo) { + ASSERT_COVERED(HMM_DotV3CPP); + return HMM_DotV3(Left, VecTwo); +} + +COVERAGE(HMM_DotV4CPP, 1) +static inline float HMM_Dot(HMM_Vec4 Left, HMM_Vec4 VecTwo) { + ASSERT_COVERED(HMM_DotV4CPP); + return HMM_DotV4(Left, VecTwo); +} + +COVERAGE(HMM_LerpV2CPP, 1) +static inline HMM_Vec2 HMM_Lerp(HMM_Vec2 Left, float Time, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_LerpV2CPP); + return HMM_LerpV2(Left, Time, Right); +} + +COVERAGE(HMM_LerpV3CPP, 1) +static inline HMM_Vec3 HMM_Lerp(HMM_Vec3 Left, float Time, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_LerpV3CPP); + return HMM_LerpV3(Left, Time, Right); +} + +COVERAGE(HMM_LerpV4CPP, 1) +static inline HMM_Vec4 HMM_Lerp(HMM_Vec4 Left, float Time, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_LerpV4CPP); + return HMM_LerpV4(Left, Time, Right); +} + +COVERAGE(HMM_TransposeM2CPP, 1) +static inline HMM_Mat2 HMM_Transpose(HMM_Mat2 Matrix) { + ASSERT_COVERED(HMM_TransposeM2CPP); + return HMM_TransposeM2(Matrix); +} + +COVERAGE(HMM_TransposeM3CPP, 1) +static inline HMM_Mat3 HMM_Transpose(HMM_Mat3 Matrix) { + ASSERT_COVERED(HMM_TransposeM3CPP); + return HMM_TransposeM3(Matrix); +} + +COVERAGE(HMM_TransposeM4CPP, 1) +static inline HMM_Mat4 HMM_Transpose(HMM_Mat4 Matrix) { + ASSERT_COVERED(HMM_TransposeM4CPP); + return HMM_TransposeM4(Matrix); +} + +COVERAGE(HMM_DeterminantM2CPP, 1) +static inline float HMM_Determinant(HMM_Mat2 Matrix) { + ASSERT_COVERED(HMM_DeterminantM2CPP); + return HMM_DeterminantM2(Matrix); +} + +COVERAGE(HMM_DeterminantM3CPP, 1) +static inline float HMM_Determinant(HMM_Mat3 Matrix) { + ASSERT_COVERED(HMM_DeterminantM3CPP); + return HMM_DeterminantM3(Matrix); +} + +COVERAGE(HMM_DeterminantM4CPP, 1) +static inline float HMM_Determinant(HMM_Mat4 Matrix) { + ASSERT_COVERED(HMM_DeterminantM4CPP); + return HMM_DeterminantM4(Matrix); +} + +COVERAGE(HMM_InvGeneralM2CPP, 1) +static inline HMM_Mat2 HMM_InvGeneral(HMM_Mat2 Matrix) { + ASSERT_COVERED(HMM_InvGeneralM2CPP); + return HMM_InvGeneralM2(Matrix); +} + +COVERAGE(HMM_InvGeneralM3CPP, 1) +static inline HMM_Mat3 HMM_InvGeneral(HMM_Mat3 Matrix) { + ASSERT_COVERED(HMM_InvGeneralM3CPP); + return HMM_InvGeneralM3(Matrix); +} + +COVERAGE(HMM_InvGeneralM4CPP, 1) +static inline HMM_Mat4 HMM_InvGeneral(HMM_Mat4 Matrix) { + ASSERT_COVERED(HMM_InvGeneralM4CPP); + return HMM_InvGeneralM4(Matrix); +} + +COVERAGE(HMM_DotQCPP, 1) +static inline float HMM_Dot(HMM_Quat QuatOne, HMM_Quat QuatTwo) { + ASSERT_COVERED(HMM_DotQCPP); + return HMM_DotQ(QuatOne, QuatTwo); +} + +COVERAGE(HMM_AddV2CPP, 1) +static inline HMM_Vec2 HMM_Add(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_AddV2CPP); + return HMM_AddV2(Left, Right); +} + +COVERAGE(HMM_AddV3CPP, 1) +static inline HMM_Vec3 HMM_Add(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_AddV3CPP); + return HMM_AddV3(Left, Right); +} + +COVERAGE(HMM_AddV4CPP, 1) +static inline HMM_Vec4 HMM_Add(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_AddV4CPP); + return HMM_AddV4(Left, Right); +} + +COVERAGE(HMM_AddM2CPP, 1) +static inline HMM_Mat2 HMM_Add(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_AddM2CPP); + return HMM_AddM2(Left, Right); +} + +COVERAGE(HMM_AddM3CPP, 1) +static inline HMM_Mat3 HMM_Add(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_AddM3CPP); + return HMM_AddM3(Left, Right); +} + +COVERAGE(HMM_AddM4CPP, 1) +static inline HMM_Mat4 HMM_Add(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_AddM4CPP); + return HMM_AddM4(Left, Right); +} + +COVERAGE(HMM_AddQCPP, 1) +static inline HMM_Quat HMM_Add(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_AddQCPP); + return HMM_AddQ(Left, Right); +} + +COVERAGE(HMM_SubV2CPP, 1) +static inline HMM_Vec2 HMM_Sub(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_SubV2CPP); + return HMM_SubV2(Left, Right); +} + +COVERAGE(HMM_SubV3CPP, 1) +static inline HMM_Vec3 HMM_Sub(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_SubV3CPP); + return HMM_SubV3(Left, Right); +} + +COVERAGE(HMM_SubV4CPP, 1) +static inline HMM_Vec4 HMM_Sub(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_SubV4CPP); + return HMM_SubV4(Left, Right); +} + +COVERAGE(HMM_SubM2CPP, 1) +static inline HMM_Mat2 HMM_Sub(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_SubM2CPP); + return HMM_SubM2(Left, Right); +} + +COVERAGE(HMM_SubM3CPP, 1) +static inline HMM_Mat3 HMM_Sub(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_SubM3CPP); + return HMM_SubM3(Left, Right); +} + +COVERAGE(HMM_SubM4CPP, 1) +static inline HMM_Mat4 HMM_Sub(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_SubM4CPP); + return HMM_SubM4(Left, Right); +} + +COVERAGE(HMM_SubQCPP, 1) +static inline HMM_Quat HMM_Sub(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_SubQCPP); + return HMM_SubQ(Left, Right); +} + +COVERAGE(HMM_MulV2CPP, 1) +static inline HMM_Vec2 HMM_Mul(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_MulV2CPP); + return HMM_MulV2(Left, Right); +} + +COVERAGE(HMM_MulV2FCPP, 1) +static inline HMM_Vec2 HMM_Mul(HMM_Vec2 Left, float Right) { + ASSERT_COVERED(HMM_MulV2FCPP); + return HMM_MulV2F(Left, Right); +} + +COVERAGE(HMM_MulV3CPP, 1) +static inline HMM_Vec3 HMM_Mul(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_MulV3CPP); + return HMM_MulV3(Left, Right); +} + +COVERAGE(HMM_MulV3FCPP, 1) +static inline HMM_Vec3 HMM_Mul(HMM_Vec3 Left, float Right) { + ASSERT_COVERED(HMM_MulV3FCPP); + return HMM_MulV3F(Left, Right); +} + +COVERAGE(HMM_MulV4CPP, 1) +static inline HMM_Vec4 HMM_Mul(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_MulV4CPP); + return HMM_MulV4(Left, Right); +} + +COVERAGE(HMM_MulV4FCPP, 1) +static inline HMM_Vec4 HMM_Mul(HMM_Vec4 Left, float Right) { + ASSERT_COVERED(HMM_MulV4FCPP); + return HMM_MulV4F(Left, Right); +} + +COVERAGE(HMM_MulM2CPP, 1) +static inline HMM_Mat2 HMM_Mul(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_MulM2CPP); + return HMM_MulM2(Left, Right); +} + +COVERAGE(HMM_MulM3CPP, 1) +static inline HMM_Mat3 HMM_Mul(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_MulM3CPP); + return HMM_MulM3(Left, Right); +} + +COVERAGE(HMM_MulM4CPP, 1) +static inline HMM_Mat4 HMM_Mul(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_MulM4CPP); + return HMM_MulM4(Left, Right); +} + +COVERAGE(HMM_MulM2FCPP, 1) +static inline HMM_Mat2 HMM_Mul(HMM_Mat2 Left, float Right) { + ASSERT_COVERED(HMM_MulM2FCPP); + return HMM_MulM2F(Left, Right); +} + +COVERAGE(HMM_MulM3FCPP, 1) +static inline HMM_Mat3 HMM_Mul(HMM_Mat3 Left, float Right) { + ASSERT_COVERED(HMM_MulM3FCPP); + return HMM_MulM3F(Left, Right); +} + +COVERAGE(HMM_MulM4FCPP, 1) +static inline HMM_Mat4 HMM_Mul(HMM_Mat4 Left, float Right) { + ASSERT_COVERED(HMM_MulM4FCPP); + return HMM_MulM4F(Left, Right); +} + +COVERAGE(HMM_MulM2V2CPP, 1) +static inline HMM_Vec2 HMM_Mul(HMM_Mat2 Matrix, HMM_Vec2 Vector) { + ASSERT_COVERED(HMM_MulM2V2CPP); + return HMM_MulM2V2(Matrix, Vector); +} + +COVERAGE(HMM_MulM3V3CPP, 1) +static inline HMM_Vec3 HMM_Mul(HMM_Mat3 Matrix, HMM_Vec3 Vector) { + ASSERT_COVERED(HMM_MulM3V3CPP); + return HMM_MulM3V3(Matrix, Vector); +} + +COVERAGE(HMM_MulM4V4CPP, 1) +static inline HMM_Vec4 HMM_Mul(HMM_Mat4 Matrix, HMM_Vec4 Vector) { + ASSERT_COVERED(HMM_MulM4V4CPP); + return HMM_MulM4V4(Matrix, Vector); +} + +COVERAGE(HMM_MulQCPP, 1) +static inline HMM_Quat HMM_Mul(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_MulQCPP); + return HMM_MulQ(Left, Right); +} + +COVERAGE(HMM_MulQFCPP, 1) +static inline HMM_Quat HMM_Mul(HMM_Quat Left, float Right) { + ASSERT_COVERED(HMM_MulQFCPP); + return HMM_MulQF(Left, Right); +} + +COVERAGE(HMM_DivV2CPP, 1) +static inline HMM_Vec2 HMM_Div(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_DivV2CPP); + return HMM_DivV2(Left, Right); +} + +COVERAGE(HMM_DivV2FCPP, 1) +static inline HMM_Vec2 HMM_Div(HMM_Vec2 Left, float Right) { + ASSERT_COVERED(HMM_DivV2FCPP); + return HMM_DivV2F(Left, Right); +} + +COVERAGE(HMM_DivV3CPP, 1) +static inline HMM_Vec3 HMM_Div(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_DivV3CPP); + return HMM_DivV3(Left, Right); +} + +COVERAGE(HMM_DivV3FCPP, 1) +static inline HMM_Vec3 HMM_Div(HMM_Vec3 Left, float Right) { + ASSERT_COVERED(HMM_DivV3FCPP); + return HMM_DivV3F(Left, Right); +} + +COVERAGE(HMM_DivV4CPP, 1) +static inline HMM_Vec4 HMM_Div(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_DivV4CPP); + return HMM_DivV4(Left, Right); +} + +COVERAGE(HMM_DivV4FCPP, 1) +static inline HMM_Vec4 HMM_Div(HMM_Vec4 Left, float Right) { + ASSERT_COVERED(HMM_DivV4FCPP); + return HMM_DivV4F(Left, Right); +} + +COVERAGE(HMM_DivM2FCPP, 1) +static inline HMM_Mat2 HMM_Div(HMM_Mat2 Left, float Right) { + ASSERT_COVERED(HMM_DivM2FCPP); + return HMM_DivM2F(Left, Right); +} + +COVERAGE(HMM_DivM3FCPP, 1) +static inline HMM_Mat3 HMM_Div(HMM_Mat3 Left, float Right) { + ASSERT_COVERED(HMM_DivM3FCPP); + return HMM_DivM3F(Left, Right); +} + +COVERAGE(HMM_DivM4FCPP, 1) +static inline HMM_Mat4 HMM_Div(HMM_Mat4 Left, float Right) { + ASSERT_COVERED(HMM_DivM4FCPP); + return HMM_DivM4F(Left, Right); +} + +COVERAGE(HMM_DivQFCPP, 1) +static inline HMM_Quat HMM_Div(HMM_Quat Left, float Right) { + ASSERT_COVERED(HMM_DivQFCPP); + return HMM_DivQF(Left, Right); +} + +COVERAGE(HMM_EqV2CPP, 1) +static inline HMM_Bool HMM_Eq(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_EqV2CPP); + return HMM_EqV2(Left, Right); +} + +COVERAGE(HMM_EqV3CPP, 1) +static inline HMM_Bool HMM_Eq(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_EqV3CPP); + return HMM_EqV3(Left, Right); +} + +COVERAGE(HMM_EqV4CPP, 1) +static inline HMM_Bool HMM_Eq(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_EqV4CPP); + return HMM_EqV4(Left, Right); +} + +COVERAGE(HMM_AddV2Op, 1) +static inline HMM_Vec2 operator+(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_AddV2Op); + return HMM_AddV2(Left, Right); +} + +COVERAGE(HMM_AddV3Op, 1) +static inline HMM_Vec3 operator+(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_AddV3Op); + return HMM_AddV3(Left, Right); +} + +COVERAGE(HMM_AddV4Op, 1) +static inline HMM_Vec4 operator+(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_AddV4Op); + return HMM_AddV4(Left, Right); +} + +COVERAGE(HMM_AddM2Op, 1) +static inline HMM_Mat2 operator+(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_AddM2Op); + return HMM_AddM2(Left, Right); +} + +COVERAGE(HMM_AddM3Op, 1) +static inline HMM_Mat3 operator+(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_AddM3Op); + return HMM_AddM3(Left, Right); +} + +COVERAGE(HMM_AddM4Op, 1) +static inline HMM_Mat4 operator+(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_AddM4Op); + return HMM_AddM4(Left, Right); +} + +COVERAGE(HMM_AddQOp, 1) +static inline HMM_Quat operator+(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_AddQOp); + return HMM_AddQ(Left, Right); +} + +COVERAGE(HMM_SubV2Op, 1) +static inline HMM_Vec2 operator-(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_SubV2Op); + return HMM_SubV2(Left, Right); +} + +COVERAGE(HMM_SubV3Op, 1) +static inline HMM_Vec3 operator-(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_SubV3Op); + return HMM_SubV3(Left, Right); +} + +COVERAGE(HMM_SubV4Op, 1) +static inline HMM_Vec4 operator-(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_SubV4Op); + return HMM_SubV4(Left, Right); +} + +COVERAGE(HMM_SubM2Op, 1) +static inline HMM_Mat2 operator-(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_SubM2Op); + return HMM_SubM2(Left, Right); +} + +COVERAGE(HMM_SubM3Op, 1) +static inline HMM_Mat3 operator-(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_SubM3Op); + return HMM_SubM3(Left, Right); +} + +COVERAGE(HMM_SubM4Op, 1) +static inline HMM_Mat4 operator-(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_SubM4Op); + return HMM_SubM4(Left, Right); +} + +COVERAGE(HMM_SubQOp, 1) +static inline HMM_Quat operator-(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_SubQOp); + return HMM_SubQ(Left, Right); +} + +COVERAGE(HMM_MulV2Op, 1) +static inline HMM_Vec2 operator*(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_MulV2Op); + return HMM_MulV2(Left, Right); +} + +COVERAGE(HMM_MulV3Op, 1) +static inline HMM_Vec3 operator*(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_MulV3Op); + return HMM_MulV3(Left, Right); +} + +COVERAGE(HMM_MulV4Op, 1) +static inline HMM_Vec4 operator*(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_MulV4Op); + return HMM_MulV4(Left, Right); +} + +COVERAGE(HMM_MulM2Op, 1) +static inline HMM_Mat2 operator*(HMM_Mat2 Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_MulM2Op); + return HMM_MulM2(Left, Right); +} + +COVERAGE(HMM_MulM3Op, 1) +static inline HMM_Mat3 operator*(HMM_Mat3 Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_MulM3Op); + return HMM_MulM3(Left, Right); +} + +COVERAGE(HMM_MulM4Op, 1) +static inline HMM_Mat4 operator*(HMM_Mat4 Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_MulM4Op); + return HMM_MulM4(Left, Right); +} + +COVERAGE(HMM_MulQOp, 1) +static inline HMM_Quat operator*(HMM_Quat Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_MulQOp); + return HMM_MulQ(Left, Right); +} + +COVERAGE(HMM_MulV2FOp, 1) +static inline HMM_Vec2 operator*(HMM_Vec2 Left, float Right) { + ASSERT_COVERED(HMM_MulV2FOp); + return HMM_MulV2F(Left, Right); +} + +COVERAGE(HMM_MulV3FOp, 1) +static inline HMM_Vec3 operator*(HMM_Vec3 Left, float Right) { + ASSERT_COVERED(HMM_MulV3FOp); + return HMM_MulV3F(Left, Right); +} + +COVERAGE(HMM_MulV4FOp, 1) +static inline HMM_Vec4 operator*(HMM_Vec4 Left, float Right) { + ASSERT_COVERED(HMM_MulV4FOp); + return HMM_MulV4F(Left, Right); +} + +COVERAGE(HMM_MulM2FOp, 1) +static inline HMM_Mat2 operator*(HMM_Mat2 Left, float Right) { + ASSERT_COVERED(HMM_MulM2FOp); + return HMM_MulM2F(Left, Right); +} + +COVERAGE(HMM_MulM3FOp, 1) +static inline HMM_Mat3 operator*(HMM_Mat3 Left, float Right) { + ASSERT_COVERED(HMM_MulM3FOp); + return HMM_MulM3F(Left, Right); +} + +COVERAGE(HMM_MulM4FOp, 1) +static inline HMM_Mat4 operator*(HMM_Mat4 Left, float Right) { + ASSERT_COVERED(HMM_MulM4FOp); + return HMM_MulM4F(Left, Right); +} + +COVERAGE(HMM_MulQFOp, 1) +static inline HMM_Quat operator*(HMM_Quat Left, float Right) { + ASSERT_COVERED(HMM_MulQFOp); + return HMM_MulQF(Left, Right); +} + +COVERAGE(HMM_MulV2FOpLeft, 1) +static inline HMM_Vec2 operator*(float Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_MulV2FOpLeft); + return HMM_MulV2F(Right, Left); +} + +COVERAGE(HMM_MulV3FOpLeft, 1) +static inline HMM_Vec3 operator*(float Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_MulV3FOpLeft); + return HMM_MulV3F(Right, Left); +} + +COVERAGE(HMM_MulV4FOpLeft, 1) +static inline HMM_Vec4 operator*(float Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_MulV4FOpLeft); + return HMM_MulV4F(Right, Left); +} + +COVERAGE(HMM_MulM2FOpLeft, 1) +static inline HMM_Mat2 operator*(float Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_MulM2FOpLeft); + return HMM_MulM2F(Right, Left); +} + +COVERAGE(HMM_MulM3FOpLeft, 1) +static inline HMM_Mat3 operator*(float Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_MulM3FOpLeft); + return HMM_MulM3F(Right, Left); +} + +COVERAGE(HMM_MulM4FOpLeft, 1) +static inline HMM_Mat4 operator*(float Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_MulM4FOpLeft); + return HMM_MulM4F(Right, Left); +} + +COVERAGE(HMM_MulQFOpLeft, 1) +static inline HMM_Quat operator*(float Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_MulQFOpLeft); + return HMM_MulQF(Right, Left); +} + +COVERAGE(HMM_MulM2V2Op, 1) +static inline HMM_Vec2 operator*(HMM_Mat2 Matrix, HMM_Vec2 Vector) { + ASSERT_COVERED(HMM_MulM2V2Op); + return HMM_MulM2V2(Matrix, Vector); +} + +COVERAGE(HMM_MulM3V3Op, 1) +static inline HMM_Vec3 operator*(HMM_Mat3 Matrix, HMM_Vec3 Vector) { + ASSERT_COVERED(HMM_MulM3V3Op); + return HMM_MulM3V3(Matrix, Vector); +} + +COVERAGE(HMM_MulM4V4Op, 1) +static inline HMM_Vec4 operator*(HMM_Mat4 Matrix, HMM_Vec4 Vector) { + ASSERT_COVERED(HMM_MulM4V4Op); + return HMM_MulM4V4(Matrix, Vector); +} + +COVERAGE(HMM_DivV2Op, 1) +static inline HMM_Vec2 operator/(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_DivV2Op); + return HMM_DivV2(Left, Right); +} + +COVERAGE(HMM_DivV3Op, 1) +static inline HMM_Vec3 operator/(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_DivV3Op); + return HMM_DivV3(Left, Right); +} + +COVERAGE(HMM_DivV4Op, 1) +static inline HMM_Vec4 operator/(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_DivV4Op); + return HMM_DivV4(Left, Right); +} + +COVERAGE(HMM_DivV2FOp, 1) +static inline HMM_Vec2 operator/(HMM_Vec2 Left, float Right) { + ASSERT_COVERED(HMM_DivV2FOp); + return HMM_DivV2F(Left, Right); +} + +COVERAGE(HMM_DivV3FOp, 1) +static inline HMM_Vec3 operator/(HMM_Vec3 Left, float Right) { + ASSERT_COVERED(HMM_DivV3FOp); + return HMM_DivV3F(Left, Right); +} + +COVERAGE(HMM_DivV4FOp, 1) +static inline HMM_Vec4 operator/(HMM_Vec4 Left, float Right) { + ASSERT_COVERED(HMM_DivV4FOp); + return HMM_DivV4F(Left, Right); +} + +COVERAGE(HMM_DivM4FOp, 1) +static inline HMM_Mat4 operator/(HMM_Mat4 Left, float Right) { + ASSERT_COVERED(HMM_DivM4FOp); + return HMM_DivM4F(Left, Right); +} + +COVERAGE(HMM_DivM3FOp, 1) +static inline HMM_Mat3 operator/(HMM_Mat3 Left, float Right) { + ASSERT_COVERED(HMM_DivM3FOp); + return HMM_DivM3F(Left, Right); +} + +COVERAGE(HMM_DivM2FOp, 1) +static inline HMM_Mat2 operator/(HMM_Mat2 Left, float Right) { + ASSERT_COVERED(HMM_DivM2FOp); + return HMM_DivM2F(Left, Right); +} + +COVERAGE(HMM_DivQFOp, 1) +static inline HMM_Quat operator/(HMM_Quat Left, float Right) { + ASSERT_COVERED(HMM_DivQFOp); + return HMM_DivQF(Left, Right); +} + +COVERAGE(HMM_AddV2Assign, 1) +static inline HMM_Vec2 &operator+=(HMM_Vec2 &Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_AddV2Assign); + return Left = Left + Right; +} + +COVERAGE(HMM_AddV3Assign, 1) +static inline HMM_Vec3 &operator+=(HMM_Vec3 &Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_AddV3Assign); + return Left = Left + Right; +} + +COVERAGE(HMM_AddV4Assign, 1) +static inline HMM_Vec4 &operator+=(HMM_Vec4 &Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_AddV4Assign); + return Left = Left + Right; +} + +COVERAGE(HMM_AddM2Assign, 1) +static inline HMM_Mat2 &operator+=(HMM_Mat2 &Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_AddM2Assign); + return Left = Left + Right; +} + +COVERAGE(HMM_AddM3Assign, 1) +static inline HMM_Mat3 &operator+=(HMM_Mat3 &Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_AddM3Assign); + return Left = Left + Right; +} + +COVERAGE(HMM_AddM4Assign, 1) +static inline HMM_Mat4 &operator+=(HMM_Mat4 &Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_AddM4Assign); + return Left = Left + Right; +} + +COVERAGE(HMM_AddQAssign, 1) +static inline HMM_Quat &operator+=(HMM_Quat &Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_AddQAssign); + return Left = Left + Right; +} + +COVERAGE(HMM_SubV2Assign, 1) +static inline HMM_Vec2 &operator-=(HMM_Vec2 &Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_SubV2Assign); + return Left = Left - Right; +} + +COVERAGE(HMM_SubV3Assign, 1) +static inline HMM_Vec3 &operator-=(HMM_Vec3 &Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_SubV3Assign); + return Left = Left - Right; +} + +COVERAGE(HMM_SubV4Assign, 1) +static inline HMM_Vec4 &operator-=(HMM_Vec4 &Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_SubV4Assign); + return Left = Left - Right; +} + +COVERAGE(HMM_SubM2Assign, 1) +static inline HMM_Mat2 &operator-=(HMM_Mat2 &Left, HMM_Mat2 Right) { + ASSERT_COVERED(HMM_SubM2Assign); + return Left = Left - Right; +} + +COVERAGE(HMM_SubM3Assign, 1) +static inline HMM_Mat3 &operator-=(HMM_Mat3 &Left, HMM_Mat3 Right) { + ASSERT_COVERED(HMM_SubM3Assign); + return Left = Left - Right; +} + +COVERAGE(HMM_SubM4Assign, 1) +static inline HMM_Mat4 &operator-=(HMM_Mat4 &Left, HMM_Mat4 Right) { + ASSERT_COVERED(HMM_SubM4Assign); + return Left = Left - Right; +} + +COVERAGE(HMM_SubQAssign, 1) +static inline HMM_Quat &operator-=(HMM_Quat &Left, HMM_Quat Right) { + ASSERT_COVERED(HMM_SubQAssign); + return Left = Left - Right; +} + +COVERAGE(HMM_MulV2Assign, 1) +static inline HMM_Vec2 &operator*=(HMM_Vec2 &Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_MulV2Assign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulV3Assign, 1) +static inline HMM_Vec3 &operator*=(HMM_Vec3 &Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_MulV3Assign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulV4Assign, 1) +static inline HMM_Vec4 &operator*=(HMM_Vec4 &Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_MulV4Assign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulV2FAssign, 1) +static inline HMM_Vec2 &operator*=(HMM_Vec2 &Left, float Right) { + ASSERT_COVERED(HMM_MulV2FAssign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulV3FAssign, 1) +static inline HMM_Vec3 &operator*=(HMM_Vec3 &Left, float Right) { + ASSERT_COVERED(HMM_MulV3FAssign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulV4FAssign, 1) +static inline HMM_Vec4 &operator*=(HMM_Vec4 &Left, float Right) { + ASSERT_COVERED(HMM_MulV4FAssign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulM2FAssign, 1) +static inline HMM_Mat2 &operator*=(HMM_Mat2 &Left, float Right) { + ASSERT_COVERED(HMM_MulM2FAssign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulM3FAssign, 1) +static inline HMM_Mat3 &operator*=(HMM_Mat3 &Left, float Right) { + ASSERT_COVERED(HMM_MulM3FAssign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulM4FAssign, 1) +static inline HMM_Mat4 &operator*=(HMM_Mat4 &Left, float Right) { + ASSERT_COVERED(HMM_MulM4FAssign); + return Left = Left * Right; +} + +COVERAGE(HMM_MulQFAssign, 1) +static inline HMM_Quat &operator*=(HMM_Quat &Left, float Right) { + ASSERT_COVERED(HMM_MulQFAssign); + return Left = Left * Right; +} + +COVERAGE(HMM_DivV2Assign, 1) +static inline HMM_Vec2 &operator/=(HMM_Vec2 &Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_DivV2Assign); + return Left = Left / Right; +} + +COVERAGE(HMM_DivV3Assign, 1) +static inline HMM_Vec3 &operator/=(HMM_Vec3 &Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_DivV3Assign); + return Left = Left / Right; +} + +COVERAGE(HMM_DivV4Assign, 1) +static inline HMM_Vec4 &operator/=(HMM_Vec4 &Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_DivV4Assign); + return Left = Left / Right; +} + +COVERAGE(HMM_DivV2FAssign, 1) +static inline HMM_Vec2 &operator/=(HMM_Vec2 &Left, float Right) { + ASSERT_COVERED(HMM_DivV2FAssign); + return Left = Left / Right; +} + +COVERAGE(HMM_DivV3FAssign, 1) +static inline HMM_Vec3 &operator/=(HMM_Vec3 &Left, float Right) { + ASSERT_COVERED(HMM_DivV3FAssign); + return Left = Left / Right; +} + +COVERAGE(HMM_DivV4FAssign, 1) +static inline HMM_Vec4 &operator/=(HMM_Vec4 &Left, float Right) { + ASSERT_COVERED(HMM_DivV4FAssign); + return Left = Left / Right; +} + +COVERAGE(HMM_DivM4FAssign, 1) +static inline HMM_Mat4 &operator/=(HMM_Mat4 &Left, float Right) { + ASSERT_COVERED(HMM_DivM4FAssign); + return Left = Left / Right; +} + +COVERAGE(HMM_DivQFAssign, 1) +static inline HMM_Quat &operator/=(HMM_Quat &Left, float Right) { + ASSERT_COVERED(HMM_DivQFAssign); + return Left = Left / Right; +} + +COVERAGE(HMM_EqV2Op, 1) +static inline HMM_Bool operator==(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_EqV2Op); + return HMM_EqV2(Left, Right); +} + +COVERAGE(HMM_EqV3Op, 1) +static inline HMM_Bool operator==(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_EqV3Op); + return HMM_EqV3(Left, Right); +} + +COVERAGE(HMM_EqV4Op, 1) +static inline HMM_Bool operator==(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_EqV4Op); + return HMM_EqV4(Left, Right); +} + +COVERAGE(HMM_EqV2OpNot, 1) +static inline HMM_Bool operator!=(HMM_Vec2 Left, HMM_Vec2 Right) { + ASSERT_COVERED(HMM_EqV2OpNot); + return !HMM_EqV2(Left, Right); +} + +COVERAGE(HMM_EqV3OpNot, 1) +static inline HMM_Bool operator!=(HMM_Vec3 Left, HMM_Vec3 Right) { + ASSERT_COVERED(HMM_EqV3OpNot); + return !HMM_EqV3(Left, Right); +} + +COVERAGE(HMM_EqV4OpNot, 1) +static inline HMM_Bool operator!=(HMM_Vec4 Left, HMM_Vec4 Right) { + ASSERT_COVERED(HMM_EqV4OpNot); + return !HMM_EqV4(Left, Right); +} + +COVERAGE(HMM_UnaryMinusV2, 1) +static inline HMM_Vec2 operator-(HMM_Vec2 In) { + ASSERT_COVERED(HMM_UnaryMinusV2); + + HMM_Vec2 Result; + Result.X = -In.X; + Result.Y = -In.Y; + + return Result; +} + +COVERAGE(HMM_UnaryMinusV3, 1) +static inline HMM_Vec3 operator-(HMM_Vec3 In) { + ASSERT_COVERED(HMM_UnaryMinusV3); + + HMM_Vec3 Result; + Result.X = -In.X; + Result.Y = -In.Y; + Result.Z = -In.Z; + + return Result; +} + +COVERAGE(HMM_UnaryMinusV4, 1) +static inline HMM_Vec4 operator-(HMM_Vec4 In) { + ASSERT_COVERED(HMM_UnaryMinusV4); + + HMM_Vec4 Result; +#if HANDMADE_MATH__USE_SSE + Result.SSE = _mm_xor_ps(In.SSE, _mm_set1_ps(-0.0f)); +#else + Result.X = -In.X; + Result.Y = -In.Y; + Result.Z = -In.Z; + Result.W = -In.W; +#endif + + return Result; +} + +#endif /* __cplusplus*/ + +#ifdef HANDMADE_MATH__USE_C11_GENERICS +#define HMM_Add(A, B) _Generic((A), \ + HMM_Vec2 \ + : HMM_AddV2, \ + HMM_Vec3 \ + : HMM_AddV3, \ + HMM_Vec4 \ + : HMM_AddV4, \ + HMM_Mat2 \ + : HMM_AddM2, \ + HMM_Mat3 \ + : HMM_AddM3, \ + HMM_Mat4 \ + : HMM_AddM4, \ + HMM_Quat \ + : HMM_AddQ)(A, B) + +#define HMM_Sub(A, B) _Generic((A), \ + HMM_Vec2 \ + : HMM_SubV2, \ + HMM_Vec3 \ + : HMM_SubV3, \ + HMM_Vec4 \ + : HMM_SubV4, \ + HMM_Mat2 \ + : HMM_SubM2, \ + HMM_Mat3 \ + : HMM_SubM3, \ + HMM_Mat4 \ + : HMM_SubM4, \ + HMM_Quat \ + : HMM_SubQ)(A, B) + +#define HMM_Mul(A, B) _Generic((B), \ + float \ + : _Generic((A), \ + HMM_Vec2 \ + : HMM_MulV2F, \ + HMM_Vec3 \ + : HMM_MulV3F, \ + HMM_Vec4 \ + : HMM_MulV4F, \ + HMM_Mat2 \ + : HMM_MulM2F, \ + HMM_Mat3 \ + : HMM_MulM3F, \ + HMM_Mat4 \ + : HMM_MulM4F, \ + HMM_Quat \ + : HMM_MulQF), \ + HMM_Mat2 \ + : HMM_MulM2, \ + HMM_Mat3 \ + : HMM_MulM3, \ + HMM_Mat4 \ + : HMM_MulM4, \ + HMM_Quat \ + : HMM_MulQ, \ + default \ + : _Generic((A), \ + HMM_Vec2 \ + : HMM_MulV2, \ + HMM_Vec3 \ + : HMM_MulV3, \ + HMM_Vec4 \ + : HMM_MulV4, \ + HMM_Mat2 \ + : HMM_MulM2V2, \ + HMM_Mat3 \ + : HMM_MulM3V3, \ + HMM_Mat4 \ + : HMM_MulM4V4))(A, B) + +#define HMM_Div(A, B) _Generic((B), \ + float \ + : _Generic((A), \ + HMM_Mat2 \ + : HMM_DivM2F, \ + HMM_Mat3 \ + : HMM_DivM3F, \ + HMM_Mat4 \ + : HMM_DivM4F, \ + HMM_Vec2 \ + : HMM_DivV2F, \ + HMM_Vec3 \ + : HMM_DivV3F, \ + HMM_Vec4 \ + : HMM_DivV4F, \ + HMM_Quat \ + : HMM_DivQF), \ + HMM_Mat2 \ + : HMM_DivM2, \ + HMM_Mat3 \ + : HMM_DivM3, \ + HMM_Mat4 \ + : HMM_DivM4, \ + HMM_Quat \ + : HMM_DivQ, \ + default \ + : _Generic((A), \ + HMM_Vec2 \ + : HMM_DivV2, \ + HMM_Vec3 \ + : HMM_DivV3, \ + HMM_Vec4 \ + : HMM_DivV4))(A, B) + +#define HMM_Len(A) _Generic((A), \ + HMM_Vec2 \ + : HMM_LenV2, \ + HMM_Vec3 \ + : HMM_LenV3, \ + HMM_Vec4 \ + : HMM_LenV4)(A) + +#define HMM_LenSqr(A) _Generic((A), \ + HMM_Vec2 \ + : HMM_LenSqrV2, \ + HMM_Vec3 \ + : HMM_LenSqrV3, \ + HMM_Vec4 \ + : HMM_LenSqrV4)(A) + +#define HMM_Norm(A) _Generic((A), \ + HMM_Vec2 \ + : HMM_NormV2, \ + HMM_Vec3 \ + : HMM_NormV3, \ + HMM_Vec4 \ + : HMM_NormV4)(A) + +#define HMM_Dot(A, B) _Generic((A), \ + HMM_Vec2 \ + : HMM_DotV2, \ + HMM_Vec3 \ + : HMM_DotV3, \ + HMM_Vec4 \ + : HMM_DotV4)(A, B) + +#define HMM_Lerp(A, T, B) _Generic((A), \ + float \ + : HMM_Lerp, \ + HMM_Vec2 \ + : HMM_LerpV2, \ + HMM_Vec3 \ + : HMM_LerpV3, \ + HMM_Vec4 \ + : HMM_LerpV4)(A, T, B) + +#define HMM_Eq(A, B) _Generic((A), \ + HMM_Vec2 \ + : HMM_EqV2, \ + HMM_Vec3 \ + : HMM_EqV3, \ + HMM_Vec4 \ + : HMM_EqV4)(A, B) + +#define HMM_Transpose(M) _Generic((M), \ + HMM_Mat2 \ + : HMM_TransposeM2, \ + HMM_Mat3 \ + : HMM_TransposeM3, \ + HMM_Mat4 \ + : HMM_TransposeM4)(M) + +#define HMM_Determinant(M) _Generic((M), \ + HMM_Mat2 \ + : HMM_DeterminantM2, \ + HMM_Mat3 \ + : HMM_DeterminantM3, \ + HMM_Mat4 \ + : HMM_DeterminantM4)(M) + +#define HMM_InvGeneral(M) _Generic((M), \ + HMM_Mat2 \ + : HMM_InvGeneralM2, \ + HMM_Mat3 \ + : HMM_InvGeneralM3, \ + HMM_Mat4 \ + : HMM_InvGeneralM4)(M) + +#endif + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#endif /* HANDMADE_MATH_H */ diff --git a/source/engine/KHR/khrplatform.h b/source/engine/KHR/khrplatform.h deleted file mode 100644 index 0164644..0000000 --- a/source/engine/KHR/khrplatform.h +++ /dev/null @@ -1,311 +0,0 @@ -#ifndef __khrplatform_h_ -#define __khrplatform_h_ - -/* -** Copyright (c) 2008-2018 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Khronos platform-specific types and definitions. - * - * The master copy of khrplatform.h is maintained in the Khronos EGL - * Registry repository at https://github.com/KhronosGroup/EGL-Registry - * The last semantic modification to khrplatform.h was at commit ID: - * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 - * - * Adopters may modify this file to suit their platform. Adopters are - * encouraged to submit platform specific modifications to the Khronos - * group so that they can be included in future versions of this file. - * Please submit changes by filing pull requests or issues on - * the EGL Registry repository linked above. - * - * - * See the Implementer's Guidelines for information about where this file - * should be located on your system and for more details of its use: - * http://www.khronos.org/registry/implementers_guide.pdf - * - * This file should be included as - * #include - * by Khronos client API header files that use its types and defines. - * - * The types in khrplatform.h should only be used to define API-specific types. - * - * Types defined in khrplatform.h: - * khronos_int8_t signed 8 bit - * khronos_uint8_t unsigned 8 bit - * khronos_int16_t signed 16 bit - * khronos_uint16_t unsigned 16 bit - * khronos_int32_t signed 32 bit - * khronos_uint32_t unsigned 32 bit - * khronos_int64_t signed 64 bit - * khronos_uint64_t unsigned 64 bit - * khronos_intptr_t signed same number of bits as a pointer - * khronos_uintptr_t unsigned same number of bits as a pointer - * khronos_ssize_t signed size - * khronos_usize_t unsigned size - * khronos_float_t signed 32 bit floating point - * khronos_time_ns_t unsigned 64 bit time in nanoseconds - * khronos_utime_nanoseconds_t unsigned time interval or absolute time in - * nanoseconds - * khronos_stime_nanoseconds_t signed time interval in nanoseconds - * khronos_boolean_enum_t enumerated boolean type. This should - * only be used as a base type when a client API's boolean type is - * an enum. Client APIs which use an integer or other type for - * booleans cannot use this as the base type for their boolean. - * - * Tokens defined in khrplatform.h: - * - * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. - * - * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. - * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. - * - * Calling convention macros defined in this file: - * KHRONOS_APICALL - * KHRONOS_APIENTRY - * KHRONOS_APIATTRIBUTES - * - * These may be used in function prototypes as: - * - * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( - * int arg1, - * int arg2) KHRONOS_APIATTRIBUTES; - */ - -#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) -# define KHRONOS_STATIC 1 -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APICALL - *------------------------------------------------------------------------- - * This precedes the return type of the function in the function prototype. - */ -#if defined(KHRONOS_STATIC) - /* If the preprocessor constant KHRONOS_STATIC is defined, make the - * header compatible with static linking. */ -# define KHRONOS_APICALL -#elif defined(_WIN32) -# define KHRONOS_APICALL __declspec(dllimport) -#elif defined (__SYMBIAN32__) -# define KHRONOS_APICALL IMPORT_C -#elif defined(__ANDROID__) -# define KHRONOS_APICALL __attribute__((visibility("default"))) -#else -# define KHRONOS_APICALL -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIENTRY - *------------------------------------------------------------------------- - * This follows the return type of the function and precedes the function - * name in the function prototype. - */ -#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) - /* Win32 but not WinCE */ -# define KHRONOS_APIENTRY __stdcall -#else -# define KHRONOS_APIENTRY -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIATTRIBUTES - *------------------------------------------------------------------------- - * This follows the closing parenthesis of the function prototype arguments. - */ -#if defined (__ARMCC_2__) -#define KHRONOS_APIATTRIBUTES __softfp -#else -#define KHRONOS_APIATTRIBUTES -#endif - -/*------------------------------------------------------------------------- - * basic type definitions - *-----------------------------------------------------------------------*/ -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) - - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 -/* - * To support platform where unsigned long cannot be used interchangeably with - * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. - * Ideally, we could just use (u)intptr_t everywhere, but this could result in - * ABI breakage if khronos_uintptr_t is changed from unsigned long to - * unsigned long long or similar (this results in different C++ name mangling). - * To avoid changes for existing platforms, we restrict usage of intptr_t to - * platforms where the size of a pointer is larger than the size of long. - */ -#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) -#if __SIZEOF_POINTER__ > __SIZEOF_LONG__ -#define KHRONOS_USE_INTPTR_T -#endif -#endif - -#elif defined(__VMS ) || defined(__sgi) - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) - -/* - * Win32 - */ -typedef __int32 khronos_int32_t; -typedef unsigned __int32 khronos_uint32_t; -typedef __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__sun__) || defined(__digital__) - -/* - * Sun or Digital - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; -#else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; -#endif /* __arch64__ */ -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif 0 - -/* - * Hypothetical platform with no float or int64 support - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#define KHRONOS_SUPPORT_INT64 0 -#define KHRONOS_SUPPORT_FLOAT 0 - -#else - -/* - * Generic fallback - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#endif - - -/* - * Types that are (so far) the same on all platforms - */ -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; - -/* - * Types that differ between LLP64 and LP64 architectures - in LLP64, - * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears - * to be the only LLP64 architecture in current use. - */ -#ifdef KHRONOS_USE_INTPTR_T -typedef intptr_t khronos_intptr_t; -typedef uintptr_t khronos_uintptr_t; -#elif defined(_WIN64) -typedef signed long long int khronos_intptr_t; -typedef unsigned long long int khronos_uintptr_t; -#else -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -#endif - -#if defined(_WIN64) -typedef signed long long int khronos_ssize_t; -typedef unsigned long long int khronos_usize_t; -#else -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; -#endif - -#if KHRONOS_SUPPORT_FLOAT -/* - * Float type - */ -typedef float khronos_float_t; -#endif - -#if KHRONOS_SUPPORT_INT64 -/* Time types - * - * These types can be used to represent a time interval in nanoseconds or - * an absolute Unadjusted System Time. Unadjusted System Time is the number - * of nanoseconds since some arbitrary system event (e.g. since the last - * time the system booted). The Unadjusted System Time is an unsigned - * 64 bit value that wraps back to 0 every 584 years. Time intervals - * may be either signed or unsigned. - */ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; -#endif - -/* - * Dummy value used to pad enum types to 32 bits. - */ -#ifndef KHRONOS_MAX_ENUM -#define KHRONOS_MAX_ENUM 0x7FFFFFFF -#endif - -/* - * Enumerated boolean type - * - * Values other than zero should be considered to be true. Therefore - * comparisons should not be made against KHRONOS_TRUE. - */ -typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM -} khronos_boolean_enum_t; - -#endif /* __khrplatform_h_ */ diff --git a/source/engine/anim.c b/source/engine/anim.c index 5af54cf..9898356 100644 --- a/source/engine/anim.c +++ b/source/engine/anim.c @@ -1,51 +1,51 @@ #include "anim.h" -#include "stb_ds.h" #include "log.h" +#include "stb_ds.h" struct anim make_anim() { - struct anim a = {0}; - a.interp = 1; + struct anim a = {0}; + a.interp = 1; - return a; + return a; } void free_anim(struct anim a) { - arrfree(a.frames); + arrfree(a.frames); } struct anim anim_add_keyframe(struct anim a, struct keyframe key) { - arrput(a.frames, key); + arrput(a.frames, key); - return a; + return a; } double interval(struct keyframe a, struct keyframe b, double t) { - return (t - a.time) / (b.time - a.time); + return (t - a.time) / (b.time - a.time); } double near_val(struct anim anim, double t) { - for (int i = 0; i < arrlen(anim.frames) - 1; i++) { + for (int i = 0; i < arrlen(anim.frames) - 1; i++) { - if (t > anim.frames[i+1].time) - continue; + if (t > anim.frames[i + 1].time) + continue; - return (interval(anim.frames[i], anim.frames[i+1], t) >= 0.5f ? anim.frames[i+1].val : anim.frames[i].val); - } + return (interval(anim.frames[i], anim.frames[i + 1], t) >= 0.5f ? anim.frames[i + 1].val : anim.frames[i].val); + } - return arrlast(anim.frames).val; + return arrlast(anim.frames).val; } double lerp_val(struct anim anim, double t) { - for (int i = 0; i < arrlen(anim.frames) - 1; i++) { - if (t > anim.frames[i+1].time) - continue; + for (int i = 0; i < arrlen(anim.frames) - 1; i++) { + if (t > anim.frames[i + 1].time) + continue; - double intv = interval(anim.frames[i], anim.frames[i+1], t); - return ((1 - intv) * anim.frames[i].val) + (intv * anim.frames[i+1].val); - } + double intv = interval(anim.frames[i], anim.frames[i + 1], t); + return ((1 - intv) * anim.frames[i].val) + (intv * anim.frames[i + 1].val); + } - return arrlast(anim.frames).val; + return arrlast(anim.frames).val; } double cubic_val(struct anim anim, double t) { @@ -53,8 +53,8 @@ double cubic_val(struct anim anim, double t) { } double anim_val(struct anim anim, double t) { - if (anim.interp == 0) - return near_val(anim, t); + if (anim.interp == 0) + return near_val(anim, t); - return lerp_val(anim, t); + return lerp_val(anim, t); } diff --git a/source/engine/anim.h b/source/engine/anim.h index 358dfba..91ce0dd 100644 --- a/source/engine/anim.h +++ b/source/engine/anim.h @@ -2,19 +2,18 @@ #define ANIM_H struct keyframe { - double time; - double val; + double time; + double val; }; struct anim { - struct keyframe *frames; - int loop; - int interp; + struct keyframe *frames; + int loop; + int interp; }; struct anim make_anim(); struct anim anim_add_keyframe(struct anim a, struct keyframe f); double anim_val(struct anim anim, double t); - #endif \ No newline at end of file diff --git a/source/engine/camera.c b/source/engine/camera.c index e63e5fa..2301bb6 100644 --- a/source/engine/camera.c +++ b/source/engine/camera.c @@ -3,70 +3,64 @@ #include "gameobject.h" #include "input.h" - const float CAMERA_MINSPEED = 1.f; const float CAMERA_MAXSPEED = 300.f; const float CAMERA_ROTATESPEED = 6.f; -void cam_goto_object(struct mCamera *cam, struct mTransform *transform) -{ - mfloat_t fwd[3] = { 0.f }; - vec3_subtract(cam->transform.position, transform->position, - vec3_multiply_f(fwd, trans_forward(fwd, transform), - 10.f)); +void cam_goto_object(struct mCamera *cam, struct mTransform *transform) { + mfloat_t fwd[3] = {0.f}; + vec3_subtract(cam->transform.position, transform->position, + vec3_multiply_f(fwd, trans_forward(fwd, transform), + 10.f)); } -void cam_inverse_goto(struct mCamera *cam, struct mTransform *transform) -{ - mfloat_t fwd[3] = { 0.f }; - vec3_add(transform->position, cam->transform.position, - vec3_multiply_f(fwd, trans_forward(fwd, &cam->transform), - 10.f)); +void cam_inverse_goto(struct mCamera *cam, struct mTransform *transform) { + mfloat_t fwd[3] = {0.f}; + vec3_add(transform->position, cam->transform.position, + vec3_multiply_f(fwd, trans_forward(fwd, &cam->transform), + 10.f)); } mfloat_t *getviewmatrix(mfloat_t view[16], - const struct mCamera *const camera) -{ - mfloat_t fwd[3] = { 0.f }; - mfloat_t look[3] = { 0.f }; - vec3_rotate_quat(fwd, FORWARD, camera->transform.rotation); - vec3_add(look, camera->transform.position, fwd); - mat4_look_at(view, camera->transform.position, look, UP); - return view; - /*return mat4_look_at(view, ncam.transform.position, - vec3_add(look, ncam.transform.position, - trans_forward(fwd, &ncam.transform)), - UP); */ + const struct mCamera *const camera) { + mfloat_t fwd[3] = {0.f}; + mfloat_t look[3] = {0.f}; + vec3_rotate_quat(fwd, FORWARD, camera->transform.rotation); + vec3_add(look, camera->transform.position, fwd); + mat4_look_at(view, camera->transform.position, look, UP); + return view; + /*return mat4_look_at(view, ncam.transform.position, + vec3_add(look, ncam.transform.position, + trans_forward(fwd, &ncam.transform)), + UP); */ } -void camera_2d_update(struct mCamera *camera, float deltaT) -{ - static mfloat_t frame[3]; - vec3_zero(frame); - if (action_down(GLFW_KEY_W)) - vec3_add(frame, frame, UP); - if (action_down(GLFW_KEY_S)) - vec3_add(frame, frame, DOWN); - if (action_down(GLFW_KEY_A)) - vec3_add(frame, frame, LEFT); - if (action_down(GLFW_KEY_D)) - vec3_add(frame, frame, RIGHT); +void camera_2d_update(struct mCamera *camera, float deltaT) { + static mfloat_t frame[3]; + vec3_zero(frame); + if (action_down(GLFW_KEY_W)) + vec3_add(frame, frame, UP); + if (action_down(GLFW_KEY_S)) + vec3_add(frame, frame, DOWN); + if (action_down(GLFW_KEY_A)) + vec3_add(frame, frame, LEFT); + if (action_down(GLFW_KEY_D)) + vec3_add(frame, frame, RIGHT); - float speedMult = action_down(GLFW_KEY_LEFT_SHIFT) ? 2.f : 1.f; - - if (!vec3_is_zero(frame)) { - vec3_normalize(frame, frame); - vec3_add(camera->transform.position, camera->transform.position, - vec3_multiply_f(frame, frame, - camera->speed * speedMult * deltaT)); - } + float speedMult = action_down(GLFW_KEY_LEFT_SHIFT) ? 2.f : 1.f; + if (!vec3_is_zero(frame)) { + vec3_normalize(frame, frame); + vec3_add(camera->transform.position, camera->transform.position, + vec3_multiply_f(frame, frame, + camera->speed * speedMult * deltaT)); + } } /* void camera_update(struct mCamera * camera, float mouseX, float mouseY, - const uint8_t * keystate, int32_t mouseWheelY, - float deltaTime) + const uint8_t * keystate, int32_t mouseWheelY, + float deltaTime) { // if (SDL_GetRelativeMouseMode()) vec3_zero(camera->frame_move); @@ -74,43 +68,43 @@ void camera_update(struct mCamera * camera, float mouseX, float mouseY, vec3_zero(camera->frame_move); if (currentKeystates[SDL_SCANCODE_W]) - vec3_add(camera->frame_move, camera->frame_move, - trans_forward(holdvec, &camera->transform)); + vec3_add(camera->frame_move, camera->frame_move, + trans_forward(holdvec, &camera->transform)); if (currentKeystates[SDL_SCANCODE_S]) - vec3_subtract(camera->frame_move, camera->frame_move, - trans_forward(holdvec, &camera->transform)); + vec3_subtract(camera->frame_move, camera->frame_move, + trans_forward(holdvec, &camera->transform)); if (currentKeystates[SDL_SCANCODE_A]) - vec3_subtract(camera->frame_move, camera->frame_move, - trans_right(holdvec, &camera->transform)); + vec3_subtract(camera->frame_move, camera->frame_move, + trans_right(holdvec, &camera->transform)); if (currentKeystates[SDL_SCANCODE_D]) - vec3_add(camera->frame_move, camera->frame_move, - trans_right(holdvec, &camera->transform)); + vec3_add(camera->frame_move, camera->frame_move, + trans_right(holdvec, &camera->transform)); if (currentKeystates[SDL_SCANCODE_E]) - vec3_add(camera->frame_move, camera->frame_move, - trans_up(holdvec, &camera->transform)); + vec3_add(camera->frame_move, camera->frame_move, + trans_up(holdvec, &camera->transform)); if (currentKeystates[SDL_SCANCODE_Q]) - vec3_subtract(camera->frame_move, camera->frame_move, - trans_up(holdvec, &camera->transform)); + vec3_subtract(camera->frame_move, camera->frame_move, + trans_up(holdvec, &camera->transform)); camera->speedMult = currentKeystates[SDL_SCANCODE_LSHIFT] ? 2.f : 1.f; if (!vec3_is_zero(camera->frame_move)) { - vec3_normalize(camera->frame_move, camera->frame_move); - vec3_add(camera->transform.position, camera->transform.position, - vec3_multiply_f(camera->frame_move, camera->frame_move, - camera->speed * camera->speedMult * - deltaTime)); + vec3_normalize(camera->frame_move, camera->frame_move); + vec3_add(camera->transform.position, camera->transform.position, + vec3_multiply_f(camera->frame_move, camera->frame_move, + camera->speed * camera->speedMult * + deltaTime)); } // Adjust speed based on mouse wheel camera->speed = - clampf(camera->speed + mouseWheelY, CAMERA_MINSPEED, - CAMERA_MAXSPEED); + clampf(camera->speed + mouseWheelY, CAMERA_MINSPEED, + CAMERA_MAXSPEED); // TODO: Handle this as additive quaternions @@ -120,9 +114,9 @@ void camera_update(struct mCamera * camera, float mouseX, float mouseY, if (camera->pitch > 89.f) - camera->pitch = 89.f; + camera->pitch = 89.f; if (camera->pitch < -89.f) - camera->pitch = -89.f; + camera->pitch = -89.f; mfloat_t qyaw[4] = {0.f}; mfloat_t qpitch[4] = {0.f}; diff --git a/source/engine/camera.h b/source/engine/camera.h index fc4634c..552c71a 100644 --- a/source/engine/camera.h +++ b/source/engine/camera.h @@ -8,10 +8,10 @@ extern const float CAMERA_MAXSPEED; extern const float CAMERA_ROTATESPEED; struct mCamera { - struct mTransform transform; - float speed; - float speedMult; - mfloat_t frame_move[VEC3_SIZE]; + struct mTransform transform; + float speed; + float speedMult; + mfloat_t frame_move[VEC3_SIZE]; }; void camera_2d_update(struct mCamera *camera, float deltaT); diff --git a/source/engine/config.h b/source/engine/config.h index d2027d3..e2d39d0 100644 --- a/source/engine/config.h +++ b/source/engine/config.h @@ -1,8 +1,7 @@ #ifndef CONFIG_H #define CONFIG_H - -#define MAXPATH 256 /* 255 chars + null */ +#define MAXPATH 256 /* 255 chars + null */ #define MAXNAME 50 #define SCREEN_WIDTH 1280 diff --git a/source/engine/datastream.c b/source/engine/datastream.c index 6423e01..8e3516f 100644 --- a/source/engine/datastream.c +++ b/source/engine/datastream.c @@ -1,206 +1,189 @@ #include "datastream.h" -#include "render.h" #include "config.h" -#include "shader.h" -#include "resources.h" -#include "sound.h" -#include -#include "log.h" -#include "texture.h" -#include -#include "mix.h" -#include "limits.h" -#include "iir.h" #include "dsp.h" +#include "iir.h" +#include "limits.h" +#include "log.h" +#include "mix.h" +#include "render.h" +#include "resources.h" +#include "shader.h" +#include "sound.h" +#include "texture.h" +#include +#include struct shader *vid_shader; -static void ds_update_texture(uint32_t unit, uint32_t texture, plm_plane_t * plane) -{ -/* - glActiveTexture(unit); - glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, plane->width, plane->height, 0, GL_RED, GL_UNSIGNED_BYTE, plane->data); -*/ +static void ds_update_texture(uint32_t unit, uint32_t texture, plm_plane_t *plane) { + /* + glActiveTexture(unit); + glBindTexture(GL_TEXTURE_2D, texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, plane->width, plane->height, 0, GL_RED, GL_UNSIGNED_BYTE, plane->data); + */ } -static void render_frame(plm_t * mpeg, plm_frame_t * frame, void *user) -{ - struct datastream *ds = user; - shader_use(ds->shader); -/* - ds_update_texture(GL_TEXTURE0, ds->texture_y, &frame->y); - ds_update_texture(GL_TEXTURE1, ds->texture_cb, &frame->cb); - ds_update_texture(GL_TEXTURE2, ds->texture_cr, &frame->cr); -*/ +static void render_frame(plm_t *mpeg, plm_frame_t *frame, void *user) { + struct datastream *ds = user; + shader_use(ds->shader); + /* + ds_update_texture(GL_TEXTURE0, ds->texture_y, &frame->y); + ds_update_texture(GL_TEXTURE1, ds->texture_cb, &frame->cb); + ds_update_texture(GL_TEXTURE2, ds->texture_cr, &frame->cr); + */ } -static void render_audio(plm_t * mpeg, plm_samples_t * samples, void *user) -{ - struct datastream *ds = user; - short t; +static void render_audio(plm_t *mpeg, plm_samples_t *samples, void *user) { + struct datastream *ds = user; + short t; - for (int i = 0; i < samples->count * CHANNELS; i++) { - t = (short)(samples->interleaved[i] * SHRT_MAX); - cbuf_push(ds->astream->buf, t*5); - } + for (int i = 0; i < samples->count * CHANNELS; i++) { + t = (short)(samples->interleaved[i] * SHRT_MAX); + cbuf_push(ds->astream->buf, t * 5); + } } -struct Texture *ds_maketexture(struct datastream *ds) -{ -/* - struct Texture *new = malloc(sizeof(*new)); - new->id = ds->texture_cb; - new->width = 500; - new->height = 500; - return new; -*/ +struct Texture *ds_maketexture(struct datastream *ds) { + /* + struct Texture *new = malloc(sizeof(*new)); + new->id = ds->texture_cb; + new->width = 500; + new->height = 500; + return new; + */ } -void ds_openvideo(struct datastream *ds, const char *video, const char *adriver) -{ - // ds_stop(ds); - char buf[MAXPATH] = {'\0'}; - sprintf(buf, "%s%s", "video/", video); - ds->plm = plm_create_with_filename(buf); +void ds_openvideo(struct datastream *ds, const char *video, const char *adriver) { + // ds_stop(ds); + char buf[MAXPATH] = {'\0'}; + sprintf(buf, "%s%s", "video/", video); + ds->plm = plm_create_with_filename(buf); - if (!ds->plm) { - YughLog(0, 0, "Couldn't open %s", video); - } + if (!ds->plm) { + YughLog(0, 0, "Couldn't open %s", video); + } - YughLog(0, 0, "Opened %s - framerate: %f, samplerate: %d, audio streams: %i, duration: %f", - video, - plm_get_framerate(ds->plm), - plm_get_samplerate(ds->plm), - plm_get_num_audio_streams(ds->plm), - plm_get_duration(ds->plm) - ); + YughLog(0, 0, "Opened %s - framerate: %f, samplerate: %d, audio streams: %i, duration: %f", + video, + plm_get_framerate(ds->plm), + plm_get_samplerate(ds->plm), + plm_get_num_audio_streams(ds->plm), + plm_get_duration(ds->plm)); - ds->astream = soundstream_make(); - struct dsp_filter astream_filter; - astream_filter.data = &ds->astream; - astream_filter.filter = soundstream_fillbuf; + ds->astream = soundstream_make(); + struct dsp_filter astream_filter; + astream_filter.data = &ds->astream; + astream_filter.filter = soundstream_fillbuf; - //struct dsp_filter lpf = lpf_make(8, 10000); - struct dsp_filter lpf = lpf_make(1, 200); - struct dsp_iir *iir = lpf.data; - iir->in = astream_filter; + // struct dsp_filter lpf = lpf_make(8, 10000); + struct dsp_filter lpf = lpf_make(1, 200); + struct dsp_iir *iir = lpf.data; + iir->in = astream_filter; + struct dsp_filter hpf = hpf_make(1, 2000); + struct dsp_iir *hiir = hpf.data; + hiir->in = astream_filter; - struct dsp_filter hpf = hpf_make(1, 2000); - struct dsp_iir *hiir = hpf.data; - hiir->in = astream_filter; + /* + struct dsp_filter llpf = lp_fir_make(20); + struct dsp_fir *fir = llpf.data; + fir->in = astream_filter; + */ -/* - struct dsp_filter llpf = lp_fir_make(20); - struct dsp_fir *fir = llpf.data; - fir->in = astream_filter; -*/ + // first_free_bus(astream_filter); - //first_free_bus(astream_filter); + plm_set_video_decode_callback(ds->plm, render_frame, ds); + plm_set_audio_decode_callback(ds->plm, render_audio, ds); + plm_set_loop(ds->plm, false); - plm_set_video_decode_callback(ds->plm, render_frame, ds); - plm_set_audio_decode_callback(ds->plm, render_audio, ds); - plm_set_loop(ds->plm, false); + plm_set_audio_enabled(ds->plm, true); + plm_set_audio_stream(ds->plm, 0); - plm_set_audio_enabled(ds->plm, true); - plm_set_audio_stream(ds->plm, 0); + // Adjust the audio lead time according to the audio_spec buffer size + plm_set_audio_lead_time(ds->plm, BUF_FRAMES / SAMPLERATE); - // Adjust the audio lead time according to the audio_spec buffer size - plm_set_audio_lead_time(ds->plm, BUF_FRAMES/SAMPLERATE); - - ds->playing = true; + ds->playing = true; } -struct datastream *MakeDatastream() -{ - struct datastream *newds = malloc(sizeof(*newds)); -/* - if (!vid_shader) vid_shader = MakeShader("videovert.glsl", "videofrag.glsl"); +struct datastream *MakeDatastream() { + struct datastream *newds = malloc(sizeof(*newds)); + /* + if (!vid_shader) vid_shader = MakeShader("videovert.glsl", "videofrag.glsl"); - newds->shader = vid_shader; - shader_use(newds->shader); - glGenTextures(1, &newds->texture_y); - glBindTexture(GL_TEXTURE_2D, newds->texture_y); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - shader_setint(newds->shader, "texture_y", 0); + newds->shader = vid_shader; + shader_use(newds->shader); + glGenTextures(1, &newds->texture_y); + glBindTexture(GL_TEXTURE_2D, newds->texture_y); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + shader_setint(newds->shader, "texture_y", 0); - glGenTextures(1, &newds->texture_cb); - glBindTexture(GL_TEXTURE_2D, newds->texture_cb); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - shader_setint(newds->shader, "texture_cb", 1); + glGenTextures(1, &newds->texture_cb); + glBindTexture(GL_TEXTURE_2D, newds->texture_cb); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + shader_setint(newds->shader, "texture_cb", 1); - glGenTextures(1, &newds->texture_cr); - glBindTexture(GL_TEXTURE_2D, newds->texture_cr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - shader_setint(newds->shader, "texture_cr", 2); -*/ - return newds; + glGenTextures(1, &newds->texture_cr); + glBindTexture(GL_TEXTURE_2D, newds->texture_cr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + shader_setint(newds->shader, "texture_cr", 2); + */ + return newds; } -void ds_advance(struct datastream *ds, double s) -{ - if (ds->playing) { - plm_decode(ds->plm, s); - } +void ds_advance(struct datastream *ds, double s) { + if (ds->playing) { + plm_decode(ds->plm, s); + } } -void ds_seek(struct datastream *ds, double time) -{ - //clear_raw(ds->audio_device); - plm_seek(ds->plm, time, false); +void ds_seek(struct datastream *ds, double time) { + // clear_raw(ds->audio_device); + plm_seek(ds->plm, time, false); } -void ds_advanceframes(struct datastream *ds, int frames) -{ - for (int i = 0; i < frames; i++) { - plm_frame_t *frame = plm_decode_video(ds->plm); - render_frame(ds->plm, frame, ds); - } +void ds_advanceframes(struct datastream *ds, int frames) { + for (int i = 0; i < frames; i++) { + plm_frame_t *frame = plm_decode_video(ds->plm); + render_frame(ds->plm, frame, ds); + } } -void ds_pause(struct datastream *ds) -{ - ds->playing = false; +void ds_pause(struct datastream *ds) { + ds->playing = false; } -void ds_stop(struct datastream *ds) -{ - if (ds->plm != NULL) { - plm_destroy(ds->plm); - ds->plm = NULL; - } - if (ds->audio_device) - close_audio_device(ds->audio_device); - ds->playing = false; +void ds_stop(struct datastream *ds) { + if (ds->plm != NULL) { + plm_destroy(ds->plm); + ds->plm = NULL; + } + if (ds->audio_device) + close_audio_device(ds->audio_device); + ds->playing = false; } // TODO: Must be a better way -int ds_videodone(struct datastream *ds) -{ - return (ds->plm == NULL) - || plm_get_time(ds->plm) >= plm_get_duration(ds->plm); +int ds_videodone(struct datastream *ds) { + return (ds->plm == NULL) || plm_get_time(ds->plm) >= plm_get_duration(ds->plm); } -double ds_remainingtime(struct datastream *ds) -{ - if (ds->plm != NULL) - return plm_get_duration(ds->plm) - plm_get_time(ds->plm); - else - return 0.f; +double ds_remainingtime(struct datastream *ds) { + if (ds->plm != NULL) + return plm_get_duration(ds->plm) - plm_get_time(ds->plm); + else + return 0.f; } -double ds_length(struct datastream *ds) -{ - return plm_get_duration(ds->plm); +double ds_length(struct datastream *ds) { + return plm_get_duration(ds->plm); } diff --git a/source/engine/datastream.h b/source/engine/datastream.h index e66f415..4f297af 100644 --- a/source/engine/datastream.h +++ b/source/engine/datastream.h @@ -1,21 +1,21 @@ #ifndef DATASTREAM_H #define DATASTREAM_H -#include #include +#include struct soundstream; struct datastream { - plm_t *plm; - struct shader *shader; - double last_time; - int playing; - int audio_device; - uint32_t texture_y; - uint32_t texture_cb; - uint32_t texture_cr; - struct soundstream *astream; + plm_t *plm; + struct shader *shader; + double last_time; + int playing; + int audio_device; + uint32_t texture_y; + uint32_t texture_cb; + uint32_t texture_cr; + struct soundstream *astream; }; struct Texture; @@ -24,7 +24,7 @@ extern struct shader *vid_shader; struct datastream *MakeDatastream(); void ds_openvideo(struct datastream *ds, const char *path, const char *adriver); -struct Texture *ds_maketexture(struct datastream*); +struct Texture *ds_maketexture(struct datastream *); void ds_advance(struct datastream *ds, double); void ds_seek(struct datastream *ds, double); void ds_advanceframes(struct datastream *ds, int frames); diff --git a/source/engine/debug/debugdraw.c b/source/engine/debug/debugdraw.c index ed5aab5..46dbfaf 100644 --- a/source/engine/debug/debugdraw.c +++ b/source/engine/debug/debugdraw.c @@ -11,75 +11,163 @@ #include "stb_ds.h" #include "sokol/sokol_gfx.h" -static uint32_t circleVBO; -static uint32_t circleVAO; -static struct shader *circleShader; +#include "font.h" -static uint32_t gridVBO; -static uint32_t gridVAO; -static struct shader *gridShader; +static sg_pipeline grid_pipe; +static sg_bindings grid_bind; +static sg_shader grid_shader; +static int grid_c = 0; -static uint32_t rectVBO; -static uint32_t rectVAO; -static struct shader *rectShader; +static sg_pipeline rect_pipe; +static sg_bindings rect_bind; +static sg_shader rect_shader; +static int rect_c = 0; -typedef struct { - float proj[16]; - float res[2]; -} circle_ubo; +static sg_pipeline circle_pipe; +static sg_bindings circle_bind; +static sg_shader csg; +static int circle_count = 0; +static int circle_vert_c = 7; void debug_flush() { - + sg_apply_pipeline(circle_pipe); + sg_apply_bindings(&circle_bind); + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(projection)); + + sg_draw(0,4,circle_count); + circle_count = 0; + + sg_apply_pipeline(rect_pipe); + sg_apply_bindings(&rect_bind); + sg_apply_uniforms(SG_SHADERSTAGE_VS,0,SG_RANGE_REF(projection)); + sg_draw(0,rect_c*2,1); + rect_c = 0; } +static sg_shader_uniform_block_desc projection_ubo = { + .size = sizeof(projection), + .uniforms = { + [0] = { .name = "proj", .type = SG_UNIFORMTYPE_MAT4 }, + } +}; + void debugdraw_init() { - sg_shader csg = sg_make_shader(&(sg_shader_desc){ + csg = sg_make_shader(&(sg_shader_desc){ .vs.source = slurp_text("shaders/circlevert.glsl"), .fs.source = slurp_text("shaders/circlefrag.glsl"), - .vs.uniform_blocks[0] = { - .size = sizeof(circle_ubo), - .uniforms = { - [0] = { .name = "proj", .type = SG_UNIFORMTYPE_MAT4 }, - [1] = { .name = "res", .type = SG_UNIFORMTYPE_FLOAT2 }, - } - } + .vs.uniform_blocks[0] = projection_ubo, }); -/* - float gridverts[] = { - -1.f, -1.f, - 1.f, -1.f, - -1.f, 1.f, - 1.f, 1.f - }; - gridShader = MakeShader("gridvert.glsl", "gridfrag.glsl"); - shader_setUBO(gridShader, "Projection", 0); - glGenBuffers(1, &gridVBO); - glGenVertexArrays(1, &gridVAO); - glBindVertexArray(gridVAO); - glBindBuffer(GL_ARRAY_BUFFER, gridVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(gridverts), &gridverts, GL_STATIC_DRAW); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); + circle_pipe = sg_make_pipeline(&(sg_pipeline_desc){ + .shader = csg, + .layout = { + .attrs = { + [0].format = SG_VERTEXFORMAT_FLOAT2, + [0].buffer_index = 1, + [1].format = SG_VERTEXFORMAT_FLOAT3, + [2].format = SG_VERTEXFORMAT_FLOAT2, + [3].format = SG_VERTEXFORMAT_FLOAT + }, + .buffers[0].step_func = SG_VERTEXSTEP_PER_INSTANCE, + }, + .primitive_type = SG_PRIMITIVETYPE_TRIANGLE_STRIP, + .cull_mode = SG_CULLMODE_BACK, + .colors[0].blend = { + .enabled = true, + .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA, + .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + .src_factor_alpha = SG_BLENDFACTOR_SRC_ALPHA, + .src_factor_alpha = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA + }, + .label = "circle pipeline" + }); - rectShader = MakeShader("linevert.glsl", "linefrag.glsl"); - shader_setUBO(rectShader, "Projection", 0); - glGenBuffers(1, &rectVBO); - glGenVertexArrays(1, &rectVAO); -*/ + circle_bind.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ + .size = sizeof(float)*circle_vert_c*5000, + .usage = SG_USAGE_STREAM, + }); + + float circleverts[8] = { + -1,-1, + -1,1, + 1,-1, + 1,1 + }; + + circle_bind.vertex_buffers[1] = sg_make_buffer(&(sg_buffer_desc){ + .data = SG_RANGE(circleverts), + .usage = SG_USAGE_IMMUTABLE, + }); + + + grid_shader = sg_make_shader(&(sg_shader_desc){ + .vs.source = slurp_text("shaders/gridvert.glsl"), + .fs.source = slurp_text("shaders/gridfrag.glsl"), + .vs.uniform_blocks[0] = projection_ubo, + .vs.uniform_blocks[1] = { + .size = sizeof(float)*2, + .uniforms = { [0] = { .name = "offset", .type = SG_UNIFORMTYPE_FLOAT2 } } }, + .fs.uniform_blocks[0] = { + .size = sizeof(float)*5, + .uniforms = { + [0] = { .name = "thickness", .type = SG_UNIFORMTYPE_FLOAT }, + [1] = { .name = "span", .type = SG_UNIFORMTYPE_FLOAT }, + [2] = { .name = "color", .type = SG_UNIFORMTYPE_FLOAT3 }, + } + }, + }); + + grid_pipe = sg_make_pipeline(&(sg_pipeline_desc){ + .shader = grid_shader, + .layout = { + .attrs = { + [0].format = SG_VERTEXFORMAT_FLOAT2 + } + }, + .primitive_type = SG_PRIMITIVETYPE_TRIANGLE_STRIP, +// .cull_mode = SG_CULLMODE_BACK, + .label = "grid pipeline", + .colors[0] = { + .blend = { + .enabled = true, + .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA, + .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + .op_rgb = SG_BLENDOP_ADD, + .src_factor_alpha = SG_BLENDFACTOR_SRC_ALPHA, + .dst_factor_alpha = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + .op_alpha = SG_BLENDOP_ADD + }, + }, + }); + + grid_bind.vertex_buffers[0] = circle_bind.vertex_buffers[1]; + + rect_shader = sg_make_shader(&(sg_shader_desc){ + .vs.source = slurp_text("shaders/linevert.glsl"), + .fs.source = slurp_text("shaders/linefrag.glsl"), + .vs.uniform_blocks[0] = projection_ubo + }); + + rect_pipe = sg_make_pipeline(&(sg_pipeline_desc){ + .shader = rect_shader, + .layout = { + .attrs = { [0].format = SG_VERTEXFORMAT_FLOAT2 } + }, + .primitive_type = SG_PRIMITIVETYPE_LINES + }); + + rect_bind.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ + .size = sizeof(float)*2*10000, + .usage = SG_USAGE_STREAM + }); } -void draw_line(int x1, int y1, int x2, int y2, float *color) +void draw_line(cpVect s, cpVect e, float *color) { - shader_use(rectShader); - float verts[] = { - x1, y1, - x2, y2 - }; - - draw_poly(verts, 2, color); + cpVect verts[2] = {s, e}; + draw_poly(verts, 2, color); } cpVect center_of_vects(cpVect *v, int n) @@ -153,8 +241,8 @@ void draw_edge(cpVect *points, int n, struct color color, int thickness) float col[3] = {(float)color.r/255, (float)color.g/255, (float)color.b/255}; - shader_use(rectShader); - shader_setvec3(rectShader, "linecolor", col); +// shader_use(rectShader); +// shader_setvec3(rectShader, "linecolor", col); /* if (thickness <= 1) { // glLineStipple(1, 0x00FF); @@ -204,29 +292,16 @@ void draw_edge(cpVect *points, int n, struct color color, int thickness) void draw_circle(int x, int y, float radius, int pixels, float *color, int fill) { -/* shader_use(circleShader); - - float verts[] = { - x - radius, y - radius, -1, -1, - x + radius, y - radius, 1, -1, - x - radius, y + radius, -1, 1, - x + radius, y + radius, 1, 1 - }; - - glBindBuffer(GL_ARRAY_BUFFER, circleVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_DYNAMIC_DRAW); - - shader_setfloat(circleShader, "radius", radius); - shader_setint(circleShader, "thickness", pixels); - shader_setvec3(circleShader, "dbgColor", color); - shader_setbool(circleShader, "fill", fill); - shader_setfloat(circleShader, "zoom", cam_zoom()); - - glBindVertexArray(circleVAO); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); -*/ + float cv[circle_vert_c] = {0}; + cv[0] = color[0]; + cv[1] = color[1]; + cv[2] = color[2]; + cv[3] = x; + cv[4] = y; + cv[5] = radius; + cv[6] = fill; + sg_append_buffer(circle_bind.vertex_buffers[0], SG_RANGE_REF(cv)); + circle_count++; } void draw_rect(int x, int y, int w, int h, float *color) @@ -234,13 +309,13 @@ void draw_rect(int x, int y, int w, int h, float *color) float hw = w / 2.f; float hh = h / 2.f; - float verts[] = { - x - hw, y - hh, - x + hw, y - hh, - x + hw, y + hh, - x - hw, y + hh + cpVect verts[4] = { + { .x = x-hw, .y = y-hh }, + { .x = x+hw, .y = y-hh }, + { .x = x+hw, .y = y+hh }, + { .x = x-hw, .y = y+hh } }; - + draw_poly(verts, 4, color); } @@ -253,27 +328,33 @@ void draw_box(struct cpVect c, struct cpVect wh, struct color color) void draw_arrow(struct cpVect start, struct cpVect end, struct color color, int capsize) { float col[3] = {(float)color.r/255, (float)color.g/255, (float)color.b/255}; - draw_line(start.x, start.y, end.x, end.y, col); + draw_line(start, end, col); draw_cppoint(end, capsize, color); } void draw_grid(int width, int span) { -/* shader_use(gridShader); - shader_setint(gridShader, "thickness", width); - shader_setint(gridShader, "span", span); - cpVect offset = cam_pos(); - offset = cpvmult(offset, 1/cam_zoom()); + offset = cpvmult(offset, 1/cam_zoom()); offset.x -= mainwin->width/2; offset.y -= mainwin->height/2; - shader_setvec2(gridShader, "offset", &offset); - - glBindVertexArray(gridVAO); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); -*/ + sg_apply_pipeline(grid_pipe); + sg_apply_bindings(&grid_bind); + + float col[3] = { 0.3, 0.5, 0.8}; + + float fubo[5]; + fubo[0] = width; + fubo[1] = span; + fubo[2] = col; + + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(projection)); + sg_apply_uniforms(SG_SHADERSTAGE_VS, 1, SG_RANGE_REF(offset)); + sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, SG_RANGE_REF(fubo)); + + sg_draw(0,4,1); } void draw_point(int x, int y, float r, float *color) @@ -293,8 +374,33 @@ void draw_points(struct cpVect *points, int n, float size, float *color) draw_point(points[i].x, points[i].y, size, color); } -void draw_poly(float *points, int n, float *color) +void draw_poly(cpVect *points, int n, float *color) { + if (n == 2) { + sg_range t; + t.ptr = points; + t.size = sizeof(cpVect)*2; + sg_append_buffer(rect_bind.vertex_buffers[0], &t); + rect_c += 1; + return; + } else if (n <= 1) return; + + + cpVect buffer[2*n]; + for (int i = 0; i < n; i++) { + buffer[i*2] = points[i]; + buffer[i*2+1] = points[i+1]; + } + + buffer[2*n-1] = points[0]; + + sg_range t; + t.ptr = buffer; + t.size = sizeof(cpVect)*2*n; + + sg_append_buffer(rect_bind.vertex_buffers[0], &t); + + rect_c += n; /* shader_use(rectShader); shader_setvec3(rectShader, "linecolor", color); glBindBuffer(GL_ARRAY_BUFFER, rectVBO); @@ -312,17 +418,6 @@ void draw_poly(float *points, int n, float *color) */ } -void draw_polyvec(cpVect *points, int n, float *color) -{ - float drawvec[n*2]; - for (int i = 0; i < n; i++) { - drawvec[i*2] = points[i].x; - drawvec[i*2+1] = points[i].y; - } - - draw_poly(drawvec, n, color); -} - void debugdraw_flush() { diff --git a/source/engine/debug/debugdraw.h b/source/engine/debug/debugdraw.h index a3e4377..5934ffa 100644 --- a/source/engine/debug/debugdraw.h +++ b/source/engine/debug/debugdraw.h @@ -5,7 +5,7 @@ struct color; void debugdraw_init(); -void draw_line(int x1, int y1, int x2, int y2, float *color); +void draw_line(cpVect s, cpVect e, float *color); void draw_edge(struct cpVect *points, int n, struct color color, int thickness); void draw_points(struct cpVect *points, int n, float size, float *color); void draw_arrow(struct cpVect start, struct cpVect end, struct color, int capsize); @@ -15,7 +15,7 @@ void draw_rect(int x, int y, int w, int h, float *color); void draw_box(struct cpVect c, struct cpVect wh, struct color color); void draw_point(int x, int y, float r, float *color); void draw_cppoint(struct cpVect point, float r, struct color color); -void draw_poly(float *points, int n, float *color); +void draw_poly(cpVect *points, int n, float *color); void debug_flush(); diff --git a/source/engine/editor/editor.h b/source/engine/editor/editor.h index b278dd8..6149995 100644 --- a/source/engine/editor/editor.h +++ b/source/engine/editor/editor.h @@ -5,7 +5,7 @@ #include #include "resources.h" -#include "nuklear.h" +#include "nuke.h" #define ASSET_TYPE_NULL 0 #define ASSET_TYPE_IMAGE 1 diff --git a/source/engine/engine.c b/source/engine/engine.c index 68b2f37..2053e97 100644 --- a/source/engine/engine.c +++ b/source/engine/engine.c @@ -16,54 +16,51 @@ #define PL_MPEG_IMPLEMENTATION #include - #ifdef EDITOR #include "editor.h" #endif #include "render.h" -#include "openglrender.h" -#include "window.h" -#include "camera.h" -#include "input.h" -#include "sprite.h" #include "2dphysics.h" +#include "camera.h" #include "gameobject.h" +#include "input.h" #include "log.h" +#include "openglrender.h" #include "resources.h" -#include "timer.h" #include "script.h" +#include "sprite.h" +#include "timer.h" +#include "window.h" #include "sound.h" #include "engine.h" -void error_callback(int error, const char *description) -{ - fprintf(stderr, "Error: %s\n", description); - YughError("GLFW Error: %s", description); +void error_callback(int error, const char *description) { + fprintf(stderr, "Error: %s\n", description); + YughError("GLFW Error: %s", description); } -void engine_init() -{ - glfwSetErrorCallback(error_callback); - /* Initialize GLFW */ - if (!glfwInit()) { - YughError("Could not init GLFW. Exiting."); - exit(1); - } else { - YughInfo("Initted GLFW."); - } +void engine_init() { + glfwSetErrorCallback(error_callback); + /* Initialize GLFW */ + if (!glfwInit()) { + YughError("Could not init GLFW. Exiting."); + exit(1); + } else { + YughInfo("Initted GLFW."); + } - resources_init(); - - YughInfo("Starting physics ..."); - phys2d_init(); - - YughInfo("Starting sound ..."); - sound_init(); + resources_init(); - YughInfo("Starting scripts ..."); - script_init(); + YughInfo("Starting physics ..."); + phys2d_init(); + + YughInfo("Starting sound ..."); + sound_init(); + + YughInfo("Starting scripts ..."); + script_init(); } diff --git a/source/engine/ffi.c b/source/engine/ffi.c index 6c4fe86..b0e49b4 100644 --- a/source/engine/ffi.c +++ b/source/engine/ffi.c @@ -2,169 +2,150 @@ #include "script.h" -#include "string.h" +#include "2dphysics.h" +#include "anim.h" #include "debug.h" -#include "window.h" +#include "debugdraw.h" #include "editor.h" #include "engine.h" -#include "log.h" -#include "input.h" -#include "gameobject.h" -#include "openglrender.h" -#include "2dphysics.h" -#include "sprite.h" -#include "anim.h" -#include "yugine.h" -#include "nuke.h" -#include "sound.h" #include "font.h" -#include "sound.h" -#include "music.h" +#include "gameobject.h" +#include "input.h" #include "level.h" -#include "tinyspline.h" +#include "log.h" #include "mix.h" -#include "debugdraw.h" +#include "music.h" +#include "nuke.h" +#include "openglrender.h" +#include "sound.h" +#include "sprite.h" #include "stb_ds.h" -#include +#include "string.h" +#include "tinyspline.h" +#include "window.h" +#include "yugine.h" #include +#include + +#include "model.h" #include "miniaudio.h" #define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" -#define BYTE_TO_BINARY(byte) \ - (byte & 0x80 ? '1' : '0'), \ - (byte & 0x40 ? '1' : '0'), \ - (byte & 0x20 ? '1' : '0'), \ - (byte & 0x10 ? '1' : '0'), \ - (byte & 0x08 ? '1' : '0'), \ - (byte & 0x04 ? '1' : '0'), \ - (byte & 0x02 ? '1' : '0'), \ - (byte & 0x01 ? '1' : '0') +#define BYTE_TO_BINARY(byte) \ + (byte & 0x80 ? '1' : '0'), \ + (byte & 0x40 ? '1' : '0'), \ + (byte & 0x20 ? '1' : '0'), \ + (byte & 0x10 ? '1' : '0'), \ + (byte & 0x08 ? '1' : '0'), \ + (byte & 0x04 ? '1' : '0'), \ + (byte & 0x02 ? '1' : '0'), \ + (byte & 0x01 ? '1' : '0') -int js2int(JSValue v) -{ +int js2int(JSValue v) { int32_t i; - JS_ToInt32(js,&i,v); + JS_ToInt32(js, &i, v); return i; } -JSValue int2js(int i) -{ +JSValue int2js(int i) { return JS_NewInt64(js, i); } -JSValue str2js(const char *c) -{ +JSValue str2js(const char *c) { return JS_NewString(js, c); } -double js2number(JSValue v) -{ +double js2number(JSValue v) { double g; - JS_ToFloat64(js,&g, v); + JS_ToFloat64(js, &g, v); return g; } -int js2bool(JSValue v) -{ - return JS_ToBool(js,v); +int js2bool(JSValue v) { + return JS_ToBool(js, v); } -JSValue float2js(double g) -{ - return JS_NewFloat64(js,g); +JSValue float2js(double g) { + return JS_NewFloat64(js, g); } -JSValue num2js(double g) -{ +JSValue num2js(double g) { return float2js(g); } -struct gameobject *js2go(JSValue v) -{ +struct gameobject *js2go(JSValue v) { return id2go(js2int(v)); } -void *js2ptr(JSValue v) -{ +void *js2ptr(JSValue v) { void *p; JS_ToInt64(js, &p, v); return p; } -JSValue ptr2js(void *ptr) -{ - return JS_NewInt64(js,(long)ptr); +JSValue ptr2js(void *ptr) { + return JS_NewInt64(js, (long)ptr); } -struct timer *js2timer(JSValue v) -{ +struct timer *js2timer(JSValue v) { return id2timer(js2int(v)); } - -double js_get_prop_number(JSValue v, const char *p) -{ +double js_get_prop_number(JSValue v, const char *p) { double num; JS_ToFloat64(js, &num, JS_GetPropertyStr(js, v, p)); return num; } -struct glrect js2glrect(JSValue v) -{ +struct glrect js2glrect(JSValue v) { struct glrect rect; - rect.s0 = js_get_prop_number(v,"s0"); - rect.s1 = js_get_prop_number(v,"s1"); - rect.t0 = js_get_prop_number(v,"t0"); - rect.t1 = js_get_prop_number(v,"t1"); + rect.s0 = js_get_prop_number(v, "s0"); + rect.s1 = js_get_prop_number(v, "s1"); + rect.t0 = js_get_prop_number(v, "t0"); + rect.t1 = js_get_prop_number(v, "t1"); return rect; } -JSValue js_arridx(JSValue v, int idx) -{ - return JS_GetPropertyUint32(js,v,idx); +JSValue js_arridx(JSValue v, int idx) { + return JS_GetPropertyUint32(js, v, idx); } -int js_arrlen(JSValue v) -{ +int js_arrlen(JSValue v) { int len; JS_ToInt32(js, &len, JS_GetPropertyStr(js, v, "length")); return len; } -struct color js2color(JSValue v) -{ - struct color color = {0,0,0}; - color.r = js2int(js_arridx(v,0)); - color.g = js2int(js_arridx(v,1)); - color.b = js2int(js_arridx(v,2)); - return color; +struct color js2color(JSValue v) { + struct color color = {0, 0, 0}; + color.r = js2int(js_arridx(v, 0)); + color.g = js2int(js_arridx(v, 1)); + color.b = js2int(js_arridx(v, 2)); + return color; } -cpVect js2vec2(JSValue v) -{ +cpVect js2vec2(JSValue v) { cpVect vect; - vect.x = js2number(js_arridx(v,0)); - vect.y = js2number(js_arridx(v,1)); + vect.x = js2number(js_arridx(v, 0)); + vect.y = js2number(js_arridx(v, 1)); return vect; } -cpBitmask js2bitmask(JSValue v) -{ - cpBitmask mask = 0; - int len = js_arrlen(v); +cpBitmask js2bitmask(JSValue v) { + cpBitmask mask = 0; + int len = js_arrlen(v); - for (int i = 0; i < len; i++) { - int val = JS_ToBool(js, JS_GetPropertyUint32(js, v, i)); - if (!val) continue; + for (int i = 0; i < len; i++) { + int val = JS_ToBool(js, JS_GetPropertyUint32(js, v, i)); + if (!val) continue; - mask |= 1<id); + return JS_NewInt64(js, win->id); } -JSValue duk_spline_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - static_assert(sizeof(tsReal)*2 == sizeof(cpVect)); - - tsBSpline spline; +JSValue duk_spline_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + static_assert(sizeof(tsReal) * 2 == sizeof(cpVect)); - int d = js2int(argv[2]); /* dimensions */ - int degrees = js2int(argv[1]); - int type = js2int(argv[3]); - JSValue ctrl_pts = argv[4]; - int n = js_arrlen(ctrl_pts); - size_t nsamples = js2int(argv[5]); + tsBSpline spline; - cpVect points[n]; + int d = js2int(argv[2]); /* dimensions */ + int degrees = js2int(argv[1]); + int type = js2int(argv[3]); + JSValue ctrl_pts = argv[4]; + int n = js_arrlen(ctrl_pts); + size_t nsamples = js2int(argv[5]); - tsStatus status; - ts_bspline_new(n, d, degrees, type, &spline, &status); + cpVect points[n]; - if (status.code) - YughCritical("Spline creation error %d: %s", status.code, status.message); - - for (int i = 0; i < n; i++) - points[i] = js2vec2(JS_GetPropertyUint32(js, ctrl_pts, i)); - - ts_bspline_set_control_points(&spline, (tsReal*)points, &status); + tsStatus status; + ts_bspline_new(n, d, degrees, type, &spline, &status); if (status.code) YughCritical("Spline creation error %d: %s", status.code, status.message); - + + for (int i = 0; i < n; i++) + points[i] = js2vec2(JS_GetPropertyUint32(js, ctrl_pts, i)); + + ts_bspline_set_control_points(&spline, (tsReal *)points, &status); + + if (status.code) + YughCritical("Spline creation error %d: %s", status.code, status.message); + cpVect samples[nsamples]; - + size_t rsamples; /* TODO: This does not work with Clang/GCC due to UB */ - ts_bspline_sample(&spline, nsamples, (tsReal**)&samples, &rsamples, &status); + ts_bspline_sample(&spline, nsamples, (tsReal **)&samples, &rsamples, &status); if (status.code) YughCritical("Spline creation error %d: %s", status.code, status.message); @@ -441,9 +409,7 @@ JSValue duk_spline_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst return arr; } - -JSValue ints2js(int *ints) -{ +JSValue ints2js(int *ints) { JSValue arr = JS_NewArray(js); for (int i = 0; i < arrlen(ints); i++) JS_SetPropertyUint32(js, arr, i, int2js(ints[i])); @@ -451,8 +417,7 @@ JSValue ints2js(int *ints) return arr; } -int vec_between(cpVect p, cpVect a, cpVect b) -{ +int vec_between(cpVect p, cpVect a, cpVect b) { cpVect n; n.x = b.x - a.x; n.y = b.y - a.y; @@ -465,41 +430,39 @@ int vec_between(cpVect p, cpVect a, cpVect b) 0 indicates 'p' comes before the first point. arrlen(segs) indicates it comes after the last point. */ -int point2segindex(cpVect p, cpVect *segs, double slop) -{ +int point2segindex(cpVect p, cpVect *segs, double slop) { float shortest = slop < 0 ? INFINITY : slop; int best = -1; - for (int i = 0; i < arrlen(segs)-1; i++) - { - float a = (segs[i+1].y - segs[i].y) / (segs[i+1].x - segs[i].x); + for (int i = 0; i < arrlen(segs) - 1; i++) { + float a = (segs[i + 1].y - segs[i].y) / (segs[i + 1].x - segs[i].x); float c = segs[i].y - (a * segs[i].x); float b = -1; - float dist = abs(a*p.x + b*p.y + c) / sqrt(pow(a,2) + 1); + float dist = abs(a * p.x + b * p.y + c) / sqrt(pow(a, 2) + 1); if (dist > shortest) continue; - int between = vec_between(p, segs[i], segs[i+1]); + int between = vec_between(p, segs[i], segs[i + 1]); if (between) { shortest = dist; - best = i+1; + best = i + 1; } else { if (i == 0 && cpvdist(p, segs[0]) < slop) { shortest = dist; - best = i; - } else if (i == arrlen(segs)-2 && cpvdist(p, arrlast(segs)) < slop) { + best = i; + } else if (i == arrlen(segs) - 2 && cpvdist(p, arrlast(segs)) < slop) { shortest = dist; - best = arrlen(segs); + best = arrlen(segs); } } } if (best == 1) { cpVect n; - n.x = segs[1].x-segs[0].x; - n.y = segs[1].y-segs[0].y; + n.x = segs[1].x - segs[0].x; + n.y = segs[1].y - segs[0].y; n = cpvnormalize(n); if (cpvdot(n, cpvsub(p, segs[0])) < 0) if (cpvdist(p, segs[0]) >= slop) @@ -508,10 +471,10 @@ int point2segindex(cpVect p, cpVect *segs, double slop) best = 0; } - if (best == arrlen(segs)-1) { + if (best == arrlen(segs) - 1) { cpVect n; - n.x = segs[best-1].x-segs[best].x; - n.y = segs[best-1].y-segs[best-1].y; + n.x = segs[best - 1].x - segs[best].x; + n.y = segs[best - 1].y - segs[best - 1].y; n = cpvnormalize(n); if (cpvdot(n, cpvsub(p, segs[best])) < 0) @@ -520,13 +483,11 @@ int point2segindex(cpVect p, cpVect *segs, double slop) else best = arrlen(segs); } - return best; } -int file_exists(char *path) -{ +int file_exists(char *path) { FILE *o = fopen(path, "r"); if (o) { fclose(o); @@ -540,19 +501,17 @@ static char *dukext; static JSValue dukarr; static int dukidx; -static int duk2path(const char *path, const struct stat *sb, int typeflag) -{ +static int duk2path(const char *path, const struct stat *sb, int typeflag) { if (typeflag == FTW_F) { char *ext = strrchr(path, '.'); if (ext && !strcmp(ext, dukext)) JS_SetPropertyUint32(js, dukarr, dukidx++, JS_NewString(js, &path[2])); } - + return 0; } -JSValue dukext2paths(char *ext) -{ +JSValue dukext2paths(char *ext) { dukext = ext; dukarr = JS_NewArray(js); dukidx = 0; @@ -560,589 +519,599 @@ JSValue dukext2paths(char *ext) return dukarr; } -JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int cmd = js2int(argv[0]); const char *str = NULL; const char *str2 = NULL; JSValue ret = JS_NULL; - switch(cmd) { - case 0: - str = JS_ToCString(js,argv[1]); - ret = JS_NewInt64(js, script_dofile(str)); - break; + switch (cmd) { + case 0: + str = JS_ToCString(js, argv[1]); + ret = JS_NewInt64(js, script_dofile(str)); + break; + + case 1: + YughWarn("Do not set pawns here anymore; Do it entirely in script."); + // set_pawn(js2ptrduk_get_heapptr(duk, 1)); + break; + + case 2: + gameobject_delete(js2int(argv[1])); + break; + + case 3: + set_timescale(js2number(argv[1])); + break; + + case 4: + debug_draw_phys(JS_ToBool(js, argv[1])); + break; + + case 5: + renderMS = js2number(argv[1]); + break; + + case 6: + updateMS = js2number(argv[1]); + break; + + case 7: + physMS = js2number(argv[1]); + break; + + case 8: + phys2d_set_gravity(js2vec2(argv[1])); + break; + + case 9: + sprite_delete(js2int(argv[1])); + break; + + case 10: + YughWarn("Pawns are handled in script only now."); + break; + + case 11: + str = JS_ToCString(js, argv[1]); + ret = JS_NewInt64(js, file_mod_secs(str)); + break; + + case 12: + str = JS_ToCString(js, argv[2]); + sprite_loadtex(id2sprite(js2int(argv[1])), str, js2glrect(argv[3])); + break; + + case 13: + str = JS_ToCString(js, argv[1]); + str2 = JS_ToCString(js, argv[2]); + play_song(str, str2); + break; + + case 14: + str = JS_ToCString(js, argv[1]); + mini_sound(str); + break; + + case 15: + music_stop(); + break; + + case 16: + color2float(js2color(argv[1]), dbg_color); + break; + + case 17: + color2float(js2color(argv[1]), trigger_color); + break; + + case 18: + shape_set_sensor(js2ptr(argv[1]), JS_ToBool(js, argv[2])); + break; + + case 19: + mini_master(js2number(argv[1])); + break; + + case 20: + sprite_enabled(js2int(argv[1]), JS_ToBool(js, argv[2])); + break; + + case 21: + return JS_NewBool(js, shape_get_sensor(js2ptr(argv[1]))); + + case 22: + shape_enabled(js2ptr(argv[1]), JS_ToBool(js, argv[2])); + break; + + case 23: + return JS_NewBool(js, shape_is_enabled(js2ptr(argv[1]))); + + case 24: + timer_pause(js2timer(argv[1])); + break; - case 1: - YughWarn("Do not set pawns here anymore; Do it entirely in script."); - //set_pawn(js2ptrduk_get_heapptr(duk, 1)); - break; + case 25: + timer_stop(js2timer(argv[1])); + break; - case 2: - gameobject_delete(js2int(argv[1])); - break; + case 26: + timer_start(js2timer(argv[1])); + break; - case 3: - set_timescale(js2number(argv[1])); - break; + case 27: + timer_remove(js2int(argv[1])); + break; - case 4: - debug_draw_phys(JS_ToBool(js, argv[1])); - break; + case 28: + timerr_settime(js2timer(argv[1]), js2number(argv[2])); + break; - case 5: - renderMS = js2number(argv[1]); - break; - - case 6: - updateMS = js2number(argv[1]); - break; - - case 7: - physMS = js2number(argv[1]); - break; - - case 8: - phys2d_set_gravity(js2vec2(argv[1])); - break; - - case 9: - sprite_delete(js2int(argv[1])); - break; - - case 10: - YughWarn("Pawns are handled in script only now."); - break; - - case 11: - str = JS_ToCString(js, argv[1]); - ret = JS_NewInt64(js, file_mod_secs(str)); - break; - - case 12: - str = JS_ToCString(js,argv[2]); - sprite_loadtex(id2sprite(js2int(argv[1])), str, js2glrect(argv[3])); - break; - - case 13: - str = JS_ToCString(js,argv[1]); - str2 = JS_ToCString(js,argv[2]); - play_song(str,str2); - break; - - case 14: - str = JS_ToCString(js, argv[1]); - mini_sound(str); - break; - - case 15: - music_stop(); - break; - - case 16: - color2float(js2color(argv[1]), dbg_color); - break; - - case 17: - color2float(js2color(argv[1]), trigger_color); - break; - - case 18: - shape_set_sensor(js2ptr(argv[1]), JS_ToBool(js, argv[2])); - break; - - case 19: - mini_master(js2number(argv[1])); - break; - - case 20: - sprite_enabled(js2int(argv[1]), JS_ToBool(js, argv[2])); - break; - - case 21: - return JS_NewBool(js, shape_get_sensor(js2ptr(argv[1]))); - - case 22: - shape_enabled(js2ptr(argv[1]), JS_ToBool(js, argv[2])); - break; - - case 23: - return JS_NewBool(js, shape_is_enabled(js2ptr(argv[1]))); - - case 24: - timer_pause(js2timer(argv[1])); - break; - - case 25: - timer_stop(js2timer(argv[1])); - break; - - case 26: - timer_start(js2timer(argv[1])); - break; - - case 27: - timer_remove(js2int(argv[1])); - break; - - case 28: - timerr_settime(js2timer(argv[1]), js2number(argv[2])); - break; - - case 29: - return JS_NewFloat64(js, js2timer(argv[1])->interval); - - case 30: - sprite_setanim(id2sprite(js2int(argv[1])), js2ptr(argv[2]), js2int(argv[3])); - return JS_NULL; - - case 31: - free(js2ptr(argv[1])); - break; - - case 32: - return JS_NewFloat64(js, js2timer(argv[1])->remain_time); - - case 33: - return JS_NewBool(js, js2timer(argv[1])->on); - - case 34: - return JS_NewBool(js, js2timer(argv[1])->repeat); - - case 35: - js2timer(argv[1])->repeat = JS_ToBool(js, argv[2]); - return JS_NULL; - - case 36: - id2go(js2int(argv[1]))->scale = js2number(argv[2]); - cpSpaceReindexShapesForBody(space, id2go(js2int(argv[1]))->body); - return JS_NULL; - - case 37: - if (!id2sprite(js2int(argv[1]))) return JS_NULL; - vec2float(js2vec2(argv[2]), id2sprite(js2int(argv[1]))->pos); - break; - - case 38: - str = JS_ToCString(js,argv[1]); - ret = JS_NewString(js, slurp_text(str)); - break; - - case 39: - str = JS_ToCString(js,argv[1]); - str2 = JS_ToCString(js,argv[2]); - ret = JS_NewInt64(js, slurp_write(str, str2)); - break; - - case 40: - id2go(js2int(argv[1]))->filter.categories = js2bitmask(argv[2]); - gameobject_apply(id2go(js2int(argv[1]))); - break; - - case 41: - id2go(js2int(argv[1]))->filter.mask = js2bitmask(argv[2]); - gameobject_apply(id2go(js2int(argv[1]))); - break; - - case 42: - return bitmask2js(id2go(js2int(argv[1]))->filter.categories); - - case 43: - return bitmask2js(id2go(js2int(argv[1]))->filter.mask); - - case 44: - return JS_NewInt64(js, pos2gameobject(js2vec2(argv[1]))); - - case 45: - return vec2js(mouse_pos); - - case 46: - set_mouse_mode(js2int(argv[1])); - return JS_NULL; - - case 47: - draw_grid(js2int(argv[1]), js2int(argv[2])); - return JS_NULL; - - case 48: - return JS_NewInt64(js, mainwin->width); - - case 49: - return JS_NewInt64(js, mainwin->height); - - case 50: - return JS_NewBool(js, action_down(js2int(argv[1]))); - - case 51: - draw_cppoint(js2vec2(argv[1]), js2number(argv[2]), js2color(argv[3])); - return JS_NULL; - - case 52: - return ints2js(phys2d_query_box(js2vec2(argv[1]), js2vec2(argv[2]))); - - case 53: - draw_box(js2vec2(argv[1]), js2vec2(argv[2]), js2color(argv[3])); - return JS_NULL; - - case 54: - gameobject_apply(js2go(argv[1])); - return JS_NULL; - - case 55: - js2go(argv[1])->flipx = JS_ToBool(js, argv[2]) ? -1 : 1; - return JS_NULL; - - case 56: - js2go(argv[1])->flipy = JS_ToBool(js, argv[2]) ? -1 : 1; - return JS_NULL; - - case 57: - return JS_NewBool(js, js2go(argv[1])->flipx == -1 ? 1 : 0); - - case 58: - return JS_NewBool(js, js2go(argv[1])->flipy == -1 ? 1 : 0); - - case 59: - return JS_NewInt64(js, point2segindex(js2vec2(argv[1]), js2cpvec2arr(argv[2]), js2number(argv[3]))); - - case 60: - if (!id2sprite(js2int(argv[1]))) return JS_NULL; - id2sprite(js2int(argv[1]))->layer = js2int(argv[2]); - break; - - case 61: - set_cam_body(id2body(js2int(argv[1]))); - break; - - case 62: - add_zoom(js2number(argv[1])); - break; - - case 63: - return JS_NewFloat64(js, deltaT); - - case 64: - str = JS_ToCString(js,argv[1]); - ret = vec2js(tex_get_dimensions(texture_pullfromfile(str))); - break; - - case 65: - str = JS_ToCString(js,argv[1]); - ret = JS_NewBool(js, file_exists(str)); - break; - - case 66: - str = JS_ToCString(js,argv[1]); - ret = dukext2paths(str); - break; - - case 67: - opengl_rendermode(LIT); - break; - - case 68: - opengl_rendermode(WIREFRAME); - break; - - case 69: - gameobject_set_sensor(js2int(argv[1]), JS_ToBool(js, argv[2])); - break; - - case 70: - return vec2js(world2go(js2go(argv[1]), js2vec2(argv[2]))); - - case 71: - return vec2js(go2world(js2go(argv[1]), js2vec2(argv[2]))); - - case 72: - return vec2js(cpSpaceGetGravity(space)); - - case 73: - cpSpaceSetDamping(space, js2number(argv[1])); - return JS_NULL; - - case 74: - return JS_NewFloat64(js, cpSpaceGetDamping(space)); - - case 75: - js2go(argv[1])->layer = js2int(argv[2]); - return JS_NULL; - - case 76: - set_cat_mask(js2int(argv[1]), js2bitmask(argv[2])); - return JS_NULL; - - case 77: - input_to_game(); - break; - - case 78: - input_to_nuke(); - break; - - case 79: - return JS_NewBool(js, phys_stepping()); - - case 80: - return ints2js(phys2d_query_shape(js2ptr(argv[1]))); - - case 81: - draw_arrow(js2vec2(argv[1]), js2vec2(argv[2]), js2color(argv[3]), js2int(argv[4])); - return JS_NULL; - - case 82: - gameobject_draw_debug(js2int(argv[1])); - return JS_NULL; - - case 83: - draw_edge(js2cpvec2arr(argv[1]), 2, js2color(argv[2]), 1); - return JS_NULL; - - case 84: - return JS_NewString(js, consolelog); - - case 85: - return vec2js(cpvproject(js2vec2(argv[1]), js2vec2(argv[2]))); - - case 86: - return ints2js(phys2d_query_box_points(js2vec2(argv[1]), js2vec2(argv[2]), js2cpvec2arr(argv[3]), js2int(argv[4]))); - - case 87: - str = JS_ToCString(js, argv[1]); - mini_music_play(str); - break; - - case 88: - mini_music_pause(); - return JS_NULL; - - case 89: - mini_music_stop(); - return JS_NULL; - - case 90: - str = JS_ToCString(js, argv[1]); - window_set_icon(str); - break; - - case 91: - str = JS_ToCString(js,argv[1]); - log_print(str); - break; - - case 92: - logLevel = js2int(argv[1]); - break; - - case 93: - ret = int2js(logLevel); - break; - - case 94: - str = JS_ToCString(js,argv[1]); - texture_pullfromfile(str)->opts.mips = js2bool(argv[2]); - texture_sync(str); - break; - - case 95: - str = JS_ToCString(js,argv[1]); - texture_pullfromfile(str)->opts.sprite = js2bool(argv[2]); - texture_sync(str); - break; - - case 96: - color2float(js2color(argv[2]), id2sprite(js2int(argv[1]))->color); - break; - } - - if (str) - JS_FreeCString(js,str); - - if (str2) - JS_FreeCString(js,str2); - - if (!JS_IsNull(ret)) - return ret; + case 29: + return JS_NewFloat64(js, js2timer(argv[1])->interval); + case 30: + sprite_setanim(id2sprite(js2int(argv[1])), js2ptr(argv[2]), js2int(argv[3])); return JS_NULL; + + case 31: + free(js2ptr(argv[1])); + break; + + case 32: + return JS_NewFloat64(js, js2timer(argv[1])->remain_time); + + case 33: + return JS_NewBool(js, js2timer(argv[1])->on); + + case 34: + return JS_NewBool(js, js2timer(argv[1])->repeat); + + case 35: + js2timer(argv[1])->repeat = JS_ToBool(js, argv[2]); + return JS_NULL; + + case 36: + id2go(js2int(argv[1]))->scale = js2number(argv[2]); + cpSpaceReindexShapesForBody(space, id2go(js2int(argv[1]))->body); + return JS_NULL; + + case 37: + if (!id2sprite(js2int(argv[1]))) return JS_NULL; + vec2float(js2vec2(argv[2]), id2sprite(js2int(argv[1]))->pos); + break; + + case 38: + str = JS_ToCString(js, argv[1]); + ret = JS_NewString(js, slurp_text(str)); + break; + + case 39: + str = JS_ToCString(js, argv[1]); + str2 = JS_ToCString(js, argv[2]); + ret = JS_NewInt64(js, slurp_write(str, str2)); + break; + + case 40: + id2go(js2int(argv[1]))->filter.categories = js2bitmask(argv[2]); + gameobject_apply(id2go(js2int(argv[1]))); + break; + + case 41: + id2go(js2int(argv[1]))->filter.mask = js2bitmask(argv[2]); + gameobject_apply(id2go(js2int(argv[1]))); + break; + + case 42: + return bitmask2js(id2go(js2int(argv[1]))->filter.categories); + + case 43: + return bitmask2js(id2go(js2int(argv[1]))->filter.mask); + + case 44: + return JS_NewInt64(js, pos2gameobject(js2vec2(argv[1]))); + + case 45: + return vec2js(mouse_pos); + + case 46: + set_mouse_mode(js2int(argv[1])); + return JS_NULL; + + case 47: + draw_grid(js2int(argv[1]), js2int(argv[2])); + return JS_NULL; + + case 48: + return JS_NewInt64(js, mainwin->width); + + case 49: + return JS_NewInt64(js, mainwin->height); + + case 50: + return JS_NewBool(js, action_down(js2int(argv[1]))); + + case 51: + draw_cppoint(js2vec2(argv[1]), js2number(argv[2]), js2color(argv[3])); + return JS_NULL; + + case 52: + return ints2js(phys2d_query_box(js2vec2(argv[1]), js2vec2(argv[2]))); + + case 53: + draw_box(js2vec2(argv[1]), js2vec2(argv[2]), js2color(argv[3])); + return JS_NULL; + + case 54: + gameobject_apply(js2go(argv[1])); + return JS_NULL; + + case 55: + js2go(argv[1])->flipx = JS_ToBool(js, argv[2]) ? -1 : 1; + return JS_NULL; + + case 56: + js2go(argv[1])->flipy = JS_ToBool(js, argv[2]) ? -1 : 1; + return JS_NULL; + + case 57: + return JS_NewBool(js, js2go(argv[1])->flipx == -1 ? 1 : 0); + + case 58: + return JS_NewBool(js, js2go(argv[1])->flipy == -1 ? 1 : 0); + + case 59: + return JS_NewInt64(js, point2segindex(js2vec2(argv[1]), js2cpvec2arr(argv[2]), js2number(argv[3]))); + + case 60: + if (!id2sprite(js2int(argv[1]))) return JS_NULL; + id2sprite(js2int(argv[1]))->layer = js2int(argv[2]); + break; + + case 61: + set_cam_body(id2body(js2int(argv[1]))); + break; + + case 62: + add_zoom(js2number(argv[1])); + break; + + case 63: + return JS_NewFloat64(js, deltaT); + + case 64: + str = JS_ToCString(js, argv[1]); + ret = vec2js(tex_get_dimensions(texture_pullfromfile(str))); + break; + + case 65: + str = JS_ToCString(js, argv[1]); + ret = JS_NewBool(js, file_exists(str)); + break; + + case 66: + str = JS_ToCString(js, argv[1]); + ret = dukext2paths(str); + break; + + case 67: + opengl_rendermode(LIT); + break; + + case 68: + opengl_rendermode(WIREFRAME); + break; + + case 69: + gameobject_set_sensor(js2int(argv[1]), JS_ToBool(js, argv[2])); + break; + + case 70: + return vec2js(world2go(js2go(argv[1]), js2vec2(argv[2]))); + + case 71: + return vec2js(go2world(js2go(argv[1]), js2vec2(argv[2]))); + + case 72: + return vec2js(cpSpaceGetGravity(space)); + + case 73: + cpSpaceSetDamping(space, js2number(argv[1])); + return JS_NULL; + + case 74: + return JS_NewFloat64(js, cpSpaceGetDamping(space)); + + case 75: + js2go(argv[1])->layer = js2int(argv[2]); + return JS_NULL; + + case 76: + set_cat_mask(js2int(argv[1]), js2bitmask(argv[2])); + return JS_NULL; + + case 77: + input_to_game(); + break; + + case 78: + input_to_nuke(); + break; + + case 79: + return JS_NewBool(js, phys_stepping()); + + case 80: + return ints2js(phys2d_query_shape(js2ptr(argv[1]))); + + case 81: + draw_arrow(js2vec2(argv[1]), js2vec2(argv[2]), js2color(argv[3]), js2int(argv[4])); + return JS_NULL; + + case 82: + gameobject_draw_debug(js2int(argv[1])); + return JS_NULL; + + case 83: + draw_edge(js2cpvec2arr(argv[1]), 2, js2color(argv[2]), 1); + return JS_NULL; + + case 84: + return JS_NewString(js, consolelog); + + case 85: + return vec2js(cpvproject(js2vec2(argv[1]), js2vec2(argv[2]))); + + case 86: + return ints2js(phys2d_query_box_points(js2vec2(argv[1]), js2vec2(argv[2]), js2cpvec2arr(argv[3]), js2int(argv[4]))); + + case 87: + str = JS_ToCString(js, argv[1]); + mini_music_play(str); + break; + + case 88: + mini_music_pause(); + return JS_NULL; + + case 89: + mini_music_stop(); + return JS_NULL; + + case 90: + str = JS_ToCString(js, argv[1]); + window_set_icon(str); + break; + + case 91: + str = JS_ToCString(js, argv[1]); + log_print(str); + break; + + case 92: + logLevel = js2int(argv[1]); + break; + + case 93: + ret = int2js(logLevel); + break; + + case 94: + str = JS_ToCString(js, argv[1]); + texture_pullfromfile(str)->opts.mips = js2bool(argv[2]); + texture_sync(str); + break; + + case 95: + str = JS_ToCString(js, argv[1]); + texture_pullfromfile(str)->opts.sprite = js2bool(argv[2]); + texture_sync(str); + break; + + case 96: + color2float(js2color(argv[2]), id2sprite(js2int(argv[1]))->color); + break; + + case 97: + eye = HMM_AddV3(eye, (HMM_Vec3){0, 0.01, 0}); + break; + + case 98: + eye = HMM_AddV3(eye, (HMM_Vec3){0, -0.01, 0}); + break; + + case 99: + eye = HMM_AddV3(eye, (HMM_Vec3){-0.01, 0, 0}); + break; + + case 100: + eye = HMM_AddV3(eye, (HMM_Vec3){0.01, 0,0}); + break; + + case 101: + eye = HMM_AddV3(eye, (HMM_Vec3){0,0,-0.01}); + break; + + case 102: + eye = HMM_AddV3(eye,(HMM_Vec3){0,0,0.01}); + break; + } + + if (str) + JS_FreeCString(js, str); + + if (str2) + JS_FreeCString(js, str2); + + if (!JS_IsNull(ret)) + return ret; + + return JS_NULL; } -JSValue duk_register(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - int cmd = js2int(argv[0]); +JSValue duk_register(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + int cmd = js2int(argv[0]); - struct callee c; - c.fn = argv[1]; - c.obj = argv[2]; + struct callee c; + c.fn = argv[1]; + c.obj = argv[2]; - switch(cmd) { - case 0: - register_update(c); - break; + switch (cmd) { + case 0: + register_update(c); + break; - case 1: - register_physics(c); - break; + case 1: + register_physics(c); + break; - case 2: - register_gui(c); - break; + case 2: + register_gui(c); + break; - case 3: - register_nk_gui(c); - break; - - case 4: -// unregister_obj(obj); - break; + case 3: + register_nk_gui(c); + break; - case 5: -// unregister_gui(c); - break; + case 4: + // unregister_obj(obj); + break; - case 6: - register_debug(c); - break; - case 7: - register_pawn(c); - break; + case 5: + // unregister_gui(c); + break; - case 8: - register_gamepad(c); - break; + case 6: + register_debug(c); + break; + case 7: + register_pawn(c); + break; - case 9: - stacktrace_callee = c; - break; - } + case 8: + register_gamepad(c); + break; - return JS_NULL; + case 9: + stacktrace_callee = c; + break; + } + return JS_NULL; } -void gameobject_add_shape_collider(int go, struct callee c, struct phys2d_shape *shape) -{ +void gameobject_add_shape_collider(int go, struct callee c, struct phys2d_shape *shape) { struct shape_cb shapecb; shapecb.shape = shape; shapecb.cbs.begin = c; arrpush(id2go(go)->shape_cbs, shapecb); } -JSValue duk_register_collide(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - int cmd = js2int(argv[0]); - int go = js2int(argv[3]); - struct callee c; - c.fn = argv[1]; - c.obj = argv[2]; +JSValue duk_register_collide(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + int cmd = js2int(argv[0]); + int go = js2int(argv[3]); + struct callee c; + c.fn = argv[1]; + c.obj = argv[2]; - switch(cmd) { - case 0: - id2go(go)->cbs.begin = c; - break; + switch (cmd) { + case 0: + id2go(go)->cbs.begin = c; + break; - case 1: - gameobject_add_shape_collider(go, c, js2ptr(argv[4])); - break; + case 1: + gameobject_add_shape_collider(go, c, js2ptr(argv[4])); + break; - case 2: - phys2d_rm_go_handlers(go); - break; + case 2: + phys2d_rm_go_handlers(go); + break; - case 3: - id2go(go)->cbs.separate = c; - break; - } + case 3: + id2go(go)->cbs.separate = c; + break; + } - return JS_NULL; + return JS_NULL; } -JSValue duk_sys_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - int cmd = js2int(argv[0]); +JSValue duk_sys_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + int cmd = js2int(argv[0]); - switch (cmd) { - case 0: - quit(); - break; + switch (cmd) { + case 0: + quit(); + break; - case 1: - sim_start(); - cpSpaceReindexStatic(space); - break; + case 1: + sim_start(); + cpSpaceReindexStatic(space); + break; - case 2: - sim_stop(); - break; + case 2: + sim_stop(); + break; - case 3: - sim_pause(); - break; + case 3: + sim_pause(); + break; - case 4: - sim_step(); - break; + case 4: + sim_step(); + break; - case 5: - return JS_NewBool(js, sim_playing()); - + case 5: + return JS_NewBool(js, sim_playing()); - case 6: - return JS_NewBool(js, sim_paused()); - + case 6: + return JS_NewBool(js, sim_paused()); - case 7: - return JS_NewInt64(js, MakeGameobject()); - + case 7: + return JS_NewInt64(js, MakeGameobject()); - case 8: - return JS_NewInt64(js, frame_fps()); - + case 8: + return JS_NewInt64(js, frame_fps()); - case 9: /* Clear the level out */ - new_level(); - break; + case 9: /* Clear the level out */ + new_level(); + break; + } - } - - return JS_NULL; + return JS_NULL; } -JSValue duk_make_gameobject(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - int g = MakeGameobject(); - struct gameobject *go = get_gameobject_from_id(g); +JSValue duk_make_gameobject(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + int g = MakeGameobject(); + struct gameobject *go = get_gameobject_from_id(g); - go->scale = js2number(argv[0]); - go->bodytype = js2int(argv[1]); - go->mass = js2number(argv[2]); - go->f = js2number(argv[3]); - go->e = js2number(argv[4]); - go->flipx = 1.f; - go->flipy = 1.f; + go->scale = js2number(argv[0]); + go->bodytype = js2int(argv[1]); + go->mass = js2number(argv[2]); + go->f = js2number(argv[3]); + go->e = js2number(argv[4]); + go->flipx = 1.f; + go->flipy = 1.f; - gameobject_apply(go); + gameobject_apply(go); - return JS_NewInt64(js,g); + return JS_NewInt64(js, g); } -JSValue duk_yughlog(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - int cmd = js2int(argv[0]); - const char *s = JS_ToCString(js, argv[1]); - const char *f = JS_ToCString(js, argv[2]); - int line = js2int(argv[3]); +JSValue duk_yughlog(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + int cmd = js2int(argv[0]); + const char *s = JS_ToCString(js, argv[1]); + const char *f = JS_ToCString(js, argv[2]); + int line = js2int(argv[3]); - mYughLog(1, cmd, line, f, s); + mYughLog(1, cmd, line, f, s); - JS_FreeCString(js,s); - JS_FreeCString(js,f); + JS_FreeCString(js, s); + JS_FreeCString(js, f); - return JS_NULL; + return JS_NULL; } -JSValue duk_set_body(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_set_body(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int cmd = js2int(argv[0]); int id = js2int(argv[1]); struct gameobject *go = get_gameobject_from_id(id); @@ -1150,57 +1119,57 @@ JSValue duk_set_body(JSContext *js, JSValueConst this, int argc, JSValueConst *a /* TODO: Possible that reindexing shapes only needs done for static shapes? */ switch (cmd) { - case 0: - gameobject_setangle(go, js2number(argv[2])); - break; + case 0: + gameobject_setangle(go, js2number(argv[2])); + break; - case 1: - go->bodytype = js2int(argv[2]); - break; + case 1: + go->bodytype = js2int(argv[2]); + break; - case 2: - cpBodySetPosition(go->body, js2vec2(argv[2])); - break; + case 2: + cpBodySetPosition(go->body, js2vec2(argv[2])); + break; - case 3: - gameobject_move(go, js2vec2(argv[2])); - break; + case 3: + gameobject_move(go, js2vec2(argv[2])); + break; - case 4: - cpBodyApplyImpulseAtWorldPoint(go->body, js2vec2(argv[2]), cpBodyGetPosition(go->body)); - return JS_NULL; + case 4: + cpBodyApplyImpulseAtWorldPoint(go->body, js2vec2(argv[2]), cpBodyGetPosition(go->body)); + return JS_NULL; - case 5: - go->flipx = JS_ToBool(js, argv[2]); - break; + case 5: + go->flipx = JS_ToBool(js, argv[2]); + break; - case 6: - go->flipy = JS_ToBool(js, argv[2]); - break; + case 6: + go->flipy = JS_ToBool(js, argv[2]); + break; - case 7: - cpBodySetMass(go->body, js2number(argv[2])); - break; + case 7: + cpBodySetMass(go->body, js2number(argv[2])); + break; - case 8: - cpBodySetAngularVelocity(go->body, js2number(argv[2])); - return JS_NULL; + case 8: + cpBodySetAngularVelocity(go->body, js2number(argv[2])); + return JS_NULL; - case 9: - cpBodySetVelocity(go->body, js2vec2(argv[2])); - return JS_NULL; + case 9: + cpBodySetVelocity(go->body, js2vec2(argv[2])); + return JS_NULL; - case 10: - go->e = fmax(js2number(argv[2]),0); - break; + case 10: + go->e = fmax(js2number(argv[2]), 0); + break; - case 11: - go->f = fmax(js2number(argv[2]),0); - break; + case 11: + go->f = fmax(js2number(argv[2]), 0); + break; - case 12: - cpBodyApplyForceAtWorldPoint(go->body, js2vec2(argv[2]), cpBodyGetPosition(go->body)); - return JS_NULL; + case 12: + cpBodyApplyForceAtWorldPoint(go->body, js2vec2(argv[2]), cpBodyGetPosition(go->body)); + return JS_NULL; } cpSpaceReindexShapesForBody(space, go->body); @@ -1208,45 +1177,42 @@ JSValue duk_set_body(JSContext *js, JSValueConst this, int argc, JSValueConst *a return JS_NULL; } -JSValue duk_q_body(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - int q = js2int(argv[0]); - struct gameobject *go = get_gameobject_from_id(js2int(argv[1])); +JSValue duk_q_body(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + int q = js2int(argv[0]); + struct gameobject *go = get_gameobject_from_id(js2int(argv[1])); - if (!go) return JS_NULL; + if (!go) return JS_NULL; - switch(q) { - case 0: - return JS_NewInt64(js, cpBodyGetType(go->body)); + switch (q) { + case 0: + return JS_NewInt64(js, cpBodyGetType(go->body)); - case 1: - return vec2js(cpBodyGetPosition(go->body)); + case 1: + return vec2js(cpBodyGetPosition(go->body)); - case 2: - return JS_NewFloat64(js, cpBodyGetAngle(go->body)); - - case 3: - return vec2js(cpBodyGetVelocity(go->body)); + case 2: + return JS_NewFloat64(js, cpBodyGetAngle(go->body)); - case 4: - return JS_NewFloat64(js, cpBodyGetAngularVelocity(go->body)); + case 3: + return vec2js(cpBodyGetVelocity(go->body)); - case 5: - return JS_NewFloat64(js, cpBodyGetMass(go->body)); + case 4: + return JS_NewFloat64(js, cpBodyGetAngularVelocity(go->body)); - case 6: - return JS_NewFloat64(js, cpBodyGetMoment(go->body)); + case 5: + return JS_NewFloat64(js, cpBodyGetMass(go->body)); - case 7: - return JS_NewBool(js, phys2d_in_air(go->body)); - - } + case 6: + return JS_NewFloat64(js, cpBodyGetMoment(go->body)); - return JS_NULL; + case 7: + return JS_NewBool(js, phys2d_in_air(go->body)); + } + + return JS_NULL; } -JSValue duk_make_sprite(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_make_sprite(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int go = js2int(argv[0]); const char *path = JS_ToCString(js, argv[1]); cpVect pos = js2vec2(argv[2]); @@ -1256,27 +1222,25 @@ JSValue duk_make_sprite(JSContext *js, JSValueConst this, int argc, JSValueConst sp->pos[0] = pos.x; sp->pos[1] = pos.y; - JS_FreeCString(js,path); + JS_FreeCString(js, path); - return JS_NewInt64(js, sprite); + return JS_NewInt64(js, sprite); } /* Make anim from texture */ -JSValue duk_make_anim2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_make_anim2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { const char *path = JS_ToCString(js, argv[0]); int frames = js2int(argv[1]); int fps = js2int(argv[2]); struct TexAnim *anim = anim2d_from_tex(path, frames, fps); - JS_FreeCString(js,path); + JS_FreeCString(js, path); return ptr2js(anim); } -JSValue duk_make_box2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_make_box2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int go = js2int(argv[0]); cpVect size = js2vec2(argv[1]); cpVect offset = js2vec2(argv[2]); @@ -1295,38 +1259,36 @@ JSValue duk_make_box2d(JSContext *js, JSValueConst this, int argc, JSValueConst return boxval; } -JSValue duk_cmd_box2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - int cmd = js2int(argv[0]); - struct phys2d_box *box = js2ptr(argv[1]); - cpVect arg; +JSValue duk_cmd_box2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + int cmd = js2int(argv[0]); + struct phys2d_box *box = js2ptr(argv[1]); + cpVect arg; - if (!box) return JS_NULL; + if (!box) return JS_NULL; - switch(cmd) { - case 0: - arg = js2vec2(argv[2]); - box->w = arg.x; - box->h = arg.y; - break; + switch (cmd) { + case 0: + arg = js2vec2(argv[2]); + box->w = arg.x; + box->h = arg.y; + break; - case 1: - arg = js2vec2(argv[2]); - box->offset[0] = arg.x; - box->offset[1] = arg.y; - break; + case 1: + arg = js2vec2(argv[2]); + box->offset[0] = arg.x; + box->offset[1] = arg.y; + break; - case 2: - box->rotation = js2number(argv[2]); - break; - } + case 2: + box->rotation = js2number(argv[2]); + break; + } - phys2d_applybox(box); - return JS_NULL; + phys2d_applybox(box); + return JS_NULL; } -JSValue duk_make_circle2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_make_circle2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int go = js2int(argv[0]); double radius = js2number(argv[1]); @@ -1335,36 +1297,34 @@ JSValue duk_make_circle2d(JSContext *js, JSValueConst this, int argc, JSValueCon circle->offset = js2vec2(argv[2]); phys2d_applycircle(circle); - + JSValue circleval = JS_NewObject(js); JS_SetPropertyStr(js, circleval, "id", ptr2js(circle)); JS_SetPropertyStr(js, circleval, "shape", ptr2js(&circle->shape)); return circleval; } -JSValue duk_cmd_circle2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - int cmd = js2int(argv[0]); - struct phys2d_circle *circle = js2ptr(argv[1]); +JSValue duk_cmd_circle2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + int cmd = js2int(argv[0]); + struct phys2d_circle *circle = js2ptr(argv[1]); - if (!circle) return JS_NULL; + if (!circle) return JS_NULL; - switch(cmd) { - case 0: - circle->radius = js2number(argv[2]); - break; + switch (cmd) { + case 0: + circle->radius = js2number(argv[2]); + break; - case 1: - circle->offset = js2vec2(argv[2]); - break; - } + case 1: + circle->offset = js2vec2(argv[2]); + break; + } - phys2d_applycircle(circle); - return JS_NULL; + phys2d_applycircle(circle); + return JS_NULL; } -JSValue duk_make_poly2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_make_poly2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int go = js2int(argv[0]); struct phys2d_poly *poly = Make2DPoly(go); phys2d_poly_setverts(poly, js2cpvec2arr(argv[1])); @@ -1375,24 +1335,22 @@ JSValue duk_make_poly2d(JSContext *js, JSValueConst this, int argc, JSValueConst return polyval; } -JSValue duk_cmd_poly2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_cmd_poly2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int cmd = js2int(argv[0]); struct phys2d_poly *poly = js2ptr(argv[1]); if (!poly) return JS_NULL; - - switch(cmd) { - case 0: - phys2d_poly_setverts(poly, js2cpvec2arr(argv[2])); - break; + + switch (cmd) { + case 0: + phys2d_poly_setverts(poly, js2cpvec2arr(argv[2])); + break; } - - return JS_NULL; + + return JS_NULL; } -JSValue duk_make_edge2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_make_edge2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int go = js2int(argv[0]); struct phys2d_edge *edge = Make2DEdge(go); @@ -1400,9 +1358,9 @@ JSValue duk_make_edge2d(JSContext *js, JSValueConst this, int argc, JSValueConst cpVect points[n]; for (int i = 0; i < n; i++) { - points[i] = js2vec2(JS_GetPropertyUint32(js, argv[1], i)); - phys2d_edgeaddvert(edge); - phys2d_edge_setvert(edge, i, points[i]); + points[i] = js2vec2(JS_GetPropertyUint32(js, argv[1], i)); + phys2d_edgeaddvert(edge); + phys2d_edge_setvert(edge, i, points[i]); } JSValue edgeval = JS_NewObject(js); @@ -1411,39 +1369,37 @@ JSValue duk_make_edge2d(JSContext *js, JSValueConst this, int argc, JSValueConst return edgeval; } -JSValue duk_cmd_edge2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_cmd_edge2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { int cmd = js2int(argv[0]); struct phys2d_edge *edge = js2ptr(argv[1]); if (!edge) return JS_NULL; - switch(cmd) { - case 0: - phys2d_edge_clearverts(edge); - phys2d_edge_addverts(edge, js2cpvec2arr(argv[2])); - break; - - case 1: - edge->thickness = js2number(argv[2]); - break; + switch (cmd) { + case 0: + phys2d_edge_clearverts(edge); + phys2d_edge_addverts(edge, js2cpvec2arr(argv[2])); + break; + + case 1: + edge->thickness = js2number(argv[2]); + break; } - + return JS_NULL; } -JSValue duk_inflate_cpv(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ +JSValue duk_inflate_cpv(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { cpVect *points = js2cpvec2arr(argv[0]); int n = js2int(argv[1]); double d = js2number(argv[2]); cpVect inflate_out[n]; cpVect inflate_in[n]; - + inflatepoints(inflate_out, points, d, n); inflatepoints(inflate_in, points, -d, n); - + JSValue arr = JS_NewArray(js); JS_SetPropertyUint32(js, arr, 0, vecarr2js(inflate_out, n)); JS_SetPropertyUint32(js, arr, 1, vecarr2js(inflate_in, n)); @@ -1451,79 +1407,76 @@ JSValue duk_inflate_cpv(JSContext *js, JSValueConst this, int argc, JSValueConst } /* These are anims for controlling properties on an object */ -JSValue duk_anim(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - JSValue prop = argv[0]; - int keyframes = js_arrlen(argv[1]); - YughInfo("Processing %d keyframes.", keyframes); +JSValue duk_anim(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + JSValue prop = argv[0]; + int keyframes = js_arrlen(argv[1]); + YughInfo("Processing %d keyframes.", keyframes); - struct anim a = make_anim(); + struct anim a = make_anim(); - for (int i = 0; i < keyframes; i++) { - struct keyframe k; - cpVect v = js2vec2(JS_GetPropertyUint32(js, argv[1], i)); - k.time = v.y; - k.val = v.x; - a = anim_add_keyframe(a, k); - } + for (int i = 0; i < keyframes; i++) { + struct keyframe k; + cpVect v = js2vec2(JS_GetPropertyUint32(js, argv[1], i)); + k.time = v.y; + k.val = v.x; + a = anim_add_keyframe(a, k); + } - for (double i = 0; i < 3.0; i = i + 0.1) { - YughInfo("Val is now %f at time %f", anim_val(a, i), i); - JSValue vv = num2js(anim_val(a,i)); - JS_Call(js, prop, JS_GetGlobalObject(js), 1, &vv); - } + for (double i = 0; i < 3.0; i = i + 0.1) { + YughInfo("Val is now %f at time %f", anim_val(a, i), i); + JSValue vv = num2js(anim_val(a, i)); + JS_Call(js, prop, JS_GetGlobalObject(js), 1, &vv); + } - return JS_NULL; + return JS_NULL; } -JSValue duk_make_timer(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) -{ - double secs = js2number(argv[1]); - struct callee *c = malloc(sizeof(*c)); - c->fn = JS_DupValue(js,argv[0]); - c->obj = JS_GetGlobalObject(js); - int id = timer_make(secs, call_callee, c, 1); +JSValue duk_make_timer(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) { + double secs = js2number(argv[1]); + struct callee *c = malloc(sizeof(*c)); + c->fn = JS_DupValue(js, argv[0]); + c->obj = JS_GetGlobalObject(js); + int id = timer_make(secs, call_callee, c, 1); - return JS_NewInt64(js, id); + return JS_NewInt64(js, id); } #define DUK_FUNC(NAME, ARGS) JS_SetPropertyStr(js, JS_GetGlobalObject(js), #NAME, JS_NewCFunction(js, duk_##NAME, #NAME, ARGS)); -void ffi_load() -{ - DUK_FUNC(yughlog, 4) - DUK_FUNC(nuke, 6) - DUK_FUNC(make_gameobject, 7) - DUK_FUNC(set_body, 3) - DUK_FUNC(q_body, 2) +void ffi_load() { + DUK_FUNC(yughlog, 4) + DUK_FUNC(nuke, 6) + DUK_FUNC(make_gameobject, 7) + DUK_FUNC(set_body, 3) + DUK_FUNC(q_body, 2) - DUK_FUNC(sys_cmd, 1) - DUK_FUNC(win_make, 3) + DUK_FUNC(sys_cmd, 1) + DUK_FUNC(win_make, 3) - DUK_FUNC(make_sprite, 3) - DUK_FUNC(make_anim2d, 3) - DUK_FUNC(spline_cmd, 6) - - DUK_FUNC(make_box2d, 3) - DUK_FUNC(cmd_box2d, 6) - DUK_FUNC(make_circle2d, 3) - DUK_FUNC(cmd_circle2d, 6) - DUK_FUNC(make_poly2d, 2) - DUK_FUNC(cmd_poly2d, 6) - DUK_FUNC(make_edge2d, 3) - DUK_FUNC(cmd_edge2d, 6) - DUK_FUNC(make_timer, 3) + DUK_FUNC(make_sprite, 3) + DUK_FUNC(make_anim2d, 3) + DUK_FUNC(spline_cmd, 6) - DUK_FUNC(cmd, 6) - DUK_FUNC(register, 3) - DUK_FUNC(register_collide, 6) + DUK_FUNC(make_box2d, 3) + DUK_FUNC(cmd_box2d, 6) + DUK_FUNC(make_circle2d, 3) + DUK_FUNC(cmd_circle2d, 6) + DUK_FUNC(make_poly2d, 2) + DUK_FUNC(cmd_poly2d, 6) + DUK_FUNC(make_edge2d, 3) + DUK_FUNC(cmd_edge2d, 6) + DUK_FUNC(make_timer, 3) - DUK_FUNC(gui_text, 6) - DUK_FUNC(ui_text, 5) - DUK_FUNC(cursor_text,5) - DUK_FUNC(gui_img, 2) - - DUK_FUNC(inflate_cpv, 3) + DUK_FUNC(cmd, 6) + DUK_FUNC(register, 3) + DUK_FUNC(register_collide, 6) - DUK_FUNC(anim, 2) + DUK_FUNC(gui_text, 6) + DUK_FUNC(ui_text, 5) + DUK_FUNC(cursor_text, 5) + DUK_FUNC(gui_img, 2) + + DUK_FUNC(inflate_cpv, 3) + + DUK_FUNC(anim, 2) } diff --git a/source/engine/font.c b/source/engine/font.c index da11c4f..debedfc 100644 --- a/source/engine/font.c +++ b/source/engine/font.c @@ -1,169 +1,153 @@ #include "font.h" +#include "log.h" #include "render.h" -#include -#include -#include #include #include +#include +#include #include +#include #include -#include "log.h" #include "openglrender.h" -#include "stb_truetype.h" -#include "stb_rect_pack.h" #include "stb_image_write.h" +#include "stb_rect_pack.h" +#include "stb_truetype.h" struct sFont *font; -static struct shader *shader; -static sg_shader fontshader; + unsigned char *slurp_file(const char *filename) { - FILE *f = fopen(filename, "rb"); + FILE *f = fopen(filename, "rb"); - if (!f) return NULL; + if (!f) return NULL; - fseek(f, 0, SEEK_END); - long fsize = ftell(f); - fseek(f, 0, SEEK_SET); - unsigned char *slurp = malloc(fsize+1); - fread(slurp,fsize,1,f); - fclose(f); + fseek(f, 0, SEEK_END); + long fsize = ftell(f); + fseek(f, 0, SEEK_SET); + unsigned char *slurp = malloc(fsize + 1); + fread(slurp, fsize, 1, f); + fclose(f); - return slurp; + return slurp; } char *slurp_text(const char *filename) { - FILE *f = fopen(filename, "r'"); - if (!f) return NULL; + FILE *f = fopen(filename, "r'"); + if (!f) return NULL; - char *buf; - long int fsize; - fseek(f, 0, SEEK_END); - fsize = ftell(f); - buf = malloc(fsize+1); - rewind(f); - size_t r = fread(buf, sizeof(char), fsize, f); - buf[r] = '\0'; + char *buf; + long int fsize; + fseek(f, 0, SEEK_END); + fsize = ftell(f); + buf = malloc(fsize + 1); + rewind(f); + size_t r = fread(buf, sizeof(char), fsize, f); + buf[r] = '\0'; - fclose(f); + fclose(f); - return buf; + return buf; } -int slurp_write(const char *txt, const char *filename) -{ - FILE *f = fopen(filename, "w"); - if (!f) return 1; +int slurp_write(const char *txt, const char *filename) { + FILE *f = fopen(filename, "w"); + if (!f) return 1; - fputs(txt, f); - fclose(f); - return 0; + fputs(txt, f); + fclose(f); + return 0; } +static sg_shader fontshader; static sg_bindings bind_text; static sg_pipeline pipe_text; -void font_init(struct shader *textshader) { - shader = textshader; +static float text_buffer[16 * 40000]; +static uint16_t text_idx_buffer[6 * 40000]; +static float color_buffer[3 * 40000]; - fontshader = sg_make_shader(&(sg_shader_desc){ +void font_init(struct shader *textshader) { + fontshader = sg_make_shader(&(sg_shader_desc){ .vs.source = slurp_text("shaders/textvert.glsl"), .fs.source = slurp_text("shaders/textfrag.glsl"), .vs.uniform_blocks[0] = { - .size = sizeof(float)*16, -// .layout = SG_UNIFORMLAYOUT_STD140, - .uniforms = { - [0] = { .name = "projection", .type = SG_UNIFORMTYPE_MAT4 } - } - }, + .size = sizeof(float) * 16, + // .layout = SG_UNIFORMLAYOUT_STD140, + .uniforms = { + [0] = {.name = "projection", .type = SG_UNIFORMTYPE_MAT4}}}, - .fs.images[0] = { - .name = "text", - .image_type = SG_IMAGETYPE_2D, - .sampler_type = SG_SAMPLERTYPE_FLOAT - } - }); + .fs.images[0] = {.name = "text", .image_type = SG_IMAGETYPE_2D, .sampler_type = SG_SAMPLERTYPE_FLOAT}}); - pipe_text = sg_make_pipeline(&(sg_pipeline_desc){ + pipe_text = sg_make_pipeline(&(sg_pipeline_desc){ .shader = fontshader, .layout = { - .attrs = { - [0].format = SG_VERTEXFORMAT_FLOAT2, - [0].buffer_index = 0, - [1].format = SG_VERTEXFORMAT_FLOAT2, - [1].buffer_index = 0, - [2].format = SG_VERTEXFORMAT_FLOAT3, - [2].buffer_index = 1}, - .buffers[2].step_func = SG_VERTEXSTEP_PER_INSTANCE, + .attrs = { + [0].format = SG_VERTEXFORMAT_FLOAT2, + [0].buffer_index = 0, + [1].format = SG_VERTEXFORMAT_FLOAT2, + [1].buffer_index = 0, + [2].format = SG_VERTEXFORMAT_FLOAT3, + [2].buffer_index = 1, + }, }, - // .primitive_type = SG_PRIMITIVETYPE_TRIANGLE_STRIP, .label = "text pipeline", - .index_type = SG_INDEXTYPE_UINT16 - }); + .index_type = SG_INDEXTYPE_UINT16}); - bind_text.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ - .size = sizeof(float)*16*500, + bind_text.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ + .size = sizeof(float) * 16 * 40000, .type = SG_BUFFERTYPE_VERTEXBUFFER, .usage = SG_USAGE_STREAM, - .label = "text buffer" - }); - - bind_text.vertex_buffers[1] = sg_make_buffer(&(sg_buffer_desc){ - .size = sizeof(float)*3*40000, + .label = "text buffer"}); + + bind_text.vertex_buffers[1] = sg_make_buffer(&(sg_buffer_desc){ + .size = sizeof(float) * 3 * 4 * 40000, .type = SG_BUFFERTYPE_VERTEXBUFFER, .usage = SG_USAGE_STREAM, - .label = "text color buffer" - }); - - bind_text.index_buffer = sg_make_buffer(&(sg_buffer_desc){ - .size = sizeof(uint16_t)*6*500, + .label = "text color buffer"}); + + bind_text.index_buffer = sg_make_buffer(&(sg_buffer_desc){ + .size = sizeof(uint16_t) * 6 * 40000, .type = SG_BUFFERTYPE_INDEXBUFFER, .usage = SG_USAGE_STREAM, - .label = "text index buffer" - }); - - font = MakeFont("LessPerfectDOSVGA.ttf", 16); - bind_text.fs_images[0] = font->texID; + .label = "text index buffer"}); + + font = MakeFont("LessPerfectDOSVGA.ttf", 16); + bind_text.fs_images[0] = font->texID; } -void font_frame(struct window *w) { - shader_use(shader); -} +struct sFont *MakeFont(const char *fontfile, int height) { + YughInfo("Making font %s.", fontfile); -struct sFont *MakeFont(const char *fontfile, int height) -{ - YughInfo("Making font %s.", fontfile); + int packsize = 1024; - int packsize = 128; + struct sFont *newfont = calloc(1, sizeof(struct sFont)); + newfont->height = height; - struct sFont *newfont = calloc(1, sizeof(struct sFont)); - newfont->height = height; + char fontpath[256]; + snprintf(fontpath, 256, "fonts/%s", fontfile); - char fontpath[256]; - snprintf(fontpath, 256, "fonts/%s", fontfile); + unsigned char *ttf_buffer = slurp_file(fontpath); + unsigned char *bitmap = malloc(packsize * packsize); - unsigned char *ttf_buffer = slurp_file(fontpath); - unsigned char *bitmap = malloc(packsize*packsize); + stbtt_packedchar glyphs[95]; - stbtt_packedchar glyphs[95]; + stbtt_pack_context pc; - stbtt_pack_context pc; + stbtt_PackBegin(&pc, bitmap, packsize, packsize, 0, 1, NULL); + stbtt_PackFontRange(&pc, ttf_buffer, 0, height, 32, 95, glyphs); + stbtt_PackEnd(&pc); - stbtt_PackBegin(&pc, bitmap, packsize, packsize, 0, 1, NULL); - stbtt_PackFontRange(&pc, ttf_buffer, 0, height, 32, 95, glyphs); - stbtt_PackEnd(&pc); + stbi_write_png("packedfont.png", packsize, packsize, 1, bitmap, sizeof(char) * packsize); - stbi_write_png("packedfont.png", packsize, packsize, 1, bitmap, sizeof(char) * packsize); + stbtt_fontinfo fontinfo; + if (!stbtt_InitFont(&fontinfo, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer, 0))) { + YughError("Failed to make font %s", fontfile); + } - stbtt_fontinfo fontinfo; - if (!stbtt_InitFont(&fontinfo, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0))) { - YughError("Failed to make font %s", fontfile); - } - - newfont->texID = sg_make_image(&(sg_image_desc){ + newfont->texID = sg_make_image(&(sg_image_desc){ .type = SG_IMAGETYPE_2D, .width = packsize, .height = packsize, @@ -172,215 +156,201 @@ struct sFont *MakeFont(const char *fontfile, int height) .min_filter = SG_FILTER_NEAREST, .mag_filter = SG_FILTER_NEAREST, .data.subimage[0][0] = { - .ptr = bitmap, - .size = packsize*packsize - } - }); + .ptr = bitmap, + .size = packsize * packsize}}); - free(ttf_buffer); - free(bitmap); + free(ttf_buffer); + free(bitmap); - for (unsigned char c = 32; c < 127; c++) { - stbtt_packedchar glyph = glyphs[c-32]; + for (unsigned char c = 32; c < 127; c++) { + stbtt_packedchar glyph = glyphs[c - 32]; - struct glrect r; - r.s0 = glyph.x0 / (float) packsize; - r.s1 = glyph.x1 / (float) packsize; - r.t0 = glyph.y0 / (float) packsize; - r.t1 = glyph.y1 / (float) packsize; + struct glrect r; + r.s0 = glyph.x0 / (float)packsize; + r.s1 = glyph.x1 / (float)packsize; + r.t0 = glyph.y0 / (float)packsize; + r.t1 = glyph.y1 / (float)packsize; - newfont->Characters[c].Advance = glyph.xadvance; - newfont->Characters[c].Size[0] = glyph.x1 - glyph.x0; - newfont->Characters[c].Size[1] = glyph.y1 - glyph.y0; - newfont->Characters[c].Bearing[0] = glyph.xoff; - newfont->Characters[c].Bearing[1] = glyph.yoff2; - newfont->Characters[c].rect = r; - } + newfont->Characters[c].Advance = glyph.xadvance; + newfont->Characters[c].Size[0] = glyph.x1 - glyph.x0; + newfont->Characters[c].Size[1] = glyph.y1 - glyph.y0; + newfont->Characters[c].Bearing[0] = glyph.xoff; + newfont->Characters[c].Bearing[1] = glyph.yoff2; + newfont->Characters[c].rect = r; + } - return newfont; + return newfont; } static int curchar = 0; -void draw_char_box(struct Character c, float cursor[2], float scale, float color[3]) -{ +void draw_char_box(struct Character c, float cursor[2], float scale, float color[3]) { int x, y, w, h; x = cursor[0]; y = cursor[1]; - w = 8*scale; + w = 8 * scale; h = 14; - x += w/2.f; - y += h/2.f; + x += w / 2.f; + y += h / 2.f; - draw_rect(x,y,w,h,color); + draw_rect(x, y, w, h, color); } -void text_flush() -{ - sg_apply_pipeline(pipe_text); - sg_apply_bindings(&bind_text); - sg_apply_uniforms(SG_SHADERSTAGE_VS,0,SG_RANGE_REF(projection)); +void text_flush() { + if (curchar == 0) return; + sg_apply_pipeline(pipe_text); + sg_apply_bindings(&bind_text); + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(projection)); + + sg_range verts; + verts.ptr = text_buffer; + verts.size = sizeof(float) * 16 * curchar; + sg_update_buffer(bind_text.vertex_buffers[0], &verts); - sg_draw(0,6*curchar,1); + sg_range idxs; + idxs.ptr = text_idx_buffer; + idxs.size = sizeof(uint16_t) * 6 * curchar; + sg_update_buffer(bind_text.index_buffer, &idxs); + + sg_range c = { + .ptr = color_buffer, + .size = sizeof(float) * 3 * 4 * curchar}; + + sg_update_buffer(bind_text.vertex_buffers[1], &c); + + sg_draw(0, 6 * curchar, 1); curchar = 0; } -void fill_charverts(float *verts, float cursor[2], float scale, struct Character c, float *offset) -{ +void fill_charverts(float *verts, float cursor[2], float scale, struct Character c, float *offset) { float w = c.Size[0] * scale; float h = c.Size[1] * scale; - float xpos = cursor[0] + (c.Bearing[0]+offset[0]) * scale; - float ypos = cursor[1] - (c.Bearing[1]+offset[1]) * scale; - + float xpos = cursor[0] + (c.Bearing[0] + offset[0]) * scale; + float ypos = cursor[1] - (c.Bearing[1] + offset[1]) * scale; + float v[16] = { - xpos, ypos, c.rect.s0, c.rect.t1, - xpos+w, ypos, c.rect.s1, c.rect.t1, - xpos, ypos + h, c.rect.s0, c.rect.t0, - xpos + w, ypos + h, c.rect.s1, c.rect.t0 - }; - - memcpy(verts, v, sizeof(float)*16); + xpos, ypos, c.rect.s0, c.rect.t1, + xpos + w, ypos, c.rect.s1, c.rect.t1, + xpos, ypos + h, c.rect.s0, c.rect.t0, + xpos + w, ypos + h, c.rect.s1, c.rect.t0}; + + memcpy(verts, v, sizeof(float) * 16); } static int drawcaret = 0; -void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct shader *shader, float color[3]) -{ - float shadowcolor[3] = {0.f, 0.f, 0.f}; - float shadowcursor[2]; - - float verts[16]; - float offset[2] = {-1, 1}; - - fill_charverts(verts, cursor, scale, c, offset); - - /* Check if the vertex is off screen */ - if (verts[5] < 0 || verts[10] < 0 || verts[0] > window_i(0)->width || verts[1] > window_i(0)->height) - return; - - curchar++; - /* SET COLOR ? */ - uint16_t pts[6] = { - 0, 1, 2, - 2, 1, 3 - }; - - for (int i = 0; i < 6; i++) pts[i] += curchar*4; - - sg_append_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); - sg_append_buffer(bind_text.vertex_buffers[1], SG_RANGE_REF(color)); - sg_append_buffer(bind_text.index_buffer, SG_RANGE_REF(pts)); - +void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, float color[3]) { + float shadowcolor[3] = {0.f, 0.f, 0.f}; + float shadowcursor[2]; + + float verts[16]; + float offset[2] = {-1, 1}; + + fill_charverts(verts, cursor, scale, c, offset); + + /* Check if the vertex is off screen */ + if (verts[5] < -window_i(0)->width / 2.f || verts[9] < -window_i(0)->height / 2.f || verts[0] > window_i(0)->width / 2.f || verts[1] > window_i(0)->height / 2.f) return; -// fill_charverts(verts, cursor, scale, c, offset); + uint16_t pts[6] = { + 0, 1, 2, + 2, 1, 3}; -/* - if (drawcaret == curchar) { - draw_char_box(c, cursor, scale, color); - shader_use(shader); - shader_setvec3(shader, "textColor", color); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, font->texID); - glBindVertexArray(VAO); - glBindBuffer(GL_ARRAY_BUFFER, VBO); - } -*/ -// sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, SG_RANGE_REF(shadowcolor)); -/* - sg_append_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); - - offset[0] = 1; - offset[1] = -1; - fill_charverts(verts, cursor, scale, c, offset); - sg_update_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); - - offset[1] = 1; - fill_charverts(verts, cursor, scale, c, offset); - sg_update_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); - - offset[0] = -1; - offset[1] = -1; - fill_charverts(verts, cursor, scale, c, offset); - sg_update_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); -*/ - offset[0] = offset[1] = 0; - fill_charverts(verts, cursor, scale, c, offset); - /* SET COLOR ? */ - sg_update_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); -} + for (int i = 0; i < 6; i++) + pts[i] += curchar * 4; -void text_settype(struct sFont *mfont) -{ - font = mfont; -} + memcpy(text_buffer + (16 * curchar), verts, sizeof(verts)); + for (int i = 0; i < 4; i++) + memcpy(color_buffer + (12 * curchar) + (3 * i), color, sizeof(color)); + memcpy(text_idx_buffer + (6 * curchar), pts, sizeof(pts)); + curchar++; + return; -int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw, int caret) -{ - int len = strlen(text); - drawcaret = caret; - - mfloat_t cursor[2] = { 0.f }; - cursor[0] = pos[0]; - cursor[1] = pos[1]; - - const unsigned char *line, *wordstart, *drawstart; - line = drawstart = (unsigned char*)text; - - float *usecolor = color; - - while (*line != '\0') { - - switch (*line) { - case '\n': - sdrawCharacter(font->Characters[*line], cursor, scale, shader, usecolor); - cursor[1] -= scale * font->height; - cursor[0] = pos[0]; - line++; - break; - - case ' ': - sdrawCharacter(font->Characters[*line], cursor, scale, shader, usecolor); - cursor[0] += font->Characters[*line].Advance * scale; - line++; - break; - - case '\t': - sdrawCharacter(font->Characters[*line], cursor, scale, shader, usecolor); - cursor[0] += font->Characters[*line].Advance * scale; - line++; - break; - - - default: - wordstart = line; - int wordWidth = 0; - - while (!isspace(*line) && *line != '\0') { - wordWidth += font->Characters[*line].Advance * scale; - line++; - } - - if (lw > 0 && (cursor[0] + wordWidth - pos[0]) >= lw) { - cursor[0] = pos[0]; - cursor[1] -= scale * font->height; - } - - while (wordstart < line) { - sdrawCharacter(font->Characters[*wordstart], cursor, scale, shader, usecolor); - cursor[0] += font->Characters[*wordstart].Advance * scale; - wordstart++; - } + /* + if (drawcaret == curchar) { + draw_char_box(c, cursor, scale, color); + shader_use(shader); } - } + */ + /* + sg_append_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); -/* if (caret > curchar) { - draw_char_box(font->Characters[69], cursor, scale, color); - } -*/ + offset[0] = 1; + offset[1] = -1; + fill_charverts(verts, cursor, scale, c, offset); + sg_update_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); + + offset[1] = 1; + fill_charverts(verts, cursor, scale, c, offset); + sg_update_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); + + offset[0] = -1; + offset[1] = -1; + fill_charverts(verts, cursor, scale, c, offset); + sg_update_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); + */ + offset[0] = offset[1] = 0; + fill_charverts(verts, cursor, scale, c, offset); + + sg_update_buffer(bind_text.vertex_buffers[0], SG_RANGE_REF(verts)); +} + +void text_settype(struct sFont *mfont) { + font = mfont; +} + +int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw, int caret) { + int len = strlen(text); + drawcaret = caret; + + mfloat_t cursor[2] = {0.f}; + cursor[0] = pos[0]; + cursor[1] = pos[1]; + + const unsigned char *line, *wordstart, *drawstart; + line = drawstart = (unsigned char *)text; + + float *usecolor = color; + + while (*line != '\0') { + if (isblank(*line)) { + sdrawCharacter(font->Characters[*line], cursor, scale, usecolor); + cursor[0] += font->Characters[*line].Advance * scale; + line++; + } else if (isspace(*line)) { + sdrawCharacter(font->Characters[*line], cursor, scale, usecolor); + cursor[1] -= scale * font->height; + cursor[0] = pos[0]; + line++; + + } else { + + wordstart = line; + int wordWidth = 0; + + while (!isspace(*line) && *line != '\0') { + wordWidth += font->Characters[*line].Advance * scale; + line++; + } + + if (lw > 0 && (cursor[0] + wordWidth - pos[0]) >= lw) { + cursor[0] = pos[0]; + cursor[1] -= scale * font->height; + } + + while (wordstart < line) { + sdrawCharacter(font->Characters[*wordstart], cursor, scale, usecolor); + cursor[0] += font->Characters[*wordstart].Advance * scale; + wordstart++; + } + } + } + /* if (caret > curchar) { + draw_char_box(font->Characters[69], cursor, scale, color); + } + */ - return cursor[1] - pos[1]; } diff --git a/source/engine/font.h b/source/engine/font.h index acc7196..9848b90 100644 --- a/source/engine/font.h +++ b/source/engine/font.h @@ -2,36 +2,34 @@ #define FONT_H #include "mathc.h" -#include "texture.h" #include "sokol/sokol_gfx.h" +#include "texture.h" struct shader; struct window; /// Holds all state information relevant to a character as loaded using FreeType struct Character { - mfloat_t Size[2]; // Size of glyph - mfloat_t Bearing[2]; // Offset from baseline to left/top of glyph - unsigned int Advance; // Horizontal offset to advance to next glyph - struct glrect rect; - + mfloat_t Size[2]; // Size of glyph + mfloat_t Bearing[2]; // Offset from baseline to left/top of glyph + unsigned int Advance; // Horizontal offset to advance to next glyph + struct glrect rect; }; struct sFont { - uint32_t fontTexture; - uint32_t height; - struct Character Characters[127]; - sg_image texID; + uint32_t fontTexture; + uint32_t height; + struct Character Characters[127]; + sg_image texID; }; void font_init(struct shader *s); -void font_frame(struct window *w); struct sFont *MakeFont(const char *fontfile, int height); -void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct shader *shader, float color[3]); +void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, float color[3]); void text_settype(struct sFont *font); -int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw,int caret); +int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw, int caret); -//void text_frame(); +// void text_frame(); void text_flush(); unsigned char *slurp_file(const char *filename); diff --git a/source/engine/gameobject.c b/source/engine/gameobject.c index 681abd5..ce502e0 100644 --- a/source/engine/gameobject.c +++ b/source/engine/gameobject.c @@ -1,61 +1,56 @@ #include "gameobject.h" +#include "2dphysics.h" +#include "debugdraw.h" +#include "input.h" +#include "log.h" +#include "nuke.h" +#include "resources.h" +#include "script.h" #include "shader.h" #include "sprite.h" -#include "2dphysics.h" -#include "script.h" -#include "input.h" -#include #include -#include "resources.h" -#include "nuke.h" -#include "log.h" -#include "debugdraw.h" +#include #include "stb_ds.h" struct gameobject *gameobjects = NULL; static int first = -1; -const int nameBuf[MAXNAME] = { 0 }; -const int prefabNameBuf[MAXNAME] = { 0 }; +const int nameBuf[MAXNAME] = {0}; +const int prefabNameBuf[MAXNAME] = {0}; -struct gameobject *get_gameobject_from_id(int id) -{ if (id < 0) return NULL; +struct gameobject *get_gameobject_from_id(int id) { + if (id < 0) return NULL; - return &gameobjects[id]; + return &gameobjects[id]; } -struct gameobject *id2go(int id) -{ - if (id < 0) return NULL; +struct gameobject *id2go(int id) { + if (id < 0) return NULL; - return &gameobjects[id]; + return &gameobjects[id]; } -int body2id(cpBody *body) -{ +int body2id(cpBody *body) { return (int)cpBodyGetUserData(body); } -cpBody *id2body(int id) -{ +cpBody *id2body(int id) { struct gameobject *go = id2go(id); - + if (go) return go->body; - + return NULL; } -int shape2gameobject(cpShape *shape) -{ +int shape2gameobject(cpShape *shape) { struct phys2d_shape *s = cpShapeGetUserData(shape); return s->go; } -int pos2gameobject(cpVect pos) -{ +int pos2gameobject(cpVect pos) { cpShape *hit = phys2d_query_pos(pos); if (hit) { @@ -73,269 +68,255 @@ int pos2gameobject(cpVect pos) } int id_from_gameobject(struct gameobject *go) { - for (int i = 0; i < arrlen(gameobjects); i++) { - if (&gameobjects[i] == go) return i; - } + for (int i = 0; i < arrlen(gameobjects); i++) { + if (&gameobjects[i] == go) return i; + } - return -1; + return -1; } -void gameobject_set_sensor(int id, int sensor) -{ +void gameobject_set_sensor(int id, int sensor) { id2go(id)->sensor = sensor; gameobject_apply(id2go(id)); } -int go2id(struct gameobject *go) -{ +int go2id(struct gameobject *go) { return id_from_gameobject(go); } -void go_shape_apply(cpBody *body, cpShape *shape, struct gameobject *go) -{ - cpShapeSetFriction(shape, go->f); - cpShapeSetElasticity(shape, go->e); - cpShapeSetCollisionType(shape, go2id(go)); - +void go_shape_apply(cpBody *body, cpShape *shape, struct gameobject *go) { + cpShapeSetFriction(shape, go->f); + cpShapeSetElasticity(shape, go->e); + cpShapeSetCollisionType(shape, go2id(go)); -/* cpShapeFilter filter; - filter.group = go2id(go); - filter.categories = 1<layer; - filter.mask = category_masks[go->layer]; - cpShapeSetFilter(shape, filter); -*/ + /* cpShapeFilter filter; + filter.group = go2id(go); + filter.categories = 1<layer; + filter.mask = category_masks[go->layer]; + cpShapeSetFilter(shape, filter); + */ } -void go_shape_moi(cpBody *body, cpShape *shape, struct gameobject *go) -{ - float moment = cpBodyGetMoment(go->body); - struct phys2d_shape *s = cpShapeGetUserData(shape); - if (!s) { - cpBodySetMoment(go->body, moment+1); - return; - } - - moment += s->moi(s->data, go->mass); - cpBodySetMoment(go->body, moment); +void go_shape_moi(cpBody *body, cpShape *shape, struct gameobject *go) { + float moment = cpBodyGetMoment(go->body); + struct phys2d_shape *s = cpShapeGetUserData(shape); + if (!s) { + cpBodySetMoment(go->body, moment + 1); + return; + } + + moment += s->moi(s->data, go->mass); + cpBodySetMoment(go->body, moment); } -void gameobject_apply(struct gameobject *go) -{ - cpBodySetType(go->body, go->bodytype); - cpBodyEachShape(go->body, go_shape_apply, go); - - if (go->bodytype == CP_BODY_TYPE_DYNAMIC) { - cpBodySetMass(go->body, go->mass); - cpBodySetMoment(go->body, 0.f); - cpBodyEachShape(go->body, go_shape_moi, go); - - if (cpBodyGetMoment(go->body) <= 0.f) - cpBodySetMoment(go->body, 1.f); - - return; - } +void gameobject_apply(struct gameobject *go) { + cpBodySetType(go->body, go->bodytype); + cpBodyEachShape(go->body, go_shape_apply, go); + + if (go->bodytype == CP_BODY_TYPE_DYNAMIC) { + cpBodySetMass(go->body, go->mass); + cpBodySetMoment(go->body, 0.f); + cpBodyEachShape(go->body, go_shape_moi, go); + + if (cpBodyGetMoment(go->body) <= 0.f) + cpBodySetMoment(go->body, 1.f); + + return; + } } -static void gameobject_setpickcolor(struct gameobject *go) -{ -/* - float r = ((go->editor.id & 0x000000FF) >> 0) / 255.f; - float g = ((go->editor.id & 0x0000FF00) >> 8) / 255.f; - float b = ((go->editor.id & 0x00FF0000) >> 16) / 255.f; +static void gameobject_setpickcolor(struct gameobject *go) { + /* + float r = ((go->editor.id & 0x000000FF) >> 0) / 255.f; + float g = ((go->editor.id & 0x0000FF00) >> 8) / 255.f; + float b = ((go->editor.id & 0x00FF0000) >> 16) / 255.f; - go->editor.color[0] = r; - go->editor.color[1] = g; - go->editor.color[2] = b; - */ + go->editor.color[0] = r; + go->editor.color[1] = g; + go->editor.color[2] = b; + */ } -int MakeGameobject() -{ - struct gameobject go = { - .scale = 1.f, - .bodytype = CP_BODY_TYPE_STATIC, - .mass = 1.f, - .next = -1, - .sensor = 0, - .shape_cbs = NULL, - }; +int MakeGameobject() { + struct gameobject go = { + .scale = 1.f, + .bodytype = CP_BODY_TYPE_STATIC, + .mass = 1.f, + .next = -1, + .sensor = 0, + .shape_cbs = NULL, + }; - go.cbs.begin.obj = JS_NULL; - go.cbs.separate.obj = JS_NULL; + go.cbs.begin.obj = JS_NULL; + go.cbs.separate.obj = JS_NULL; - go.body = cpSpaceAddBody(space, cpBodyNew(go.mass, 1.f)); + go.body = cpSpaceAddBody(space, cpBodyNew(go.mass, 1.f)); - int retid; + int retid; - if (first<0) { - arrput(gameobjects, go); - retid = arrlast(gameobjects).id = arrlen(gameobjects)-1; - } else { - retid = first; - first = id2go(first)->next; - *id2go(retid) = go; - } - - cpBodySetUserData(go.body, (void*)retid); - phys2d_setup_handlers(retid); - return retid; + if (first < 0) { + arrput(gameobjects, go); + retid = arrlast(gameobjects).id = arrlen(gameobjects) - 1; + } else { + retid = first; + first = id2go(first)->next; + *id2go(retid) = go; + } + + cpBodySetUserData(go.body, (void *)retid); + phys2d_setup_handlers(retid); + return retid; } void rm_body_shapes(cpBody *body, cpShape *shape, void *data) { - struct phys2d_shape *s = cpShapeGetUserData(shape); - if (s->data) { - free(s->data); - s->data = NULL; - } - cpSpaceRemoveShape(space, shape); - cpShapeFree(shape); + struct phys2d_shape *s = cpShapeGetUserData(shape); + if (s->data) { + free(s->data); + s->data = NULL; + } + cpSpaceRemoveShape(space, shape); + cpShapeFree(shape); } int *go_toclean = NULL; /* Free this gameobject */ void gameobject_clean(int id) { - struct gameobject *go = id2go(id); - arrfree(go->shape_cbs); - cpBodyEachShape(go->body, rm_body_shapes, NULL); - cpSpaceRemoveBody(space, go->body); - cpBodyFree(go->body); - go->body = NULL; + struct gameobject *go = id2go(id); + arrfree(go->shape_cbs); + cpBodyEachShape(go->body, rm_body_shapes, NULL); + cpSpaceRemoveBody(space, go->body); + cpBodyFree(go->body); + go->body = NULL; } /* Really more of a "mark for deletion" ... */ -void gameobject_delete(int id) -{ - id2go(id)->next = first; - first = id; +void gameobject_delete(int id) { + id2go(id)->next = first; + first = id; - if (cpSpaceIsLocked(space)) - arrpush(go_toclean, id); - else - gameobject_clean(id); + if (cpSpaceIsLocked(space)) + arrpush(go_toclean, id); + else + gameobject_clean(id); } void gameobjects_cleanup() { - for (int i = 0; i < arrlen(go_toclean); i++) - gameobject_clean(go_toclean[i]); + for (int i = 0; i < arrlen(go_toclean); i++) + gameobject_clean(go_toclean[i]); - arrsetlen(go_toclean, 0); - - return; + arrsetlen(go_toclean, 0); - int clean = first; + return; - while (clean >= 0 && id2go(clean)->body) { - gameobject_clean(clean); - clean = id2go(clean)->next; - } + int clean = first; + + while (clean >= 0 && id2go(clean)->body) { + gameobject_clean(clean); + clean = id2go(clean)->next; + } } -void gameobject_move(struct gameobject *go, cpVect vec) -{ - cpVect p = cpBodyGetPosition(go->body); - p.x += vec.x; - p.y += vec.y; - cpBodySetPosition(go->body, p); +void gameobject_move(struct gameobject *go, cpVect vec) { + cpVect p = cpBodyGetPosition(go->body); + p.x += vec.x; + p.y += vec.y; + cpBodySetPosition(go->body, p); - phys2d_reindex_body(go->body); + phys2d_reindex_body(go->body); } -void gameobject_rotate(struct gameobject *go, float as) -{ - cpFloat a = cpBodyGetAngle(go->body); - a += as * deltaT; - cpBodySetAngle(go->body, a); +void gameobject_rotate(struct gameobject *go, float as) { + cpFloat a = cpBodyGetAngle(go->body); + a += as * deltaT; + cpBodySetAngle(go->body, a); - phys2d_reindex_body(go->body); + phys2d_reindex_body(go->body); } void gameobject_setangle(struct gameobject *go, float angle) { - cpBodySetAngle(go->body, angle); - phys2d_reindex_body(go->body); + cpBodySetAngle(go->body, angle); + phys2d_reindex_body(go->body); } void gameobject_setpos(struct gameobject *go, cpVect vec) { - if (!go || !go->body) return; - cpBodySetPosition(go->body, vec); + if (!go || !go->body) return; + cpBodySetPosition(go->body, vec); - phys2d_reindex_body(go->body); + phys2d_reindex_body(go->body); } -void object_gui(struct gameobject *go) -{ -/* - float temp_pos[2]; - temp_pos[0] = cpBodyGetPosition(go->body).x; - temp_pos[1] = cpBodyGetPosition(go->body).y; +void object_gui(struct gameobject *go) { + /* + float temp_pos[2]; + temp_pos[0] = cpBodyGetPosition(go->body).x; + temp_pos[1] = cpBodyGetPosition(go->body).y; - draw_point(temp_pos[0], temp_pos[1], 3); + draw_point(temp_pos[0], temp_pos[1], 3); - nuke_property_float2("Position", -1000000.f, temp_pos, 1000000.f, 1.f, 0.5f); + nuke_property_float2("Position", -1000000.f, temp_pos, 1000000.f, 1.f, 0.5f); - cpVect tvect = { temp_pos[0], temp_pos[1] }; - cpBodySetPosition(go->body, tvect); + cpVect tvect = { temp_pos[0], temp_pos[1] }; + cpBodySetPosition(go->body, tvect); - float mtry = cpBodyGetAngle(go->body); - float modtry = fmodf(mtry * RAD2DEGS, 360.f); - if (modtry < 0.f) - modtry += 360.f; + float mtry = cpBodyGetAngle(go->body); + float modtry = fmodf(mtry * RAD2DEGS, 360.f); + if (modtry < 0.f) + modtry += 360.f; - float modtry2 = modtry; - nuke_property_float("Angle", -1000.f, &modtry, 1000.f, 0.5f, 0.5f); - modtry -= modtry2; - cpBodySetAngle(go->body, mtry + (modtry * DEG2RADS)); + float modtry2 = modtry; + nuke_property_float("Angle", -1000.f, &modtry, 1000.f, 0.5f, 0.5f); + modtry -= modtry2; + cpBodySetAngle(go->body, mtry + (modtry * DEG2RADS)); - nuke_property_float("Scale", 0.f, &go->scale, 1000.f, 0.01f, go->scale * 0.01f); + nuke_property_float("Scale", 0.f, &go->scale, 1000.f, 0.01f, go->scale * 0.01f); - nuke_nel(3); - nuke_radio_btn("Static", &go->bodytype, CP_BODY_TYPE_STATIC); - nuke_radio_btn("Dynamic", &go->bodytype, CP_BODY_TYPE_DYNAMIC); - nuke_radio_btn("Kinematic", &go->bodytype, CP_BODY_TYPE_KINEMATIC); + nuke_nel(3); + nuke_radio_btn("Static", &go->bodytype, CP_BODY_TYPE_STATIC); + nuke_radio_btn("Dynamic", &go->bodytype, CP_BODY_TYPE_DYNAMIC); + nuke_radio_btn("Kinematic", &go->bodytype, CP_BODY_TYPE_KINEMATIC); - cpBodySetType(go->body, go->bodytype); + cpBodySetType(go->body, go->bodytype); - if (go->bodytype == CP_BODY_TYPE_DYNAMIC) { - nuke_property_float("Mass", 0.01f, &go->mass, 1000.f, 0.01f, 0.01f); - cpBodySetMass(go->body, go->mass); - } + if (go->bodytype == CP_BODY_TYPE_DYNAMIC) { + nuke_property_float("Mass", 0.01f, &go->mass, 1000.f, 0.01f, 0.01f); + cpBodySetMass(go->body, go->mass); + } - nuke_property_float("Friction", 0.f, &go->f, 10.f, 0.01f, 0.01f); - nuke_property_float("Elasticity", 0.f, &go->e, 2.f, 0.01f, 0.01f); + nuke_property_float("Friction", 0.f, &go->f, 10.f, 0.01f, 0.01f); + nuke_property_float("Elasticity", 0.f, &go->e, 2.f, 0.01f, 0.01f); - int n = -1; + int n = -1; - for (int i = 0; i < arrlen(go->components); i++) { - struct component *c = &go->components[i]; + for (int i = 0; i < arrlen(go->components); i++) { + struct component *c = &go->components[i]; - comp_draw_debug(c); + comp_draw_debug(c); - nuke_nel(5); - if (nuke_btn("Del")) n = i; + nuke_nel(5); + if (nuke_btn("Del")) n = i; - if (nuke_push_tree_id(c->ref->name, i)) { - comp_draw_gui(c); - nuke_tree_pop(); - } + if (nuke_push_tree_id(c->ref->name, i)) { + comp_draw_gui(c); + nuke_tree_pop(); + } - } + } - if (n >= 0) - gameobject_delcomponent(go, n); -*/ + if (n >= 0) + gameobject_delcomponent(go, n); + */ } - void body_draw_shapes_dbg(cpBody *body, cpShape *shape, void *data) { - struct phys2d_shape *s = cpShapeGetUserData(shape); - s->debugdraw(s->data); + struct phys2d_shape *s = cpShapeGetUserData(shape); + s->debugdraw(s->data); } -void gameobject_draw_debug(int go) -{ +void gameobject_draw_debug(int go) { struct gameobject *g = id2go(go); if (!g || !g->body) return; @@ -346,37 +327,40 @@ void gameobject_draw_debug(int go) } void gameobject_draw_debugs() { - for (int i = 0; i < arrlen(gameobjects); i++) - gameobject_draw_debug(i); + for (int i = 0; i < arrlen(gameobjects); i++) + gameobject_draw_debug(i); } - -static struct {struct gameobject go; cpVect pos; float angle; } *saveobjects = NULL; +static struct { + struct gameobject go; + cpVect pos; + float angle; +} *saveobjects = NULL; void gameobject_saveall() { - arrfree(saveobjects); - arrsetlen(saveobjects, arrlen(gameobjects)); + arrfree(saveobjects); + arrsetlen(saveobjects, arrlen(gameobjects)); - for (int i = 0; i < arrlen(gameobjects); i++) { - saveobjects[i].go = gameobjects[i]; - saveobjects[i].pos = cpBodyGetPosition(gameobjects[i].body); - saveobjects[i].angle = cpBodyGetAngle(gameobjects[i].body); - } + for (int i = 0; i < arrlen(gameobjects); i++) { + saveobjects[i].go = gameobjects[i]; + saveobjects[i].pos = cpBodyGetPosition(gameobjects[i].body); + saveobjects[i].angle = cpBodyGetAngle(gameobjects[i].body); + } } void gameobject_loadall() { - YughInfo("N gameobjects: %d, N saved: %d", arrlen(gameobjects), arrlen(saveobjects)); - for (int i = 0; i < arrlen(saveobjects); i++) { - gameobjects[i] = saveobjects[i].go; - cpBodySetPosition(gameobjects[i].body, saveobjects[i].pos); - cpBodySetAngle(gameobjects[i].body, saveobjects[i].angle); - cpBodySetVelocity(gameobjects[i].body, cpvzero); - cpBodySetAngularVelocity(gameobjects[i].body, 0.f); - } + YughInfo("N gameobjects: %d, N saved: %d", arrlen(gameobjects), arrlen(saveobjects)); + for (int i = 0; i < arrlen(saveobjects); i++) { + gameobjects[i] = saveobjects[i].go; + cpBodySetPosition(gameobjects[i].body, saveobjects[i].pos); + cpBodySetAngle(gameobjects[i].body, saveobjects[i].angle); + cpBodySetVelocity(gameobjects[i].body, cpvzero); + cpBodySetAngularVelocity(gameobjects[i].body, 0.f); + } - arrfree(saveobjects); + arrfree(saveobjects); } int gameobjects_saved() { - return arrlen(saveobjects); + return arrlen(saveobjects); } diff --git a/source/engine/gameobject.h b/source/engine/gameobject.h index fcf92b9..ce613ff 100644 --- a/source/engine/gameobject.h +++ b/source/engine/gameobject.h @@ -1,33 +1,33 @@ #ifndef GAMEOBJECT_H #define GAMEOBJECT_H -#include -#include "mathc.h" -#include "config.h" -#include -#include #include "2dphysics.h" +#include "config.h" +#include "mathc.h" +#include +#include +#include struct shader; struct sprite; struct component; struct gameobject { - cpBodyType bodytype; - int next; - float scale; - float mass; - float f; /* friction */ - float e; /* elasticity */ - int flipx; /* 1 or -1 */ - int flipy; - int sensor; - unsigned int layer; - cpShapeFilter filter; - cpBody *body; /* NULL if this object is dead */ - int id; - struct phys_cbs cbs; - struct shape_cb *shape_cbs; + cpBodyType bodytype; + int next; + float scale; + float mass; + float f; /* friction */ + float e; /* elasticity */ + int flipx; /* 1 or -1 */ + int flipy; + int sensor; + unsigned int layer; + cpShapeFilter filter; + cpBody *body; /* NULL if this object is dead */ + int id; + struct phys_cbs cbs; + struct shape_cb *shape_cbs; }; extern struct gameobject *gameobjects; diff --git a/source/engine/glad/gl.c b/source/engine/glad/gl.c index 74131b7..e983732 100644 --- a/source/engine/glad/gl.c +++ b/source/engine/glad/gl.c @@ -1,7 +1,7 @@ +#include #include #include #include -#include #ifndef GLAD_IMPL_UTIL_C_ #define GLAD_IMPL_UTIL_C_ @@ -18,8 +18,6 @@ extern "C" { #endif - - int GLAD_GL_VERSION_1_0 = 0; int GLAD_GL_VERSION_1_1 = 0; int GLAD_GL_VERSION_1_2 = 0; @@ -38,8 +36,6 @@ int GLAD_GL_VERSION_4_2 = 0; int GLAD_GL_VERSION_4_3 = 0; int GLAD_GL_VERSION_4_4 = 0; - - PFNGLACCUMPROC glad_glAccum = NULL; PFNGLACTIVESHADERPROGRAMPROC glad_glActiveShaderProgram = NULL; PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL; @@ -963,1186 +959,1174 @@ PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv = NULL; PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL; PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL; - -static void glad_gl_load_GL_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_0) return; - glad_glAccum = (PFNGLACCUMPROC) load(userptr, "glAccum"); - glad_glAlphaFunc = (PFNGLALPHAFUNCPROC) load(userptr, "glAlphaFunc"); - glad_glBegin = (PFNGLBEGINPROC) load(userptr, "glBegin"); - glad_glBitmap = (PFNGLBITMAPPROC) load(userptr, "glBitmap"); - glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc"); - glad_glCallList = (PFNGLCALLLISTPROC) load(userptr, "glCallList"); - glad_glCallLists = (PFNGLCALLLISTSPROC) load(userptr, "glCallLists"); - glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear"); - glad_glClearAccum = (PFNGLCLEARACCUMPROC) load(userptr, "glClearAccum"); - glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor"); - glad_glClearDepth = (PFNGLCLEARDEPTHPROC) load(userptr, "glClearDepth"); - glad_glClearIndex = (PFNGLCLEARINDEXPROC) load(userptr, "glClearIndex"); - glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil"); - glad_glClipPlane = (PFNGLCLIPPLANEPROC) load(userptr, "glClipPlane"); - glad_glColor3b = (PFNGLCOLOR3BPROC) load(userptr, "glColor3b"); - glad_glColor3bv = (PFNGLCOLOR3BVPROC) load(userptr, "glColor3bv"); - glad_glColor3d = (PFNGLCOLOR3DPROC) load(userptr, "glColor3d"); - glad_glColor3dv = (PFNGLCOLOR3DVPROC) load(userptr, "glColor3dv"); - glad_glColor3f = (PFNGLCOLOR3FPROC) load(userptr, "glColor3f"); - glad_glColor3fv = (PFNGLCOLOR3FVPROC) load(userptr, "glColor3fv"); - glad_glColor3i = (PFNGLCOLOR3IPROC) load(userptr, "glColor3i"); - glad_glColor3iv = (PFNGLCOLOR3IVPROC) load(userptr, "glColor3iv"); - glad_glColor3s = (PFNGLCOLOR3SPROC) load(userptr, "glColor3s"); - glad_glColor3sv = (PFNGLCOLOR3SVPROC) load(userptr, "glColor3sv"); - glad_glColor3ub = (PFNGLCOLOR3UBPROC) load(userptr, "glColor3ub"); - glad_glColor3ubv = (PFNGLCOLOR3UBVPROC) load(userptr, "glColor3ubv"); - glad_glColor3ui = (PFNGLCOLOR3UIPROC) load(userptr, "glColor3ui"); - glad_glColor3uiv = (PFNGLCOLOR3UIVPROC) load(userptr, "glColor3uiv"); - glad_glColor3us = (PFNGLCOLOR3USPROC) load(userptr, "glColor3us"); - glad_glColor3usv = (PFNGLCOLOR3USVPROC) load(userptr, "glColor3usv"); - glad_glColor4b = (PFNGLCOLOR4BPROC) load(userptr, "glColor4b"); - glad_glColor4bv = (PFNGLCOLOR4BVPROC) load(userptr, "glColor4bv"); - glad_glColor4d = (PFNGLCOLOR4DPROC) load(userptr, "glColor4d"); - glad_glColor4dv = (PFNGLCOLOR4DVPROC) load(userptr, "glColor4dv"); - glad_glColor4f = (PFNGLCOLOR4FPROC) load(userptr, "glColor4f"); - glad_glColor4fv = (PFNGLCOLOR4FVPROC) load(userptr, "glColor4fv"); - glad_glColor4i = (PFNGLCOLOR4IPROC) load(userptr, "glColor4i"); - glad_glColor4iv = (PFNGLCOLOR4IVPROC) load(userptr, "glColor4iv"); - glad_glColor4s = (PFNGLCOLOR4SPROC) load(userptr, "glColor4s"); - glad_glColor4sv = (PFNGLCOLOR4SVPROC) load(userptr, "glColor4sv"); - glad_glColor4ub = (PFNGLCOLOR4UBPROC) load(userptr, "glColor4ub"); - glad_glColor4ubv = (PFNGLCOLOR4UBVPROC) load(userptr, "glColor4ubv"); - glad_glColor4ui = (PFNGLCOLOR4UIPROC) load(userptr, "glColor4ui"); - glad_glColor4uiv = (PFNGLCOLOR4UIVPROC) load(userptr, "glColor4uiv"); - glad_glColor4us = (PFNGLCOLOR4USPROC) load(userptr, "glColor4us"); - glad_glColor4usv = (PFNGLCOLOR4USVPROC) load(userptr, "glColor4usv"); - glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask"); - glad_glColorMaterial = (PFNGLCOLORMATERIALPROC) load(userptr, "glColorMaterial"); - glad_glCopyPixels = (PFNGLCOPYPIXELSPROC) load(userptr, "glCopyPixels"); - glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace"); - glad_glDeleteLists = (PFNGLDELETELISTSPROC) load(userptr, "glDeleteLists"); - glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc"); - glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask"); - glad_glDepthRange = (PFNGLDEPTHRANGEPROC) load(userptr, "glDepthRange"); - glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable"); - glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC) load(userptr, "glDrawBuffer"); - glad_glDrawPixels = (PFNGLDRAWPIXELSPROC) load(userptr, "glDrawPixels"); - glad_glEdgeFlag = (PFNGLEDGEFLAGPROC) load(userptr, "glEdgeFlag"); - glad_glEdgeFlagv = (PFNGLEDGEFLAGVPROC) load(userptr, "glEdgeFlagv"); - glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable"); - glad_glEnd = (PFNGLENDPROC) load(userptr, "glEnd"); - glad_glEndList = (PFNGLENDLISTPROC) load(userptr, "glEndList"); - glad_glEvalCoord1d = (PFNGLEVALCOORD1DPROC) load(userptr, "glEvalCoord1d"); - glad_glEvalCoord1dv = (PFNGLEVALCOORD1DVPROC) load(userptr, "glEvalCoord1dv"); - glad_glEvalCoord1f = (PFNGLEVALCOORD1FPROC) load(userptr, "glEvalCoord1f"); - glad_glEvalCoord1fv = (PFNGLEVALCOORD1FVPROC) load(userptr, "glEvalCoord1fv"); - glad_glEvalCoord2d = (PFNGLEVALCOORD2DPROC) load(userptr, "glEvalCoord2d"); - glad_glEvalCoord2dv = (PFNGLEVALCOORD2DVPROC) load(userptr, "glEvalCoord2dv"); - glad_glEvalCoord2f = (PFNGLEVALCOORD2FPROC) load(userptr, "glEvalCoord2f"); - glad_glEvalCoord2fv = (PFNGLEVALCOORD2FVPROC) load(userptr, "glEvalCoord2fv"); - glad_glEvalMesh1 = (PFNGLEVALMESH1PROC) load(userptr, "glEvalMesh1"); - glad_glEvalMesh2 = (PFNGLEVALMESH2PROC) load(userptr, "glEvalMesh2"); - glad_glEvalPoint1 = (PFNGLEVALPOINT1PROC) load(userptr, "glEvalPoint1"); - glad_glEvalPoint2 = (PFNGLEVALPOINT2PROC) load(userptr, "glEvalPoint2"); - glad_glFeedbackBuffer = (PFNGLFEEDBACKBUFFERPROC) load(userptr, "glFeedbackBuffer"); - glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish"); - glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush"); - glad_glFogf = (PFNGLFOGFPROC) load(userptr, "glFogf"); - glad_glFogfv = (PFNGLFOGFVPROC) load(userptr, "glFogfv"); - glad_glFogi = (PFNGLFOGIPROC) load(userptr, "glFogi"); - glad_glFogiv = (PFNGLFOGIVPROC) load(userptr, "glFogiv"); - glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace"); - glad_glFrustum = (PFNGLFRUSTUMPROC) load(userptr, "glFrustum"); - glad_glGenLists = (PFNGLGENLISTSPROC) load(userptr, "glGenLists"); - glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv"); - glad_glGetClipPlane = (PFNGLGETCLIPPLANEPROC) load(userptr, "glGetClipPlane"); - glad_glGetDoublev = (PFNGLGETDOUBLEVPROC) load(userptr, "glGetDoublev"); - glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError"); - glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv"); - glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv"); - glad_glGetLightfv = (PFNGLGETLIGHTFVPROC) load(userptr, "glGetLightfv"); - glad_glGetLightiv = (PFNGLGETLIGHTIVPROC) load(userptr, "glGetLightiv"); - glad_glGetMapdv = (PFNGLGETMAPDVPROC) load(userptr, "glGetMapdv"); - glad_glGetMapfv = (PFNGLGETMAPFVPROC) load(userptr, "glGetMapfv"); - glad_glGetMapiv = (PFNGLGETMAPIVPROC) load(userptr, "glGetMapiv"); - glad_glGetMaterialfv = (PFNGLGETMATERIALFVPROC) load(userptr, "glGetMaterialfv"); - glad_glGetMaterialiv = (PFNGLGETMATERIALIVPROC) load(userptr, "glGetMaterialiv"); - glad_glGetPixelMapfv = (PFNGLGETPIXELMAPFVPROC) load(userptr, "glGetPixelMapfv"); - glad_glGetPixelMapuiv = (PFNGLGETPIXELMAPUIVPROC) load(userptr, "glGetPixelMapuiv"); - glad_glGetPixelMapusv = (PFNGLGETPIXELMAPUSVPROC) load(userptr, "glGetPixelMapusv"); - glad_glGetPolygonStipple = (PFNGLGETPOLYGONSTIPPLEPROC) load(userptr, "glGetPolygonStipple"); - glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString"); - glad_glGetTexEnvfv = (PFNGLGETTEXENVFVPROC) load(userptr, "glGetTexEnvfv"); - glad_glGetTexEnviv = (PFNGLGETTEXENVIVPROC) load(userptr, "glGetTexEnviv"); - glad_glGetTexGendv = (PFNGLGETTEXGENDVPROC) load(userptr, "glGetTexGendv"); - glad_glGetTexGenfv = (PFNGLGETTEXGENFVPROC) load(userptr, "glGetTexGenfv"); - glad_glGetTexGeniv = (PFNGLGETTEXGENIVPROC) load(userptr, "glGetTexGeniv"); - glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC) load(userptr, "glGetTexImage"); - glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load(userptr, "glGetTexLevelParameterfv"); - glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load(userptr, "glGetTexLevelParameteriv"); - glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv"); - glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv"); - glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint"); - glad_glIndexMask = (PFNGLINDEXMASKPROC) load(userptr, "glIndexMask"); - glad_glIndexd = (PFNGLINDEXDPROC) load(userptr, "glIndexd"); - glad_glIndexdv = (PFNGLINDEXDVPROC) load(userptr, "glIndexdv"); - glad_glIndexf = (PFNGLINDEXFPROC) load(userptr, "glIndexf"); - glad_glIndexfv = (PFNGLINDEXFVPROC) load(userptr, "glIndexfv"); - glad_glIndexi = (PFNGLINDEXIPROC) load(userptr, "glIndexi"); - glad_glIndexiv = (PFNGLINDEXIVPROC) load(userptr, "glIndexiv"); - glad_glIndexs = (PFNGLINDEXSPROC) load(userptr, "glIndexs"); - glad_glIndexsv = (PFNGLINDEXSVPROC) load(userptr, "glIndexsv"); - glad_glInitNames = (PFNGLINITNAMESPROC) load(userptr, "glInitNames"); - glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled"); - glad_glIsList = (PFNGLISLISTPROC) load(userptr, "glIsList"); - glad_glLightModelf = (PFNGLLIGHTMODELFPROC) load(userptr, "glLightModelf"); - glad_glLightModelfv = (PFNGLLIGHTMODELFVPROC) load(userptr, "glLightModelfv"); - glad_glLightModeli = (PFNGLLIGHTMODELIPROC) load(userptr, "glLightModeli"); - glad_glLightModeliv = (PFNGLLIGHTMODELIVPROC) load(userptr, "glLightModeliv"); - glad_glLightf = (PFNGLLIGHTFPROC) load(userptr, "glLightf"); - glad_glLightfv = (PFNGLLIGHTFVPROC) load(userptr, "glLightfv"); - glad_glLighti = (PFNGLLIGHTIPROC) load(userptr, "glLighti"); - glad_glLightiv = (PFNGLLIGHTIVPROC) load(userptr, "glLightiv"); - glad_glLineStipple = (PFNGLLINESTIPPLEPROC) load(userptr, "glLineStipple"); - glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth"); - glad_glListBase = (PFNGLLISTBASEPROC) load(userptr, "glListBase"); - glad_glLoadIdentity = (PFNGLLOADIDENTITYPROC) load(userptr, "glLoadIdentity"); - glad_glLoadMatrixd = (PFNGLLOADMATRIXDPROC) load(userptr, "glLoadMatrixd"); - glad_glLoadMatrixf = (PFNGLLOADMATRIXFPROC) load(userptr, "glLoadMatrixf"); - glad_glLoadName = (PFNGLLOADNAMEPROC) load(userptr, "glLoadName"); - glad_glLogicOp = (PFNGLLOGICOPPROC) load(userptr, "glLogicOp"); - glad_glMap1d = (PFNGLMAP1DPROC) load(userptr, "glMap1d"); - glad_glMap1f = (PFNGLMAP1FPROC) load(userptr, "glMap1f"); - glad_glMap2d = (PFNGLMAP2DPROC) load(userptr, "glMap2d"); - glad_glMap2f = (PFNGLMAP2FPROC) load(userptr, "glMap2f"); - glad_glMapGrid1d = (PFNGLMAPGRID1DPROC) load(userptr, "glMapGrid1d"); - glad_glMapGrid1f = (PFNGLMAPGRID1FPROC) load(userptr, "glMapGrid1f"); - glad_glMapGrid2d = (PFNGLMAPGRID2DPROC) load(userptr, "glMapGrid2d"); - glad_glMapGrid2f = (PFNGLMAPGRID2FPROC) load(userptr, "glMapGrid2f"); - glad_glMaterialf = (PFNGLMATERIALFPROC) load(userptr, "glMaterialf"); - glad_glMaterialfv = (PFNGLMATERIALFVPROC) load(userptr, "glMaterialfv"); - glad_glMateriali = (PFNGLMATERIALIPROC) load(userptr, "glMateriali"); - glad_glMaterialiv = (PFNGLMATERIALIVPROC) load(userptr, "glMaterialiv"); - glad_glMatrixMode = (PFNGLMATRIXMODEPROC) load(userptr, "glMatrixMode"); - glad_glMultMatrixd = (PFNGLMULTMATRIXDPROC) load(userptr, "glMultMatrixd"); - glad_glMultMatrixf = (PFNGLMULTMATRIXFPROC) load(userptr, "glMultMatrixf"); - glad_glNewList = (PFNGLNEWLISTPROC) load(userptr, "glNewList"); - glad_glNormal3b = (PFNGLNORMAL3BPROC) load(userptr, "glNormal3b"); - glad_glNormal3bv = (PFNGLNORMAL3BVPROC) load(userptr, "glNormal3bv"); - glad_glNormal3d = (PFNGLNORMAL3DPROC) load(userptr, "glNormal3d"); - glad_glNormal3dv = (PFNGLNORMAL3DVPROC) load(userptr, "glNormal3dv"); - glad_glNormal3f = (PFNGLNORMAL3FPROC) load(userptr, "glNormal3f"); - glad_glNormal3fv = (PFNGLNORMAL3FVPROC) load(userptr, "glNormal3fv"); - glad_glNormal3i = (PFNGLNORMAL3IPROC) load(userptr, "glNormal3i"); - glad_glNormal3iv = (PFNGLNORMAL3IVPROC) load(userptr, "glNormal3iv"); - glad_glNormal3s = (PFNGLNORMAL3SPROC) load(userptr, "glNormal3s"); - glad_glNormal3sv = (PFNGLNORMAL3SVPROC) load(userptr, "glNormal3sv"); - glad_glOrtho = (PFNGLORTHOPROC) load(userptr, "glOrtho"); - glad_glPassThrough = (PFNGLPASSTHROUGHPROC) load(userptr, "glPassThrough"); - glad_glPixelMapfv = (PFNGLPIXELMAPFVPROC) load(userptr, "glPixelMapfv"); - glad_glPixelMapuiv = (PFNGLPIXELMAPUIVPROC) load(userptr, "glPixelMapuiv"); - glad_glPixelMapusv = (PFNGLPIXELMAPUSVPROC) load(userptr, "glPixelMapusv"); - glad_glPixelStoref = (PFNGLPIXELSTOREFPROC) load(userptr, "glPixelStoref"); - glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei"); - glad_glPixelTransferf = (PFNGLPIXELTRANSFERFPROC) load(userptr, "glPixelTransferf"); - glad_glPixelTransferi = (PFNGLPIXELTRANSFERIPROC) load(userptr, "glPixelTransferi"); - glad_glPixelZoom = (PFNGLPIXELZOOMPROC) load(userptr, "glPixelZoom"); - glad_glPointSize = (PFNGLPOINTSIZEPROC) load(userptr, "glPointSize"); - glad_glPolygonMode = (PFNGLPOLYGONMODEPROC) load(userptr, "glPolygonMode"); - glad_glPolygonStipple = (PFNGLPOLYGONSTIPPLEPROC) load(userptr, "glPolygonStipple"); - glad_glPopAttrib = (PFNGLPOPATTRIBPROC) load(userptr, "glPopAttrib"); - glad_glPopMatrix = (PFNGLPOPMATRIXPROC) load(userptr, "glPopMatrix"); - glad_glPopName = (PFNGLPOPNAMEPROC) load(userptr, "glPopName"); - glad_glPushAttrib = (PFNGLPUSHATTRIBPROC) load(userptr, "glPushAttrib"); - glad_glPushMatrix = (PFNGLPUSHMATRIXPROC) load(userptr, "glPushMatrix"); - glad_glPushName = (PFNGLPUSHNAMEPROC) load(userptr, "glPushName"); - glad_glRasterPos2d = (PFNGLRASTERPOS2DPROC) load(userptr, "glRasterPos2d"); - glad_glRasterPos2dv = (PFNGLRASTERPOS2DVPROC) load(userptr, "glRasterPos2dv"); - glad_glRasterPos2f = (PFNGLRASTERPOS2FPROC) load(userptr, "glRasterPos2f"); - glad_glRasterPos2fv = (PFNGLRASTERPOS2FVPROC) load(userptr, "glRasterPos2fv"); - glad_glRasterPos2i = (PFNGLRASTERPOS2IPROC) load(userptr, "glRasterPos2i"); - glad_glRasterPos2iv = (PFNGLRASTERPOS2IVPROC) load(userptr, "glRasterPos2iv"); - glad_glRasterPos2s = (PFNGLRASTERPOS2SPROC) load(userptr, "glRasterPos2s"); - glad_glRasterPos2sv = (PFNGLRASTERPOS2SVPROC) load(userptr, "glRasterPos2sv"); - glad_glRasterPos3d = (PFNGLRASTERPOS3DPROC) load(userptr, "glRasterPos3d"); - glad_glRasterPos3dv = (PFNGLRASTERPOS3DVPROC) load(userptr, "glRasterPos3dv"); - glad_glRasterPos3f = (PFNGLRASTERPOS3FPROC) load(userptr, "glRasterPos3f"); - glad_glRasterPos3fv = (PFNGLRASTERPOS3FVPROC) load(userptr, "glRasterPos3fv"); - glad_glRasterPos3i = (PFNGLRASTERPOS3IPROC) load(userptr, "glRasterPos3i"); - glad_glRasterPos3iv = (PFNGLRASTERPOS3IVPROC) load(userptr, "glRasterPos3iv"); - glad_glRasterPos3s = (PFNGLRASTERPOS3SPROC) load(userptr, "glRasterPos3s"); - glad_glRasterPos3sv = (PFNGLRASTERPOS3SVPROC) load(userptr, "glRasterPos3sv"); - glad_glRasterPos4d = (PFNGLRASTERPOS4DPROC) load(userptr, "glRasterPos4d"); - glad_glRasterPos4dv = (PFNGLRASTERPOS4DVPROC) load(userptr, "glRasterPos4dv"); - glad_glRasterPos4f = (PFNGLRASTERPOS4FPROC) load(userptr, "glRasterPos4f"); - glad_glRasterPos4fv = (PFNGLRASTERPOS4FVPROC) load(userptr, "glRasterPos4fv"); - glad_glRasterPos4i = (PFNGLRASTERPOS4IPROC) load(userptr, "glRasterPos4i"); - glad_glRasterPos4iv = (PFNGLRASTERPOS4IVPROC) load(userptr, "glRasterPos4iv"); - glad_glRasterPos4s = (PFNGLRASTERPOS4SPROC) load(userptr, "glRasterPos4s"); - glad_glRasterPos4sv = (PFNGLRASTERPOS4SVPROC) load(userptr, "glRasterPos4sv"); - glad_glReadBuffer = (PFNGLREADBUFFERPROC) load(userptr, "glReadBuffer"); - glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels"); - glad_glRectd = (PFNGLRECTDPROC) load(userptr, "glRectd"); - glad_glRectdv = (PFNGLRECTDVPROC) load(userptr, "glRectdv"); - glad_glRectf = (PFNGLRECTFPROC) load(userptr, "glRectf"); - glad_glRectfv = (PFNGLRECTFVPROC) load(userptr, "glRectfv"); - glad_glRecti = (PFNGLRECTIPROC) load(userptr, "glRecti"); - glad_glRectiv = (PFNGLRECTIVPROC) load(userptr, "glRectiv"); - glad_glRects = (PFNGLRECTSPROC) load(userptr, "glRects"); - glad_glRectsv = (PFNGLRECTSVPROC) load(userptr, "glRectsv"); - glad_glRenderMode = (PFNGLRENDERMODEPROC) load(userptr, "glRenderMode"); - glad_glRotated = (PFNGLROTATEDPROC) load(userptr, "glRotated"); - glad_glRotatef = (PFNGLROTATEFPROC) load(userptr, "glRotatef"); - glad_glScaled = (PFNGLSCALEDPROC) load(userptr, "glScaled"); - glad_glScalef = (PFNGLSCALEFPROC) load(userptr, "glScalef"); - glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor"); - glad_glSelectBuffer = (PFNGLSELECTBUFFERPROC) load(userptr, "glSelectBuffer"); - glad_glShadeModel = (PFNGLSHADEMODELPROC) load(userptr, "glShadeModel"); - glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc"); - glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask"); - glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp"); - glad_glTexCoord1d = (PFNGLTEXCOORD1DPROC) load(userptr, "glTexCoord1d"); - glad_glTexCoord1dv = (PFNGLTEXCOORD1DVPROC) load(userptr, "glTexCoord1dv"); - glad_glTexCoord1f = (PFNGLTEXCOORD1FPROC) load(userptr, "glTexCoord1f"); - glad_glTexCoord1fv = (PFNGLTEXCOORD1FVPROC) load(userptr, "glTexCoord1fv"); - glad_glTexCoord1i = (PFNGLTEXCOORD1IPROC) load(userptr, "glTexCoord1i"); - glad_glTexCoord1iv = (PFNGLTEXCOORD1IVPROC) load(userptr, "glTexCoord1iv"); - glad_glTexCoord1s = (PFNGLTEXCOORD1SPROC) load(userptr, "glTexCoord1s"); - glad_glTexCoord1sv = (PFNGLTEXCOORD1SVPROC) load(userptr, "glTexCoord1sv"); - glad_glTexCoord2d = (PFNGLTEXCOORD2DPROC) load(userptr, "glTexCoord2d"); - glad_glTexCoord2dv = (PFNGLTEXCOORD2DVPROC) load(userptr, "glTexCoord2dv"); - glad_glTexCoord2f = (PFNGLTEXCOORD2FPROC) load(userptr, "glTexCoord2f"); - glad_glTexCoord2fv = (PFNGLTEXCOORD2FVPROC) load(userptr, "glTexCoord2fv"); - glad_glTexCoord2i = (PFNGLTEXCOORD2IPROC) load(userptr, "glTexCoord2i"); - glad_glTexCoord2iv = (PFNGLTEXCOORD2IVPROC) load(userptr, "glTexCoord2iv"); - glad_glTexCoord2s = (PFNGLTEXCOORD2SPROC) load(userptr, "glTexCoord2s"); - glad_glTexCoord2sv = (PFNGLTEXCOORD2SVPROC) load(userptr, "glTexCoord2sv"); - glad_glTexCoord3d = (PFNGLTEXCOORD3DPROC) load(userptr, "glTexCoord3d"); - glad_glTexCoord3dv = (PFNGLTEXCOORD3DVPROC) load(userptr, "glTexCoord3dv"); - glad_glTexCoord3f = (PFNGLTEXCOORD3FPROC) load(userptr, "glTexCoord3f"); - glad_glTexCoord3fv = (PFNGLTEXCOORD3FVPROC) load(userptr, "glTexCoord3fv"); - glad_glTexCoord3i = (PFNGLTEXCOORD3IPROC) load(userptr, "glTexCoord3i"); - glad_glTexCoord3iv = (PFNGLTEXCOORD3IVPROC) load(userptr, "glTexCoord3iv"); - glad_glTexCoord3s = (PFNGLTEXCOORD3SPROC) load(userptr, "glTexCoord3s"); - glad_glTexCoord3sv = (PFNGLTEXCOORD3SVPROC) load(userptr, "glTexCoord3sv"); - glad_glTexCoord4d = (PFNGLTEXCOORD4DPROC) load(userptr, "glTexCoord4d"); - glad_glTexCoord4dv = (PFNGLTEXCOORD4DVPROC) load(userptr, "glTexCoord4dv"); - glad_glTexCoord4f = (PFNGLTEXCOORD4FPROC) load(userptr, "glTexCoord4f"); - glad_glTexCoord4fv = (PFNGLTEXCOORD4FVPROC) load(userptr, "glTexCoord4fv"); - glad_glTexCoord4i = (PFNGLTEXCOORD4IPROC) load(userptr, "glTexCoord4i"); - glad_glTexCoord4iv = (PFNGLTEXCOORD4IVPROC) load(userptr, "glTexCoord4iv"); - glad_glTexCoord4s = (PFNGLTEXCOORD4SPROC) load(userptr, "glTexCoord4s"); - glad_glTexCoord4sv = (PFNGLTEXCOORD4SVPROC) load(userptr, "glTexCoord4sv"); - glad_glTexEnvf = (PFNGLTEXENVFPROC) load(userptr, "glTexEnvf"); - glad_glTexEnvfv = (PFNGLTEXENVFVPROC) load(userptr, "glTexEnvfv"); - glad_glTexEnvi = (PFNGLTEXENVIPROC) load(userptr, "glTexEnvi"); - glad_glTexEnviv = (PFNGLTEXENVIVPROC) load(userptr, "glTexEnviv"); - glad_glTexGend = (PFNGLTEXGENDPROC) load(userptr, "glTexGend"); - glad_glTexGendv = (PFNGLTEXGENDVPROC) load(userptr, "glTexGendv"); - glad_glTexGenf = (PFNGLTEXGENFPROC) load(userptr, "glTexGenf"); - glad_glTexGenfv = (PFNGLTEXGENFVPROC) load(userptr, "glTexGenfv"); - glad_glTexGeni = (PFNGLTEXGENIPROC) load(userptr, "glTexGeni"); - glad_glTexGeniv = (PFNGLTEXGENIVPROC) load(userptr, "glTexGeniv"); - glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC) load(userptr, "glTexImage1D"); - glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D"); - glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf"); - glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv"); - glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri"); - glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv"); - glad_glTranslated = (PFNGLTRANSLATEDPROC) load(userptr, "glTranslated"); - glad_glTranslatef = (PFNGLTRANSLATEFPROC) load(userptr, "glTranslatef"); - glad_glVertex2d = (PFNGLVERTEX2DPROC) load(userptr, "glVertex2d"); - glad_glVertex2dv = (PFNGLVERTEX2DVPROC) load(userptr, "glVertex2dv"); - glad_glVertex2f = (PFNGLVERTEX2FPROC) load(userptr, "glVertex2f"); - glad_glVertex2fv = (PFNGLVERTEX2FVPROC) load(userptr, "glVertex2fv"); - glad_glVertex2i = (PFNGLVERTEX2IPROC) load(userptr, "glVertex2i"); - glad_glVertex2iv = (PFNGLVERTEX2IVPROC) load(userptr, "glVertex2iv"); - glad_glVertex2s = (PFNGLVERTEX2SPROC) load(userptr, "glVertex2s"); - glad_glVertex2sv = (PFNGLVERTEX2SVPROC) load(userptr, "glVertex2sv"); - glad_glVertex3d = (PFNGLVERTEX3DPROC) load(userptr, "glVertex3d"); - glad_glVertex3dv = (PFNGLVERTEX3DVPROC) load(userptr, "glVertex3dv"); - glad_glVertex3f = (PFNGLVERTEX3FPROC) load(userptr, "glVertex3f"); - glad_glVertex3fv = (PFNGLVERTEX3FVPROC) load(userptr, "glVertex3fv"); - glad_glVertex3i = (PFNGLVERTEX3IPROC) load(userptr, "glVertex3i"); - glad_glVertex3iv = (PFNGLVERTEX3IVPROC) load(userptr, "glVertex3iv"); - glad_glVertex3s = (PFNGLVERTEX3SPROC) load(userptr, "glVertex3s"); - glad_glVertex3sv = (PFNGLVERTEX3SVPROC) load(userptr, "glVertex3sv"); - glad_glVertex4d = (PFNGLVERTEX4DPROC) load(userptr, "glVertex4d"); - glad_glVertex4dv = (PFNGLVERTEX4DVPROC) load(userptr, "glVertex4dv"); - glad_glVertex4f = (PFNGLVERTEX4FPROC) load(userptr, "glVertex4f"); - glad_glVertex4fv = (PFNGLVERTEX4FVPROC) load(userptr, "glVertex4fv"); - glad_glVertex4i = (PFNGLVERTEX4IPROC) load(userptr, "glVertex4i"); - glad_glVertex4iv = (PFNGLVERTEX4IVPROC) load(userptr, "glVertex4iv"); - glad_glVertex4s = (PFNGLVERTEX4SPROC) load(userptr, "glVertex4s"); - glad_glVertex4sv = (PFNGLVERTEX4SVPROC) load(userptr, "glVertex4sv"); - glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport"); +static void glad_gl_load_GL_VERSION_1_0(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_1_0) return; + glad_glAccum = (PFNGLACCUMPROC)load(userptr, "glAccum"); + glad_glAlphaFunc = (PFNGLALPHAFUNCPROC)load(userptr, "glAlphaFunc"); + glad_glBegin = (PFNGLBEGINPROC)load(userptr, "glBegin"); + glad_glBitmap = (PFNGLBITMAPPROC)load(userptr, "glBitmap"); + glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load(userptr, "glBlendFunc"); + glad_glCallList = (PFNGLCALLLISTPROC)load(userptr, "glCallList"); + glad_glCallLists = (PFNGLCALLLISTSPROC)load(userptr, "glCallLists"); + glad_glClear = (PFNGLCLEARPROC)load(userptr, "glClear"); + glad_glClearAccum = (PFNGLCLEARACCUMPROC)load(userptr, "glClearAccum"); + glad_glClearColor = (PFNGLCLEARCOLORPROC)load(userptr, "glClearColor"); + glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load(userptr, "glClearDepth"); + glad_glClearIndex = (PFNGLCLEARINDEXPROC)load(userptr, "glClearIndex"); + glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load(userptr, "glClearStencil"); + glad_glClipPlane = (PFNGLCLIPPLANEPROC)load(userptr, "glClipPlane"); + glad_glColor3b = (PFNGLCOLOR3BPROC)load(userptr, "glColor3b"); + glad_glColor3bv = (PFNGLCOLOR3BVPROC)load(userptr, "glColor3bv"); + glad_glColor3d = (PFNGLCOLOR3DPROC)load(userptr, "glColor3d"); + glad_glColor3dv = (PFNGLCOLOR3DVPROC)load(userptr, "glColor3dv"); + glad_glColor3f = (PFNGLCOLOR3FPROC)load(userptr, "glColor3f"); + glad_glColor3fv = (PFNGLCOLOR3FVPROC)load(userptr, "glColor3fv"); + glad_glColor3i = (PFNGLCOLOR3IPROC)load(userptr, "glColor3i"); + glad_glColor3iv = (PFNGLCOLOR3IVPROC)load(userptr, "glColor3iv"); + glad_glColor3s = (PFNGLCOLOR3SPROC)load(userptr, "glColor3s"); + glad_glColor3sv = (PFNGLCOLOR3SVPROC)load(userptr, "glColor3sv"); + glad_glColor3ub = (PFNGLCOLOR3UBPROC)load(userptr, "glColor3ub"); + glad_glColor3ubv = (PFNGLCOLOR3UBVPROC)load(userptr, "glColor3ubv"); + glad_glColor3ui = (PFNGLCOLOR3UIPROC)load(userptr, "glColor3ui"); + glad_glColor3uiv = (PFNGLCOLOR3UIVPROC)load(userptr, "glColor3uiv"); + glad_glColor3us = (PFNGLCOLOR3USPROC)load(userptr, "glColor3us"); + glad_glColor3usv = (PFNGLCOLOR3USVPROC)load(userptr, "glColor3usv"); + glad_glColor4b = (PFNGLCOLOR4BPROC)load(userptr, "glColor4b"); + glad_glColor4bv = (PFNGLCOLOR4BVPROC)load(userptr, "glColor4bv"); + glad_glColor4d = (PFNGLCOLOR4DPROC)load(userptr, "glColor4d"); + glad_glColor4dv = (PFNGLCOLOR4DVPROC)load(userptr, "glColor4dv"); + glad_glColor4f = (PFNGLCOLOR4FPROC)load(userptr, "glColor4f"); + glad_glColor4fv = (PFNGLCOLOR4FVPROC)load(userptr, "glColor4fv"); + glad_glColor4i = (PFNGLCOLOR4IPROC)load(userptr, "glColor4i"); + glad_glColor4iv = (PFNGLCOLOR4IVPROC)load(userptr, "glColor4iv"); + glad_glColor4s = (PFNGLCOLOR4SPROC)load(userptr, "glColor4s"); + glad_glColor4sv = (PFNGLCOLOR4SVPROC)load(userptr, "glColor4sv"); + glad_glColor4ub = (PFNGLCOLOR4UBPROC)load(userptr, "glColor4ub"); + glad_glColor4ubv = (PFNGLCOLOR4UBVPROC)load(userptr, "glColor4ubv"); + glad_glColor4ui = (PFNGLCOLOR4UIPROC)load(userptr, "glColor4ui"); + glad_glColor4uiv = (PFNGLCOLOR4UIVPROC)load(userptr, "glColor4uiv"); + glad_glColor4us = (PFNGLCOLOR4USPROC)load(userptr, "glColor4us"); + glad_glColor4usv = (PFNGLCOLOR4USVPROC)load(userptr, "glColor4usv"); + glad_glColorMask = (PFNGLCOLORMASKPROC)load(userptr, "glColorMask"); + glad_glColorMaterial = (PFNGLCOLORMATERIALPROC)load(userptr, "glColorMaterial"); + glad_glCopyPixels = (PFNGLCOPYPIXELSPROC)load(userptr, "glCopyPixels"); + glad_glCullFace = (PFNGLCULLFACEPROC)load(userptr, "glCullFace"); + glad_glDeleteLists = (PFNGLDELETELISTSPROC)load(userptr, "glDeleteLists"); + glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load(userptr, "glDepthFunc"); + glad_glDepthMask = (PFNGLDEPTHMASKPROC)load(userptr, "glDepthMask"); + glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load(userptr, "glDepthRange"); + glad_glDisable = (PFNGLDISABLEPROC)load(userptr, "glDisable"); + glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load(userptr, "glDrawBuffer"); + glad_glDrawPixels = (PFNGLDRAWPIXELSPROC)load(userptr, "glDrawPixels"); + glad_glEdgeFlag = (PFNGLEDGEFLAGPROC)load(userptr, "glEdgeFlag"); + glad_glEdgeFlagv = (PFNGLEDGEFLAGVPROC)load(userptr, "glEdgeFlagv"); + glad_glEnable = (PFNGLENABLEPROC)load(userptr, "glEnable"); + glad_glEnd = (PFNGLENDPROC)load(userptr, "glEnd"); + glad_glEndList = (PFNGLENDLISTPROC)load(userptr, "glEndList"); + glad_glEvalCoord1d = (PFNGLEVALCOORD1DPROC)load(userptr, "glEvalCoord1d"); + glad_glEvalCoord1dv = (PFNGLEVALCOORD1DVPROC)load(userptr, "glEvalCoord1dv"); + glad_glEvalCoord1f = (PFNGLEVALCOORD1FPROC)load(userptr, "glEvalCoord1f"); + glad_glEvalCoord1fv = (PFNGLEVALCOORD1FVPROC)load(userptr, "glEvalCoord1fv"); + glad_glEvalCoord2d = (PFNGLEVALCOORD2DPROC)load(userptr, "glEvalCoord2d"); + glad_glEvalCoord2dv = (PFNGLEVALCOORD2DVPROC)load(userptr, "glEvalCoord2dv"); + glad_glEvalCoord2f = (PFNGLEVALCOORD2FPROC)load(userptr, "glEvalCoord2f"); + glad_glEvalCoord2fv = (PFNGLEVALCOORD2FVPROC)load(userptr, "glEvalCoord2fv"); + glad_glEvalMesh1 = (PFNGLEVALMESH1PROC)load(userptr, "glEvalMesh1"); + glad_glEvalMesh2 = (PFNGLEVALMESH2PROC)load(userptr, "glEvalMesh2"); + glad_glEvalPoint1 = (PFNGLEVALPOINT1PROC)load(userptr, "glEvalPoint1"); + glad_glEvalPoint2 = (PFNGLEVALPOINT2PROC)load(userptr, "glEvalPoint2"); + glad_glFeedbackBuffer = (PFNGLFEEDBACKBUFFERPROC)load(userptr, "glFeedbackBuffer"); + glad_glFinish = (PFNGLFINISHPROC)load(userptr, "glFinish"); + glad_glFlush = (PFNGLFLUSHPROC)load(userptr, "glFlush"); + glad_glFogf = (PFNGLFOGFPROC)load(userptr, "glFogf"); + glad_glFogfv = (PFNGLFOGFVPROC)load(userptr, "glFogfv"); + glad_glFogi = (PFNGLFOGIPROC)load(userptr, "glFogi"); + glad_glFogiv = (PFNGLFOGIVPROC)load(userptr, "glFogiv"); + glad_glFrontFace = (PFNGLFRONTFACEPROC)load(userptr, "glFrontFace"); + glad_glFrustum = (PFNGLFRUSTUMPROC)load(userptr, "glFrustum"); + glad_glGenLists = (PFNGLGENLISTSPROC)load(userptr, "glGenLists"); + glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load(userptr, "glGetBooleanv"); + glad_glGetClipPlane = (PFNGLGETCLIPPLANEPROC)load(userptr, "glGetClipPlane"); + glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load(userptr, "glGetDoublev"); + glad_glGetError = (PFNGLGETERRORPROC)load(userptr, "glGetError"); + glad_glGetFloatv = (PFNGLGETFLOATVPROC)load(userptr, "glGetFloatv"); + glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load(userptr, "glGetIntegerv"); + glad_glGetLightfv = (PFNGLGETLIGHTFVPROC)load(userptr, "glGetLightfv"); + glad_glGetLightiv = (PFNGLGETLIGHTIVPROC)load(userptr, "glGetLightiv"); + glad_glGetMapdv = (PFNGLGETMAPDVPROC)load(userptr, "glGetMapdv"); + glad_glGetMapfv = (PFNGLGETMAPFVPROC)load(userptr, "glGetMapfv"); + glad_glGetMapiv = (PFNGLGETMAPIVPROC)load(userptr, "glGetMapiv"); + glad_glGetMaterialfv = (PFNGLGETMATERIALFVPROC)load(userptr, "glGetMaterialfv"); + glad_glGetMaterialiv = (PFNGLGETMATERIALIVPROC)load(userptr, "glGetMaterialiv"); + glad_glGetPixelMapfv = (PFNGLGETPIXELMAPFVPROC)load(userptr, "glGetPixelMapfv"); + glad_glGetPixelMapuiv = (PFNGLGETPIXELMAPUIVPROC)load(userptr, "glGetPixelMapuiv"); + glad_glGetPixelMapusv = (PFNGLGETPIXELMAPUSVPROC)load(userptr, "glGetPixelMapusv"); + glad_glGetPolygonStipple = (PFNGLGETPOLYGONSTIPPLEPROC)load(userptr, "glGetPolygonStipple"); + glad_glGetString = (PFNGLGETSTRINGPROC)load(userptr, "glGetString"); + glad_glGetTexEnvfv = (PFNGLGETTEXENVFVPROC)load(userptr, "glGetTexEnvfv"); + glad_glGetTexEnviv = (PFNGLGETTEXENVIVPROC)load(userptr, "glGetTexEnviv"); + glad_glGetTexGendv = (PFNGLGETTEXGENDVPROC)load(userptr, "glGetTexGendv"); + glad_glGetTexGenfv = (PFNGLGETTEXGENFVPROC)load(userptr, "glGetTexGenfv"); + glad_glGetTexGeniv = (PFNGLGETTEXGENIVPROC)load(userptr, "glGetTexGeniv"); + glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load(userptr, "glGetTexImage"); + glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load(userptr, "glGetTexLevelParameterfv"); + glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load(userptr, "glGetTexLevelParameteriv"); + glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load(userptr, "glGetTexParameterfv"); + glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load(userptr, "glGetTexParameteriv"); + glad_glHint = (PFNGLHINTPROC)load(userptr, "glHint"); + glad_glIndexMask = (PFNGLINDEXMASKPROC)load(userptr, "glIndexMask"); + glad_glIndexd = (PFNGLINDEXDPROC)load(userptr, "glIndexd"); + glad_glIndexdv = (PFNGLINDEXDVPROC)load(userptr, "glIndexdv"); + glad_glIndexf = (PFNGLINDEXFPROC)load(userptr, "glIndexf"); + glad_glIndexfv = (PFNGLINDEXFVPROC)load(userptr, "glIndexfv"); + glad_glIndexi = (PFNGLINDEXIPROC)load(userptr, "glIndexi"); + glad_glIndexiv = (PFNGLINDEXIVPROC)load(userptr, "glIndexiv"); + glad_glIndexs = (PFNGLINDEXSPROC)load(userptr, "glIndexs"); + glad_glIndexsv = (PFNGLINDEXSVPROC)load(userptr, "glIndexsv"); + glad_glInitNames = (PFNGLINITNAMESPROC)load(userptr, "glInitNames"); + glad_glIsEnabled = (PFNGLISENABLEDPROC)load(userptr, "glIsEnabled"); + glad_glIsList = (PFNGLISLISTPROC)load(userptr, "glIsList"); + glad_glLightModelf = (PFNGLLIGHTMODELFPROC)load(userptr, "glLightModelf"); + glad_glLightModelfv = (PFNGLLIGHTMODELFVPROC)load(userptr, "glLightModelfv"); + glad_glLightModeli = (PFNGLLIGHTMODELIPROC)load(userptr, "glLightModeli"); + glad_glLightModeliv = (PFNGLLIGHTMODELIVPROC)load(userptr, "glLightModeliv"); + glad_glLightf = (PFNGLLIGHTFPROC)load(userptr, "glLightf"); + glad_glLightfv = (PFNGLLIGHTFVPROC)load(userptr, "glLightfv"); + glad_glLighti = (PFNGLLIGHTIPROC)load(userptr, "glLighti"); + glad_glLightiv = (PFNGLLIGHTIVPROC)load(userptr, "glLightiv"); + glad_glLineStipple = (PFNGLLINESTIPPLEPROC)load(userptr, "glLineStipple"); + glad_glLineWidth = (PFNGLLINEWIDTHPROC)load(userptr, "glLineWidth"); + glad_glListBase = (PFNGLLISTBASEPROC)load(userptr, "glListBase"); + glad_glLoadIdentity = (PFNGLLOADIDENTITYPROC)load(userptr, "glLoadIdentity"); + glad_glLoadMatrixd = (PFNGLLOADMATRIXDPROC)load(userptr, "glLoadMatrixd"); + glad_glLoadMatrixf = (PFNGLLOADMATRIXFPROC)load(userptr, "glLoadMatrixf"); + glad_glLoadName = (PFNGLLOADNAMEPROC)load(userptr, "glLoadName"); + glad_glLogicOp = (PFNGLLOGICOPPROC)load(userptr, "glLogicOp"); + glad_glMap1d = (PFNGLMAP1DPROC)load(userptr, "glMap1d"); + glad_glMap1f = (PFNGLMAP1FPROC)load(userptr, "glMap1f"); + glad_glMap2d = (PFNGLMAP2DPROC)load(userptr, "glMap2d"); + glad_glMap2f = (PFNGLMAP2FPROC)load(userptr, "glMap2f"); + glad_glMapGrid1d = (PFNGLMAPGRID1DPROC)load(userptr, "glMapGrid1d"); + glad_glMapGrid1f = (PFNGLMAPGRID1FPROC)load(userptr, "glMapGrid1f"); + glad_glMapGrid2d = (PFNGLMAPGRID2DPROC)load(userptr, "glMapGrid2d"); + glad_glMapGrid2f = (PFNGLMAPGRID2FPROC)load(userptr, "glMapGrid2f"); + glad_glMaterialf = (PFNGLMATERIALFPROC)load(userptr, "glMaterialf"); + glad_glMaterialfv = (PFNGLMATERIALFVPROC)load(userptr, "glMaterialfv"); + glad_glMateriali = (PFNGLMATERIALIPROC)load(userptr, "glMateriali"); + glad_glMaterialiv = (PFNGLMATERIALIVPROC)load(userptr, "glMaterialiv"); + glad_glMatrixMode = (PFNGLMATRIXMODEPROC)load(userptr, "glMatrixMode"); + glad_glMultMatrixd = (PFNGLMULTMATRIXDPROC)load(userptr, "glMultMatrixd"); + glad_glMultMatrixf = (PFNGLMULTMATRIXFPROC)load(userptr, "glMultMatrixf"); + glad_glNewList = (PFNGLNEWLISTPROC)load(userptr, "glNewList"); + glad_glNormal3b = (PFNGLNORMAL3BPROC)load(userptr, "glNormal3b"); + glad_glNormal3bv = (PFNGLNORMAL3BVPROC)load(userptr, "glNormal3bv"); + glad_glNormal3d = (PFNGLNORMAL3DPROC)load(userptr, "glNormal3d"); + glad_glNormal3dv = (PFNGLNORMAL3DVPROC)load(userptr, "glNormal3dv"); + glad_glNormal3f = (PFNGLNORMAL3FPROC)load(userptr, "glNormal3f"); + glad_glNormal3fv = (PFNGLNORMAL3FVPROC)load(userptr, "glNormal3fv"); + glad_glNormal3i = (PFNGLNORMAL3IPROC)load(userptr, "glNormal3i"); + glad_glNormal3iv = (PFNGLNORMAL3IVPROC)load(userptr, "glNormal3iv"); + glad_glNormal3s = (PFNGLNORMAL3SPROC)load(userptr, "glNormal3s"); + glad_glNormal3sv = (PFNGLNORMAL3SVPROC)load(userptr, "glNormal3sv"); + glad_glOrtho = (PFNGLORTHOPROC)load(userptr, "glOrtho"); + glad_glPassThrough = (PFNGLPASSTHROUGHPROC)load(userptr, "glPassThrough"); + glad_glPixelMapfv = (PFNGLPIXELMAPFVPROC)load(userptr, "glPixelMapfv"); + glad_glPixelMapuiv = (PFNGLPIXELMAPUIVPROC)load(userptr, "glPixelMapuiv"); + glad_glPixelMapusv = (PFNGLPIXELMAPUSVPROC)load(userptr, "glPixelMapusv"); + glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load(userptr, "glPixelStoref"); + glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load(userptr, "glPixelStorei"); + glad_glPixelTransferf = (PFNGLPIXELTRANSFERFPROC)load(userptr, "glPixelTransferf"); + glad_glPixelTransferi = (PFNGLPIXELTRANSFERIPROC)load(userptr, "glPixelTransferi"); + glad_glPixelZoom = (PFNGLPIXELZOOMPROC)load(userptr, "glPixelZoom"); + glad_glPointSize = (PFNGLPOINTSIZEPROC)load(userptr, "glPointSize"); + glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load(userptr, "glPolygonMode"); + glad_glPolygonStipple = (PFNGLPOLYGONSTIPPLEPROC)load(userptr, "glPolygonStipple"); + glad_glPopAttrib = (PFNGLPOPATTRIBPROC)load(userptr, "glPopAttrib"); + glad_glPopMatrix = (PFNGLPOPMATRIXPROC)load(userptr, "glPopMatrix"); + glad_glPopName = (PFNGLPOPNAMEPROC)load(userptr, "glPopName"); + glad_glPushAttrib = (PFNGLPUSHATTRIBPROC)load(userptr, "glPushAttrib"); + glad_glPushMatrix = (PFNGLPUSHMATRIXPROC)load(userptr, "glPushMatrix"); + glad_glPushName = (PFNGLPUSHNAMEPROC)load(userptr, "glPushName"); + glad_glRasterPos2d = (PFNGLRASTERPOS2DPROC)load(userptr, "glRasterPos2d"); + glad_glRasterPos2dv = (PFNGLRASTERPOS2DVPROC)load(userptr, "glRasterPos2dv"); + glad_glRasterPos2f = (PFNGLRASTERPOS2FPROC)load(userptr, "glRasterPos2f"); + glad_glRasterPos2fv = (PFNGLRASTERPOS2FVPROC)load(userptr, "glRasterPos2fv"); + glad_glRasterPos2i = (PFNGLRASTERPOS2IPROC)load(userptr, "glRasterPos2i"); + glad_glRasterPos2iv = (PFNGLRASTERPOS2IVPROC)load(userptr, "glRasterPos2iv"); + glad_glRasterPos2s = (PFNGLRASTERPOS2SPROC)load(userptr, "glRasterPos2s"); + glad_glRasterPos2sv = (PFNGLRASTERPOS2SVPROC)load(userptr, "glRasterPos2sv"); + glad_glRasterPos3d = (PFNGLRASTERPOS3DPROC)load(userptr, "glRasterPos3d"); + glad_glRasterPos3dv = (PFNGLRASTERPOS3DVPROC)load(userptr, "glRasterPos3dv"); + glad_glRasterPos3f = (PFNGLRASTERPOS3FPROC)load(userptr, "glRasterPos3f"); + glad_glRasterPos3fv = (PFNGLRASTERPOS3FVPROC)load(userptr, "glRasterPos3fv"); + glad_glRasterPos3i = (PFNGLRASTERPOS3IPROC)load(userptr, "glRasterPos3i"); + glad_glRasterPos3iv = (PFNGLRASTERPOS3IVPROC)load(userptr, "glRasterPos3iv"); + glad_glRasterPos3s = (PFNGLRASTERPOS3SPROC)load(userptr, "glRasterPos3s"); + glad_glRasterPos3sv = (PFNGLRASTERPOS3SVPROC)load(userptr, "glRasterPos3sv"); + glad_glRasterPos4d = (PFNGLRASTERPOS4DPROC)load(userptr, "glRasterPos4d"); + glad_glRasterPos4dv = (PFNGLRASTERPOS4DVPROC)load(userptr, "glRasterPos4dv"); + glad_glRasterPos4f = (PFNGLRASTERPOS4FPROC)load(userptr, "glRasterPos4f"); + glad_glRasterPos4fv = (PFNGLRASTERPOS4FVPROC)load(userptr, "glRasterPos4fv"); + glad_glRasterPos4i = (PFNGLRASTERPOS4IPROC)load(userptr, "glRasterPos4i"); + glad_glRasterPos4iv = (PFNGLRASTERPOS4IVPROC)load(userptr, "glRasterPos4iv"); + glad_glRasterPos4s = (PFNGLRASTERPOS4SPROC)load(userptr, "glRasterPos4s"); + glad_glRasterPos4sv = (PFNGLRASTERPOS4SVPROC)load(userptr, "glRasterPos4sv"); + glad_glReadBuffer = (PFNGLREADBUFFERPROC)load(userptr, "glReadBuffer"); + glad_glReadPixels = (PFNGLREADPIXELSPROC)load(userptr, "glReadPixels"); + glad_glRectd = (PFNGLRECTDPROC)load(userptr, "glRectd"); + glad_glRectdv = (PFNGLRECTDVPROC)load(userptr, "glRectdv"); + glad_glRectf = (PFNGLRECTFPROC)load(userptr, "glRectf"); + glad_glRectfv = (PFNGLRECTFVPROC)load(userptr, "glRectfv"); + glad_glRecti = (PFNGLRECTIPROC)load(userptr, "glRecti"); + glad_glRectiv = (PFNGLRECTIVPROC)load(userptr, "glRectiv"); + glad_glRects = (PFNGLRECTSPROC)load(userptr, "glRects"); + glad_glRectsv = (PFNGLRECTSVPROC)load(userptr, "glRectsv"); + glad_glRenderMode = (PFNGLRENDERMODEPROC)load(userptr, "glRenderMode"); + glad_glRotated = (PFNGLROTATEDPROC)load(userptr, "glRotated"); + glad_glRotatef = (PFNGLROTATEFPROC)load(userptr, "glRotatef"); + glad_glScaled = (PFNGLSCALEDPROC)load(userptr, "glScaled"); + glad_glScalef = (PFNGLSCALEFPROC)load(userptr, "glScalef"); + glad_glScissor = (PFNGLSCISSORPROC)load(userptr, "glScissor"); + glad_glSelectBuffer = (PFNGLSELECTBUFFERPROC)load(userptr, "glSelectBuffer"); + glad_glShadeModel = (PFNGLSHADEMODELPROC)load(userptr, "glShadeModel"); + glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load(userptr, "glStencilFunc"); + glad_glStencilMask = (PFNGLSTENCILMASKPROC)load(userptr, "glStencilMask"); + glad_glStencilOp = (PFNGLSTENCILOPPROC)load(userptr, "glStencilOp"); + glad_glTexCoord1d = (PFNGLTEXCOORD1DPROC)load(userptr, "glTexCoord1d"); + glad_glTexCoord1dv = (PFNGLTEXCOORD1DVPROC)load(userptr, "glTexCoord1dv"); + glad_glTexCoord1f = (PFNGLTEXCOORD1FPROC)load(userptr, "glTexCoord1f"); + glad_glTexCoord1fv = (PFNGLTEXCOORD1FVPROC)load(userptr, "glTexCoord1fv"); + glad_glTexCoord1i = (PFNGLTEXCOORD1IPROC)load(userptr, "glTexCoord1i"); + glad_glTexCoord1iv = (PFNGLTEXCOORD1IVPROC)load(userptr, "glTexCoord1iv"); + glad_glTexCoord1s = (PFNGLTEXCOORD1SPROC)load(userptr, "glTexCoord1s"); + glad_glTexCoord1sv = (PFNGLTEXCOORD1SVPROC)load(userptr, "glTexCoord1sv"); + glad_glTexCoord2d = (PFNGLTEXCOORD2DPROC)load(userptr, "glTexCoord2d"); + glad_glTexCoord2dv = (PFNGLTEXCOORD2DVPROC)load(userptr, "glTexCoord2dv"); + glad_glTexCoord2f = (PFNGLTEXCOORD2FPROC)load(userptr, "glTexCoord2f"); + glad_glTexCoord2fv = (PFNGLTEXCOORD2FVPROC)load(userptr, "glTexCoord2fv"); + glad_glTexCoord2i = (PFNGLTEXCOORD2IPROC)load(userptr, "glTexCoord2i"); + glad_glTexCoord2iv = (PFNGLTEXCOORD2IVPROC)load(userptr, "glTexCoord2iv"); + glad_glTexCoord2s = (PFNGLTEXCOORD2SPROC)load(userptr, "glTexCoord2s"); + glad_glTexCoord2sv = (PFNGLTEXCOORD2SVPROC)load(userptr, "glTexCoord2sv"); + glad_glTexCoord3d = (PFNGLTEXCOORD3DPROC)load(userptr, "glTexCoord3d"); + glad_glTexCoord3dv = (PFNGLTEXCOORD3DVPROC)load(userptr, "glTexCoord3dv"); + glad_glTexCoord3f = (PFNGLTEXCOORD3FPROC)load(userptr, "glTexCoord3f"); + glad_glTexCoord3fv = (PFNGLTEXCOORD3FVPROC)load(userptr, "glTexCoord3fv"); + glad_glTexCoord3i = (PFNGLTEXCOORD3IPROC)load(userptr, "glTexCoord3i"); + glad_glTexCoord3iv = (PFNGLTEXCOORD3IVPROC)load(userptr, "glTexCoord3iv"); + glad_glTexCoord3s = (PFNGLTEXCOORD3SPROC)load(userptr, "glTexCoord3s"); + glad_glTexCoord3sv = (PFNGLTEXCOORD3SVPROC)load(userptr, "glTexCoord3sv"); + glad_glTexCoord4d = (PFNGLTEXCOORD4DPROC)load(userptr, "glTexCoord4d"); + glad_glTexCoord4dv = (PFNGLTEXCOORD4DVPROC)load(userptr, "glTexCoord4dv"); + glad_glTexCoord4f = (PFNGLTEXCOORD4FPROC)load(userptr, "glTexCoord4f"); + glad_glTexCoord4fv = (PFNGLTEXCOORD4FVPROC)load(userptr, "glTexCoord4fv"); + glad_glTexCoord4i = (PFNGLTEXCOORD4IPROC)load(userptr, "glTexCoord4i"); + glad_glTexCoord4iv = (PFNGLTEXCOORD4IVPROC)load(userptr, "glTexCoord4iv"); + glad_glTexCoord4s = (PFNGLTEXCOORD4SPROC)load(userptr, "glTexCoord4s"); + glad_glTexCoord4sv = (PFNGLTEXCOORD4SVPROC)load(userptr, "glTexCoord4sv"); + glad_glTexEnvf = (PFNGLTEXENVFPROC)load(userptr, "glTexEnvf"); + glad_glTexEnvfv = (PFNGLTEXENVFVPROC)load(userptr, "glTexEnvfv"); + glad_glTexEnvi = (PFNGLTEXENVIPROC)load(userptr, "glTexEnvi"); + glad_glTexEnviv = (PFNGLTEXENVIVPROC)load(userptr, "glTexEnviv"); + glad_glTexGend = (PFNGLTEXGENDPROC)load(userptr, "glTexGend"); + glad_glTexGendv = (PFNGLTEXGENDVPROC)load(userptr, "glTexGendv"); + glad_glTexGenf = (PFNGLTEXGENFPROC)load(userptr, "glTexGenf"); + glad_glTexGenfv = (PFNGLTEXGENFVPROC)load(userptr, "glTexGenfv"); + glad_glTexGeni = (PFNGLTEXGENIPROC)load(userptr, "glTexGeni"); + glad_glTexGeniv = (PFNGLTEXGENIVPROC)load(userptr, "glTexGeniv"); + glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load(userptr, "glTexImage1D"); + glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load(userptr, "glTexImage2D"); + glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load(userptr, "glTexParameterf"); + glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load(userptr, "glTexParameterfv"); + glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load(userptr, "glTexParameteri"); + glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load(userptr, "glTexParameteriv"); + glad_glTranslated = (PFNGLTRANSLATEDPROC)load(userptr, "glTranslated"); + glad_glTranslatef = (PFNGLTRANSLATEFPROC)load(userptr, "glTranslatef"); + glad_glVertex2d = (PFNGLVERTEX2DPROC)load(userptr, "glVertex2d"); + glad_glVertex2dv = (PFNGLVERTEX2DVPROC)load(userptr, "glVertex2dv"); + glad_glVertex2f = (PFNGLVERTEX2FPROC)load(userptr, "glVertex2f"); + glad_glVertex2fv = (PFNGLVERTEX2FVPROC)load(userptr, "glVertex2fv"); + glad_glVertex2i = (PFNGLVERTEX2IPROC)load(userptr, "glVertex2i"); + glad_glVertex2iv = (PFNGLVERTEX2IVPROC)load(userptr, "glVertex2iv"); + glad_glVertex2s = (PFNGLVERTEX2SPROC)load(userptr, "glVertex2s"); + glad_glVertex2sv = (PFNGLVERTEX2SVPROC)load(userptr, "glVertex2sv"); + glad_glVertex3d = (PFNGLVERTEX3DPROC)load(userptr, "glVertex3d"); + glad_glVertex3dv = (PFNGLVERTEX3DVPROC)load(userptr, "glVertex3dv"); + glad_glVertex3f = (PFNGLVERTEX3FPROC)load(userptr, "glVertex3f"); + glad_glVertex3fv = (PFNGLVERTEX3FVPROC)load(userptr, "glVertex3fv"); + glad_glVertex3i = (PFNGLVERTEX3IPROC)load(userptr, "glVertex3i"); + glad_glVertex3iv = (PFNGLVERTEX3IVPROC)load(userptr, "glVertex3iv"); + glad_glVertex3s = (PFNGLVERTEX3SPROC)load(userptr, "glVertex3s"); + glad_glVertex3sv = (PFNGLVERTEX3SVPROC)load(userptr, "glVertex3sv"); + glad_glVertex4d = (PFNGLVERTEX4DPROC)load(userptr, "glVertex4d"); + glad_glVertex4dv = (PFNGLVERTEX4DVPROC)load(userptr, "glVertex4dv"); + glad_glVertex4f = (PFNGLVERTEX4FPROC)load(userptr, "glVertex4f"); + glad_glVertex4fv = (PFNGLVERTEX4FVPROC)load(userptr, "glVertex4fv"); + glad_glVertex4i = (PFNGLVERTEX4IPROC)load(userptr, "glVertex4i"); + glad_glVertex4iv = (PFNGLVERTEX4IVPROC)load(userptr, "glVertex4iv"); + glad_glVertex4s = (PFNGLVERTEX4SPROC)load(userptr, "glVertex4s"); + glad_glVertex4sv = (PFNGLVERTEX4SVPROC)load(userptr, "glVertex4sv"); + glad_glViewport = (PFNGLVIEWPORTPROC)load(userptr, "glViewport"); } -static void glad_gl_load_GL_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_1) return; - glad_glAreTexturesResident = (PFNGLARETEXTURESRESIDENTPROC) load(userptr, "glAreTexturesResident"); - glad_glArrayElement = (PFNGLARRAYELEMENTPROC) load(userptr, "glArrayElement"); - glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture"); - glad_glColorPointer = (PFNGLCOLORPOINTERPROC) load(userptr, "glColorPointer"); - glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load(userptr, "glCopyTexImage1D"); - glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D"); - glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load(userptr, "glCopyTexSubImage1D"); - glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D"); - glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures"); - glad_glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC) load(userptr, "glDisableClientState"); - glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays"); - glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements"); - glad_glEdgeFlagPointer = (PFNGLEDGEFLAGPOINTERPROC) load(userptr, "glEdgeFlagPointer"); - glad_glEnableClientState = (PFNGLENABLECLIENTSTATEPROC) load(userptr, "glEnableClientState"); - glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures"); - glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv"); - glad_glIndexPointer = (PFNGLINDEXPOINTERPROC) load(userptr, "glIndexPointer"); - glad_glIndexub = (PFNGLINDEXUBPROC) load(userptr, "glIndexub"); - glad_glIndexubv = (PFNGLINDEXUBVPROC) load(userptr, "glIndexubv"); - glad_glInterleavedArrays = (PFNGLINTERLEAVEDARRAYSPROC) load(userptr, "glInterleavedArrays"); - glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture"); - glad_glNormalPointer = (PFNGLNORMALPOINTERPROC) load(userptr, "glNormalPointer"); - glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset"); - glad_glPopClientAttrib = (PFNGLPOPCLIENTATTRIBPROC) load(userptr, "glPopClientAttrib"); - glad_glPrioritizeTextures = (PFNGLPRIORITIZETEXTURESPROC) load(userptr, "glPrioritizeTextures"); - glad_glPushClientAttrib = (PFNGLPUSHCLIENTATTRIBPROC) load(userptr, "glPushClientAttrib"); - glad_glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC) load(userptr, "glTexCoordPointer"); - glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load(userptr, "glTexSubImage1D"); - glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D"); - glad_glVertexPointer = (PFNGLVERTEXPOINTERPROC) load(userptr, "glVertexPointer"); +static void glad_gl_load_GL_VERSION_1_1(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_1_1) return; + glad_glAreTexturesResident = (PFNGLARETEXTURESRESIDENTPROC)load(userptr, "glAreTexturesResident"); + glad_glArrayElement = (PFNGLARRAYELEMENTPROC)load(userptr, "glArrayElement"); + glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load(userptr, "glBindTexture"); + glad_glColorPointer = (PFNGLCOLORPOINTERPROC)load(userptr, "glColorPointer"); + glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load(userptr, "glCopyTexImage1D"); + glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load(userptr, "glCopyTexImage2D"); + glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load(userptr, "glCopyTexSubImage1D"); + glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load(userptr, "glCopyTexSubImage2D"); + glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load(userptr, "glDeleteTextures"); + glad_glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC)load(userptr, "glDisableClientState"); + glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load(userptr, "glDrawArrays"); + glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load(userptr, "glDrawElements"); + glad_glEdgeFlagPointer = (PFNGLEDGEFLAGPOINTERPROC)load(userptr, "glEdgeFlagPointer"); + glad_glEnableClientState = (PFNGLENABLECLIENTSTATEPROC)load(userptr, "glEnableClientState"); + glad_glGenTextures = (PFNGLGENTEXTURESPROC)load(userptr, "glGenTextures"); + glad_glGetPointerv = (PFNGLGETPOINTERVPROC)load(userptr, "glGetPointerv"); + glad_glIndexPointer = (PFNGLINDEXPOINTERPROC)load(userptr, "glIndexPointer"); + glad_glIndexub = (PFNGLINDEXUBPROC)load(userptr, "glIndexub"); + glad_glIndexubv = (PFNGLINDEXUBVPROC)load(userptr, "glIndexubv"); + glad_glInterleavedArrays = (PFNGLINTERLEAVEDARRAYSPROC)load(userptr, "glInterleavedArrays"); + glad_glIsTexture = (PFNGLISTEXTUREPROC)load(userptr, "glIsTexture"); + glad_glNormalPointer = (PFNGLNORMALPOINTERPROC)load(userptr, "glNormalPointer"); + glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load(userptr, "glPolygonOffset"); + glad_glPopClientAttrib = (PFNGLPOPCLIENTATTRIBPROC)load(userptr, "glPopClientAttrib"); + glad_glPrioritizeTextures = (PFNGLPRIORITIZETEXTURESPROC)load(userptr, "glPrioritizeTextures"); + glad_glPushClientAttrib = (PFNGLPUSHCLIENTATTRIBPROC)load(userptr, "glPushClientAttrib"); + glad_glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC)load(userptr, "glTexCoordPointer"); + glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load(userptr, "glTexSubImage1D"); + glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load(userptr, "glTexSubImage2D"); + glad_glVertexPointer = (PFNGLVERTEXPOINTERPROC)load(userptr, "glVertexPointer"); } -static void glad_gl_load_GL_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_2) return; - glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load(userptr, "glCopyTexSubImage3D"); - glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load(userptr, "glDrawRangeElements"); - glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC) load(userptr, "glTexImage3D"); - glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load(userptr, "glTexSubImage3D"); +static void glad_gl_load_GL_VERSION_1_2(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_1_2) return; + glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load(userptr, "glCopyTexSubImage3D"); + glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load(userptr, "glDrawRangeElements"); + glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load(userptr, "glTexImage3D"); + glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load(userptr, "glTexSubImage3D"); } -static void glad_gl_load_GL_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_3) return; - glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture"); - glad_glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC) load(userptr, "glClientActiveTexture"); - glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load(userptr, "glCompressedTexImage1D"); - glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D"); - glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load(userptr, "glCompressedTexImage3D"); - glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load(userptr, "glCompressedTexSubImage1D"); - glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D"); - glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load(userptr, "glCompressedTexSubImage3D"); - glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load(userptr, "glGetCompressedTexImage"); - glad_glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC) load(userptr, "glLoadTransposeMatrixd"); - glad_glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC) load(userptr, "glLoadTransposeMatrixf"); - glad_glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC) load(userptr, "glMultTransposeMatrixd"); - glad_glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC) load(userptr, "glMultTransposeMatrixf"); - glad_glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC) load(userptr, "glMultiTexCoord1d"); - glad_glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC) load(userptr, "glMultiTexCoord1dv"); - glad_glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC) load(userptr, "glMultiTexCoord1f"); - glad_glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC) load(userptr, "glMultiTexCoord1fv"); - glad_glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC) load(userptr, "glMultiTexCoord1i"); - glad_glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC) load(userptr, "glMultiTexCoord1iv"); - glad_glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC) load(userptr, "glMultiTexCoord1s"); - glad_glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC) load(userptr, "glMultiTexCoord1sv"); - glad_glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC) load(userptr, "glMultiTexCoord2d"); - glad_glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC) load(userptr, "glMultiTexCoord2dv"); - glad_glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) load(userptr, "glMultiTexCoord2f"); - glad_glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) load(userptr, "glMultiTexCoord2fv"); - glad_glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC) load(userptr, "glMultiTexCoord2i"); - glad_glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC) load(userptr, "glMultiTexCoord2iv"); - glad_glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC) load(userptr, "glMultiTexCoord2s"); - glad_glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC) load(userptr, "glMultiTexCoord2sv"); - glad_glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC) load(userptr, "glMultiTexCoord3d"); - glad_glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC) load(userptr, "glMultiTexCoord3dv"); - glad_glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC) load(userptr, "glMultiTexCoord3f"); - glad_glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC) load(userptr, "glMultiTexCoord3fv"); - glad_glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC) load(userptr, "glMultiTexCoord3i"); - glad_glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC) load(userptr, "glMultiTexCoord3iv"); - glad_glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC) load(userptr, "glMultiTexCoord3s"); - glad_glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC) load(userptr, "glMultiTexCoord3sv"); - glad_glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) load(userptr, "glMultiTexCoord4d"); - glad_glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC) load(userptr, "glMultiTexCoord4dv"); - glad_glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) load(userptr, "glMultiTexCoord4f"); - glad_glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC) load(userptr, "glMultiTexCoord4fv"); - glad_glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC) load(userptr, "glMultiTexCoord4i"); - glad_glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC) load(userptr, "glMultiTexCoord4iv"); - glad_glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC) load(userptr, "glMultiTexCoord4s"); - glad_glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC) load(userptr, "glMultiTexCoord4sv"); - glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage"); +static void glad_gl_load_GL_VERSION_1_3(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_1_3) return; + glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load(userptr, "glActiveTexture"); + glad_glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)load(userptr, "glClientActiveTexture"); + glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load(userptr, "glCompressedTexImage1D"); + glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load(userptr, "glCompressedTexImage2D"); + glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load(userptr, "glCompressedTexImage3D"); + glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load(userptr, "glCompressedTexSubImage1D"); + glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load(userptr, "glCompressedTexSubImage2D"); + glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load(userptr, "glCompressedTexSubImage3D"); + glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load(userptr, "glGetCompressedTexImage"); + glad_glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC)load(userptr, "glLoadTransposeMatrixd"); + glad_glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC)load(userptr, "glLoadTransposeMatrixf"); + glad_glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC)load(userptr, "glMultTransposeMatrixd"); + glad_glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC)load(userptr, "glMultTransposeMatrixf"); + glad_glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC)load(userptr, "glMultiTexCoord1d"); + glad_glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC)load(userptr, "glMultiTexCoord1dv"); + glad_glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC)load(userptr, "glMultiTexCoord1f"); + glad_glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC)load(userptr, "glMultiTexCoord1fv"); + glad_glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC)load(userptr, "glMultiTexCoord1i"); + glad_glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC)load(userptr, "glMultiTexCoord1iv"); + glad_glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC)load(userptr, "glMultiTexCoord1s"); + glad_glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC)load(userptr, "glMultiTexCoord1sv"); + glad_glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC)load(userptr, "glMultiTexCoord2d"); + glad_glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC)load(userptr, "glMultiTexCoord2dv"); + glad_glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC)load(userptr, "glMultiTexCoord2f"); + glad_glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC)load(userptr, "glMultiTexCoord2fv"); + glad_glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC)load(userptr, "glMultiTexCoord2i"); + glad_glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC)load(userptr, "glMultiTexCoord2iv"); + glad_glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC)load(userptr, "glMultiTexCoord2s"); + glad_glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC)load(userptr, "glMultiTexCoord2sv"); + glad_glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC)load(userptr, "glMultiTexCoord3d"); + glad_glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC)load(userptr, "glMultiTexCoord3dv"); + glad_glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC)load(userptr, "glMultiTexCoord3f"); + glad_glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC)load(userptr, "glMultiTexCoord3fv"); + glad_glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC)load(userptr, "glMultiTexCoord3i"); + glad_glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC)load(userptr, "glMultiTexCoord3iv"); + glad_glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC)load(userptr, "glMultiTexCoord3s"); + glad_glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC)load(userptr, "glMultiTexCoord3sv"); + glad_glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC)load(userptr, "glMultiTexCoord4d"); + glad_glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC)load(userptr, "glMultiTexCoord4dv"); + glad_glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC)load(userptr, "glMultiTexCoord4f"); + glad_glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC)load(userptr, "glMultiTexCoord4fv"); + glad_glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC)load(userptr, "glMultiTexCoord4i"); + glad_glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC)load(userptr, "glMultiTexCoord4iv"); + glad_glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC)load(userptr, "glMultiTexCoord4s"); + glad_glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC)load(userptr, "glMultiTexCoord4sv"); + glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load(userptr, "glSampleCoverage"); } -static void glad_gl_load_GL_VERSION_1_4( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_4) return; - glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor"); - glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation"); - glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate"); - glad_glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC) load(userptr, "glFogCoordPointer"); - glad_glFogCoordd = (PFNGLFOGCOORDDPROC) load(userptr, "glFogCoordd"); - glad_glFogCoorddv = (PFNGLFOGCOORDDVPROC) load(userptr, "glFogCoorddv"); - glad_glFogCoordf = (PFNGLFOGCOORDFPROC) load(userptr, "glFogCoordf"); - glad_glFogCoordfv = (PFNGLFOGCOORDFVPROC) load(userptr, "glFogCoordfv"); - glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load(userptr, "glMultiDrawArrays"); - glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load(userptr, "glMultiDrawElements"); - glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load(userptr, "glPointParameterf"); - glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load(userptr, "glPointParameterfv"); - glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load(userptr, "glPointParameteri"); - glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load(userptr, "glPointParameteriv"); - glad_glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC) load(userptr, "glSecondaryColor3b"); - glad_glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC) load(userptr, "glSecondaryColor3bv"); - glad_glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC) load(userptr, "glSecondaryColor3d"); - glad_glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC) load(userptr, "glSecondaryColor3dv"); - glad_glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC) load(userptr, "glSecondaryColor3f"); - glad_glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC) load(userptr, "glSecondaryColor3fv"); - glad_glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC) load(userptr, "glSecondaryColor3i"); - glad_glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC) load(userptr, "glSecondaryColor3iv"); - glad_glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC) load(userptr, "glSecondaryColor3s"); - glad_glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC) load(userptr, "glSecondaryColor3sv"); - glad_glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC) load(userptr, "glSecondaryColor3ub"); - glad_glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC) load(userptr, "glSecondaryColor3ubv"); - glad_glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC) load(userptr, "glSecondaryColor3ui"); - glad_glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC) load(userptr, "glSecondaryColor3uiv"); - glad_glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC) load(userptr, "glSecondaryColor3us"); - glad_glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC) load(userptr, "glSecondaryColor3usv"); - glad_glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC) load(userptr, "glSecondaryColorPointer"); - glad_glWindowPos2d = (PFNGLWINDOWPOS2DPROC) load(userptr, "glWindowPos2d"); - glad_glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC) load(userptr, "glWindowPos2dv"); - glad_glWindowPos2f = (PFNGLWINDOWPOS2FPROC) load(userptr, "glWindowPos2f"); - glad_glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC) load(userptr, "glWindowPos2fv"); - glad_glWindowPos2i = (PFNGLWINDOWPOS2IPROC) load(userptr, "glWindowPos2i"); - glad_glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC) load(userptr, "glWindowPos2iv"); - glad_glWindowPos2s = (PFNGLWINDOWPOS2SPROC) load(userptr, "glWindowPos2s"); - glad_glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC) load(userptr, "glWindowPos2sv"); - glad_glWindowPos3d = (PFNGLWINDOWPOS3DPROC) load(userptr, "glWindowPos3d"); - glad_glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC) load(userptr, "glWindowPos3dv"); - glad_glWindowPos3f = (PFNGLWINDOWPOS3FPROC) load(userptr, "glWindowPos3f"); - glad_glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC) load(userptr, "glWindowPos3fv"); - glad_glWindowPos3i = (PFNGLWINDOWPOS3IPROC) load(userptr, "glWindowPos3i"); - glad_glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC) load(userptr, "glWindowPos3iv"); - glad_glWindowPos3s = (PFNGLWINDOWPOS3SPROC) load(userptr, "glWindowPos3s"); - glad_glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC) load(userptr, "glWindowPos3sv"); +static void glad_gl_load_GL_VERSION_1_4(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_1_4) return; + glad_glBlendColor = (PFNGLBLENDCOLORPROC)load(userptr, "glBlendColor"); + glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load(userptr, "glBlendEquation"); + glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load(userptr, "glBlendFuncSeparate"); + glad_glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC)load(userptr, "glFogCoordPointer"); + glad_glFogCoordd = (PFNGLFOGCOORDDPROC)load(userptr, "glFogCoordd"); + glad_glFogCoorddv = (PFNGLFOGCOORDDVPROC)load(userptr, "glFogCoorddv"); + glad_glFogCoordf = (PFNGLFOGCOORDFPROC)load(userptr, "glFogCoordf"); + glad_glFogCoordfv = (PFNGLFOGCOORDFVPROC)load(userptr, "glFogCoordfv"); + glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load(userptr, "glMultiDrawArrays"); + glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load(userptr, "glMultiDrawElements"); + glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load(userptr, "glPointParameterf"); + glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load(userptr, "glPointParameterfv"); + glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load(userptr, "glPointParameteri"); + glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load(userptr, "glPointParameteriv"); + glad_glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC)load(userptr, "glSecondaryColor3b"); + glad_glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC)load(userptr, "glSecondaryColor3bv"); + glad_glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC)load(userptr, "glSecondaryColor3d"); + glad_glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC)load(userptr, "glSecondaryColor3dv"); + glad_glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC)load(userptr, "glSecondaryColor3f"); + glad_glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC)load(userptr, "glSecondaryColor3fv"); + glad_glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC)load(userptr, "glSecondaryColor3i"); + glad_glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC)load(userptr, "glSecondaryColor3iv"); + glad_glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC)load(userptr, "glSecondaryColor3s"); + glad_glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC)load(userptr, "glSecondaryColor3sv"); + glad_glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC)load(userptr, "glSecondaryColor3ub"); + glad_glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC)load(userptr, "glSecondaryColor3ubv"); + glad_glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC)load(userptr, "glSecondaryColor3ui"); + glad_glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC)load(userptr, "glSecondaryColor3uiv"); + glad_glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC)load(userptr, "glSecondaryColor3us"); + glad_glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC)load(userptr, "glSecondaryColor3usv"); + glad_glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC)load(userptr, "glSecondaryColorPointer"); + glad_glWindowPos2d = (PFNGLWINDOWPOS2DPROC)load(userptr, "glWindowPos2d"); + glad_glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC)load(userptr, "glWindowPos2dv"); + glad_glWindowPos2f = (PFNGLWINDOWPOS2FPROC)load(userptr, "glWindowPos2f"); + glad_glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC)load(userptr, "glWindowPos2fv"); + glad_glWindowPos2i = (PFNGLWINDOWPOS2IPROC)load(userptr, "glWindowPos2i"); + glad_glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC)load(userptr, "glWindowPos2iv"); + glad_glWindowPos2s = (PFNGLWINDOWPOS2SPROC)load(userptr, "glWindowPos2s"); + glad_glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC)load(userptr, "glWindowPos2sv"); + glad_glWindowPos3d = (PFNGLWINDOWPOS3DPROC)load(userptr, "glWindowPos3d"); + glad_glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC)load(userptr, "glWindowPos3dv"); + glad_glWindowPos3f = (PFNGLWINDOWPOS3FPROC)load(userptr, "glWindowPos3f"); + glad_glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC)load(userptr, "glWindowPos3fv"); + glad_glWindowPos3i = (PFNGLWINDOWPOS3IPROC)load(userptr, "glWindowPos3i"); + glad_glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC)load(userptr, "glWindowPos3iv"); + glad_glWindowPos3s = (PFNGLWINDOWPOS3SPROC)load(userptr, "glWindowPos3s"); + glad_glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC)load(userptr, "glWindowPos3sv"); } -static void glad_gl_load_GL_VERSION_1_5( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_5) return; - glad_glBeginQuery = (PFNGLBEGINQUERYPROC) load(userptr, "glBeginQuery"); - glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer"); - glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData"); - glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData"); - glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers"); - glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC) load(userptr, "glDeleteQueries"); - glad_glEndQuery = (PFNGLENDQUERYPROC) load(userptr, "glEndQuery"); - glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers"); - glad_glGenQueries = (PFNGLGENQUERIESPROC) load(userptr, "glGenQueries"); - glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv"); - glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load(userptr, "glGetBufferPointerv"); - glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load(userptr, "glGetBufferSubData"); - glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load(userptr, "glGetQueryObjectiv"); - glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load(userptr, "glGetQueryObjectuiv"); - glad_glGetQueryiv = (PFNGLGETQUERYIVPROC) load(userptr, "glGetQueryiv"); - glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer"); - glad_glIsQuery = (PFNGLISQUERYPROC) load(userptr, "glIsQuery"); - glad_glMapBuffer = (PFNGLMAPBUFFERPROC) load(userptr, "glMapBuffer"); - glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load(userptr, "glUnmapBuffer"); +static void glad_gl_load_GL_VERSION_1_5(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_1_5) return; + glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load(userptr, "glBeginQuery"); + glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load(userptr, "glBindBuffer"); + glad_glBufferData = (PFNGLBUFFERDATAPROC)load(userptr, "glBufferData"); + glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load(userptr, "glBufferSubData"); + glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load(userptr, "glDeleteBuffers"); + glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load(userptr, "glDeleteQueries"); + glad_glEndQuery = (PFNGLENDQUERYPROC)load(userptr, "glEndQuery"); + glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load(userptr, "glGenBuffers"); + glad_glGenQueries = (PFNGLGENQUERIESPROC)load(userptr, "glGenQueries"); + glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load(userptr, "glGetBufferParameteriv"); + glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load(userptr, "glGetBufferPointerv"); + glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load(userptr, "glGetBufferSubData"); + glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load(userptr, "glGetQueryObjectiv"); + glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load(userptr, "glGetQueryObjectuiv"); + glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load(userptr, "glGetQueryiv"); + glad_glIsBuffer = (PFNGLISBUFFERPROC)load(userptr, "glIsBuffer"); + glad_glIsQuery = (PFNGLISQUERYPROC)load(userptr, "glIsQuery"); + glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load(userptr, "glMapBuffer"); + glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load(userptr, "glUnmapBuffer"); } -static void glad_gl_load_GL_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_2_0) return; - glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader"); - glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation"); - glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate"); - glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader"); - glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram"); - glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader"); - glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram"); - glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader"); - glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader"); - glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray"); - glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load(userptr, "glDrawBuffers"); - glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray"); - glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib"); - glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform"); - glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders"); - glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation"); - glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog"); - glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv"); - glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog"); - glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource"); - glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv"); - glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation"); - glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv"); - glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv"); - glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv"); - glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load(userptr, "glGetVertexAttribdv"); - glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv"); - glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv"); - glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram"); - glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader"); - glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram"); - glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource"); - glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate"); - glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate"); - glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate"); - glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f"); - glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv"); - glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i"); - glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv"); - glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f"); - glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv"); - glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i"); - glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv"); - glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f"); - glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv"); - glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i"); - glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv"); - glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f"); - glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv"); - glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i"); - glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv"); - glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv"); - glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv"); - glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv"); - glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram"); - glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram"); - glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load(userptr, "glVertexAttrib1d"); - glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load(userptr, "glVertexAttrib1dv"); - glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f"); - glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv"); - glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load(userptr, "glVertexAttrib1s"); - glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load(userptr, "glVertexAttrib1sv"); - glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load(userptr, "glVertexAttrib2d"); - glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load(userptr, "glVertexAttrib2dv"); - glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f"); - glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv"); - glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load(userptr, "glVertexAttrib2s"); - glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load(userptr, "glVertexAttrib2sv"); - glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load(userptr, "glVertexAttrib3d"); - glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load(userptr, "glVertexAttrib3dv"); - glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f"); - glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv"); - glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load(userptr, "glVertexAttrib3s"); - glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load(userptr, "glVertexAttrib3sv"); - glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load(userptr, "glVertexAttrib4Nbv"); - glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load(userptr, "glVertexAttrib4Niv"); - glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load(userptr, "glVertexAttrib4Nsv"); - glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load(userptr, "glVertexAttrib4Nub"); - glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load(userptr, "glVertexAttrib4Nubv"); - glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load(userptr, "glVertexAttrib4Nuiv"); - glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load(userptr, "glVertexAttrib4Nusv"); - glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load(userptr, "glVertexAttrib4bv"); - glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load(userptr, "glVertexAttrib4d"); - glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load(userptr, "glVertexAttrib4dv"); - glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f"); - glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv"); - glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load(userptr, "glVertexAttrib4iv"); - glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load(userptr, "glVertexAttrib4s"); - glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load(userptr, "glVertexAttrib4sv"); - glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load(userptr, "glVertexAttrib4ubv"); - glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load(userptr, "glVertexAttrib4uiv"); - glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load(userptr, "glVertexAttrib4usv"); - glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer"); +static void glad_gl_load_GL_VERSION_2_0(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_2_0) return; + glad_glAttachShader = (PFNGLATTACHSHADERPROC)load(userptr, "glAttachShader"); + glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load(userptr, "glBindAttribLocation"); + glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load(userptr, "glBlendEquationSeparate"); + glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load(userptr, "glCompileShader"); + glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load(userptr, "glCreateProgram"); + glad_glCreateShader = (PFNGLCREATESHADERPROC)load(userptr, "glCreateShader"); + glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load(userptr, "glDeleteProgram"); + glad_glDeleteShader = (PFNGLDELETESHADERPROC)load(userptr, "glDeleteShader"); + glad_glDetachShader = (PFNGLDETACHSHADERPROC)load(userptr, "glDetachShader"); + glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load(userptr, "glDisableVertexAttribArray"); + glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load(userptr, "glDrawBuffers"); + glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load(userptr, "glEnableVertexAttribArray"); + glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load(userptr, "glGetActiveAttrib"); + glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load(userptr, "glGetActiveUniform"); + glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load(userptr, "glGetAttachedShaders"); + glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load(userptr, "glGetAttribLocation"); + glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load(userptr, "glGetProgramInfoLog"); + glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load(userptr, "glGetProgramiv"); + glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load(userptr, "glGetShaderInfoLog"); + glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load(userptr, "glGetShaderSource"); + glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load(userptr, "glGetShaderiv"); + glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load(userptr, "glGetUniformLocation"); + glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load(userptr, "glGetUniformfv"); + glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load(userptr, "glGetUniformiv"); + glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load(userptr, "glGetVertexAttribPointerv"); + glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load(userptr, "glGetVertexAttribdv"); + glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load(userptr, "glGetVertexAttribfv"); + glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load(userptr, "glGetVertexAttribiv"); + glad_glIsProgram = (PFNGLISPROGRAMPROC)load(userptr, "glIsProgram"); + glad_glIsShader = (PFNGLISSHADERPROC)load(userptr, "glIsShader"); + glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load(userptr, "glLinkProgram"); + glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load(userptr, "glShaderSource"); + glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load(userptr, "glStencilFuncSeparate"); + glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load(userptr, "glStencilMaskSeparate"); + glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load(userptr, "glStencilOpSeparate"); + glad_glUniform1f = (PFNGLUNIFORM1FPROC)load(userptr, "glUniform1f"); + glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load(userptr, "glUniform1fv"); + glad_glUniform1i = (PFNGLUNIFORM1IPROC)load(userptr, "glUniform1i"); + glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load(userptr, "glUniform1iv"); + glad_glUniform2f = (PFNGLUNIFORM2FPROC)load(userptr, "glUniform2f"); + glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load(userptr, "glUniform2fv"); + glad_glUniform2i = (PFNGLUNIFORM2IPROC)load(userptr, "glUniform2i"); + glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load(userptr, "glUniform2iv"); + glad_glUniform3f = (PFNGLUNIFORM3FPROC)load(userptr, "glUniform3f"); + glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load(userptr, "glUniform3fv"); + glad_glUniform3i = (PFNGLUNIFORM3IPROC)load(userptr, "glUniform3i"); + glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load(userptr, "glUniform3iv"); + glad_glUniform4f = (PFNGLUNIFORM4FPROC)load(userptr, "glUniform4f"); + glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load(userptr, "glUniform4fv"); + glad_glUniform4i = (PFNGLUNIFORM4IPROC)load(userptr, "glUniform4i"); + glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load(userptr, "glUniform4iv"); + glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load(userptr, "glUniformMatrix2fv"); + glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load(userptr, "glUniformMatrix3fv"); + glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load(userptr, "glUniformMatrix4fv"); + glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load(userptr, "glUseProgram"); + glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load(userptr, "glValidateProgram"); + glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load(userptr, "glVertexAttrib1d"); + glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load(userptr, "glVertexAttrib1dv"); + glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load(userptr, "glVertexAttrib1f"); + glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load(userptr, "glVertexAttrib1fv"); + glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load(userptr, "glVertexAttrib1s"); + glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load(userptr, "glVertexAttrib1sv"); + glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load(userptr, "glVertexAttrib2d"); + glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load(userptr, "glVertexAttrib2dv"); + glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load(userptr, "glVertexAttrib2f"); + glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load(userptr, "glVertexAttrib2fv"); + glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load(userptr, "glVertexAttrib2s"); + glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load(userptr, "glVertexAttrib2sv"); + glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load(userptr, "glVertexAttrib3d"); + glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load(userptr, "glVertexAttrib3dv"); + glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load(userptr, "glVertexAttrib3f"); + glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load(userptr, "glVertexAttrib3fv"); + glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load(userptr, "glVertexAttrib3s"); + glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load(userptr, "glVertexAttrib3sv"); + glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load(userptr, "glVertexAttrib4Nbv"); + glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load(userptr, "glVertexAttrib4Niv"); + glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load(userptr, "glVertexAttrib4Nsv"); + glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load(userptr, "glVertexAttrib4Nub"); + glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load(userptr, "glVertexAttrib4Nubv"); + glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load(userptr, "glVertexAttrib4Nuiv"); + glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load(userptr, "glVertexAttrib4Nusv"); + glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load(userptr, "glVertexAttrib4bv"); + glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load(userptr, "glVertexAttrib4d"); + glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load(userptr, "glVertexAttrib4dv"); + glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load(userptr, "glVertexAttrib4f"); + glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load(userptr, "glVertexAttrib4fv"); + glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load(userptr, "glVertexAttrib4iv"); + glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load(userptr, "glVertexAttrib4s"); + glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load(userptr, "glVertexAttrib4sv"); + glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load(userptr, "glVertexAttrib4ubv"); + glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load(userptr, "glVertexAttrib4uiv"); + glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load(userptr, "glVertexAttrib4usv"); + glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load(userptr, "glVertexAttribPointer"); } -static void glad_gl_load_GL_VERSION_2_1( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_2_1) return; - glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load(userptr, "glUniformMatrix2x3fv"); - glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load(userptr, "glUniformMatrix2x4fv"); - glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load(userptr, "glUniformMatrix3x2fv"); - glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load(userptr, "glUniformMatrix3x4fv"); - glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load(userptr, "glUniformMatrix4x2fv"); - glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load(userptr, "glUniformMatrix4x3fv"); +static void glad_gl_load_GL_VERSION_2_1(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_2_1) return; + glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load(userptr, "glUniformMatrix2x3fv"); + glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load(userptr, "glUniformMatrix2x4fv"); + glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load(userptr, "glUniformMatrix3x2fv"); + glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load(userptr, "glUniformMatrix3x4fv"); + glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load(userptr, "glUniformMatrix4x2fv"); + glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load(userptr, "glUniformMatrix4x3fv"); } -static void glad_gl_load_GL_VERSION_3_0( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_3_0) return; - glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load(userptr, "glBeginConditionalRender"); - glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load(userptr, "glBeginTransformFeedback"); - glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase"); - glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange"); - glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load(userptr, "glBindFragDataLocation"); - glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer"); - glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer"); - glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load(userptr, "glBindVertexArray"); - glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load(userptr, "glBlitFramebuffer"); - glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus"); - glad_glClampColor = (PFNGLCLAMPCOLORPROC) load(userptr, "glClampColor"); - glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load(userptr, "glClearBufferfi"); - glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load(userptr, "glClearBufferfv"); - glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load(userptr, "glClearBufferiv"); - glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load(userptr, "glClearBufferuiv"); - glad_glColorMaski = (PFNGLCOLORMASKIPROC) load(userptr, "glColorMaski"); - glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers"); - glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers"); - glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load(userptr, "glDeleteVertexArrays"); - glad_glDisablei = (PFNGLDISABLEIPROC) load(userptr, "glDisablei"); - glad_glEnablei = (PFNGLENABLEIPROC) load(userptr, "glEnablei"); - glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load(userptr, "glEndConditionalRender"); - glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load(userptr, "glEndTransformFeedback"); - glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load(userptr, "glFlushMappedBufferRange"); - glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer"); - glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load(userptr, "glFramebufferTexture1D"); - glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D"); - glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load(userptr, "glFramebufferTexture3D"); - glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load(userptr, "glFramebufferTextureLayer"); - glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers"); - glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers"); - glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load(userptr, "glGenVertexArrays"); - glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap"); - glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load(userptr, "glGetBooleani_v"); - glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load(userptr, "glGetFragDataLocation"); - glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv"); - glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v"); - glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv"); - glad_glGetStringi = (PFNGLGETSTRINGIPROC) load(userptr, "glGetStringi"); - glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load(userptr, "glGetTexParameterIiv"); - glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load(userptr, "glGetTexParameterIuiv"); - glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load(userptr, "glGetTransformFeedbackVarying"); - glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load(userptr, "glGetUniformuiv"); - glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load(userptr, "glGetVertexAttribIiv"); - glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load(userptr, "glGetVertexAttribIuiv"); - glad_glIsEnabledi = (PFNGLISENABLEDIPROC) load(userptr, "glIsEnabledi"); - glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer"); - glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer"); - glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load(userptr, "glIsVertexArray"); - glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load(userptr, "glMapBufferRange"); - glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage"); - glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load(userptr, "glRenderbufferStorageMultisample"); - glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load(userptr, "glTexParameterIiv"); - glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load(userptr, "glTexParameterIuiv"); - glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load(userptr, "glTransformFeedbackVaryings"); - glad_glUniform1ui = (PFNGLUNIFORM1UIPROC) load(userptr, "glUniform1ui"); - glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load(userptr, "glUniform1uiv"); - glad_glUniform2ui = (PFNGLUNIFORM2UIPROC) load(userptr, "glUniform2ui"); - glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load(userptr, "glUniform2uiv"); - glad_glUniform3ui = (PFNGLUNIFORM3UIPROC) load(userptr, "glUniform3ui"); - glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load(userptr, "glUniform3uiv"); - glad_glUniform4ui = (PFNGLUNIFORM4UIPROC) load(userptr, "glUniform4ui"); - glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load(userptr, "glUniform4uiv"); - glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load(userptr, "glVertexAttribI1i"); - glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load(userptr, "glVertexAttribI1iv"); - glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load(userptr, "glVertexAttribI1ui"); - glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load(userptr, "glVertexAttribI1uiv"); - glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load(userptr, "glVertexAttribI2i"); - glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load(userptr, "glVertexAttribI2iv"); - glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load(userptr, "glVertexAttribI2ui"); - glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load(userptr, "glVertexAttribI2uiv"); - glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load(userptr, "glVertexAttribI3i"); - glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load(userptr, "glVertexAttribI3iv"); - glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load(userptr, "glVertexAttribI3ui"); - glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load(userptr, "glVertexAttribI3uiv"); - glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load(userptr, "glVertexAttribI4bv"); - glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load(userptr, "glVertexAttribI4i"); - glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load(userptr, "glVertexAttribI4iv"); - glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load(userptr, "glVertexAttribI4sv"); - glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load(userptr, "glVertexAttribI4ubv"); - glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load(userptr, "glVertexAttribI4ui"); - glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load(userptr, "glVertexAttribI4uiv"); - glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load(userptr, "glVertexAttribI4usv"); - glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load(userptr, "glVertexAttribIPointer"); +static void glad_gl_load_GL_VERSION_3_0(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_3_0) return; + glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load(userptr, "glBeginConditionalRender"); + glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load(userptr, "glBeginTransformFeedback"); + glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load(userptr, "glBindBufferBase"); + glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load(userptr, "glBindBufferRange"); + glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load(userptr, "glBindFragDataLocation"); + glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load(userptr, "glBindFramebuffer"); + glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load(userptr, "glBindRenderbuffer"); + glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load(userptr, "glBindVertexArray"); + glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load(userptr, "glBlitFramebuffer"); + glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load(userptr, "glCheckFramebufferStatus"); + glad_glClampColor = (PFNGLCLAMPCOLORPROC)load(userptr, "glClampColor"); + glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load(userptr, "glClearBufferfi"); + glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load(userptr, "glClearBufferfv"); + glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load(userptr, "glClearBufferiv"); + glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load(userptr, "glClearBufferuiv"); + glad_glColorMaski = (PFNGLCOLORMASKIPROC)load(userptr, "glColorMaski"); + glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load(userptr, "glDeleteFramebuffers"); + glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load(userptr, "glDeleteRenderbuffers"); + glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load(userptr, "glDeleteVertexArrays"); + glad_glDisablei = (PFNGLDISABLEIPROC)load(userptr, "glDisablei"); + glad_glEnablei = (PFNGLENABLEIPROC)load(userptr, "glEnablei"); + glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load(userptr, "glEndConditionalRender"); + glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load(userptr, "glEndTransformFeedback"); + glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load(userptr, "glFlushMappedBufferRange"); + glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load(userptr, "glFramebufferRenderbuffer"); + glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load(userptr, "glFramebufferTexture1D"); + glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load(userptr, "glFramebufferTexture2D"); + glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load(userptr, "glFramebufferTexture3D"); + glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load(userptr, "glFramebufferTextureLayer"); + glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load(userptr, "glGenFramebuffers"); + glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load(userptr, "glGenRenderbuffers"); + glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load(userptr, "glGenVertexArrays"); + glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load(userptr, "glGenerateMipmap"); + glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load(userptr, "glGetBooleani_v"); + glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load(userptr, "glGetFragDataLocation"); + glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load(userptr, "glGetFramebufferAttachmentParameteriv"); + glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load(userptr, "glGetIntegeri_v"); + glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load(userptr, "glGetRenderbufferParameteriv"); + glad_glGetStringi = (PFNGLGETSTRINGIPROC)load(userptr, "glGetStringi"); + glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load(userptr, "glGetTexParameterIiv"); + glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load(userptr, "glGetTexParameterIuiv"); + glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load(userptr, "glGetTransformFeedbackVarying"); + glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load(userptr, "glGetUniformuiv"); + glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load(userptr, "glGetVertexAttribIiv"); + glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load(userptr, "glGetVertexAttribIuiv"); + glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load(userptr, "glIsEnabledi"); + glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load(userptr, "glIsFramebuffer"); + glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load(userptr, "glIsRenderbuffer"); + glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load(userptr, "glIsVertexArray"); + glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load(userptr, "glMapBufferRange"); + glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load(userptr, "glRenderbufferStorage"); + glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load(userptr, "glRenderbufferStorageMultisample"); + glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load(userptr, "glTexParameterIiv"); + glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load(userptr, "glTexParameterIuiv"); + glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load(userptr, "glTransformFeedbackVaryings"); + glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load(userptr, "glUniform1ui"); + glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load(userptr, "glUniform1uiv"); + glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load(userptr, "glUniform2ui"); + glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load(userptr, "glUniform2uiv"); + glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load(userptr, "glUniform3ui"); + glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load(userptr, "glUniform3uiv"); + glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load(userptr, "glUniform4ui"); + glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load(userptr, "glUniform4uiv"); + glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load(userptr, "glVertexAttribI1i"); + glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load(userptr, "glVertexAttribI1iv"); + glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load(userptr, "glVertexAttribI1ui"); + glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load(userptr, "glVertexAttribI1uiv"); + glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load(userptr, "glVertexAttribI2i"); + glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load(userptr, "glVertexAttribI2iv"); + glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load(userptr, "glVertexAttribI2ui"); + glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load(userptr, "glVertexAttribI2uiv"); + glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load(userptr, "glVertexAttribI3i"); + glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load(userptr, "glVertexAttribI3iv"); + glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load(userptr, "glVertexAttribI3ui"); + glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load(userptr, "glVertexAttribI3uiv"); + glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load(userptr, "glVertexAttribI4bv"); + glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load(userptr, "glVertexAttribI4i"); + glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load(userptr, "glVertexAttribI4iv"); + glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load(userptr, "glVertexAttribI4sv"); + glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load(userptr, "glVertexAttribI4ubv"); + glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load(userptr, "glVertexAttribI4ui"); + glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load(userptr, "glVertexAttribI4uiv"); + glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load(userptr, "glVertexAttribI4usv"); + glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load(userptr, "glVertexAttribIPointer"); } -static void glad_gl_load_GL_VERSION_3_1( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_3_1) return; - glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase"); - glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange"); - glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load(userptr, "glCopyBufferSubData"); - glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load(userptr, "glDrawArraysInstanced"); - glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load(userptr, "glDrawElementsInstanced"); - glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load(userptr, "glGetActiveUniformBlockName"); - glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load(userptr, "glGetActiveUniformBlockiv"); - glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load(userptr, "glGetActiveUniformName"); - glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load(userptr, "glGetActiveUniformsiv"); - glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v"); - glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load(userptr, "glGetUniformBlockIndex"); - glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load(userptr, "glGetUniformIndices"); - glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load(userptr, "glPrimitiveRestartIndex"); - glad_glTexBuffer = (PFNGLTEXBUFFERPROC) load(userptr, "glTexBuffer"); - glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load(userptr, "glUniformBlockBinding"); +static void glad_gl_load_GL_VERSION_3_1(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_3_1) return; + glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load(userptr, "glBindBufferBase"); + glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load(userptr, "glBindBufferRange"); + glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load(userptr, "glCopyBufferSubData"); + glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load(userptr, "glDrawArraysInstanced"); + glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load(userptr, "glDrawElementsInstanced"); + glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load(userptr, "glGetActiveUniformBlockName"); + glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load(userptr, "glGetActiveUniformBlockiv"); + glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load(userptr, "glGetActiveUniformName"); + glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load(userptr, "glGetActiveUniformsiv"); + glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load(userptr, "glGetIntegeri_v"); + glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load(userptr, "glGetUniformBlockIndex"); + glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load(userptr, "glGetUniformIndices"); + glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load(userptr, "glPrimitiveRestartIndex"); + glad_glTexBuffer = (PFNGLTEXBUFFERPROC)load(userptr, "glTexBuffer"); + glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load(userptr, "glUniformBlockBinding"); } -static void glad_gl_load_GL_VERSION_3_2( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_3_2) return; - glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load(userptr, "glClientWaitSync"); - glad_glDeleteSync = (PFNGLDELETESYNCPROC) load(userptr, "glDeleteSync"); - glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glDrawElementsBaseVertex"); - glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load(userptr, "glDrawElementsInstancedBaseVertex"); - glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load(userptr, "glDrawRangeElementsBaseVertex"); - glad_glFenceSync = (PFNGLFENCESYNCPROC) load(userptr, "glFenceSync"); - glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load(userptr, "glFramebufferTexture"); - glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load(userptr, "glGetBufferParameteri64v"); - glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load(userptr, "glGetInteger64i_v"); - glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC) load(userptr, "glGetInteger64v"); - glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load(userptr, "glGetMultisamplefv"); - glad_glGetSynciv = (PFNGLGETSYNCIVPROC) load(userptr, "glGetSynciv"); - glad_glIsSync = (PFNGLISSYNCPROC) load(userptr, "glIsSync"); - glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glMultiDrawElementsBaseVertex"); - glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load(userptr, "glProvokingVertex"); - glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC) load(userptr, "glSampleMaski"); - glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load(userptr, "glTexImage2DMultisample"); - glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load(userptr, "glTexImage3DMultisample"); - glad_glWaitSync = (PFNGLWAITSYNCPROC) load(userptr, "glWaitSync"); +static void glad_gl_load_GL_VERSION_3_2(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_3_2) return; + glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load(userptr, "glClientWaitSync"); + glad_glDeleteSync = (PFNGLDELETESYNCPROC)load(userptr, "glDeleteSync"); + glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load(userptr, "glDrawElementsBaseVertex"); + glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load(userptr, "glDrawElementsInstancedBaseVertex"); + glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load(userptr, "glDrawRangeElementsBaseVertex"); + glad_glFenceSync = (PFNGLFENCESYNCPROC)load(userptr, "glFenceSync"); + glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load(userptr, "glFramebufferTexture"); + glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load(userptr, "glGetBufferParameteri64v"); + glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load(userptr, "glGetInteger64i_v"); + glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load(userptr, "glGetInteger64v"); + glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load(userptr, "glGetMultisamplefv"); + glad_glGetSynciv = (PFNGLGETSYNCIVPROC)load(userptr, "glGetSynciv"); + glad_glIsSync = (PFNGLISSYNCPROC)load(userptr, "glIsSync"); + glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load(userptr, "glMultiDrawElementsBaseVertex"); + glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load(userptr, "glProvokingVertex"); + glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load(userptr, "glSampleMaski"); + glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load(userptr, "glTexImage2DMultisample"); + glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load(userptr, "glTexImage3DMultisample"); + glad_glWaitSync = (PFNGLWAITSYNCPROC)load(userptr, "glWaitSync"); } -static void glad_gl_load_GL_VERSION_3_3( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_3_3) return; - glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load(userptr, "glBindFragDataLocationIndexed"); - glad_glBindSampler = (PFNGLBINDSAMPLERPROC) load(userptr, "glBindSampler"); - glad_glColorP3ui = (PFNGLCOLORP3UIPROC) load(userptr, "glColorP3ui"); - glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC) load(userptr, "glColorP3uiv"); - glad_glColorP4ui = (PFNGLCOLORP4UIPROC) load(userptr, "glColorP4ui"); - glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC) load(userptr, "glColorP4uiv"); - glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load(userptr, "glDeleteSamplers"); - glad_glGenSamplers = (PFNGLGENSAMPLERSPROC) load(userptr, "glGenSamplers"); - glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load(userptr, "glGetFragDataIndex"); - glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load(userptr, "glGetQueryObjecti64v"); - glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load(userptr, "glGetQueryObjectui64v"); - glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load(userptr, "glGetSamplerParameterIiv"); - glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load(userptr, "glGetSamplerParameterIuiv"); - glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load(userptr, "glGetSamplerParameterfv"); - glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load(userptr, "glGetSamplerParameteriv"); - glad_glIsSampler = (PFNGLISSAMPLERPROC) load(userptr, "glIsSampler"); - glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC) load(userptr, "glMultiTexCoordP1ui"); - glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC) load(userptr, "glMultiTexCoordP1uiv"); - glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC) load(userptr, "glMultiTexCoordP2ui"); - glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC) load(userptr, "glMultiTexCoordP2uiv"); - glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC) load(userptr, "glMultiTexCoordP3ui"); - glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC) load(userptr, "glMultiTexCoordP3uiv"); - glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC) load(userptr, "glMultiTexCoordP4ui"); - glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC) load(userptr, "glMultiTexCoordP4uiv"); - glad_glNormalP3ui = (PFNGLNORMALP3UIPROC) load(userptr, "glNormalP3ui"); - glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC) load(userptr, "glNormalP3uiv"); - glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC) load(userptr, "glQueryCounter"); - glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load(userptr, "glSamplerParameterIiv"); - glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load(userptr, "glSamplerParameterIuiv"); - glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load(userptr, "glSamplerParameterf"); - glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load(userptr, "glSamplerParameterfv"); - glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load(userptr, "glSamplerParameteri"); - glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load(userptr, "glSamplerParameteriv"); - glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC) load(userptr, "glSecondaryColorP3ui"); - glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC) load(userptr, "glSecondaryColorP3uiv"); - glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC) load(userptr, "glTexCoordP1ui"); - glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC) load(userptr, "glTexCoordP1uiv"); - glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC) load(userptr, "glTexCoordP2ui"); - glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC) load(userptr, "glTexCoordP2uiv"); - glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC) load(userptr, "glTexCoordP3ui"); - glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC) load(userptr, "glTexCoordP3uiv"); - glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC) load(userptr, "glTexCoordP4ui"); - glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC) load(userptr, "glTexCoordP4uiv"); - glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load(userptr, "glVertexAttribDivisor"); - glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load(userptr, "glVertexAttribP1ui"); - glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load(userptr, "glVertexAttribP1uiv"); - glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load(userptr, "glVertexAttribP2ui"); - glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load(userptr, "glVertexAttribP2uiv"); - glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load(userptr, "glVertexAttribP3ui"); - glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load(userptr, "glVertexAttribP3uiv"); - glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load(userptr, "glVertexAttribP4ui"); - glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load(userptr, "glVertexAttribP4uiv"); - glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC) load(userptr, "glVertexP2ui"); - glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC) load(userptr, "glVertexP2uiv"); - glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC) load(userptr, "glVertexP3ui"); - glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC) load(userptr, "glVertexP3uiv"); - glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC) load(userptr, "glVertexP4ui"); - glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC) load(userptr, "glVertexP4uiv"); +static void glad_gl_load_GL_VERSION_3_3(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_3_3) return; + glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load(userptr, "glBindFragDataLocationIndexed"); + glad_glBindSampler = (PFNGLBINDSAMPLERPROC)load(userptr, "glBindSampler"); + glad_glColorP3ui = (PFNGLCOLORP3UIPROC)load(userptr, "glColorP3ui"); + glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC)load(userptr, "glColorP3uiv"); + glad_glColorP4ui = (PFNGLCOLORP4UIPROC)load(userptr, "glColorP4ui"); + glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC)load(userptr, "glColorP4uiv"); + glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)load(userptr, "glDeleteSamplers"); + glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load(userptr, "glGenSamplers"); + glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load(userptr, "glGetFragDataIndex"); + glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)load(userptr, "glGetQueryObjecti64v"); + glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)load(userptr, "glGetQueryObjectui64v"); + glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)load(userptr, "glGetSamplerParameterIiv"); + glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)load(userptr, "glGetSamplerParameterIuiv"); + glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)load(userptr, "glGetSamplerParameterfv"); + glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)load(userptr, "glGetSamplerParameteriv"); + glad_glIsSampler = (PFNGLISSAMPLERPROC)load(userptr, "glIsSampler"); + glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)load(userptr, "glMultiTexCoordP1ui"); + glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)load(userptr, "glMultiTexCoordP1uiv"); + glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)load(userptr, "glMultiTexCoordP2ui"); + glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)load(userptr, "glMultiTexCoordP2uiv"); + glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)load(userptr, "glMultiTexCoordP3ui"); + glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)load(userptr, "glMultiTexCoordP3uiv"); + glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)load(userptr, "glMultiTexCoordP4ui"); + glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)load(userptr, "glMultiTexCoordP4uiv"); + glad_glNormalP3ui = (PFNGLNORMALP3UIPROC)load(userptr, "glNormalP3ui"); + glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC)load(userptr, "glNormalP3uiv"); + glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC)load(userptr, "glQueryCounter"); + glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)load(userptr, "glSamplerParameterIiv"); + glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)load(userptr, "glSamplerParameterIuiv"); + glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)load(userptr, "glSamplerParameterf"); + glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)load(userptr, "glSamplerParameterfv"); + glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)load(userptr, "glSamplerParameteri"); + glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)load(userptr, "glSamplerParameteriv"); + glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load(userptr, "glSecondaryColorP3ui"); + glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load(userptr, "glSecondaryColorP3uiv"); + glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)load(userptr, "glTexCoordP1ui"); + glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)load(userptr, "glTexCoordP1uiv"); + glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)load(userptr, "glTexCoordP2ui"); + glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)load(userptr, "glTexCoordP2uiv"); + glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)load(userptr, "glTexCoordP3ui"); + glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)load(userptr, "glTexCoordP3uiv"); + glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)load(userptr, "glTexCoordP4ui"); + glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)load(userptr, "glTexCoordP4uiv"); + glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)load(userptr, "glVertexAttribDivisor"); + glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)load(userptr, "glVertexAttribP1ui"); + glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)load(userptr, "glVertexAttribP1uiv"); + glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)load(userptr, "glVertexAttribP2ui"); + glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)load(userptr, "glVertexAttribP2uiv"); + glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)load(userptr, "glVertexAttribP3ui"); + glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)load(userptr, "glVertexAttribP3uiv"); + glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)load(userptr, "glVertexAttribP4ui"); + glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)load(userptr, "glVertexAttribP4uiv"); + glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC)load(userptr, "glVertexP2ui"); + glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)load(userptr, "glVertexP2uiv"); + glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC)load(userptr, "glVertexP3ui"); + glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)load(userptr, "glVertexP3uiv"); + glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC)load(userptr, "glVertexP4ui"); + glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)load(userptr, "glVertexP4uiv"); } -static void glad_gl_load_GL_VERSION_4_0( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_4_0) return; - glad_glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC) load(userptr, "glBeginQueryIndexed"); - glad_glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC) load(userptr, "glBindTransformFeedback"); - glad_glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC) load(userptr, "glBlendEquationSeparatei"); - glad_glBlendEquationi = (PFNGLBLENDEQUATIONIPROC) load(userptr, "glBlendEquationi"); - glad_glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC) load(userptr, "glBlendFuncSeparatei"); - glad_glBlendFunci = (PFNGLBLENDFUNCIPROC) load(userptr, "glBlendFunci"); - glad_glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC) load(userptr, "glDeleteTransformFeedbacks"); - glad_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC) load(userptr, "glDrawArraysIndirect"); - glad_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC) load(userptr, "glDrawElementsIndirect"); - glad_glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC) load(userptr, "glDrawTransformFeedback"); - glad_glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) load(userptr, "glDrawTransformFeedbackStream"); - glad_glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC) load(userptr, "glEndQueryIndexed"); - glad_glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC) load(userptr, "glGenTransformFeedbacks"); - glad_glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC) load(userptr, "glGetActiveSubroutineName"); - glad_glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) load(userptr, "glGetActiveSubroutineUniformName"); - glad_glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) load(userptr, "glGetActiveSubroutineUniformiv"); - glad_glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC) load(userptr, "glGetProgramStageiv"); - glad_glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC) load(userptr, "glGetQueryIndexediv"); - glad_glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC) load(userptr, "glGetSubroutineIndex"); - glad_glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) load(userptr, "glGetSubroutineUniformLocation"); - glad_glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC) load(userptr, "glGetUniformSubroutineuiv"); - glad_glGetUniformdv = (PFNGLGETUNIFORMDVPROC) load(userptr, "glGetUniformdv"); - glad_glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC) load(userptr, "glIsTransformFeedback"); - glad_glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC) load(userptr, "glMinSampleShading"); - glad_glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC) load(userptr, "glPatchParameterfv"); - glad_glPatchParameteri = (PFNGLPATCHPARAMETERIPROC) load(userptr, "glPatchParameteri"); - glad_glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC) load(userptr, "glPauseTransformFeedback"); - glad_glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC) load(userptr, "glResumeTransformFeedback"); - glad_glUniform1d = (PFNGLUNIFORM1DPROC) load(userptr, "glUniform1d"); - glad_glUniform1dv = (PFNGLUNIFORM1DVPROC) load(userptr, "glUniform1dv"); - glad_glUniform2d = (PFNGLUNIFORM2DPROC) load(userptr, "glUniform2d"); - glad_glUniform2dv = (PFNGLUNIFORM2DVPROC) load(userptr, "glUniform2dv"); - glad_glUniform3d = (PFNGLUNIFORM3DPROC) load(userptr, "glUniform3d"); - glad_glUniform3dv = (PFNGLUNIFORM3DVPROC) load(userptr, "glUniform3dv"); - glad_glUniform4d = (PFNGLUNIFORM4DPROC) load(userptr, "glUniform4d"); - glad_glUniform4dv = (PFNGLUNIFORM4DVPROC) load(userptr, "glUniform4dv"); - glad_glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC) load(userptr, "glUniformMatrix2dv"); - glad_glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC) load(userptr, "glUniformMatrix2x3dv"); - glad_glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC) load(userptr, "glUniformMatrix2x4dv"); - glad_glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC) load(userptr, "glUniformMatrix3dv"); - glad_glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC) load(userptr, "glUniformMatrix3x2dv"); - glad_glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC) load(userptr, "glUniformMatrix3x4dv"); - glad_glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC) load(userptr, "glUniformMatrix4dv"); - glad_glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC) load(userptr, "glUniformMatrix4x2dv"); - glad_glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC) load(userptr, "glUniformMatrix4x3dv"); - glad_glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC) load(userptr, "glUniformSubroutinesuiv"); +static void glad_gl_load_GL_VERSION_4_0(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_4_0) return; + glad_glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC)load(userptr, "glBeginQueryIndexed"); + glad_glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)load(userptr, "glBindTransformFeedback"); + glad_glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC)load(userptr, "glBlendEquationSeparatei"); + glad_glBlendEquationi = (PFNGLBLENDEQUATIONIPROC)load(userptr, "glBlendEquationi"); + glad_glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC)load(userptr, "glBlendFuncSeparatei"); + glad_glBlendFunci = (PFNGLBLENDFUNCIPROC)load(userptr, "glBlendFunci"); + glad_glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC)load(userptr, "glDeleteTransformFeedbacks"); + glad_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)load(userptr, "glDrawArraysIndirect"); + glad_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)load(userptr, "glDrawElementsIndirect"); + glad_glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)load(userptr, "glDrawTransformFeedback"); + glad_glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)load(userptr, "glDrawTransformFeedbackStream"); + glad_glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC)load(userptr, "glEndQueryIndexed"); + glad_glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)load(userptr, "glGenTransformFeedbacks"); + glad_glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC)load(userptr, "glGetActiveSubroutineName"); + glad_glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)load(userptr, "glGetActiveSubroutineUniformName"); + glad_glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)load(userptr, "glGetActiveSubroutineUniformiv"); + glad_glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC)load(userptr, "glGetProgramStageiv"); + glad_glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC)load(userptr, "glGetQueryIndexediv"); + glad_glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC)load(userptr, "glGetSubroutineIndex"); + glad_glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)load(userptr, "glGetSubroutineUniformLocation"); + glad_glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC)load(userptr, "glGetUniformSubroutineuiv"); + glad_glGetUniformdv = (PFNGLGETUNIFORMDVPROC)load(userptr, "glGetUniformdv"); + glad_glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC)load(userptr, "glIsTransformFeedback"); + glad_glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC)load(userptr, "glMinSampleShading"); + glad_glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC)load(userptr, "glPatchParameterfv"); + glad_glPatchParameteri = (PFNGLPATCHPARAMETERIPROC)load(userptr, "glPatchParameteri"); + glad_glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC)load(userptr, "glPauseTransformFeedback"); + glad_glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC)load(userptr, "glResumeTransformFeedback"); + glad_glUniform1d = (PFNGLUNIFORM1DPROC)load(userptr, "glUniform1d"); + glad_glUniform1dv = (PFNGLUNIFORM1DVPROC)load(userptr, "glUniform1dv"); + glad_glUniform2d = (PFNGLUNIFORM2DPROC)load(userptr, "glUniform2d"); + glad_glUniform2dv = (PFNGLUNIFORM2DVPROC)load(userptr, "glUniform2dv"); + glad_glUniform3d = (PFNGLUNIFORM3DPROC)load(userptr, "glUniform3d"); + glad_glUniform3dv = (PFNGLUNIFORM3DVPROC)load(userptr, "glUniform3dv"); + glad_glUniform4d = (PFNGLUNIFORM4DPROC)load(userptr, "glUniform4d"); + glad_glUniform4dv = (PFNGLUNIFORM4DVPROC)load(userptr, "glUniform4dv"); + glad_glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC)load(userptr, "glUniformMatrix2dv"); + glad_glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC)load(userptr, "glUniformMatrix2x3dv"); + glad_glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC)load(userptr, "glUniformMatrix2x4dv"); + glad_glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC)load(userptr, "glUniformMatrix3dv"); + glad_glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC)load(userptr, "glUniformMatrix3x2dv"); + glad_glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC)load(userptr, "glUniformMatrix3x4dv"); + glad_glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC)load(userptr, "glUniformMatrix4dv"); + glad_glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC)load(userptr, "glUniformMatrix4x2dv"); + glad_glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC)load(userptr, "glUniformMatrix4x3dv"); + glad_glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC)load(userptr, "glUniformSubroutinesuiv"); } -static void glad_gl_load_GL_VERSION_4_1( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_4_1) return; - glad_glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC) load(userptr, "glActiveShaderProgram"); - glad_glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC) load(userptr, "glBindProgramPipeline"); - glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf"); - glad_glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC) load(userptr, "glCreateShaderProgramv"); - glad_glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC) load(userptr, "glDeleteProgramPipelines"); - glad_glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC) load(userptr, "glDepthRangeArrayv"); - glad_glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC) load(userptr, "glDepthRangeIndexed"); - glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef"); - glad_glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC) load(userptr, "glGenProgramPipelines"); - glad_glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC) load(userptr, "glGetDoublei_v"); - glad_glGetFloati_v = (PFNGLGETFLOATI_VPROC) load(userptr, "glGetFloati_v"); - glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC) load(userptr, "glGetProgramBinary"); - glad_glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC) load(userptr, "glGetProgramPipelineInfoLog"); - glad_glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC) load(userptr, "glGetProgramPipelineiv"); - glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load(userptr, "glGetShaderPrecisionFormat"); - glad_glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC) load(userptr, "glGetVertexAttribLdv"); - glad_glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC) load(userptr, "glIsProgramPipeline"); - glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC) load(userptr, "glProgramBinary"); - glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) load(userptr, "glProgramParameteri"); - glad_glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC) load(userptr, "glProgramUniform1d"); - glad_glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC) load(userptr, "glProgramUniform1dv"); - glad_glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC) load(userptr, "glProgramUniform1f"); - glad_glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC) load(userptr, "glProgramUniform1fv"); - glad_glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC) load(userptr, "glProgramUniform1i"); - glad_glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC) load(userptr, "glProgramUniform1iv"); - glad_glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC) load(userptr, "glProgramUniform1ui"); - glad_glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC) load(userptr, "glProgramUniform1uiv"); - glad_glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC) load(userptr, "glProgramUniform2d"); - glad_glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC) load(userptr, "glProgramUniform2dv"); - glad_glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC) load(userptr, "glProgramUniform2f"); - glad_glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC) load(userptr, "glProgramUniform2fv"); - glad_glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC) load(userptr, "glProgramUniform2i"); - glad_glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC) load(userptr, "glProgramUniform2iv"); - glad_glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC) load(userptr, "glProgramUniform2ui"); - glad_glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC) load(userptr, "glProgramUniform2uiv"); - glad_glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC) load(userptr, "glProgramUniform3d"); - glad_glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC) load(userptr, "glProgramUniform3dv"); - glad_glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC) load(userptr, "glProgramUniform3f"); - glad_glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC) load(userptr, "glProgramUniform3fv"); - glad_glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC) load(userptr, "glProgramUniform3i"); - glad_glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC) load(userptr, "glProgramUniform3iv"); - glad_glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC) load(userptr, "glProgramUniform3ui"); - glad_glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC) load(userptr, "glProgramUniform3uiv"); - glad_glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC) load(userptr, "glProgramUniform4d"); - glad_glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC) load(userptr, "glProgramUniform4dv"); - glad_glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC) load(userptr, "glProgramUniform4f"); - glad_glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC) load(userptr, "glProgramUniform4fv"); - glad_glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC) load(userptr, "glProgramUniform4i"); - glad_glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC) load(userptr, "glProgramUniform4iv"); - glad_glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC) load(userptr, "glProgramUniform4ui"); - glad_glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC) load(userptr, "glProgramUniform4uiv"); - glad_glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC) load(userptr, "glProgramUniformMatrix2dv"); - glad_glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC) load(userptr, "glProgramUniformMatrix2fv"); - glad_glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) load(userptr, "glProgramUniformMatrix2x3dv"); - glad_glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) load(userptr, "glProgramUniformMatrix2x3fv"); - glad_glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) load(userptr, "glProgramUniformMatrix2x4dv"); - glad_glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) load(userptr, "glProgramUniformMatrix2x4fv"); - glad_glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC) load(userptr, "glProgramUniformMatrix3dv"); - glad_glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC) load(userptr, "glProgramUniformMatrix3fv"); - glad_glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) load(userptr, "glProgramUniformMatrix3x2dv"); - glad_glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) load(userptr, "glProgramUniformMatrix3x2fv"); - glad_glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) load(userptr, "glProgramUniformMatrix3x4dv"); - glad_glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) load(userptr, "glProgramUniformMatrix3x4fv"); - glad_glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC) load(userptr, "glProgramUniformMatrix4dv"); - glad_glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC) load(userptr, "glProgramUniformMatrix4fv"); - glad_glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) load(userptr, "glProgramUniformMatrix4x2dv"); - glad_glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) load(userptr, "glProgramUniformMatrix4x2fv"); - glad_glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) load(userptr, "glProgramUniformMatrix4x3dv"); - glad_glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) load(userptr, "glProgramUniformMatrix4x3fv"); - glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load(userptr, "glReleaseShaderCompiler"); - glad_glScissorArrayv = (PFNGLSCISSORARRAYVPROC) load(userptr, "glScissorArrayv"); - glad_glScissorIndexed = (PFNGLSCISSORINDEXEDPROC) load(userptr, "glScissorIndexed"); - glad_glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC) load(userptr, "glScissorIndexedv"); - glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load(userptr, "glShaderBinary"); - glad_glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC) load(userptr, "glUseProgramStages"); - glad_glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC) load(userptr, "glValidateProgramPipeline"); - glad_glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC) load(userptr, "glVertexAttribL1d"); - glad_glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC) load(userptr, "glVertexAttribL1dv"); - glad_glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC) load(userptr, "glVertexAttribL2d"); - glad_glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC) load(userptr, "glVertexAttribL2dv"); - glad_glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC) load(userptr, "glVertexAttribL3d"); - glad_glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC) load(userptr, "glVertexAttribL3dv"); - glad_glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC) load(userptr, "glVertexAttribL4d"); - glad_glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC) load(userptr, "glVertexAttribL4dv"); - glad_glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC) load(userptr, "glVertexAttribLPointer"); - glad_glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC) load(userptr, "glViewportArrayv"); - glad_glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC) load(userptr, "glViewportIndexedf"); - glad_glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC) load(userptr, "glViewportIndexedfv"); +static void glad_gl_load_GL_VERSION_4_1(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_4_1) return; + glad_glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC)load(userptr, "glActiveShaderProgram"); + glad_glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC)load(userptr, "glBindProgramPipeline"); + glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC)load(userptr, "glClearDepthf"); + glad_glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC)load(userptr, "glCreateShaderProgramv"); + glad_glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC)load(userptr, "glDeleteProgramPipelines"); + glad_glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC)load(userptr, "glDepthRangeArrayv"); + glad_glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC)load(userptr, "glDepthRangeIndexed"); + glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC)load(userptr, "glDepthRangef"); + glad_glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC)load(userptr, "glGenProgramPipelines"); + glad_glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC)load(userptr, "glGetDoublei_v"); + glad_glGetFloati_v = (PFNGLGETFLOATI_VPROC)load(userptr, "glGetFloati_v"); + glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC)load(userptr, "glGetProgramBinary"); + glad_glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC)load(userptr, "glGetProgramPipelineInfoLog"); + glad_glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC)load(userptr, "glGetProgramPipelineiv"); + glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)load(userptr, "glGetShaderPrecisionFormat"); + glad_glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC)load(userptr, "glGetVertexAttribLdv"); + glad_glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC)load(userptr, "glIsProgramPipeline"); + glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC)load(userptr, "glProgramBinary"); + glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)load(userptr, "glProgramParameteri"); + glad_glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC)load(userptr, "glProgramUniform1d"); + glad_glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC)load(userptr, "glProgramUniform1dv"); + glad_glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC)load(userptr, "glProgramUniform1f"); + glad_glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC)load(userptr, "glProgramUniform1fv"); + glad_glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC)load(userptr, "glProgramUniform1i"); + glad_glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC)load(userptr, "glProgramUniform1iv"); + glad_glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC)load(userptr, "glProgramUniform1ui"); + glad_glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC)load(userptr, "glProgramUniform1uiv"); + glad_glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC)load(userptr, "glProgramUniform2d"); + glad_glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC)load(userptr, "glProgramUniform2dv"); + glad_glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC)load(userptr, "glProgramUniform2f"); + glad_glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC)load(userptr, "glProgramUniform2fv"); + glad_glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC)load(userptr, "glProgramUniform2i"); + glad_glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC)load(userptr, "glProgramUniform2iv"); + glad_glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC)load(userptr, "glProgramUniform2ui"); + glad_glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC)load(userptr, "glProgramUniform2uiv"); + glad_glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC)load(userptr, "glProgramUniform3d"); + glad_glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC)load(userptr, "glProgramUniform3dv"); + glad_glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC)load(userptr, "glProgramUniform3f"); + glad_glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC)load(userptr, "glProgramUniform3fv"); + glad_glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC)load(userptr, "glProgramUniform3i"); + glad_glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC)load(userptr, "glProgramUniform3iv"); + glad_glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC)load(userptr, "glProgramUniform3ui"); + glad_glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC)load(userptr, "glProgramUniform3uiv"); + glad_glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC)load(userptr, "glProgramUniform4d"); + glad_glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC)load(userptr, "glProgramUniform4dv"); + glad_glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC)load(userptr, "glProgramUniform4f"); + glad_glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC)load(userptr, "glProgramUniform4fv"); + glad_glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC)load(userptr, "glProgramUniform4i"); + glad_glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC)load(userptr, "glProgramUniform4iv"); + glad_glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC)load(userptr, "glProgramUniform4ui"); + glad_glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC)load(userptr, "glProgramUniform4uiv"); + glad_glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC)load(userptr, "glProgramUniformMatrix2dv"); + glad_glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC)load(userptr, "glProgramUniformMatrix2fv"); + glad_glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)load(userptr, "glProgramUniformMatrix2x3dv"); + glad_glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)load(userptr, "glProgramUniformMatrix2x3fv"); + glad_glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)load(userptr, "glProgramUniformMatrix2x4dv"); + glad_glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)load(userptr, "glProgramUniformMatrix2x4fv"); + glad_glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC)load(userptr, "glProgramUniformMatrix3dv"); + glad_glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC)load(userptr, "glProgramUniformMatrix3fv"); + glad_glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)load(userptr, "glProgramUniformMatrix3x2dv"); + glad_glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)load(userptr, "glProgramUniformMatrix3x2fv"); + glad_glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)load(userptr, "glProgramUniformMatrix3x4dv"); + glad_glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)load(userptr, "glProgramUniformMatrix3x4fv"); + glad_glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC)load(userptr, "glProgramUniformMatrix4dv"); + glad_glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC)load(userptr, "glProgramUniformMatrix4fv"); + glad_glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)load(userptr, "glProgramUniformMatrix4x2dv"); + glad_glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)load(userptr, "glProgramUniformMatrix4x2fv"); + glad_glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)load(userptr, "glProgramUniformMatrix4x3dv"); + glad_glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)load(userptr, "glProgramUniformMatrix4x3fv"); + glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)load(userptr, "glReleaseShaderCompiler"); + glad_glScissorArrayv = (PFNGLSCISSORARRAYVPROC)load(userptr, "glScissorArrayv"); + glad_glScissorIndexed = (PFNGLSCISSORINDEXEDPROC)load(userptr, "glScissorIndexed"); + glad_glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC)load(userptr, "glScissorIndexedv"); + glad_glShaderBinary = (PFNGLSHADERBINARYPROC)load(userptr, "glShaderBinary"); + glad_glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC)load(userptr, "glUseProgramStages"); + glad_glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC)load(userptr, "glValidateProgramPipeline"); + glad_glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC)load(userptr, "glVertexAttribL1d"); + glad_glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC)load(userptr, "glVertexAttribL1dv"); + glad_glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC)load(userptr, "glVertexAttribL2d"); + glad_glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC)load(userptr, "glVertexAttribL2dv"); + glad_glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC)load(userptr, "glVertexAttribL3d"); + glad_glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC)load(userptr, "glVertexAttribL3dv"); + glad_glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC)load(userptr, "glVertexAttribL4d"); + glad_glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC)load(userptr, "glVertexAttribL4dv"); + glad_glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC)load(userptr, "glVertexAttribLPointer"); + glad_glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC)load(userptr, "glViewportArrayv"); + glad_glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC)load(userptr, "glViewportIndexedf"); + glad_glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC)load(userptr, "glViewportIndexedfv"); } -static void glad_gl_load_GL_VERSION_4_2( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_4_2) return; - glad_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC) load(userptr, "glBindImageTexture"); - glad_glDrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) load(userptr, "glDrawArraysInstancedBaseInstance"); - glad_glDrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) load(userptr, "glDrawElementsInstancedBaseInstance"); - glad_glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) load(userptr, "glDrawElementsInstancedBaseVertexBaseInstance"); - glad_glDrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) load(userptr, "glDrawTransformFeedbackInstanced"); - glad_glDrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) load(userptr, "glDrawTransformFeedbackStreamInstanced"); - glad_glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) load(userptr, "glGetActiveAtomicCounterBufferiv"); - glad_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC) load(userptr, "glGetInternalformativ"); - glad_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC) load(userptr, "glMemoryBarrier"); - glad_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC) load(userptr, "glTexStorage1D"); - glad_glTexStorage2D = (PFNGLTEXSTORAGE2DPROC) load(userptr, "glTexStorage2D"); - glad_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC) load(userptr, "glTexStorage3D"); +static void glad_gl_load_GL_VERSION_4_2(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_4_2) return; + glad_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)load(userptr, "glBindImageTexture"); + glad_glDrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)load(userptr, "glDrawArraysInstancedBaseInstance"); + glad_glDrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)load(userptr, "glDrawElementsInstancedBaseInstance"); + glad_glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)load(userptr, "glDrawElementsInstancedBaseVertexBaseInstance"); + glad_glDrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)load(userptr, "glDrawTransformFeedbackInstanced"); + glad_glDrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)load(userptr, "glDrawTransformFeedbackStreamInstanced"); + glad_glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)load(userptr, "glGetActiveAtomicCounterBufferiv"); + glad_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC)load(userptr, "glGetInternalformativ"); + glad_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)load(userptr, "glMemoryBarrier"); + glad_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC)load(userptr, "glTexStorage1D"); + glad_glTexStorage2D = (PFNGLTEXSTORAGE2DPROC)load(userptr, "glTexStorage2D"); + glad_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)load(userptr, "glTexStorage3D"); } -static void glad_gl_load_GL_VERSION_4_3( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_4_3) return; - glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC) load(userptr, "glBindVertexBuffer"); - glad_glClearBufferData = (PFNGLCLEARBUFFERDATAPROC) load(userptr, "glClearBufferData"); - glad_glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC) load(userptr, "glClearBufferSubData"); - glad_glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC) load(userptr, "glCopyImageSubData"); - glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load(userptr, "glDebugMessageCallback"); - glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load(userptr, "glDebugMessageControl"); - glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load(userptr, "glDebugMessageInsert"); - glad_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC) load(userptr, "glDispatchCompute"); - glad_glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC) load(userptr, "glDispatchComputeIndirect"); - glad_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC) load(userptr, "glFramebufferParameteri"); - glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load(userptr, "glGetDebugMessageLog"); - glad_glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC) load(userptr, "glGetFramebufferParameteriv"); - glad_glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC) load(userptr, "glGetInternalformati64v"); - glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load(userptr, "glGetObjectLabel"); - glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load(userptr, "glGetObjectPtrLabel"); - glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv"); - glad_glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC) load(userptr, "glGetProgramInterfaceiv"); - glad_glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC) load(userptr, "glGetProgramResourceIndex"); - glad_glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC) load(userptr, "glGetProgramResourceLocation"); - glad_glGetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) load(userptr, "glGetProgramResourceLocationIndex"); - glad_glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC) load(userptr, "glGetProgramResourceName"); - glad_glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC) load(userptr, "glGetProgramResourceiv"); - glad_glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC) load(userptr, "glInvalidateBufferData"); - glad_glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC) load(userptr, "glInvalidateBufferSubData"); - glad_glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC) load(userptr, "glInvalidateFramebuffer"); - glad_glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC) load(userptr, "glInvalidateSubFramebuffer"); - glad_glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC) load(userptr, "glInvalidateTexImage"); - glad_glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC) load(userptr, "glInvalidateTexSubImage"); - glad_glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC) load(userptr, "glMultiDrawArraysIndirect"); - glad_glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC) load(userptr, "glMultiDrawElementsIndirect"); - glad_glObjectLabel = (PFNGLOBJECTLABELPROC) load(userptr, "glObjectLabel"); - glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load(userptr, "glObjectPtrLabel"); - glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load(userptr, "glPopDebugGroup"); - glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load(userptr, "glPushDebugGroup"); - glad_glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC) load(userptr, "glShaderStorageBlockBinding"); - glad_glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC) load(userptr, "glTexBufferRange"); - glad_glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC) load(userptr, "glTexStorage2DMultisample"); - glad_glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC) load(userptr, "glTexStorage3DMultisample"); - glad_glTextureView = (PFNGLTEXTUREVIEWPROC) load(userptr, "glTextureView"); - glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC) load(userptr, "glVertexAttribBinding"); - glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC) load(userptr, "glVertexAttribFormat"); - glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC) load(userptr, "glVertexAttribIFormat"); - glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC) load(userptr, "glVertexAttribLFormat"); - glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC) load(userptr, "glVertexBindingDivisor"); +static void glad_gl_load_GL_VERSION_4_3(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_4_3) return; + glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)load(userptr, "glBindVertexBuffer"); + glad_glClearBufferData = (PFNGLCLEARBUFFERDATAPROC)load(userptr, "glClearBufferData"); + glad_glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC)load(userptr, "glClearBufferSubData"); + glad_glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC)load(userptr, "glCopyImageSubData"); + glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)load(userptr, "glDebugMessageCallback"); + glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)load(userptr, "glDebugMessageControl"); + glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC)load(userptr, "glDebugMessageInsert"); + glad_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC)load(userptr, "glDispatchCompute"); + glad_glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC)load(userptr, "glDispatchComputeIndirect"); + glad_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC)load(userptr, "glFramebufferParameteri"); + glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC)load(userptr, "glGetDebugMessageLog"); + glad_glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC)load(userptr, "glGetFramebufferParameteriv"); + glad_glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC)load(userptr, "glGetInternalformati64v"); + glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC)load(userptr, "glGetObjectLabel"); + glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC)load(userptr, "glGetObjectPtrLabel"); + glad_glGetPointerv = (PFNGLGETPOINTERVPROC)load(userptr, "glGetPointerv"); + glad_glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC)load(userptr, "glGetProgramInterfaceiv"); + glad_glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC)load(userptr, "glGetProgramResourceIndex"); + glad_glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC)load(userptr, "glGetProgramResourceLocation"); + glad_glGetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)load(userptr, "glGetProgramResourceLocationIndex"); + glad_glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC)load(userptr, "glGetProgramResourceName"); + glad_glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC)load(userptr, "glGetProgramResourceiv"); + glad_glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC)load(userptr, "glInvalidateBufferData"); + glad_glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC)load(userptr, "glInvalidateBufferSubData"); + glad_glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC)load(userptr, "glInvalidateFramebuffer"); + glad_glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC)load(userptr, "glInvalidateSubFramebuffer"); + glad_glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC)load(userptr, "glInvalidateTexImage"); + glad_glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC)load(userptr, "glInvalidateTexSubImage"); + glad_glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC)load(userptr, "glMultiDrawArraysIndirect"); + glad_glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC)load(userptr, "glMultiDrawElementsIndirect"); + glad_glObjectLabel = (PFNGLOBJECTLABELPROC)load(userptr, "glObjectLabel"); + glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC)load(userptr, "glObjectPtrLabel"); + glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC)load(userptr, "glPopDebugGroup"); + glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC)load(userptr, "glPushDebugGroup"); + glad_glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC)load(userptr, "glShaderStorageBlockBinding"); + glad_glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC)load(userptr, "glTexBufferRange"); + glad_glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)load(userptr, "glTexStorage2DMultisample"); + glad_glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC)load(userptr, "glTexStorage3DMultisample"); + glad_glTextureView = (PFNGLTEXTUREVIEWPROC)load(userptr, "glTextureView"); + glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)load(userptr, "glVertexAttribBinding"); + glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)load(userptr, "glVertexAttribFormat"); + glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)load(userptr, "glVertexAttribIFormat"); + glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)load(userptr, "glVertexAttribLFormat"); + glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)load(userptr, "glVertexBindingDivisor"); } -static void glad_gl_load_GL_VERSION_4_4( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_4_4) return; - glad_glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC) load(userptr, "glBindBuffersBase"); - glad_glBindBuffersRange = (PFNGLBINDBUFFERSRANGEPROC) load(userptr, "glBindBuffersRange"); - glad_glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC) load(userptr, "glBindImageTextures"); - glad_glBindSamplers = (PFNGLBINDSAMPLERSPROC) load(userptr, "glBindSamplers"); - glad_glBindTextures = (PFNGLBINDTEXTURESPROC) load(userptr, "glBindTextures"); - glad_glBindVertexBuffers = (PFNGLBINDVERTEXBUFFERSPROC) load(userptr, "glBindVertexBuffers"); - glad_glBufferStorage = (PFNGLBUFFERSTORAGEPROC) load(userptr, "glBufferStorage"); - glad_glClearTexImage = (PFNGLCLEARTEXIMAGEPROC) load(userptr, "glClearTexImage"); - glad_glClearTexSubImage = (PFNGLCLEARTEXSUBIMAGEPROC) load(userptr, "glClearTexSubImage"); +static void glad_gl_load_GL_VERSION_4_4(GLADuserptrloadfunc load, void *userptr) { + if (!GLAD_GL_VERSION_4_4) return; + glad_glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC)load(userptr, "glBindBuffersBase"); + glad_glBindBuffersRange = (PFNGLBINDBUFFERSRANGEPROC)load(userptr, "glBindBuffersRange"); + glad_glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC)load(userptr, "glBindImageTextures"); + glad_glBindSamplers = (PFNGLBINDSAMPLERSPROC)load(userptr, "glBindSamplers"); + glad_glBindTextures = (PFNGLBINDTEXTURESPROC)load(userptr, "glBindTextures"); + glad_glBindVertexBuffers = (PFNGLBINDVERTEXBUFFERSPROC)load(userptr, "glBindVertexBuffers"); + glad_glBufferStorage = (PFNGLBUFFERSTORAGEPROC)load(userptr, "glBufferStorage"); + glad_glClearTexImage = (PFNGLCLEARTEXIMAGEPROC)load(userptr, "glClearTexImage"); + glad_glClearTexSubImage = (PFNGLCLEARTEXSUBIMAGEPROC)load(userptr, "glClearTexSubImage"); } - - #if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) #define GLAD_GL_IS_SOME_NEW_VERSION 1 #else #define GLAD_GL_IS_SOME_NEW_VERSION 0 #endif -static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) { +static int glad_gl_get_extensions(int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) { #if GLAD_GL_IS_SOME_NEW_VERSION - if(GLAD_VERSION_MAJOR(version) < 3) { + if (GLAD_VERSION_MAJOR(version) < 3) { #else - (void) version; - (void) out_num_exts_i; - (void) out_exts_i; + (void)version; + (void)out_num_exts_i; + (void)out_exts_i; #endif - if (glad_glGetString == NULL) { - return 0; - } - *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS); + if (glad_glGetString == NULL) { + return 0; + } + *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS); #if GLAD_GL_IS_SOME_NEW_VERSION - } else { - unsigned int index = 0; - unsigned int num_exts_i = 0; - char **exts_i = NULL; - if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) { - return 0; - } - glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i); - if (num_exts_i > 0) { - exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i)); - } - if (exts_i == NULL) { - return 0; - } - for(index = 0; index < num_exts_i; index++) { - const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index); - size_t len = strlen(gl_str_tmp) + 1; - - char *local_str = (char*) malloc(len * sizeof(char)); - if(local_str != NULL) { - memcpy(local_str, gl_str_tmp, len * sizeof(char)); - } - - exts_i[index] = local_str; - } - - *out_num_exts_i = num_exts_i; - *out_exts_i = exts_i; - } -#endif - return 1; -} -static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) { - if (exts_i != NULL) { - unsigned int index; - for(index = 0; index < num_exts_i; index++) { - free((void *) (exts_i[index])); - } - free((void *)exts_i); - exts_i = NULL; - } -} -static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) { - if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) { - const char *extensions; - const char *loc; - const char *terminator; - extensions = exts; - if(extensions == NULL || ext == NULL) { - return 0; - } - while(1) { - loc = strstr(extensions, ext); - if(loc == NULL) { - return 0; - } - terminator = loc + strlen(ext); - if((loc == extensions || *(loc - 1) == ' ') && - (*terminator == ' ' || *terminator == '\0')) { - return 1; - } - extensions = terminator; - } - } else { - unsigned int index; - for(index = 0; index < num_exts_i; index++) { - const char *e = exts_i[index]; - if(strcmp(e, ext) == 0) { - return 1; - } - } - } - return 0; -} - -static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) { - return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name); -} - -static int glad_gl_find_extensions_gl( int version) { - const char *exts = NULL; + } else { + unsigned int index = 0; unsigned int num_exts_i = 0; char **exts_i = NULL; - if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0; + if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) { + return 0; + } + glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int *)&num_exts_i); + if (num_exts_i > 0) { + exts_i = (char **)malloc(num_exts_i * (sizeof *exts_i)); + } + if (exts_i == NULL) { + return 0; + } + for (index = 0; index < num_exts_i; index++) { + const char *gl_str_tmp = (const char *)glad_glGetStringi(GL_EXTENSIONS, index); + size_t len = strlen(gl_str_tmp) + 1; - (void) glad_gl_has_extension; + char *local_str = (char *)malloc(len * sizeof(char)); + if (local_str != NULL) { + memcpy(local_str, gl_str_tmp, len * sizeof(char)); + } - glad_gl_free_extensions(exts_i, num_exts_i); + exts_i[index] = local_str; + } - return 1; + *out_num_exts_i = num_exts_i; + *out_exts_i = exts_i; + } +#endif + return 1; +} +static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) { + if (exts_i != NULL) { + unsigned int index; + for (index = 0; index < num_exts_i; index++) { + free((void *)(exts_i[index])); + } + free((void *)exts_i); + exts_i = NULL; + } +} +static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) { + if (GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) { + const char *extensions; + const char *loc; + const char *terminator; + extensions = exts; + if (extensions == NULL || ext == NULL) { + return 0; + } + while (1) { + loc = strstr(extensions, ext); + if (loc == NULL) { + return 0; + } + terminator = loc + strlen(ext); + if ((loc == extensions || *(loc - 1) == ' ') && + (*terminator == ' ' || *terminator == '\0')) { + return 1; + } + extensions = terminator; + } + } else { + unsigned int index; + for (index = 0; index < num_exts_i; index++) { + const char *e = exts_i[index]; + if (strcmp(e, ext) == 0) { + return 1; + } + } + } + return 0; +} + +static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char *name) { + return (GLAD_GNUC_EXTENSION(GLADapiproc(*)(const char *name)) userptr)(name); +} + +static int glad_gl_find_extensions_gl(int version) { + const char *exts = NULL; + unsigned int num_exts_i = 0; + char **exts_i = NULL; + if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0; + + (void)glad_gl_has_extension; + + glad_gl_free_extensions(exts_i, num_exts_i); + + return 1; } static int glad_gl_find_core_gl(void) { - int i; - const char* version; - const char* prefixes[] = { - "OpenGL ES-CM ", - "OpenGL ES-CL ", - "OpenGL ES ", - "OpenGL SC ", - NULL - }; - int major = 0; - int minor = 0; - version = (const char*) glad_glGetString(GL_VERSION); - if (!version) return 0; - for (i = 0; prefixes[i]; i++) { - const size_t length = strlen(prefixes[i]); - if (strncmp(version, prefixes[i], length) == 0) { - version += length; - break; - } + int i; + const char *version; + const char *prefixes[] = { + "OpenGL ES-CM ", + "OpenGL ES-CL ", + "OpenGL ES ", + "OpenGL SC ", + NULL}; + int major = 0; + int minor = 0; + version = (const char *)glad_glGetString(GL_VERSION); + if (!version) return 0; + for (i = 0; prefixes[i]; i++) { + const size_t length = strlen(prefixes[i]); + if (strncmp(version, prefixes[i], length) == 0) { + version += length; + break; } + } - GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor); + GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor); - GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; - GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; - GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; - GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1; - GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1; - GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1; - GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; - GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2; - GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3; - GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3; - GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3; - GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3; - GLAD_GL_VERSION_4_0 = (major == 4 && minor >= 0) || major > 4; - GLAD_GL_VERSION_4_1 = (major == 4 && minor >= 1) || major > 4; - GLAD_GL_VERSION_4_2 = (major == 4 && minor >= 2) || major > 4; - GLAD_GL_VERSION_4_3 = (major == 4 && minor >= 3) || major > 4; - GLAD_GL_VERSION_4_4 = (major == 4 && minor >= 4) || major > 4; + GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; + GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; + GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; + GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1; + GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1; + GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1; + GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; + GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2; + GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3; + GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3; + GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3; + GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3; + GLAD_GL_VERSION_4_0 = (major == 4 && minor >= 0) || major > 4; + GLAD_GL_VERSION_4_1 = (major == 4 && minor >= 1) || major > 4; + GLAD_GL_VERSION_4_2 = (major == 4 && minor >= 2) || major > 4; + GLAD_GL_VERSION_4_3 = (major == 4 && minor >= 3) || major > 4; + GLAD_GL_VERSION_4_4 = (major == 4 && minor >= 4) || major > 4; - return GLAD_MAKE_VERSION(major, minor); + return GLAD_MAKE_VERSION(major, minor); } -int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) { - int version; +int gladLoadGLUserPtr(GLADuserptrloadfunc load, void *userptr) { + int version; - glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString"); - if(glad_glGetString == NULL) return 0; - if(glad_glGetString(GL_VERSION) == NULL) return 0; - version = glad_gl_find_core_gl(); + glad_glGetString = (PFNGLGETSTRINGPROC)load(userptr, "glGetString"); + if (glad_glGetString == NULL) return 0; + if (glad_glGetString(GL_VERSION) == NULL) return 0; + version = glad_gl_find_core_gl(); - glad_gl_load_GL_VERSION_1_0(load, userptr); - glad_gl_load_GL_VERSION_1_1(load, userptr); - glad_gl_load_GL_VERSION_1_2(load, userptr); - glad_gl_load_GL_VERSION_1_3(load, userptr); - glad_gl_load_GL_VERSION_1_4(load, userptr); - glad_gl_load_GL_VERSION_1_5(load, userptr); - glad_gl_load_GL_VERSION_2_0(load, userptr); - glad_gl_load_GL_VERSION_2_1(load, userptr); - glad_gl_load_GL_VERSION_3_0(load, userptr); - glad_gl_load_GL_VERSION_3_1(load, userptr); - glad_gl_load_GL_VERSION_3_2(load, userptr); - glad_gl_load_GL_VERSION_3_3(load, userptr); - glad_gl_load_GL_VERSION_4_0(load, userptr); - glad_gl_load_GL_VERSION_4_1(load, userptr); - glad_gl_load_GL_VERSION_4_2(load, userptr); - glad_gl_load_GL_VERSION_4_3(load, userptr); - glad_gl_load_GL_VERSION_4_4(load, userptr); + glad_gl_load_GL_VERSION_1_0(load, userptr); + glad_gl_load_GL_VERSION_1_1(load, userptr); + glad_gl_load_GL_VERSION_1_2(load, userptr); + glad_gl_load_GL_VERSION_1_3(load, userptr); + glad_gl_load_GL_VERSION_1_4(load, userptr); + glad_gl_load_GL_VERSION_1_5(load, userptr); + glad_gl_load_GL_VERSION_2_0(load, userptr); + glad_gl_load_GL_VERSION_2_1(load, userptr); + glad_gl_load_GL_VERSION_3_0(load, userptr); + glad_gl_load_GL_VERSION_3_1(load, userptr); + glad_gl_load_GL_VERSION_3_2(load, userptr); + glad_gl_load_GL_VERSION_3_3(load, userptr); + glad_gl_load_GL_VERSION_4_0(load, userptr); + glad_gl_load_GL_VERSION_4_1(load, userptr); + glad_gl_load_GL_VERSION_4_2(load, userptr); + glad_gl_load_GL_VERSION_4_3(load, userptr); + glad_gl_load_GL_VERSION_4_4(load, userptr); - if (!glad_gl_find_extensions_gl(version)) return 0; + if (!glad_gl_find_extensions_gl(version)) return 0; - - - return version; + return version; } - -int gladLoadGL( GLADloadfunc load) { - return gladLoadGLUserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); +int gladLoadGL(GLADloadfunc load) { + return gladLoadGLUserPtr(glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION(void *) load); } - - - - - #ifdef __cplusplus } #endif diff --git a/source/engine/glad/gl.h b/source/engine/glad/gl.h index 6fabd6f..15804a0 100644 --- a/source/engine/glad/gl.h +++ b/source/engine/glad/gl.h @@ -33,19 +33,19 @@ #pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #ifdef __gl_h_ - #error OpenGL (gl.h) header already included (API: gl), remove previous include! +#error OpenGL (gl.h) header already included (API: gl), remove previous include! #endif #define __gl_h_ 1 #ifdef __gl3_h_ - #error OpenGL (gl3.h) header already included (API: gl), remove previous include! +#error OpenGL (gl3.h) header already included (API: gl), remove previous include! #endif #define __gl3_h_ 1 #ifdef __glext_h_ - #error OpenGL (glext.h) header already included (API: gl), remove previous include! +#error OpenGL (glext.h) header already included (API: gl), remove previous include! #endif #define __glext_h_ 1 #ifdef __gl3ext_h_ - #error OpenGL (gl3ext.h) header already included (API: gl), remove previous include! +#error OpenGL (gl3ext.h) header already included (API: gl), remove previous include! #endif #define __gl3ext_h_ 1 #ifdef __clang__ @@ -62,90 +62,90 @@ extern "C" { #define GLAD_PLATFORM_H_ #ifndef GLAD_PLATFORM_WIN32 - #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__) - #define GLAD_PLATFORM_WIN32 1 - #else - #define GLAD_PLATFORM_WIN32 0 - #endif +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__) +#define GLAD_PLATFORM_WIN32 1 +#else +#define GLAD_PLATFORM_WIN32 0 +#endif #endif #ifndef GLAD_PLATFORM_APPLE - #ifdef __APPLE__ - #define GLAD_PLATFORM_APPLE 1 - #else - #define GLAD_PLATFORM_APPLE 0 - #endif +#ifdef __APPLE__ +#define GLAD_PLATFORM_APPLE 1 +#else +#define GLAD_PLATFORM_APPLE 0 +#endif #endif #ifndef GLAD_PLATFORM_EMSCRIPTEN - #ifdef __EMSCRIPTEN__ - #define GLAD_PLATFORM_EMSCRIPTEN 1 - #else - #define GLAD_PLATFORM_EMSCRIPTEN 0 - #endif +#ifdef __EMSCRIPTEN__ +#define GLAD_PLATFORM_EMSCRIPTEN 1 +#else +#define GLAD_PLATFORM_EMSCRIPTEN 0 +#endif #endif #ifndef GLAD_PLATFORM_UWP - #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY) - #ifdef __has_include - #if __has_include() - #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1 - #endif - #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_ - #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1 - #endif - #endif +#if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY) +#ifdef __has_include +#if __has_include() +#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1 +#endif +#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_ +#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1 +#endif +#endif - #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY - #include - #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) - #define GLAD_PLATFORM_UWP 1 - #endif - #endif +#ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY +#include +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +#define GLAD_PLATFORM_UWP 1 +#endif +#endif - #ifndef GLAD_PLATFORM_UWP - #define GLAD_PLATFORM_UWP 0 - #endif +#ifndef GLAD_PLATFORM_UWP +#define GLAD_PLATFORM_UWP 0 +#endif #endif #ifdef __GNUC__ - #define GLAD_GNUC_EXTENSION __extension__ +#define GLAD_GNUC_EXTENSION __extension__ #else - #define GLAD_GNUC_EXTENSION +#define GLAD_GNUC_EXTENSION #endif #ifndef GLAD_API_CALL - #if defined(GLAD_API_CALL_EXPORT) - #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__) - #if defined(GLAD_API_CALL_EXPORT_BUILD) - #if defined(__GNUC__) - #define GLAD_API_CALL __attribute__ ((dllexport)) extern - #else - #define GLAD_API_CALL __declspec(dllexport) extern - #endif - #else - #if defined(__GNUC__) - #define GLAD_API_CALL __attribute__ ((dllimport)) extern - #else - #define GLAD_API_CALL __declspec(dllimport) extern - #endif - #endif - #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD) - #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern - #else - #define GLAD_API_CALL extern - #endif - #else - #define GLAD_API_CALL extern - #endif +#if defined(GLAD_API_CALL_EXPORT) +#if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__) +#if defined(GLAD_API_CALL_EXPORT_BUILD) +#if defined(__GNUC__) +#define GLAD_API_CALL __attribute__((dllexport)) extern +#else +#define GLAD_API_CALL __declspec(dllexport) extern +#endif +#else +#if defined(__GNUC__) +#define GLAD_API_CALL __attribute__((dllimport)) extern +#else +#define GLAD_API_CALL __declspec(dllimport) extern +#endif +#endif +#elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD) +#define GLAD_API_CALL __attribute__((visibility("default"))) extern +#else +#define GLAD_API_CALL extern +#endif +#else +#define GLAD_API_CALL extern +#endif #endif #ifdef APIENTRY - #define GLAD_API_PTR APIENTRY +#define GLAD_API_PTR APIENTRY #elif GLAD_PLATFORM_WIN32 - #define GLAD_API_PTR __stdcall +#define GLAD_API_PTR __stdcall #else - #define GLAD_API_PTR +#define GLAD_API_PTR #endif #ifndef GLAPI @@ -1925,7 +1925,6 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro #define GL_ZOOM_X 0x0D16 #define GL_ZOOM_Y 0x0D17 - #include typedef unsigned int GLenum; typedef unsigned char GLboolean; @@ -1982,14 +1981,13 @@ typedef khronos_uint64_t GLuint64EXT; typedef struct __GLsync *GLsync; struct _cl_context; struct _cl_event; -typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +typedef void(GLAD_API_PTR *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); +typedef void(GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); +typedef void(GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); +typedef void(GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar *message, void *userParam); typedef unsigned short GLhalfNV; typedef GLintptr GLvdpauSurfaceNV; -typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void); - +typedef void(GLAD_API_PTR *GLVULKANPROCNV)(void); #define GL_VERSION_1_0 1 GLAD_API_CALL int GLAD_GL_VERSION_1_0; @@ -2026,929 +2024,928 @@ GLAD_API_CALL int GLAD_GL_VERSION_4_3; #define GL_VERSION_4_4 1 GLAD_API_CALL int GLAD_GL_VERSION_4_4; - -typedef void (GLAD_API_PTR *PFNGLACCUMPROC)(GLenum op, GLfloat value); -typedef void (GLAD_API_PTR *PFNGLACTIVESHADERPROGRAMPROC)(GLuint pipeline, GLuint program); -typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture); -typedef void (GLAD_API_PTR *PFNGLALPHAFUNCPROC)(GLenum func, GLfloat ref); -typedef GLboolean (GLAD_API_PTR *PFNGLARETEXTURESRESIDENTPROC)(GLsizei n, const GLuint * textures, GLboolean * residences); -typedef void (GLAD_API_PTR *PFNGLARRAYELEMENTPROC)(GLint i); -typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); -typedef void (GLAD_API_PTR *PFNGLBEGINPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); -typedef void (GLAD_API_PTR *PFNGLBEGINQUERYINDEXEDPROC)(GLenum target, GLuint index, GLuint id); -typedef void (GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode); -typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); -typedef void (GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer); -typedef void (GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAD_API_PTR *PFNGLBINDBUFFERSBASEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint * buffers); -typedef void (GLAD_API_PTR *PFNGLBINDBUFFERSRANGEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint * buffers, const GLintptr * offsets, const GLsizeiptr * sizes); -typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); -typedef void (GLAD_API_PTR *PFNGLBINDIMAGETEXTUREPROC)(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (GLAD_API_PTR *PFNGLBINDIMAGETEXTURESPROC)(GLuint first, GLsizei count, const GLuint * textures); -typedef void (GLAD_API_PTR *PFNGLBINDPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); -typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); -typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERSPROC)(GLuint first, GLsizei count, const GLuint * samplers); -typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); -typedef void (GLAD_API_PTR *PFNGLBINDTEXTURESPROC)(GLuint first, GLsizei count, const GLuint * textures); -typedef void (GLAD_API_PTR *PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, GLuint id); -typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint array); -typedef void (GLAD_API_PTR *PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (GLAD_API_PTR *PFNGLBINDVERTEXBUFFERSPROC)(GLuint first, GLsizei count, const GLuint * buffers, const GLintptr * offsets, const GLsizei * strides); -typedef void (GLAD_API_PTR *PFNGLBITMAPPROC)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); -typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIPROC)(GLuint buf, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); -typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIPROC)(GLuint buf, GLenum src, GLenum dst); -typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage); -typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEPROC)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags); -typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data); -typedef void (GLAD_API_PTR *PFNGLCALLLISTPROC)(GLuint list); -typedef void (GLAD_API_PTR *PFNGLCALLLISTSPROC)(GLsizei n, GLenum type, const void * lists); -typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); -typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp); -typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask); -typedef void (GLAD_API_PTR *PFNGLCLEARACCUMPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERDATAPROC)(GLenum target, GLenum internalformat, GLenum format, GLenum type, const void * data); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERSUBDATAPROC)(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void * data); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble depth); -typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHFPROC)(GLfloat d); -typedef void (GLAD_API_PTR *PFNGLCLEARINDEXPROC)(GLfloat c); -typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s); -typedef void (GLAD_API_PTR *PFNGLCLEARTEXIMAGEPROC)(GLuint texture, GLint level, GLenum format, GLenum type, const void * data); -typedef void (GLAD_API_PTR *PFNGLCLEARTEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); -typedef void (GLAD_API_PTR *PFNGLCLIENTACTIVETEXTUREPROC)(GLenum texture); -typedef GLenum (GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (GLAD_API_PTR *PFNGLCLIPPLANEPROC)(GLenum plane, const GLdouble * equation); -typedef void (GLAD_API_PTR *PFNGLCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3BVPROC)(const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3IPROC)(GLint red, GLint green, GLint blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3UBVPROC)(const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3UIVPROC)(const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3USVPROC)(const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4BPROC)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4BVPROC)(const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4DPROC)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4FPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4IPROC)(GLint red, GLint green, GLint blue, GLint alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4SPROC)(GLshort red, GLshort green, GLshort blue, GLshort alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4UBPROC)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4UBVPROC)(const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4UIPROC)(GLuint red, GLuint green, GLuint blue, GLuint alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4UIVPROC)(const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4USPROC)(GLushort red, GLushort green, GLushort blue, GLushort alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4USVPROC)(const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -typedef void (GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (GLAD_API_PTR *PFNGLCOLORMATERIALPROC)(GLenum face, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLCOLORP3UIPROC)(GLenum type, GLuint color); -typedef void (GLAD_API_PTR *PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint * color); -typedef void (GLAD_API_PTR *PFNGLCOLORP4UIPROC)(GLenum type, GLuint color); -typedef void (GLAD_API_PTR *PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint * color); -typedef void (GLAD_API_PTR *PFNGLCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAPROC)(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -typedef void (GLAD_API_PTR *PFNGLCOPYPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void); -typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type); -typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROGRAMVPROC)(GLenum type, GLsizei count, const GLchar *const* strings); -typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, const void * userParam); -typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled); -typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf); -typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers); -typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers); -typedef void (GLAD_API_PTR *PFNGLDELETELISTSPROC)(GLuint list, GLsizei range); -typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program); -typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPIPELINESPROC)(GLsizei n, const GLuint * pipelines); -typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint * ids); -typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers); -typedef void (GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint * samplers); -typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader); -typedef void (GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync sync); -typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures); -typedef void (GLAD_API_PTR *PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, const GLuint * ids); -typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint * arrays); -typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func); -typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag); -typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f); -typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEARRAYVPROC)(GLuint first, GLsizei count, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEINDEXEDPROC)(GLuint index, GLdouble n, GLdouble f); -typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); -typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); -typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap); -typedef void (GLAD_API_PTR *PFNGLDISABLECLIENTSTATEPROC)(GLenum array); -typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void (GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum target, GLuint index); -typedef void (GLAD_API_PTR *PFNGLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -typedef void (GLAD_API_PTR *PFNGLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect); -typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count); -typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINDIRECTPROC)(GLenum mode, const void * indirect); -typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum buf); -typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum * bufs); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void * indirect); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLuint baseinstance); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -typedef void (GLAD_API_PTR *PFNGLDRAWPIXELSPROC)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices); -typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex); -typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKPROC)(GLenum mode, GLuint id); -typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)(GLenum mode, GLuint id, GLsizei instancecount); -typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)(GLenum mode, GLuint id, GLuint stream); -typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)(GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPROC)(GLboolean flag); -typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPOINTERPROC)(GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLEDGEFLAGVPROC)(const GLboolean * flag); -typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap); -typedef void (GLAD_API_PTR *PFNGLENABLECLIENTSTATEPROC)(GLenum array); -typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void (GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum target, GLuint index); -typedef void (GLAD_API_PTR *PFNGLENDPROC)(void); -typedef void (GLAD_API_PTR *PFNGLENDCONDITIONALRENDERPROC)(void); -typedef void (GLAD_API_PTR *PFNGLENDLISTPROC)(void); -typedef void (GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum target); -typedef void (GLAD_API_PTR *PFNGLENDQUERYINDEXEDPROC)(GLenum target, GLuint index); -typedef void (GLAD_API_PTR *PFNGLENDTRANSFORMFEEDBACKPROC)(void); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DPROC)(GLdouble u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DVPROC)(const GLdouble * u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FPROC)(GLfloat u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FVPROC)(const GLfloat * u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DPROC)(GLdouble u, GLdouble v); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DVPROC)(const GLdouble * u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FPROC)(GLfloat u, GLfloat v); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FVPROC)(const GLfloat * u); -typedef void (GLAD_API_PTR *PFNGLEVALMESH1PROC)(GLenum mode, GLint i1, GLint i2); -typedef void (GLAD_API_PTR *PFNGLEVALMESH2PROC)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); -typedef void (GLAD_API_PTR *PFNGLEVALPOINT1PROC)(GLint i); -typedef void (GLAD_API_PTR *PFNGLEVALPOINT2PROC)(GLint i, GLint j); -typedef void (GLAD_API_PTR *PFNGLFEEDBACKBUFFERPROC)(GLsizei size, GLenum type, GLfloat * buffer); -typedef GLsync (GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags); -typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void); -typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void); -typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDDPROC)(GLdouble coord); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDDVPROC)(const GLdouble * coord); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDFPROC)(GLfloat coord); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDFVPROC)(const GLfloat * coord); -typedef void (GLAD_API_PTR *PFNGLFOGFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLFOGFVPROC)(GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLFOGIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLFOGIVPROC)(GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLFRUSTUMPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers); -typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers); -typedef GLuint (GLAD_API_PTR *PFNGLGENLISTSPROC)(GLsizei range); -typedef void (GLAD_API_PTR *PFNGLGENPROGRAMPIPELINESPROC)(GLsizei n, GLuint * pipelines); -typedef void (GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei n, GLuint * ids); -typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers); -typedef void (GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint * samplers); -typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures); -typedef void (GLAD_API_PTR *PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint * ids); -typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint * arrays); -typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)(GLuint program, GLuint bufferIndex, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETACTIVESUBROUTINENAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)(GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint * values); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders); -typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean * data); -typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data); -typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 * params); -typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void ** params); -typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void * data); -typedef void (GLAD_API_PTR *PFNGLGETCLIPPLANEPROC)(GLenum plane, GLdouble * equation); -typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void * img); -typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog); -typedef void (GLAD_API_PTR *PFNGLGETDOUBLEI_VPROC)(GLenum target, GLuint index, GLdouble * data); -typedef void (GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble * data); -typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void); -typedef void (GLAD_API_PTR *PFNGLGETFLOATI_VPROC)(GLenum target, GLuint index, GLfloat * data); -typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data); -typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar * name); -typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 * data); -typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 * data); -typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint * data); -typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data); -typedef void (GLAD_API_PTR *PFNGLGETINTERNALFORMATI64VPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 * params); -typedef void (GLAD_API_PTR *PFNGLGETINTERNALFORMATIVPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETLIGHTFVPROC)(GLenum light, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETLIGHTIVPROC)(GLenum light, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETMAPDVPROC)(GLenum target, GLenum query, GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLGETMAPFVPROC)(GLenum target, GLenum query, GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLGETMAPIVPROC)(GLenum target, GLenum query, GLint * v); -typedef void (GLAD_API_PTR *PFNGLGETMATERIALFVPROC)(GLenum face, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETMATERIALIVPROC)(GLenum face, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat * val); -typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label); -typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELPROC)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label); -typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPFVPROC)(GLenum map, GLfloat * values); -typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUIVPROC)(GLenum map, GLuint * values); -typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUSVPROC)(GLenum map, GLushort * values); -typedef void (GLAD_API_PTR *PFNGLGETPOINTERVPROC)(GLenum pname, void ** params); -typedef void (GLAD_API_PTR *PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte * mask); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMBINARYPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINTERFACEIVPROC)(GLuint program, GLenum programInterface, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEINFOLOGPROC)(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEIVPROC)(GLuint pipeline, GLenum pname, GLint * params); -typedef GLuint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCEINDEXPROC)(GLuint program, GLenum programInterface, const GLchar * name); -typedef GLint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONPROC)(GLuint program, GLenum programInterface, const GLchar * name); -typedef GLint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)(GLuint program, GLenum programInterface, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCENAMEPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCEIVPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei count, GLsizei * length, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMSTAGEIVPROC)(GLuint program, GLenum shadertype, GLenum pname, GLint * values); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYINDEXEDIVPROC)(GLenum target, GLuint index, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog); -typedef void (GLAD_API_PTR *PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision); -typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source); -typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params); -typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name); -typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum name, GLuint index); -typedef GLuint (GLAD_API_PTR *PFNGLGETSUBROUTINEINDEXPROC)(GLuint program, GLenum shadertype, const GLchar * name); -typedef GLint (GLAD_API_PTR *PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)(GLuint program, GLenum shadertype, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei * length, GLint * values); -typedef void (GLAD_API_PTR *PFNGLGETTEXENVFVPROC)(GLenum target, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXENVIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXGENDVPROC)(GLenum coord, GLenum pname, GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXGENFVPROC)(GLenum coord, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXGENIVPROC)(GLenum coord, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels); -typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); -typedef GLuint (GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar * uniformBlockName); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices); -typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMSUBROUTINEUIVPROC)(GLenum shadertype, GLint location, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMDVPROC)(GLuint program, GLint location, GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBLDVPROC)(GLuint index, GLenum pname, GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLINDEXMASKPROC)(GLuint mask); -typedef void (GLAD_API_PTR *PFNGLINDEXPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLINDEXDPROC)(GLdouble c); -typedef void (GLAD_API_PTR *PFNGLINDEXDVPROC)(const GLdouble * c); -typedef void (GLAD_API_PTR *PFNGLINDEXFPROC)(GLfloat c); -typedef void (GLAD_API_PTR *PFNGLINDEXFVPROC)(const GLfloat * c); -typedef void (GLAD_API_PTR *PFNGLINDEXIPROC)(GLint c); -typedef void (GLAD_API_PTR *PFNGLINDEXIVPROC)(const GLint * c); -typedef void (GLAD_API_PTR *PFNGLINDEXSPROC)(GLshort c); -typedef void (GLAD_API_PTR *PFNGLINDEXSVPROC)(const GLshort * c); -typedef void (GLAD_API_PTR *PFNGLINDEXUBPROC)(GLubyte c); -typedef void (GLAD_API_PTR *PFNGLINDEXUBVPROC)(const GLubyte * c); -typedef void (GLAD_API_PTR *PFNGLINITNAMESPROC)(void); -typedef void (GLAD_API_PTR *PFNGLINTERLEAVEDARRAYSPROC)(GLenum format, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer); -typedef void (GLAD_API_PTR *PFNGLINVALIDATEBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (GLAD_API_PTR *PFNGLINVALIDATEFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum * attachments); -typedef void (GLAD_API_PTR *PFNGLINVALIDATESUBFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLINVALIDATETEXIMAGEPROC)(GLuint texture, GLint level); -typedef void (GLAD_API_PTR *PFNGLINVALIDATETEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer); -typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap); -typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum target, GLuint index); -typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); -typedef GLboolean (GLAD_API_PTR *PFNGLISLISTPROC)(GLuint list); -typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program); -typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint id); -typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); -typedef GLboolean (GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint sampler); -typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader); -typedef GLboolean (GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync sync); -typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture); -typedef GLboolean (GLAD_API_PTR *PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id); -typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint array); -typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFVPROC)(GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIVPROC)(GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLLIGHTFPROC)(GLenum light, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLLIGHTFVPROC)(GLenum light, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLLIGHTIPROC)(GLenum light, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLLIGHTIVPROC)(GLenum light, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLLINESTIPPLEPROC)(GLint factor, GLushort pattern); -typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width); -typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program); -typedef void (GLAD_API_PTR *PFNGLLISTBASEPROC)(GLuint base); -typedef void (GLAD_API_PTR *PFNGLLOADIDENTITYPROC)(void); -typedef void (GLAD_API_PTR *PFNGLLOADMATRIXDPROC)(const GLdouble * m); -typedef void (GLAD_API_PTR *PFNGLLOADMATRIXFPROC)(const GLfloat * m); -typedef void (GLAD_API_PTR *PFNGLLOADNAMEPROC)(GLuint name); -typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXDPROC)(const GLdouble * m); -typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXFPROC)(const GLfloat * m); -typedef void (GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum opcode); -typedef void (GLAD_API_PTR *PFNGLMAP1DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points); -typedef void (GLAD_API_PTR *PFNGLMAP1FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points); -typedef void (GLAD_API_PTR *PFNGLMAP2DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points); -typedef void (GLAD_API_PTR *PFNGLMAP2FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points); -typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum target, GLenum access); -typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (GLAD_API_PTR *PFNGLMAPGRID1DPROC)(GLint un, GLdouble u1, GLdouble u2); -typedef void (GLAD_API_PTR *PFNGLMAPGRID1FPROC)(GLint un, GLfloat u1, GLfloat u2); -typedef void (GLAD_API_PTR *PFNGLMAPGRID2DPROC)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); -typedef void (GLAD_API_PTR *PFNGLMAPGRID2FPROC)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); -typedef void (GLAD_API_PTR *PFNGLMATERIALFPROC)(GLenum face, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLMATERIALFVPROC)(GLenum face, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLMATERIALIPROC)(GLenum face, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLMATERIALIVPROC)(GLenum face, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLMATRIXMODEPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLMEMORYBARRIERPROC)(GLbitfield barriers); -typedef void (GLAD_API_PTR *PFNGLMINSAMPLESHADINGPROC)(GLfloat value); -typedef void (GLAD_API_PTR *PFNGLMULTMATRIXDPROC)(const GLdouble * m); -typedef void (GLAD_API_PTR *PFNGLMULTMATRIXFPROC)(const GLfloat * m); -typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXDPROC)(const GLdouble * m); -typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXFPROC)(const GLfloat * m); -typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount); -typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSINDIRECTPROC)(GLenum mode, const void * indirect, GLsizei drawcount, GLsizei stride); -typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount); -typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex); -typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void * indirect, GLsizei drawcount, GLsizei stride); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DPROC)(GLenum target, GLdouble s); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DVPROC)(GLenum target, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FPROC)(GLenum target, GLfloat s); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FVPROC)(GLenum target, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IPROC)(GLenum target, GLint s); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IVPROC)(GLenum target, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SPROC)(GLenum target, GLshort s); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SVPROC)(GLenum target, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DPROC)(GLenum target, GLdouble s, GLdouble t); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DVPROC)(GLenum target, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, GLfloat t); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FVPROC)(GLenum target, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IPROC)(GLenum target, GLint s, GLint t); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IVPROC)(GLenum target, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SPROC)(GLenum target, GLshort s, GLshort t); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SVPROC)(GLenum target, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DVPROC)(GLenum target, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FVPROC)(GLenum target, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IPROC)(GLenum target, GLint s, GLint t, GLint r); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IVPROC)(GLenum target, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SPROC)(GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SVPROC)(GLenum target, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DVPROC)(GLenum target, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FVPROC)(GLenum target, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IPROC)(GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IVPROC)(GLenum target, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SPROC)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SVPROC)(GLenum target, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLNEWLISTPROC)(GLuint list, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLNORMAL3BPROC)(GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3BVPROC)(const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLNORMAL3DPROC)(GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLNORMAL3FPROC)(GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLNORMAL3IPROC)(GLint nx, GLint ny, GLint nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLNORMAL3SPROC)(GLshort nx, GLshort ny, GLshort nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLNORMALPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label); -typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELPROC)(const void * ptr, GLsizei length, const GLchar * label); -typedef void (GLAD_API_PTR *PFNGLORTHOPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (GLAD_API_PTR *PFNGLPASSTHROUGHPROC)(GLfloat token); -typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERFVPROC)(GLenum pname, const GLfloat * values); -typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERIPROC)(GLenum pname, GLint value); -typedef void (GLAD_API_PTR *PFNGLPAUSETRANSFORMFEEDBACKPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPIXELMAPFVPROC)(GLenum map, GLsizei mapsize, const GLfloat * values); -typedef void (GLAD_API_PTR *PFNGLPIXELMAPUIVPROC)(GLenum map, GLsizei mapsize, const GLuint * values); -typedef void (GLAD_API_PTR *PFNGLPIXELMAPUSVPROC)(GLenum map, GLsizei mapsize, const GLushort * values); -typedef void (GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLPIXELZOOMPROC)(GLfloat xfactor, GLfloat yfactor); -typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat size); -typedef void (GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units); -typedef void (GLAD_API_PTR *PFNGLPOLYGONSTIPPLEPROC)(const GLubyte * mask); -typedef void (GLAD_API_PTR *PFNGLPOPATTRIBPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPOPCLIENTATTRIBPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPOPMATRIXPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPOPNAMEPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index); -typedef void (GLAD_API_PTR *PFNGLPRIORITIZETEXTURESPROC)(GLsizei n, const GLuint * textures, const GLfloat * priorities); -typedef void (GLAD_API_PTR *PFNGLPROGRAMBINARYPROC)(GLuint program, GLenum binaryFormat, const void * binary, GLsizei length); -typedef void (GLAD_API_PTR *PFNGLPROGRAMPARAMETERIPROC)(GLuint program, GLenum pname, GLint value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1DPROC)(GLuint program, GLint location, GLdouble v0); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FPROC)(GLuint program, GLint location, GLfloat v0); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IPROC)(GLuint program, GLint location, GLint v0); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IVPROC)(GLuint program, GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIPROC)(GLuint program, GLint location, GLuint v0); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IPROC)(GLuint program, GLint location, GLint v0, GLint v1); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IVPROC)(GLuint program, GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IVPROC)(GLuint program, GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IVPROC)(GLuint program, GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLPUSHATTRIBPROC)(GLbitfield mask); -typedef void (GLAD_API_PTR *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield mask); -typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar * message); -typedef void (GLAD_API_PTR *PFNGLPUSHMATRIXPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPUSHNAMEPROC)(GLuint name); -typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DPROC)(GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FPROC)(GLfloat x, GLfloat y); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IPROC)(GLint x, GLint y); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SPROC)(GLshort x, GLshort y); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IPROC)(GLint x, GLint y, GLint z); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SPROC)(GLshort x, GLshort y, GLshort z); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IPROC)(GLint x, GLint y, GLint z, GLint w); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum src); -typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels); -typedef void (GLAD_API_PTR *PFNGLRECTDPROC)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); -typedef void (GLAD_API_PTR *PFNGLRECTDVPROC)(const GLdouble * v1, const GLdouble * v2); -typedef void (GLAD_API_PTR *PFNGLRECTFPROC)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); -typedef void (GLAD_API_PTR *PFNGLRECTFVPROC)(const GLfloat * v1, const GLfloat * v2); -typedef void (GLAD_API_PTR *PFNGLRECTIPROC)(GLint x1, GLint y1, GLint x2, GLint y2); -typedef void (GLAD_API_PTR *PFNGLRECTIVPROC)(const GLint * v1, const GLint * v2); -typedef void (GLAD_API_PTR *PFNGLRECTSPROC)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); -typedef void (GLAD_API_PTR *PFNGLRECTSVPROC)(const GLshort * v1, const GLshort * v2); -typedef void (GLAD_API_PTR *PFNGLRELEASESHADERCOMPILERPROC)(void); -typedef GLint (GLAD_API_PTR *PFNGLRENDERMODEPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLRESUMETRANSFORMFEEDBACKPROC)(void); -typedef void (GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert); -typedef void (GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint * param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint * param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat * param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint * param); -typedef void (GLAD_API_PTR *PFNGLSCALEDPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLSCALEFPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLSCISSORARRAYVPROC)(GLuint first, GLsizei count, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDPROC)(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BVPROC)(const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IPROC)(GLint red, GLint green, GLint blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBVPROC)(const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIVPROC)(const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USVPROC)(const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint * color); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLSELECTBUFFERPROC)(GLsizei size, GLuint * buffer); -typedef void (GLAD_API_PTR *PFNGLSHADEMODELPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint * shaders, GLenum binaryFormat, const void * binary, GLsizei length); -typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length); -typedef void (GLAD_API_PTR *PFNGLSHADERSTORAGEBLOCKBINDINGPROC)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask); -typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask); -typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); -typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass); -typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer); -typedef void (GLAD_API_PTR *PFNGLTEXBUFFERRANGEPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DPROC)(GLdouble s); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FPROC)(GLfloat s); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IPROC)(GLint s); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SPROC)(GLshort s); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DPROC)(GLdouble s, GLdouble t); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FPROC)(GLfloat s, GLfloat t); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IPROC)(GLint s, GLint t); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SPROC)(GLshort s, GLshort t); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DPROC)(GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FPROC)(GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IPROC)(GLint s, GLint t, GLint r); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SPROC)(GLshort s, GLshort t, GLshort r); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DPROC)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FPROC)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IPROC)(GLint s, GLint t, GLint r, GLint q); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SPROC)(GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLTEXENVFPROC)(GLenum target, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLTEXENVFVPROC)(GLenum target, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLTEXENVIPROC)(GLenum target, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLTEXENVIVPROC)(GLenum target, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLTEXGENDPROC)(GLenum coord, GLenum pname, GLdouble param); -typedef void (GLAD_API_PTR *PFNGLTEXGENDVPROC)(GLenum coord, GLenum pname, const GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLTEXGENFPROC)(GLenum coord, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLTEXGENFVPROC)(GLenum coord, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLTEXGENIPROC)(GLenum coord, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLTEXGENIVPROC)(GLenum coord, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint * params); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE1DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE2DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXTUREVIEWPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); -typedef void (GLAD_API_PTR *PFNGLTRANSLATEDPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLTRANSLATEFPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1DPROC)(GLint location, GLdouble x); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1DVPROC)(GLint location, GLsizei count, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2DPROC)(GLint location, GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2DVPROC)(GLint location, GLsizei count, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3DVPROC)(GLint location, GLsizei count, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4DVPROC)(GLint location, GLsizei count, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMSUBROUTINESUIVPROC)(GLenum shadertype, GLsizei count, const GLuint * indices); -typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum target); -typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program); -typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMSTAGESPROC)(GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program); -typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef void (GLAD_API_PTR *PFNGLVERTEX2DPROC)(GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLVERTEX2DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX2FPROC)(GLfloat x, GLfloat y); -typedef void (GLAD_API_PTR *PFNGLVERTEX2FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX2IPROC)(GLint x, GLint y); -typedef void (GLAD_API_PTR *PFNGLVERTEX2IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX2SPROC)(GLshort x, GLshort y); -typedef void (GLAD_API_PTR *PFNGLVERTEX2SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX3DPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLVERTEX3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX3FPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLVERTEX3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX3IPROC)(GLint x, GLint y, GLint z); -typedef void (GLAD_API_PTR *PFNGLVERTEX3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX3SPROC)(GLshort x, GLshort y, GLshort z); -typedef void (GLAD_API_PTR *PFNGLVERTEX3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAD_API_PTR *PFNGLVERTEX4DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAD_API_PTR *PFNGLVERTEX4FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX4IPROC)(GLint x, GLint y, GLint z, GLint w); -typedef void (GLAD_API_PTR *PFNGLVERTEX4IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAD_API_PTR *PFNGLVERTEX4SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, GLuint bindingindex); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL1DPROC)(GLuint index, GLdouble x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL1DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL2DPROC)(GLuint index, GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL2DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL3DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBL4DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBLFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBLPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, GLuint divisor); -typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLVIEWPORTARRAYVPROC)(GLuint first, GLsizei count, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DPROC)(GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FPROC)(GLfloat x, GLfloat y); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IPROC)(GLint x, GLint y); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SPROC)(GLshort x, GLshort y); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IPROC)(GLint x, GLint y, GLint z); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SPROC)(GLshort x, GLshort y, GLshort z); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SVPROC)(const GLshort * v); +typedef void(GLAD_API_PTR *PFNGLACCUMPROC)(GLenum op, GLfloat value); +typedef void(GLAD_API_PTR *PFNGLACTIVESHADERPROGRAMPROC)(GLuint pipeline, GLuint program); +typedef void(GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture); +typedef void(GLAD_API_PTR *PFNGLALPHAFUNCPROC)(GLenum func, GLfloat ref); +typedef GLboolean(GLAD_API_PTR *PFNGLARETEXTURESRESIDENTPROC)(GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void(GLAD_API_PTR *PFNGLARRAYELEMENTPROC)(GLint i); +typedef void(GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); +typedef void(GLAD_API_PTR *PFNGLBEGINPROC)(GLenum mode); +typedef void(GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode); +typedef void(GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); +typedef void(GLAD_API_PTR *PFNGLBEGINQUERYINDEXEDPROC)(GLenum target, GLuint index, GLuint id); +typedef void(GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode); +typedef void(GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar *name); +typedef void(GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); +typedef void(GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer); +typedef void(GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void(GLAD_API_PTR *PFNGLBINDBUFFERSBASEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void(GLAD_API_PTR *PFNGLBINDBUFFERSRANGEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void(GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar *name); +typedef void(GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef void(GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); +typedef void(GLAD_API_PTR *PFNGLBINDIMAGETEXTUREPROC)(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void(GLAD_API_PTR *PFNGLBINDIMAGETEXTURESPROC)(GLuint first, GLsizei count, const GLuint *textures); +typedef void(GLAD_API_PTR *PFNGLBINDPROGRAMPIPELINEPROC)(GLuint pipeline); +typedef void(GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); +typedef void(GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); +typedef void(GLAD_API_PTR *PFNGLBINDSAMPLERSPROC)(GLuint first, GLsizei count, const GLuint *samplers); +typedef void(GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); +typedef void(GLAD_API_PTR *PFNGLBINDTEXTURESPROC)(GLuint first, GLsizei count, const GLuint *textures); +typedef void(GLAD_API_PTR *PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, GLuint id); +typedef void(GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint array); +typedef void(GLAD_API_PTR *PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void(GLAD_API_PTR *PFNGLBINDVERTEXBUFFERSPROC)(GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void(GLAD_API_PTR *PFNGLBITMAPPROC)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +typedef void(GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void(GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode); +typedef void(GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); +typedef void(GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void(GLAD_API_PTR *PFNGLBLENDEQUATIONIPROC)(GLuint buf, GLenum mode); +typedef void(GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); +typedef void(GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void(GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void(GLAD_API_PTR *PFNGLBLENDFUNCIPROC)(GLuint buf, GLenum src, GLenum dst); +typedef void(GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void(GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void(GLAD_API_PTR *PFNGLBUFFERSTORAGEPROC)(GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void(GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void(GLAD_API_PTR *PFNGLCALLLISTPROC)(GLuint list); +typedef void(GLAD_API_PTR *PFNGLCALLLISTSPROC)(GLsizei n, GLenum type, const void *lists); +typedef GLenum(GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); +typedef void(GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp); +typedef void(GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask); +typedef void(GLAD_API_PTR *PFNGLCLEARACCUMPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void(GLAD_API_PTR *PFNGLCLEARBUFFERDATAPROC)(GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void(GLAD_API_PTR *PFNGLCLEARBUFFERSUBDATAPROC)(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void(GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void(GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void(GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble depth); +typedef void(GLAD_API_PTR *PFNGLCLEARDEPTHFPROC)(GLfloat d); +typedef void(GLAD_API_PTR *PFNGLCLEARINDEXPROC)(GLfloat c); +typedef void(GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s); +typedef void(GLAD_API_PTR *PFNGLCLEARTEXIMAGEPROC)(GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void(GLAD_API_PTR *PFNGLCLEARTEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void(GLAD_API_PTR *PFNGLCLIENTACTIVETEXTUREPROC)(GLenum texture); +typedef GLenum(GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void(GLAD_API_PTR *PFNGLCLIPPLANEPROC)(GLenum plane, const GLdouble *equation); +typedef void(GLAD_API_PTR *PFNGLCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); +typedef void(GLAD_API_PTR *PFNGLCOLOR3BVPROC)(const GLbyte *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); +typedef void(GLAD_API_PTR *PFNGLCOLOR3DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); +typedef void(GLAD_API_PTR *PFNGLCOLOR3FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR3IPROC)(GLint red, GLint green, GLint blue); +typedef void(GLAD_API_PTR *PFNGLCOLOR3IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); +typedef void(GLAD_API_PTR *PFNGLCOLOR3SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); +typedef void(GLAD_API_PTR *PFNGLCOLOR3UBVPROC)(const GLubyte *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); +typedef void(GLAD_API_PTR *PFNGLCOLOR3UIVPROC)(const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); +typedef void(GLAD_API_PTR *PFNGLCOLOR3USVPROC)(const GLushort *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR4BPROC)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +typedef void(GLAD_API_PTR *PFNGLCOLOR4BVPROC)(const GLbyte *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR4DPROC)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +typedef void(GLAD_API_PTR *PFNGLCOLOR4DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR4FPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void(GLAD_API_PTR *PFNGLCOLOR4FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR4IPROC)(GLint red, GLint green, GLint blue, GLint alpha); +typedef void(GLAD_API_PTR *PFNGLCOLOR4IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR4SPROC)(GLshort red, GLshort green, GLshort blue, GLshort alpha); +typedef void(GLAD_API_PTR *PFNGLCOLOR4SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR4UBPROC)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +typedef void(GLAD_API_PTR *PFNGLCOLOR4UBVPROC)(const GLubyte *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR4UIPROC)(GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef void(GLAD_API_PTR *PFNGLCOLOR4UIVPROC)(const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLCOLOR4USPROC)(GLushort red, GLushort green, GLushort blue, GLushort alpha); +typedef void(GLAD_API_PTR *PFNGLCOLOR4USVPROC)(const GLushort *v); +typedef void(GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void(GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void(GLAD_API_PTR *PFNGLCOLORMATERIALPROC)(GLenum face, GLenum mode); +typedef void(GLAD_API_PTR *PFNGLCOLORP3UIPROC)(GLenum type, GLuint color); +typedef void(GLAD_API_PTR *PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint *color); +typedef void(GLAD_API_PTR *PFNGLCOLORP4UIPROC)(GLenum type, GLuint color); +typedef void(GLAD_API_PTR *PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint *color); +typedef void(GLAD_API_PTR *PFNGLCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader); +typedef void(GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void(GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void(GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void(GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void(GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void(GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void(GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void(GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAPROC)(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void(GLAD_API_PTR *PFNGLCOPYPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +typedef void(GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void(GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void(GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void(GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint(GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void); +typedef GLuint(GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type); +typedef GLuint(GLAD_API_PTR *PFNGLCREATESHADERPROGRAMVPROC)(GLenum type, GLsizei count, const GLchar *const *strings); +typedef void(GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode); +typedef void(GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, const void *userParam); +typedef void(GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void(GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void(GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint *buffers); +typedef void(GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers); +typedef void(GLAD_API_PTR *PFNGLDELETELISTSPROC)(GLuint list, GLsizei range); +typedef void(GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program); +typedef void(GLAD_API_PTR *PFNGLDELETEPROGRAMPIPELINESPROC)(GLsizei n, const GLuint *pipelines); +typedef void(GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint *ids); +typedef void(GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers); +typedef void(GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint *samplers); +typedef void(GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader); +typedef void(GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync sync); +typedef void(GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint *textures); +typedef void(GLAD_API_PTR *PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, const GLuint *ids); +typedef void(GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint *arrays); +typedef void(GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func); +typedef void(GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag); +typedef void(GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f); +typedef void(GLAD_API_PTR *PFNGLDEPTHRANGEARRAYVPROC)(GLuint first, GLsizei count, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLDEPTHRANGEINDEXEDPROC)(GLuint index, GLdouble n, GLdouble f); +typedef void(GLAD_API_PTR *PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); +typedef void(GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); +typedef void(GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap); +typedef void(GLAD_API_PTR *PFNGLDISABLECLIENTSTATEPROC)(GLenum array); +typedef void(GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void(GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum target, GLuint index); +typedef void(GLAD_API_PTR *PFNGLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void(GLAD_API_PTR *PFNGLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect); +typedef void(GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count); +typedef void(GLAD_API_PTR *PFNGLDRAWARRAYSINDIRECTPROC)(GLenum mode, const void *indirect); +typedef void(GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void(GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void(GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum buf); +typedef void(GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum *bufs); +typedef void(GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void(GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void(GLAD_API_PTR *PFNGLDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void *indirect); +typedef void(GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void(GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void(GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void(GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void(GLAD_API_PTR *PFNGLDRAWPIXELSPROC)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void(GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void(GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void(GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKPROC)(GLenum mode, GLuint id); +typedef void(GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)(GLenum mode, GLuint id, GLsizei instancecount); +typedef void(GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)(GLenum mode, GLuint id, GLuint stream); +typedef void(GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)(GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +typedef void(GLAD_API_PTR *PFNGLEDGEFLAGPROC)(GLboolean flag); +typedef void(GLAD_API_PTR *PFNGLEDGEFLAGPOINTERPROC)(GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLEDGEFLAGVPROC)(const GLboolean *flag); +typedef void(GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap); +typedef void(GLAD_API_PTR *PFNGLENABLECLIENTSTATEPROC)(GLenum array); +typedef void(GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void(GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum target, GLuint index); +typedef void(GLAD_API_PTR *PFNGLENDPROC)(void); +typedef void(GLAD_API_PTR *PFNGLENDCONDITIONALRENDERPROC)(void); +typedef void(GLAD_API_PTR *PFNGLENDLISTPROC)(void); +typedef void(GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum target); +typedef void(GLAD_API_PTR *PFNGLENDQUERYINDEXEDPROC)(GLenum target, GLuint index); +typedef void(GLAD_API_PTR *PFNGLENDTRANSFORMFEEDBACKPROC)(void); +typedef void(GLAD_API_PTR *PFNGLEVALCOORD1DPROC)(GLdouble u); +typedef void(GLAD_API_PTR *PFNGLEVALCOORD1DVPROC)(const GLdouble *u); +typedef void(GLAD_API_PTR *PFNGLEVALCOORD1FPROC)(GLfloat u); +typedef void(GLAD_API_PTR *PFNGLEVALCOORD1FVPROC)(const GLfloat *u); +typedef void(GLAD_API_PTR *PFNGLEVALCOORD2DPROC)(GLdouble u, GLdouble v); +typedef void(GLAD_API_PTR *PFNGLEVALCOORD2DVPROC)(const GLdouble *u); +typedef void(GLAD_API_PTR *PFNGLEVALCOORD2FPROC)(GLfloat u, GLfloat v); +typedef void(GLAD_API_PTR *PFNGLEVALCOORD2FVPROC)(const GLfloat *u); +typedef void(GLAD_API_PTR *PFNGLEVALMESH1PROC)(GLenum mode, GLint i1, GLint i2); +typedef void(GLAD_API_PTR *PFNGLEVALMESH2PROC)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +typedef void(GLAD_API_PTR *PFNGLEVALPOINT1PROC)(GLint i); +typedef void(GLAD_API_PTR *PFNGLEVALPOINT2PROC)(GLint i, GLint j); +typedef void(GLAD_API_PTR *PFNGLFEEDBACKBUFFERPROC)(GLsizei size, GLenum type, GLfloat *buffer); +typedef GLsync(GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags); +typedef void(GLAD_API_PTR *PFNGLFINISHPROC)(void); +typedef void(GLAD_API_PTR *PFNGLFLUSHPROC)(void); +typedef void(GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length); +typedef void(GLAD_API_PTR *PFNGLFOGCOORDPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLFOGCOORDDPROC)(GLdouble coord); +typedef void(GLAD_API_PTR *PFNGLFOGCOORDDVPROC)(const GLdouble *coord); +typedef void(GLAD_API_PTR *PFNGLFOGCOORDFPROC)(GLfloat coord); +typedef void(GLAD_API_PTR *PFNGLFOGCOORDFVPROC)(const GLfloat *coord); +typedef void(GLAD_API_PTR *PFNGLFOGFPROC)(GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLFOGFVPROC)(GLenum pname, const GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLFOGIPROC)(GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLFOGIVPROC)(GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLFRAMEBUFFERPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void(GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void(GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void(GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void(GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void(GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void(GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode); +typedef void(GLAD_API_PTR *PFNGLFRUSTUMPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void(GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint *buffers); +typedef void(GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers); +typedef GLuint(GLAD_API_PTR *PFNGLGENLISTSPROC)(GLsizei range); +typedef void(GLAD_API_PTR *PFNGLGENPROGRAMPIPELINESPROC)(GLsizei n, GLuint *pipelines); +typedef void(GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei n, GLuint *ids); +typedef void(GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers); +typedef void(GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint *samplers); +typedef void(GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint *textures); +typedef void(GLAD_API_PTR *PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint *ids); +typedef void(GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint *arrays); +typedef void(GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target); +typedef void(GLAD_API_PTR *PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)(GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETACTIVESUBROUTINENAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)(GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void(GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void(GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef void(GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint(GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean *data); +typedef void(GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean *data); +typedef void(GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 *params); +typedef void(GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void **params); +typedef void(GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void(GLAD_API_PTR *PFNGLGETCLIPPLANEPROC)(GLenum plane, GLdouble *equation); +typedef void(GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void *img); +typedef GLuint(GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void(GLAD_API_PTR *PFNGLGETDOUBLEI_VPROC)(GLenum target, GLuint index, GLdouble *data); +typedef void(GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble *data); +typedef GLenum(GLAD_API_PTR *PFNGLGETERRORPROC)(void); +typedef void(GLAD_API_PTR *PFNGLGETFLOATI_VPROC)(GLenum target, GLuint index, GLfloat *data); +typedef void(GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat *data); +typedef GLint(GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar *name); +typedef GLint(GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 *data); +typedef void(GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 *data); +typedef void(GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint *data); +typedef void(GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint *data); +typedef void(GLAD_API_PTR *PFNGLGETINTERNALFORMATI64VPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); +typedef void(GLAD_API_PTR *PFNGLGETINTERNALFORMATIVPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETLIGHTFVPROC)(GLenum light, GLenum pname, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETLIGHTIVPROC)(GLenum light, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETMAPDVPROC)(GLenum target, GLenum query, GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLGETMAPFVPROC)(GLenum target, GLenum query, GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLGETMAPIVPROC)(GLenum target, GLenum query, GLint *v); +typedef void(GLAD_API_PTR *PFNGLGETMATERIALFVPROC)(GLenum face, GLenum pname, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETMATERIALIVPROC)(GLenum face, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat *val); +typedef void(GLAD_API_PTR *PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void(GLAD_API_PTR *PFNGLGETOBJECTPTRLABELPROC)(const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void(GLAD_API_PTR *PFNGLGETPIXELMAPFVPROC)(GLenum map, GLfloat *values); +typedef void(GLAD_API_PTR *PFNGLGETPIXELMAPUIVPROC)(GLenum map, GLuint *values); +typedef void(GLAD_API_PTR *PFNGLGETPIXELMAPUSVPROC)(GLenum map, GLushort *values); +typedef void(GLAD_API_PTR *PFNGLGETPOINTERVPROC)(GLenum pname, void **params); +typedef void(GLAD_API_PTR *PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte *mask); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMBINARYPROC)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMINTERFACEIVPROC)(GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEINFOLOGPROC)(GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEIVPROC)(GLuint pipeline, GLenum pname, GLint *params); +typedef GLuint(GLAD_API_PTR *PFNGLGETPROGRAMRESOURCEINDEXPROC)(GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint(GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONPROC)(GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint(GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)(GLuint program, GLenum programInterface, const GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMRESOURCENAMEPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMRESOURCEIVPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMSTAGEIVPROC)(GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void(GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETQUERYINDEXEDIVPROC)(GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 *params); +typedef void(GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 *params); +typedef void(GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint *params); +typedef void(GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint *params); +typedef void(GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void(GLAD_API_PTR *PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void(GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef void(GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params); +typedef const GLubyte *(GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name); +typedef const GLubyte *(GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum name, GLuint index); +typedef GLuint(GLAD_API_PTR *PFNGLGETSUBROUTINEINDEXPROC)(GLuint program, GLenum shadertype, const GLchar *name); +typedef GLint(GLAD_API_PTR *PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)(GLuint program, GLenum shadertype, const GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +typedef void(GLAD_API_PTR *PFNGLGETTEXENVFVPROC)(GLenum target, GLenum pname, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXENVIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXGENDVPROC)(GLenum coord, GLenum pname, GLdouble *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXGENFVPROC)(GLenum coord, GLenum pname, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXGENIVPROC)(GLenum coord, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void(GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef GLuint(GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar *uniformBlockName); +typedef void(GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices); +typedef GLint(GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar *name); +typedef void(GLAD_API_PTR *PFNGLGETUNIFORMSUBROUTINEUIVPROC)(GLenum shadertype, GLint location, GLuint *params); +typedef void(GLAD_API_PTR *PFNGLGETUNIFORMDVPROC)(GLuint program, GLint location, GLdouble *params); +typedef void(GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint *params); +typedef void(GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint *params); +typedef void(GLAD_API_PTR *PFNGLGETVERTEXATTRIBLDVPROC)(GLuint index, GLenum pname, GLdouble *params); +typedef void(GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void **pointer); +typedef void(GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble *params); +typedef void(GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint *params); +typedef void(GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode); +typedef void(GLAD_API_PTR *PFNGLINDEXMASKPROC)(GLuint mask); +typedef void(GLAD_API_PTR *PFNGLINDEXPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLINDEXDPROC)(GLdouble c); +typedef void(GLAD_API_PTR *PFNGLINDEXDVPROC)(const GLdouble *c); +typedef void(GLAD_API_PTR *PFNGLINDEXFPROC)(GLfloat c); +typedef void(GLAD_API_PTR *PFNGLINDEXFVPROC)(const GLfloat *c); +typedef void(GLAD_API_PTR *PFNGLINDEXIPROC)(GLint c); +typedef void(GLAD_API_PTR *PFNGLINDEXIVPROC)(const GLint *c); +typedef void(GLAD_API_PTR *PFNGLINDEXSPROC)(GLshort c); +typedef void(GLAD_API_PTR *PFNGLINDEXSVPROC)(const GLshort *c); +typedef void(GLAD_API_PTR *PFNGLINDEXUBPROC)(GLubyte c); +typedef void(GLAD_API_PTR *PFNGLINDEXUBVPROC)(const GLubyte *c); +typedef void(GLAD_API_PTR *PFNGLINITNAMESPROC)(void); +typedef void(GLAD_API_PTR *PFNGLINTERLEAVEDARRAYSPROC)(GLenum format, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer); +typedef void(GLAD_API_PTR *PFNGLINVALIDATEBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void(GLAD_API_PTR *PFNGLINVALIDATEFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void(GLAD_API_PTR *PFNGLINVALIDATESUBFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(GLAD_API_PTR *PFNGLINVALIDATETEXIMAGEPROC)(GLuint texture, GLint level); +typedef void(GLAD_API_PTR *PFNGLINVALIDATETEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef GLboolean(GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer); +typedef GLboolean(GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap); +typedef GLboolean(GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum target, GLuint index); +typedef GLboolean(GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); +typedef GLboolean(GLAD_API_PTR *PFNGLISLISTPROC)(GLuint list); +typedef GLboolean(GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program); +typedef GLboolean(GLAD_API_PTR *PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline); +typedef GLboolean(GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint id); +typedef GLboolean(GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); +typedef GLboolean(GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint sampler); +typedef GLboolean(GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader); +typedef GLboolean(GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync sync); +typedef GLboolean(GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture); +typedef GLboolean(GLAD_API_PTR *PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id); +typedef GLboolean(GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint array); +typedef void(GLAD_API_PTR *PFNGLLIGHTMODELFPROC)(GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLLIGHTMODELFVPROC)(GLenum pname, const GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLLIGHTMODELIPROC)(GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLLIGHTMODELIVPROC)(GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLLIGHTFPROC)(GLenum light, GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLLIGHTFVPROC)(GLenum light, GLenum pname, const GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLLIGHTIPROC)(GLenum light, GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLLIGHTIVPROC)(GLenum light, GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLLINESTIPPLEPROC)(GLint factor, GLushort pattern); +typedef void(GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width); +typedef void(GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program); +typedef void(GLAD_API_PTR *PFNGLLISTBASEPROC)(GLuint base); +typedef void(GLAD_API_PTR *PFNGLLOADIDENTITYPROC)(void); +typedef void(GLAD_API_PTR *PFNGLLOADMATRIXDPROC)(const GLdouble *m); +typedef void(GLAD_API_PTR *PFNGLLOADMATRIXFPROC)(const GLfloat *m); +typedef void(GLAD_API_PTR *PFNGLLOADNAMEPROC)(GLuint name); +typedef void(GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXDPROC)(const GLdouble *m); +typedef void(GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXFPROC)(const GLfloat *m); +typedef void(GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum opcode); +typedef void(GLAD_API_PTR *PFNGLMAP1DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void(GLAD_API_PTR *PFNGLMAP1FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void(GLAD_API_PTR *PFNGLMAP2DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void(GLAD_API_PTR *PFNGLMAP2FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +typedef void *(GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum target, GLenum access); +typedef void *(GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void(GLAD_API_PTR *PFNGLMAPGRID1DPROC)(GLint un, GLdouble u1, GLdouble u2); +typedef void(GLAD_API_PTR *PFNGLMAPGRID1FPROC)(GLint un, GLfloat u1, GLfloat u2); +typedef void(GLAD_API_PTR *PFNGLMAPGRID2DPROC)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +typedef void(GLAD_API_PTR *PFNGLMAPGRID2FPROC)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +typedef void(GLAD_API_PTR *PFNGLMATERIALFPROC)(GLenum face, GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLMATERIALFVPROC)(GLenum face, GLenum pname, const GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLMATERIALIPROC)(GLenum face, GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLMATERIALIVPROC)(GLenum face, GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLMATRIXMODEPROC)(GLenum mode); +typedef void(GLAD_API_PTR *PFNGLMEMORYBARRIERPROC)(GLbitfield barriers); +typedef void(GLAD_API_PTR *PFNGLMINSAMPLESHADINGPROC)(GLfloat value); +typedef void(GLAD_API_PTR *PFNGLMULTMATRIXDPROC)(const GLdouble *m); +typedef void(GLAD_API_PTR *PFNGLMULTMATRIXFPROC)(const GLfloat *m); +typedef void(GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXDPROC)(const GLdouble *m); +typedef void(GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXFPROC)(const GLfloat *m); +typedef void(GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void(GLAD_API_PTR *PFNGLMULTIDRAWARRAYSINDIRECTPROC)(GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void(GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei *count, GLenum type, const void *const *indices, GLsizei drawcount); +typedef void(GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei *count, GLenum type, const void *const *indices, GLsizei drawcount, const GLint *basevertex); +typedef void(GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD1DPROC)(GLenum target, GLdouble s); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD1DVPROC)(GLenum target, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD1FPROC)(GLenum target, GLfloat s); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD1FVPROC)(GLenum target, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD1IPROC)(GLenum target, GLint s); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD1IVPROC)(GLenum target, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD1SPROC)(GLenum target, GLshort s); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD1SVPROC)(GLenum target, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD2DPROC)(GLenum target, GLdouble s, GLdouble t); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD2DVPROC)(GLenum target, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, GLfloat t); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD2FVPROC)(GLenum target, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD2IPROC)(GLenum target, GLint s, GLint t); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD2IVPROC)(GLenum target, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD2SPROC)(GLenum target, GLshort s, GLshort t); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD2SVPROC)(GLenum target, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD3DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD3DVPROC)(GLenum target, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD3FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD3FVPROC)(GLenum target, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD3IPROC)(GLenum target, GLint s, GLint t, GLint r); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD3IVPROC)(GLenum target, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD3SPROC)(GLenum target, GLshort s, GLshort t, GLshort r); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD3SVPROC)(GLenum target, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD4DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD4DVPROC)(GLenum target, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD4FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD4FVPROC)(GLenum target, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD4IPROC)(GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD4IVPROC)(GLenum target, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD4SPROC)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORD4SVPROC)(GLenum target, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLNEWLISTPROC)(GLuint list, GLenum mode); +typedef void(GLAD_API_PTR *PFNGLNORMAL3BPROC)(GLbyte nx, GLbyte ny, GLbyte nz); +typedef void(GLAD_API_PTR *PFNGLNORMAL3BVPROC)(const GLbyte *v); +typedef void(GLAD_API_PTR *PFNGLNORMAL3DPROC)(GLdouble nx, GLdouble ny, GLdouble nz); +typedef void(GLAD_API_PTR *PFNGLNORMAL3DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLNORMAL3FPROC)(GLfloat nx, GLfloat ny, GLfloat nz); +typedef void(GLAD_API_PTR *PFNGLNORMAL3FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLNORMAL3IPROC)(GLint nx, GLint ny, GLint nz); +typedef void(GLAD_API_PTR *PFNGLNORMAL3IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLNORMAL3SPROC)(GLshort nx, GLshort ny, GLshort nz); +typedef void(GLAD_API_PTR *PFNGLNORMAL3SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLNORMALPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void(GLAD_API_PTR *PFNGLOBJECTPTRLABELPROC)(const void *ptr, GLsizei length, const GLchar *label); +typedef void(GLAD_API_PTR *PFNGLORTHOPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void(GLAD_API_PTR *PFNGLPASSTHROUGHPROC)(GLfloat token); +typedef void(GLAD_API_PTR *PFNGLPATCHPARAMETERFVPROC)(GLenum pname, const GLfloat *values); +typedef void(GLAD_API_PTR *PFNGLPATCHPARAMETERIPROC)(GLenum pname, GLint value); +typedef void(GLAD_API_PTR *PFNGLPAUSETRANSFORMFEEDBACKPROC)(void); +typedef void(GLAD_API_PTR *PFNGLPIXELMAPFVPROC)(GLenum map, GLsizei mapsize, const GLfloat *values); +typedef void(GLAD_API_PTR *PFNGLPIXELMAPUIVPROC)(GLenum map, GLsizei mapsize, const GLuint *values); +typedef void(GLAD_API_PTR *PFNGLPIXELMAPUSVPROC)(GLenum map, GLsizei mapsize, const GLushort *values); +typedef void(GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLPIXELTRANSFERFPROC)(GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLPIXELTRANSFERIPROC)(GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLPIXELZOOMPROC)(GLfloat xfactor, GLfloat yfactor); +typedef void(GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat size); +typedef void(GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode); +typedef void(GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units); +typedef void(GLAD_API_PTR *PFNGLPOLYGONSTIPPLEPROC)(const GLubyte *mask); +typedef void(GLAD_API_PTR *PFNGLPOPATTRIBPROC)(void); +typedef void(GLAD_API_PTR *PFNGLPOPCLIENTATTRIBPROC)(void); +typedef void(GLAD_API_PTR *PFNGLPOPDEBUGGROUPPROC)(void); +typedef void(GLAD_API_PTR *PFNGLPOPMATRIXPROC)(void); +typedef void(GLAD_API_PTR *PFNGLPOPNAMEPROC)(void); +typedef void(GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index); +typedef void(GLAD_API_PTR *PFNGLPRIORITIZETEXTURESPROC)(GLsizei n, const GLuint *textures, const GLfloat *priorities); +typedef void(GLAD_API_PTR *PFNGLPROGRAMBINARYPROC)(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void(GLAD_API_PTR *PFNGLPROGRAMPARAMETERIPROC)(GLuint program, GLenum pname, GLint value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM1DPROC)(GLuint program, GLint location, GLdouble v0); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM1DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FPROC)(GLuint program, GLint location, GLfloat v0); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IPROC)(GLuint program, GLint location, GLint v0); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIPROC)(GLuint program, GLint location, GLuint v0); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM2DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM2DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IPROC)(GLuint program, GLint location, GLint v0, GLint v1); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM3DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM3DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM4DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM4DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum mode); +typedef void(GLAD_API_PTR *PFNGLPUSHATTRIBPROC)(GLbitfield mask); +typedef void(GLAD_API_PTR *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield mask); +typedef void(GLAD_API_PTR *PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void(GLAD_API_PTR *PFNGLPUSHMATRIXPROC)(void); +typedef void(GLAD_API_PTR *PFNGLPUSHNAMEPROC)(GLuint name); +typedef void(GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS2DPROC)(GLdouble x, GLdouble y); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS2DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS2FPROC)(GLfloat x, GLfloat y); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS2FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS2IPROC)(GLint x, GLint y); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS2IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS2SPROC)(GLshort x, GLshort y); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS2SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS3DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS3FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS3IPROC)(GLint x, GLint y, GLint z); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS3IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS3SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS4DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS4FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS4IPROC)(GLint x, GLint y, GLint z, GLint w); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS4IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); +typedef void(GLAD_API_PTR *PFNGLRASTERPOS4SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum src); +typedef void(GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void(GLAD_API_PTR *PFNGLRECTDPROC)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +typedef void(GLAD_API_PTR *PFNGLRECTDVPROC)(const GLdouble *v1, const GLdouble *v2); +typedef void(GLAD_API_PTR *PFNGLRECTFPROC)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +typedef void(GLAD_API_PTR *PFNGLRECTFVPROC)(const GLfloat *v1, const GLfloat *v2); +typedef void(GLAD_API_PTR *PFNGLRECTIPROC)(GLint x1, GLint y1, GLint x2, GLint y2); +typedef void(GLAD_API_PTR *PFNGLRECTIVPROC)(const GLint *v1, const GLint *v2); +typedef void(GLAD_API_PTR *PFNGLRECTSPROC)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +typedef void(GLAD_API_PTR *PFNGLRECTSVPROC)(const GLshort *v1, const GLshort *v2); +typedef void(GLAD_API_PTR *PFNGLRELEASESHADERCOMPILERPROC)(void); +typedef GLint(GLAD_API_PTR *PFNGLRENDERMODEPROC)(GLenum mode); +typedef void(GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void(GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void(GLAD_API_PTR *PFNGLRESUMETRANSFORMFEEDBACKPROC)(void); +typedef void(GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void(GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert); +typedef void(GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask); +typedef void(GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint *param); +typedef void(GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint *param); +typedef void(GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat *param); +typedef void(GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint *param); +typedef void(GLAD_API_PTR *PFNGLSCALEDPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLSCALEFPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(GLAD_API_PTR *PFNGLSCISSORARRAYVPROC)(GLuint first, GLsizei count, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLSCISSORINDEXEDPROC)(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void(GLAD_API_PTR *PFNGLSCISSORINDEXEDVPROC)(GLuint index, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3BVPROC)(const GLbyte *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3IPROC)(GLint red, GLint green, GLint blue); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBVPROC)(const GLubyte *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIVPROC)(const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLOR3USVPROC)(const GLushort *v); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint *color); +typedef void(GLAD_API_PTR *PFNGLSECONDARYCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLSELECTBUFFERPROC)(GLsizei size, GLuint *buffer); +typedef void(GLAD_API_PTR *PFNGLSHADEMODELPROC)(GLenum mode); +typedef void(GLAD_API_PTR *PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void(GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length); +typedef void(GLAD_API_PTR *PFNGLSHADERSTORAGEBLOCKBINDINGPROC)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void(GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask); +typedef void(GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void(GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask); +typedef void(GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); +typedef void(GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass); +typedef void(GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void(GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer); +typedef void(GLAD_API_PTR *PFNGLTEXBUFFERRANGEPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD1DPROC)(GLdouble s); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD1DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD1FPROC)(GLfloat s); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD1FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD1IPROC)(GLint s); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD1IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD1SPROC)(GLshort s); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD1SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD2DPROC)(GLdouble s, GLdouble t); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD2DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD2FPROC)(GLfloat s, GLfloat t); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD2FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD2IPROC)(GLint s, GLint t); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD2IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD2SPROC)(GLshort s, GLshort t); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD2SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD3DPROC)(GLdouble s, GLdouble t, GLdouble r); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD3DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD3FPROC)(GLfloat s, GLfloat t, GLfloat r); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD3FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD3IPROC)(GLint s, GLint t, GLint r); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD3IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD3SPROC)(GLshort s, GLshort t, GLshort r); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD3SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD4DPROC)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD4DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD4FPROC)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD4FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD4IPROC)(GLint s, GLint t, GLint r, GLint q); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD4IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD4SPROC)(GLshort s, GLshort t, GLshort r, GLshort q); +typedef void(GLAD_API_PTR *PFNGLTEXCOORD4SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint *coords); +typedef void(GLAD_API_PTR *PFNGLTEXCOORDPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLTEXENVFPROC)(GLenum target, GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLTEXENVFVPROC)(GLenum target, GLenum pname, const GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLTEXENVIPROC)(GLenum target, GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLTEXENVIVPROC)(GLenum target, GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLTEXGENDPROC)(GLenum coord, GLenum pname, GLdouble param); +typedef void(GLAD_API_PTR *PFNGLTEXGENDVPROC)(GLenum coord, GLenum pname, const GLdouble *params); +typedef void(GLAD_API_PTR *PFNGLTEXGENFPROC)(GLenum coord, GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLTEXGENFVPROC)(GLenum coord, GLenum pname, const GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLTEXGENIPROC)(GLenum coord, GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLTEXGENIVPROC)(GLenum coord, GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void(GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void(GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void(GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void(GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void(GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint *params); +typedef void(GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param); +typedef void(GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat *params); +typedef void(GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); +typedef void(GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint *params); +typedef void(GLAD_API_PTR *PFNGLTEXSTORAGE1DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void(GLAD_API_PTR *PFNGLTEXSTORAGE2DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void(GLAD_API_PTR *PFNGLTEXSTORAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void(GLAD_API_PTR *PFNGLTEXSTORAGE3DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void(GLAD_API_PTR *PFNGLTEXSTORAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void(GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void(GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void(GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void(GLAD_API_PTR *PFNGLTEXTUREVIEWPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void(GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const *varyings, GLenum bufferMode); +typedef void(GLAD_API_PTR *PFNGLTRANSLATEDPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLTRANSLATEFPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(GLAD_API_PTR *PFNGLUNIFORM1DPROC)(GLint location, GLdouble x); +typedef void(GLAD_API_PTR *PFNGLUNIFORM1DVPROC)(GLint location, GLsizei count, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); +typedef void(GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0); +typedef void(GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); +typedef void(GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM2DPROC)(GLint location, GLdouble x, GLdouble y); +typedef void(GLAD_API_PTR *PFNGLUNIFORM2DVPROC)(GLint location, GLsizei count, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); +typedef void(GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); +typedef void(GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1); +typedef void(GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM3DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLUNIFORM3DVPROC)(GLint location, GLsizei count, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void(GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); +typedef void(GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void(GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM4DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(GLAD_API_PTR *PFNGLUNIFORM4DVPROC)(GLint location, GLsizei count, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void(GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void(GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void(GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(GLAD_API_PTR *PFNGLUNIFORMSUBROUTINESUIVPROC)(GLenum shadertype, GLsizei count, const GLuint *indices); +typedef GLboolean(GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum target); +typedef void(GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program); +typedef void(GLAD_API_PTR *PFNGLUSEPROGRAMSTAGESPROC)(GLuint pipeline, GLbitfield stages, GLuint program); +typedef void(GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program); +typedef void(GLAD_API_PTR *PFNGLVALIDATEPROGRAMPIPELINEPROC)(GLuint pipeline); +typedef void(GLAD_API_PTR *PFNGLVERTEX2DPROC)(GLdouble x, GLdouble y); +typedef void(GLAD_API_PTR *PFNGLVERTEX2DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX2FPROC)(GLfloat x, GLfloat y); +typedef void(GLAD_API_PTR *PFNGLVERTEX2FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX2IPROC)(GLint x, GLint y); +typedef void(GLAD_API_PTR *PFNGLVERTEX2IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX2SPROC)(GLshort x, GLshort y); +typedef void(GLAD_API_PTR *PFNGLVERTEX2SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLVERTEX3DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(GLAD_API_PTR *PFNGLVERTEX3FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX3IPROC)(GLint x, GLint y, GLint z); +typedef void(GLAD_API_PTR *PFNGLVERTEX3IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void(GLAD_API_PTR *PFNGLVERTEX3SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(GLAD_API_PTR *PFNGLVERTEX4DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void(GLAD_API_PTR *PFNGLVERTEX4FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX4IPROC)(GLint x, GLint y, GLint z, GLint w); +typedef void(GLAD_API_PTR *PFNGLVERTEX4IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEX4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); +typedef void(GLAD_API_PTR *PFNGLVERTEX4SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, GLuint bindingindex); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBL1DPROC)(GLuint index, GLdouble x); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBL1DVPROC)(GLuint index, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBL2DPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBL2DVPROC)(GLuint index, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBL3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBL3DVPROC)(GLuint index, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBL4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBL4DVPROC)(GLuint index, const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBLFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBLPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, GLuint divisor); +typedef void(GLAD_API_PTR *PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value); +typedef void(GLAD_API_PTR *PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value); +typedef void(GLAD_API_PTR *PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value); +typedef void(GLAD_API_PTR *PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint *value); +typedef void(GLAD_API_PTR *PFNGLVERTEXPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(GLAD_API_PTR *PFNGLVIEWPORTARRAYVPROC)(GLuint first, GLsizei count, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void(GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFVPROC)(GLuint index, const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS2DPROC)(GLdouble x, GLdouble y); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS2DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS2FPROC)(GLfloat x, GLfloat y); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS2FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS2IPROC)(GLint x, GLint y); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS2IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS2SPROC)(GLshort x, GLshort y); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS2SVPROC)(const GLshort *v); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS3DVPROC)(const GLdouble *v); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS3FVPROC)(const GLfloat *v); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS3IPROC)(GLint x, GLint y, GLint z); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS3IVPROC)(const GLint *v); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void(GLAD_API_PTR *PFNGLWINDOWPOS3SVPROC)(const GLshort *v); GLAD_API_CALL PFNGLACCUMPROC glad_glAccum; #define glAccum glad_glAccum @@ -4795,14 +4792,8 @@ GLAD_API_CALL PFNGLWINDOWPOS3SPROC glad_glWindowPos3s; GLAD_API_CALL PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv; #define glWindowPos3sv glad_glWindowPos3sv - - - - -GLAD_API_CALL int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr); -GLAD_API_CALL int gladLoadGL( GLADloadfunc load); - - +GLAD_API_CALL int gladLoadGLUserPtr(GLADuserptrloadfunc load, void *userptr); +GLAD_API_CALL int gladLoadGL(GLADloadfunc load); #ifdef __cplusplus } diff --git a/source/engine/input.c b/source/engine/input.c index 4309ecb..9944856 100644 --- a/source/engine/input.c +++ b/source/engine/input.c @@ -1,14 +1,14 @@ #include "input.h" -#include +#include "ffi.h" +#include "font.h" +#include "log.h" #include "script.h" #include "stb_ds.h" -#include "log.h" -#include "ffi.h" #include "time.h" -#include "font.h" +#include -#inlcude "stb_ds.h" +#include "stb_ds.h" int32_t mouseWheelX = 0; int32_t mouseWheelY = 0; @@ -24,8 +24,8 @@ JSValue jsany; JSValue jsmouse; JSValue jspos; -cpVect mouse_pos = {0,0}; -cpVect mouse_delta = {0,0}; +cpVect mouse_pos = {0, 0}; +cpVect mouse_delta = {0, 0}; struct joystick { int id; @@ -45,8 +45,7 @@ static struct { JSValue value; } *jshash = NULL; -JSValue input2js(const char *input) -{ +JSValue input2js(const char *input) { int idx = shgeti(jshash, input); if (idx != -1) return jshash[idx].value; @@ -60,36 +59,48 @@ JSValue input2js(const char *input) return n; } -const char *gamepad2str(int btn) -{ - switch(btn) { - case GLFW_GAMEPAD_BUTTON_CROSS: return "cross"; - case GLFW_GAMEPAD_BUTTON_CIRCLE: return "circle"; - case GLFW_GAMEPAD_BUTTON_SQUARE: return "square"; - case GLFW_GAMEPAD_BUTTON_TRIANGLE: return "triangle"; - case GLFW_GAMEPAD_BUTTON_START: return "start"; - case GLFW_GAMEPAD_BUTTON_LEFT_BUMPER: return "lbump"; - case GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER: return "rbump"; - case GLFW_GAMEPAD_BUTTON_GUIDE: return "guide"; - case GLFW_GAMEPAD_BUTTON_BACK: return "back"; - case GLFW_GAMEPAD_BUTTON_DPAD_UP: return "dup"; - case GLFW_GAMEPAD_BUTTON_DPAD_DOWN: return "ddown"; - case GLFW_GAMEPAD_BUTTON_DPAD_LEFT: return "dleft"; - case GLFW_GAMEPAD_BUTTON_DPAD_RIGHT: return "dright"; - case GLFW_GAMEPAD_BUTTON_LEFT_THUMB: return "lthumb"; - case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB: return "rthumb"; +const char *gamepad2str(int btn) { + switch (btn) { + case GLFW_GAMEPAD_BUTTON_CROSS: + return "cross"; + case GLFW_GAMEPAD_BUTTON_CIRCLE: + return "circle"; + case GLFW_GAMEPAD_BUTTON_SQUARE: + return "square"; + case GLFW_GAMEPAD_BUTTON_TRIANGLE: + return "triangle"; + case GLFW_GAMEPAD_BUTTON_START: + return "start"; + case GLFW_GAMEPAD_BUTTON_LEFT_BUMPER: + return "lbump"; + case GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER: + return "rbump"; + case GLFW_GAMEPAD_BUTTON_GUIDE: + return "guide"; + case GLFW_GAMEPAD_BUTTON_BACK: + return "back"; + case GLFW_GAMEPAD_BUTTON_DPAD_UP: + return "dup"; + case GLFW_GAMEPAD_BUTTON_DPAD_DOWN: + return "ddown"; + case GLFW_GAMEPAD_BUTTON_DPAD_LEFT: + return "dleft"; + case GLFW_GAMEPAD_BUTTON_DPAD_RIGHT: + return "dright"; + case GLFW_GAMEPAD_BUTTON_LEFT_THUMB: + return "lthumb"; + case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB: + return "rthumb"; } - + return "NOBTN"; } -void register_pawn(struct callee c) -{ +void register_pawn(struct callee c) { pawn_callee = c; } -void register_gamepad(struct callee c) -{ +void register_gamepad(struct callee c) { gamepad_callee = c; } @@ -108,25 +119,23 @@ void rm_downkey(int key) { } } -static void cursor_pos_cb(GLFWwindow *w, double xpos, double ypos) -{ - mouse_delta.x = xpos - mouse_pos.x; - mouse_delta.y = ypos - mouse_pos.y; +static void cursor_pos_cb(GLFWwindow *w, double xpos, double ypos) { + mouse_delta.x = xpos - mouse_pos.x; + mouse_delta.y = ypos - mouse_pos.y; - mouse_pos.x = xpos; - mouse_pos.y = ypos; + mouse_pos.x = xpos; + mouse_pos.y = ypos; - JSValue argv[4]; - argv[0] = jsinput; - argv[1] = jsmouse; - argv[2] = jspos; - argv[3] = vec2js(mouse_pos); - script_callee(pawn_callee, 4, argv); - JS_FreeValue(js, argv[3]); + JSValue argv[4]; + argv[0] = jsinput; + argv[1] = jsmouse; + argv[2] = jspos; + argv[3] = vec2js(mouse_pos); + script_callee(pawn_callee, 4, argv); + JS_FreeValue(js, argv[3]); } -static void pawn_call_keydown(int key) -{ +static void pawn_call_keydown(int key) { JSValue argv[4]; argv[0] = jsinput; argv[1] = jsnum; @@ -137,48 +146,44 @@ static void pawn_call_keydown(int key) JS_FreeValue(js, argv[3]); } -static void scroll_cb(GLFWwindow *w, double xoffset, double yoffset) -{ - mouseWheelY = yoffset; - mouseWheelX = xoffset; +static void scroll_cb(GLFWwindow *w, double xoffset, double yoffset) { + mouseWheelY = yoffset; + mouseWheelX = xoffset; } -static void mb_cb(GLFWwindow *w, int button, int action, int mods) -{ +static void mb_cb(GLFWwindow *w, int button, int action, int mods) { JSValue argv[3]; argv[0] = jsinput; switch (action) { - case GLFW_PRESS: - argv[2] = jsinputstate[2]; - add_downkey(button); - break; + case GLFW_PRESS: + argv[2] = jsinputstate[2]; + add_downkey(button); + break; - case GLFW_RELEASE: - rm_downkey(button); - argv[2] = jsinputstate[0]; - argv[1] = jsany; - script_callee(pawn_callee,3,argv); - break; + case GLFW_RELEASE: + rm_downkey(button); + argv[2] = jsinputstate[0]; + argv[1] = jsany; + script_callee(pawn_callee, 3, argv); + break; - case GLFW_REPEAT: - argv[2] = jsinputstate[1]; - break; + case GLFW_REPEAT: + argv[2] = jsinputstate[1]; + break; } - argv[1] = input2js(keyname_extd(button,button)); - script_callee(pawn_callee,3,argv); + argv[1] = input2js(keyname_extd(button, button)); + script_callee(pawn_callee, 3, argv); } -void set_mouse_mode(int mousemode) -{ +void set_mouse_mode(int mousemode) { glfwSetInputMode(mainwin->window, GLFW_CURSOR, mousemode); } -void char_cb(GLFWwindow *w, unsigned int codepoint) -{ +void char_cb(GLFWwindow *w, unsigned int codepoint) { static char out[2] = {0}; static JSValue argv[2]; - + out[0] = (char)codepoint; argv[0] = JS_NewString(js, "input_text"); argv[1] = JS_NewString(js, out); @@ -190,76 +195,70 @@ void char_cb(GLFWwindow *w, unsigned int codepoint) static GLFWcharfun nukechar; -void joystick_add(int id) -{ +void joystick_add(int id) { struct joystick joy = {0}; joy.id = id; arrpush(joysticks, joy); } -void joystick_cb(int jid, int event) -{ +void joystick_cb(int jid, int event) { YughWarn("IN joystick cb"); if (event == GLFW_CONNECTED) { for (int i = 0; i < arrlen(joysticks); i++) if (joysticks[i].id == jid) return; - + joystick_add(jid); } else if (event == GLFW_DISCONNECTED) { for (int i = 0; i < arrlen(joysticks); i++) { if (joysticks[i].id == jid) { - arrdelswap(joysticks,i); - return; + arrdelswap(joysticks, i); + return; } } } } +void input_init() { + glfwSetCursorPosCallback(mainwin->window, cursor_pos_cb); + glfwSetScrollCallback(mainwin->window, scroll_cb); + glfwSetMouseButtonCallback(mainwin->window, mb_cb); + glfwSetJoystickCallback(joystick_cb); + nukechar = glfwSetCharCallback(mainwin->window, char_cb); -void input_init() -{ - glfwSetCursorPosCallback(mainwin->window, cursor_pos_cb); - glfwSetScrollCallback(mainwin->window, scroll_cb); - glfwSetMouseButtonCallback(mainwin->window, mb_cb); - glfwSetJoystickCallback(joystick_cb); - nukechar = glfwSetCharCallback(mainwin->window, char_cb); + char *paddb = slurp_text("data/gamecontrollerdb.txt"); + glfwUpdateGamepadMappings(paddb); + free(paddb); - char *paddb = slurp_text("data/gamecontrollerdb.txt"); - glfwUpdateGamepadMappings(paddb); - free(paddb); + for (int b = 0; b < 15; b++) + jsgamepadstr[b] = str2js(gamepad2str(b)); - for (int b = 0; b < 15; b++) - jsgamepadstr[b] = str2js(gamepad2str(b)); + jsaxesstr[0] = str2js("ljoy"); + jsaxesstr[1] = str2js("rjoy"); + jsaxesstr[2] = str2js("ltrigger"); + jsaxesstr[3] = str2js("rtrigger"); + jsaxis = str2js("axis"); - jsaxesstr[0] = str2js("ljoy"); - jsaxesstr[1] = str2js("rjoy"); - jsaxesstr[2] = str2js("ltrigger"); - jsaxesstr[3] = str2js("rtrigger"); - jsaxis = str2js("axis"); + /* Grab all joysticks initially present */ + for (int i = 0; i < 16; i++) + if (glfwJoystickPresent(i)) joystick_add(i); - /* Grab all joysticks initially present */ - for (int i = 0; i < 16; i++) - if (glfwJoystickPresent(i)) joystick_add(i); - - jsinputstate[0] = str2js("released"); - jsinputstate[1] = str2js("rep"); - jsinputstate[2] = str2js("pressed"); - jsinputstate[3] = str2js("pressrep"); - jsinputstate[4] = str2js("down"); - jsinput = str2js("input"); - jsnum = str2js("num"); - jsany = str2js("any"); - jsmouse = str2js("mouse"); - jspos = str2js("pos"); + jsinputstate[0] = str2js("released"); + jsinputstate[1] = str2js("rep"); + jsinputstate[2] = str2js("pressed"); + jsinputstate[3] = str2js("pressrep"); + jsinputstate[4] = str2js("down"); + jsinput = str2js("input"); + jsnum = str2js("num"); + jsany = str2js("any"); + jsmouse = str2js("mouse"); + jspos = str2js("pos"); } -void input_to_nuke() -{ +void input_to_nuke() { glfwSetCharCallback(mainwin->window, nukechar); } -void input_to_game() -{ +void input_to_game() { glfwSetCharCallback(mainwin->window, char_cb); } @@ -272,308 +271,303 @@ void call_input_signal(char *signal) { char keybuf[50]; const char *keyname_extd(int key, int scancode) { - const char *kkey = NULL; + const char *kkey = NULL; - if (key > 289 && key < 302) { - int num = key-289; - sprintf(keybuf, "f%d", num); - return keybuf; - } else if (key >= 320 && key <= 329) { - int num = key-320; - sprintf(keybuf, "kp%d",num); - return keybuf; - } else { - switch(key) { - case GLFW_KEY_ENTER: - kkey = "enter"; - break; + if (key > 289 && key < 302) { + int num = key - 289; + sprintf(keybuf, "f%d", num); + return keybuf; + } else if (key >= 320 && key <= 329) { + int num = key - 320; + sprintf(keybuf, "kp%d", num); + return keybuf; + } else { + switch (key) { + case GLFW_KEY_ENTER: + kkey = "enter"; + break; - case GLFW_KEY_ESCAPE: - kkey = "escape"; - break; + case GLFW_KEY_ESCAPE: + kkey = "escape"; + break; - case GLFW_KEY_DELETE: - kkey = "delete"; - break; + case GLFW_KEY_DELETE: + kkey = "delete"; + break; - case GLFW_KEY_INSERT: - kkey = "insert"; - break; + case GLFW_KEY_INSERT: + kkey = "insert"; + break; - case GLFW_KEY_TAB: - kkey = "tab"; - break; + case GLFW_KEY_TAB: + kkey = "tab"; + break; - case GLFW_KEY_RIGHT: - kkey = "right"; - break; + case GLFW_KEY_RIGHT: + kkey = "right"; + break; - case GLFW_KEY_LEFT: - kkey = "left"; - break; + case GLFW_KEY_LEFT: + kkey = "left"; + break; - case GLFW_KEY_UP: - kkey = "up"; - break; + case GLFW_KEY_UP: + kkey = "up"; + break; - case GLFW_KEY_DOWN: - kkey = "down"; - break; + case GLFW_KEY_DOWN: + kkey = "down"; + break; - case GLFW_KEY_LEFT_SHIFT: - kkey = "lshift"; - break; + case GLFW_KEY_LEFT_SHIFT: + kkey = "lshift"; + break; - case GLFW_KEY_RIGHT_SHIFT: - kkey = "rshift"; - break; + case GLFW_KEY_RIGHT_SHIFT: + kkey = "rshift"; + break; - case GLFW_KEY_LEFT_CONTROL: - kkey = "lctrl"; - break; + case GLFW_KEY_LEFT_CONTROL: + kkey = "lctrl"; + break; - case GLFW_KEY_LEFT_ALT: - kkey = "lalt"; - break; + case GLFW_KEY_LEFT_ALT: + kkey = "lalt"; + break; - case GLFW_KEY_RIGHT_CONTROL: - kkey = "rctrl"; - break; + case GLFW_KEY_RIGHT_CONTROL: + kkey = "rctrl"; + break; - case GLFW_KEY_RIGHT_ALT: - kkey= "ralt"; - break; + case GLFW_KEY_RIGHT_ALT: + kkey = "ralt"; + break; - case GLFW_KEY_SPACE: - kkey = "space"; - break; - - case GLFW_MOUSE_BUTTON_RIGHT: - kkey = "rmouse"; - break; + case GLFW_KEY_SPACE: + kkey = "space"; + break; - case GLFW_MOUSE_BUTTON_LEFT: - kkey = "lmouse"; - break; + case GLFW_MOUSE_BUTTON_RIGHT: + kkey = "rmouse"; + break; - case GLFW_MOUSE_BUTTON_MIDDLE: - kkey = "mmouse"; - break; + case GLFW_MOUSE_BUTTON_LEFT: + kkey = "lmouse"; + break; - case GLFW_KEY_KP_ADD: - kkey = "plus"; - break; + case GLFW_MOUSE_BUTTON_MIDDLE: + kkey = "mmouse"; + break; - case GLFW_KEY_KP_SUBTRACT: - kkey = "minus"; - break; - case GLFW_KEY_GRAVE_ACCENT: - kkey = "backtick"; - break; + case GLFW_KEY_KP_ADD: + kkey = "plus"; + break; - case GLFW_KEY_LEFT_BRACKET: - kkey = "lbracket"; - break; + case GLFW_KEY_KP_SUBTRACT: + kkey = "minus"; + break; + case GLFW_KEY_GRAVE_ACCENT: + kkey = "backtick"; + break; - case GLFW_KEY_RIGHT_BRACKET: - kkey = "rbracket"; - break; + case GLFW_KEY_LEFT_BRACKET: + kkey = "lbracket"; + break; - case GLFW_KEY_BACKSPACE: - kkey = "backspace"; - break; - } + case GLFW_KEY_RIGHT_BRACKET: + kkey = "rbracket"; + break; - if (kkey) return kkey; - - } - - kkey = glfwGetKeyName(key, scancode); + case GLFW_KEY_BACKSPACE: + kkey = "backspace"; + break; + } if (kkey) return kkey; + } - return "NULL"; + kkey = glfwGetKeyName(key, scancode); + + if (kkey) return kkey; + + return "NULL"; } void call_input_down(int *key) { - JSValue argv[3]; - argv[0] = jsinput; - argv[1] = input2js(keyname_extd(*key, *key)); - argv[2] = jsinputstate[4]; - script_callee(pawn_callee,3,argv); + JSValue argv[3]; + argv[0] = jsinput; + argv[1] = input2js(keyname_extd(*key, *key)); + argv[2] = jsinputstate[4]; + script_callee(pawn_callee, 3, argv); } - -const char *axis2str(int axis) -{ - switch (axis) - { - case GLFW_GAMEPAD_AXIS_LEFT_X: return "lx"; - case GLFW_GAMEPAD_AXIS_LEFT_Y: return "ly"; - case GLFW_GAMEPAD_AXIS_RIGHT_X: return "rx"; - case GLFW_GAMEPAD_AXIS_RIGHT_Y: return "ry"; - case GLFW_GAMEPAD_AXIS_LEFT_TRIGGER: return "ltrigger"; - case GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER: return "rtrigger"; +const char *axis2str(int axis) { + switch (axis) { + case GLFW_GAMEPAD_AXIS_LEFT_X: + return "lx"; + case GLFW_GAMEPAD_AXIS_LEFT_Y: + return "ly"; + case GLFW_GAMEPAD_AXIS_RIGHT_X: + return "rx"; + case GLFW_GAMEPAD_AXIS_RIGHT_Y: + return "ry"; + case GLFW_GAMEPAD_AXIS_LEFT_TRIGGER: + return "ltrigger"; + case GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER: + return "rtrigger"; } - + return "NOAXIS"; } /* This is called once every frame - or more if we want it more! */ -void input_poll(double wait) -{ - mouse_delta = cpvzero; - mouseWheelX = 0; - mouseWheelY = 0; +void input_poll(double wait) { + mouse_delta = cpvzero; + mouseWheelX = 0; + mouseWheelY = 0; - glfwPollEvents(); + glfwPollEvents(); -// glfwWaitEventsTimeout(wait); + // glfwWaitEventsTimeout(wait); - for (int i = 0; i < arrlen(downkeys); i++) - call_input_down(&downkeys[i]); + for (int i = 0; i < arrlen(downkeys); i++) + call_input_down(&downkeys[i]); - for (int i = 0; i < arrlen(joysticks); i++) { - GLFWgamepadstate state; - if (!glfwGetGamepadState(joysticks[i].id, &state)) continue; + for (int i = 0; i < arrlen(joysticks); i++) { + GLFWgamepadstate state; + if (!glfwGetGamepadState(joysticks[i].id, &state)) continue; - JSValue argv[4]; - argv[0] = num_cache[joysticks[i].id]; - for (int b = 0; b < 15; b++) { - argv[1] = jsgamepadstr[b]; - - if (state.buttons[b]) { - argv[2] = num_cache[0]; - script_callee(gamepad_callee,3,argv); - - if (!joysticks[i].state.buttons[b]) { - argv[2] = num_cache[1]; - script_callee(gamepad_callee,3,argv); - } - } - else if (!state.buttons[b] && joysticks[i].state.buttons[b]) { - argv[2] = num_cache[2]; - script_callee(gamepad_callee,3,argv); - } + JSValue argv[4]; + argv[0] = num_cache[joysticks[i].id]; + for (int b = 0; b < 15; b++) { + argv[1] = jsgamepadstr[b]; + + if (state.buttons[b]) { + argv[2] = num_cache[0]; + script_callee(gamepad_callee, 3, argv); + + if (!joysticks[i].state.buttons[b]) { + argv[2] = num_cache[1]; + script_callee(gamepad_callee, 3, argv); + } + } else if (!state.buttons[b] && joysticks[i].state.buttons[b]) { + argv[2] = num_cache[2]; + script_callee(gamepad_callee, 3, argv); } - - argv[2] = jsaxis; - - float deadzone = 0.05; - - for (int i = 0; i < 4; i++) - state.axes[i] = fabs(state.axes[i]) > deadzone ? state.axes[i] : 0; - - argv[1] = jsaxesstr[0]; - cpVect v; - v.x = state.axes[0]; - v.y = -state.axes[1]; - argv[3] = vec2js(v); - script_callee(gamepad_callee,4,argv); - JS_FreeValue(js, argv[3]); - - argv[1] = jsaxesstr[1]; - v.x = state.axes[2]; - v.y = -state.axes[3]; - argv[3] = vec2js(v); - script_callee(gamepad_callee,4,argv); - JS_FreeValue(js, argv[3]); - - argv[1] = jsaxesstr[2]; - argv[3] = num2js((state.axes[4]+1)/2); - script_callee(gamepad_callee,4,argv); - JS_FreeValue(js, argv[3]); - - argv[1] = jsaxesstr[3]; - argv[3] = num2js((state.axes[5]+1)/2); - script_callee(gamepad_callee,4,argv); - JS_FreeValue(js, argv[3]); - - joysticks[i].state = state; } + + argv[2] = jsaxis; + + float deadzone = 0.05; + + for (int i = 0; i < 4; i++) + state.axes[i] = fabs(state.axes[i]) > deadzone ? state.axes[i] : 0; + + argv[1] = jsaxesstr[0]; + cpVect v; + v.x = state.axes[0]; + v.y = -state.axes[1]; + argv[3] = vec2js(v); + script_callee(gamepad_callee, 4, argv); + JS_FreeValue(js, argv[3]); + + argv[1] = jsaxesstr[1]; + v.x = state.axes[2]; + v.y = -state.axes[3]; + argv[3] = vec2js(v); + script_callee(gamepad_callee, 4, argv); + JS_FreeValue(js, argv[3]); + + argv[1] = jsaxesstr[2]; + argv[3] = num2js((state.axes[4] + 1) / 2); + script_callee(gamepad_callee, 4, argv); + JS_FreeValue(js, argv[3]); + + argv[1] = jsaxesstr[3]; + argv[3] = num2js((state.axes[5] + 1) / 2); + script_callee(gamepad_callee, 4, argv); + JS_FreeValue(js, argv[3]); + + joysticks[i].state = state; + } } int key_is_num(int key) { return key <= 57 && key >= 48; } -void win_key_callback(GLFWwindow *w, int key, int scancode, int action, int mods) -{ - JSValue argv[3]; - argv[0] = jsinput; - argv[1] = input2js(keyname_extd(key,scancode)); +void win_key_callback(GLFWwindow *w, int key, int scancode, int action, int mods) { + JSValue argv[3]; + argv[0] = jsinput; + argv[1] = input2js(keyname_extd(key, scancode)); - switch (action) { - case GLFW_PRESS: - argv[2] = jsinputstate[2]; - script_callee(pawn_callee, 3, argv); - argv[2] = jsinputstate[3]; - script_callee(pawn_callee,3,argv); - add_downkey(key); - argv[1] = jsany; - argv[2] = jsinputstate[2]; - script_callee(pawn_callee,3,argv); - - if (key_is_num(key)) - pawn_call_keydown(key-48); - - break; + switch (action) { + case GLFW_PRESS: + argv[2] = jsinputstate[2]; + script_callee(pawn_callee, 3, argv); + argv[2] = jsinputstate[3]; + script_callee(pawn_callee, 3, argv); + add_downkey(key); + argv[1] = jsany; + argv[2] = jsinputstate[2]; + script_callee(pawn_callee, 3, argv); - case GLFW_RELEASE: - argv[2] = jsinputstate[0]; - script_callee(pawn_callee,3,argv); - rm_downkey(key); - argv[1] = jsany; - script_callee(pawn_callee,3,argv); - break; + if (key_is_num(key)) + pawn_call_keydown(key - 48); - case GLFW_REPEAT: - argv[2] = jsinputstate[1]; - script_callee(pawn_callee,3,argv); - argv[2] = jsinputstate[3]; - script_callee(pawn_callee,3,argv); - break; + break; + + case GLFW_RELEASE: + argv[2] = jsinputstate[0]; + script_callee(pawn_callee, 3, argv); + rm_downkey(key); + argv[1] = jsany; + script_callee(pawn_callee, 3, argv); + break; + + case GLFW_REPEAT: + argv[2] = jsinputstate[1]; + script_callee(pawn_callee, 3, argv); + argv[2] = jsinputstate[3]; + script_callee(pawn_callee, 3, argv); + break; + } +} + +void cursor_hide() { + glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); +} + +void cursor_show() { + glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); +} + +int action_down(int scancode) { + for (int i = 0; i < arrlen(downkeys); i++) { + if (downkeys[i] == scancode) + return 1; + } + + return 0; +} + +int action_up(int scancode) { + int found = 0; + for (int i = 0; i < arrlen(downkeys); i++) { + if (downkeys[i] == scancode) { + found = 1; + break; } -} + } -void cursor_hide() -{ - glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); -} - -void cursor_show() -{ - glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); -} - -int action_down(int scancode) -{ - for (int i = 0; i < arrlen(downkeys); i++) { - if (downkeys[i] == scancode) - return 1; - } - - return 0; -} - -int action_up(int scancode) -{ - int found = 0; - for (int i = 0; i < arrlen(downkeys); i++) { - if (downkeys[i] == scancode) { - found = 1; - break; - } - } - - return !found; + return !found; } int want_quit() { - return mquit; + return mquit; } void quit() { - YughInfo("Exiting game."); - mquit = 1; + YughInfo("Exiting game."); + mquit = 1; } diff --git a/source/engine/input.h b/source/engine/input.h index f4ac489..fd25563 100644 --- a/source/engine/input.h +++ b/source/engine/input.h @@ -1,10 +1,10 @@ #ifndef INPUT_H #define INPUT_H -#include +#include "script.h" #include "window.h" #include -#include "script.h" +#include extern int32_t mouseWheelX; extern int32_t mouseWheelY; @@ -33,9 +33,8 @@ void quit(); void win_key_callback(GLFWwindow *w, int key, int scancode, int action, int mods); -struct inputaction -{ - int scancode; +struct inputaction { + int scancode; }; void input_to_nuke(); diff --git a/source/engine/level.c b/source/engine/level.c index 472e5b2..2c70409 100644 --- a/source/engine/level.c +++ b/source/engine/level.c @@ -1,53 +1,49 @@ #include "level.h" -#include -#include #include "gameobject.h" #include "resources.h" +#include +#include #include "stb_ds.h" -void save_level(char name[MAXNAME]) -{ - FILE *lfile = res_open(name, "wb+"); +void save_level(char name[MAXNAME]) { + FILE *lfile = res_open(name, "wb+"); - if (!lfile) return; + if (!lfile) return; + int objs = arrlen(gameobjects); + fwrite(&objs, sizeof(objs), 1, lfile); - int objs = arrlen(gameobjects); - fwrite(&objs, sizeof(objs), 1, lfile); - - fclose(lfile); + fclose(lfile); } -void load_level(char name[MAXNAME]) -{ -/* - FILE *lfile = fopen(name, "rb"); +void load_level(char name[MAXNAME]) { + /* + FILE *lfile = fopen(name, "rb"); - if (!lfile) return; + if (!lfile) return; - new_level(); + new_level(); - int objs; - fread(&objs, sizeof(objs), 1, lfile); + int objs; + fread(&objs, sizeof(objs), 1, lfile); - arraddn(gameobjects, objs); + arraddn(gameobjects, objs); - for (int i = 0; i < objs; i++) { - struct gameobject *go = &gameobjects[i]; - fread(go, sizeof(struct gameobject), 1, lfile); - go->components = NULL; - gameobject_init(go, lfile); - } + for (int i = 0; i < objs; i++) { + struct gameobject *go = &gameobjects[i]; + fread(go, sizeof(struct gameobject), 1, lfile); + go->components = NULL; + gameobject_init(go, lfile); + } - fclose(lfile); - */ + fclose(lfile); + */ } -void new_level() -{ - for (int i = 0; i < arrlen(gameobjects); i++) - gameobject_delete(i); +void new_level() { + for (int i = 0; i < arrlen(gameobjects); i++) + gameobject_delete(i); - arrfree(gameobjects); + arrfree(gameobjects); } diff --git a/source/engine/level.h b/source/engine/level.h index 8f3e7df..b638fdd 100644 --- a/source/engine/level.h +++ b/source/engine/level.h @@ -6,12 +6,11 @@ // This class holds all of the entities and options for a level. Really it's nothing more than a container and access point for all the entities currently loaded into the game. struct level { - char name[MAXNAME]; + char name[MAXNAME]; }; void save_level(char name[MAXNAME]); void load_level(char name[MAXNAME]); void new_level(); - #endif diff --git a/source/engine/mathc.c b/source/engine/mathc.c index 90c09a4..4dbfe6b 100644 --- a/source/engine/mathc.c +++ b/source/engine/mathc.c @@ -20,7525 +20,6571 @@ the following restrictions: #include "mathc.h" -const mfloat_t VEC3ZERO[3] = { 0.f, 0.f, 0.f }; -const mfloat_t UP[3] = { 0.f, 1.f, 0.f }; -const mfloat_t DOWN[3] = { 0.f, -1.f, 0.f }; -const mfloat_t FORWARD[3] = { 0.f, 0.f, 1.f }; -const mfloat_t BACK[3] = { 0.f, 0.f, -1.f }; -const mfloat_t RIGHT[3] = { 1.f, 0.f, 0.f }; -const mfloat_t LEFT[3] = { -1.f, 0.f, 0.f }; +const mfloat_t VEC3ZERO[3] = {0.f, 0.f, 0.f}; +const mfloat_t UP[3] = {0.f, 1.f, 0.f}; +const mfloat_t DOWN[3] = {0.f, -1.f, 0.f}; +const mfloat_t FORWARD[3] = {0.f, 0.f, 1.f}; +const mfloat_t BACK[3] = {0.f, 0.f, -1.f}; +const mfloat_t RIGHT[3] = {1.f, 0.f, 0.f}; +const mfloat_t LEFT[3] = {-1.f, 0.f, 0.f}; const float UNITMAT4[16] = - { 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, -0.f, 1.f }; + {1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, + 0.f, 1.f}; -const mfloat_t VEC2_ZERO[2] = { 0.f, 0.f }; -const mint_t VEC2I_ZERO[2] = { 0, 0 }; -const mfloat_t VEC3_ZERO[3] = { 0.f, 0.f, 0.f }; -const mint_t VEC3I_ZERO[3] = { 0, 0, 0 }; +const mfloat_t VEC2_ZERO[2] = {0.f, 0.f}; +const mint_t VEC2I_ZERO[2] = {0, 0}; +const mfloat_t VEC3_ZERO[3] = {0.f, 0.f, 0.f}; +const mint_t VEC3I_ZERO[3] = {0, 0, 0}; -const mfloat_t VEC2_ONE[2] = { 1.f, 1.f }; -const mint_t VEC2I_ONE[2] = { 1, 1 }; -const mfloat_t VEC3_ONE[3] = { 1.f, 1.f, 1.f }; -const mint_t VEC3I_ONE[3] = { 1, 1, 1 }; +const mfloat_t VEC2_ONE[2] = {1.f, 1.f}; +const mint_t VEC2I_ONE[2] = {1, 1}; +const mfloat_t VEC3_ONE[3] = {1.f, 1.f, 1.f}; +const mint_t VEC3I_ONE[3] = {1, 1, 1}; #include #if defined(MATHC_USE_INT) -mint_t clampi(mint_t value, mint_t min, mint_t max) -{ - if (value < min) { - value = min; - } else if (value > max) { - value = max; - } - return value; +mint_t clampi(mint_t value, mint_t min, mint_t max) { + if (value < min) { + value = min; + } else if (value > max) { + value = max; + } + return value; } #endif #if defined(MATHC_USE_FLOATING_POINT) -bool nearly_equal(mfloat_t a, mfloat_t b, mfloat_t epsilon) -{ - bool result = false; - if (a == b) { - result = true; - } else if (MFABS(a - b) <= epsilon) { - result = true; - } - return result; +bool nearly_equal(mfloat_t a, mfloat_t b, mfloat_t epsilon) { + bool result = false; + if (a == b) { + result = true; + } else if (MFABS(a - b) <= epsilon) { + result = true; + } + return result; } -mfloat_t to_radians(mfloat_t degrees) -{ - return MRADIANS(degrees); +mfloat_t to_radians(mfloat_t degrees) { + return MRADIANS(degrees); } -mfloat_t to_degrees(mfloat_t radians) -{ - return MDEGREES(radians); +mfloat_t to_degrees(mfloat_t radians) { + return MDEGREES(radians); } -mfloat_t clampf(mfloat_t value, mfloat_t min, mfloat_t max) -{ - if (value < min) { - value = min; - } else if (value > max) { - value = max; - } - return value; +mfloat_t clampf(mfloat_t value, mfloat_t min, mfloat_t max) { + if (value < min) { + value = min; + } else if (value > max) { + value = max; + } + return value; } #endif #if defined(MATHC_USE_INT) -bool vec2i_is_zero(mint_t * v0) -{ - return v0[0] == 0 && v0[1] == 0; +bool vec2i_is_zero(mint_t *v0) { + return v0[0] == 0 && v0[1] == 0; } -bool vec2i_is_equal(mint_t * v0, mint_t * v1) -{ - return v0[0] == v1[0] && v0[1] == v1[1]; +bool vec2i_is_equal(mint_t *v0, mint_t *v1) { + return v0[0] == v1[0] && v0[1] == v1[1]; } -mint_t *vec2i(mint_t * result, mint_t x, mint_t y) -{ - result[0] = x; - result[1] = y; - return result; +mint_t *vec2i(mint_t *result, mint_t x, mint_t y) { + result[0] = x; + result[1] = y; + return result; } -mint_t *vec2i_assign(mint_t * result, mint_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - return result; +mint_t *vec2i_assign(mint_t *result, mint_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + return result; } #if defined(MATHC_USE_FLOATING_POINT) -mint_t *vec2i_assign_vec2(mint_t * result, mfloat_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - return result; +mint_t *vec2i_assign_vec2(mint_t *result, mfloat_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + return result; } #endif -mint_t *vec2i_zero(mint_t * result) -{ - result[0] = 0; - result[1] = 0; - return result; +mint_t *vec2i_zero(mint_t *result) { + result[0] = 0; + result[1] = 0; + return result; } -mint_t *vec2i_one(mint_t * result) -{ +mint_t *vec2i_one(mint_t *result) { + result[0] = 1; + result[1] = 1; + return result; +} + +mint_t *vec2i_sign(mint_t *result, mint_t *v0) { + if (v0[0] > 0) { result[0] = 1; + } else if (v0[0] < 0) { + result[0] = -1; + } else { + result[0] = 0; + } + if (v0[1] > 0) { result[1] = 1; - return result; + } else if (v0[1] < 0) { + result[1] = -1; + } else { + result[1] = 0; + } + return result; } -mint_t *vec2i_sign(mint_t * result, mint_t * v0) -{ - if (v0[0] > 0) { - result[0] = 1; - } else if (v0[0] < 0) { - result[0] = -1; - } else { - result[0] = 0; - } - if (v0[1] > 0) { - result[1] = 1; - } else if (v0[1] < 0) { - result[1] = -1; - } else { - result[1] = 0; - } - return result; +mint_t *vec2i_add(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] + v1[0]; + result[1] = v0[1] + v1[1]; + return result; } -mint_t *vec2i_add(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] + v1[0]; - result[1] = v0[1] + v1[1]; - return result; +mint_t *vec2i_add_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] + i; + result[1] = v0[1] + i; + return result; } -mint_t *vec2i_add_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] + i; - result[1] = v0[1] + i; - return result; +mint_t *vec2i_subtract(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] - v1[0]; + result[1] = v0[1] - v1[1]; + return result; } -mint_t *vec2i_subtract(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] - v1[0]; - result[1] = v0[1] - v1[1]; - return result; +mint_t *vec2i_subtract_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] - i; + result[1] = v0[1] - i; + return result; } -mint_t *vec2i_subtract_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] - i; - result[1] = v0[1] - i; - return result; +mint_t *vec2i_multiply(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] * v1[0]; + result[1] = v0[1] * v1[1]; + return result; } -mint_t *vec2i_multiply(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] * v1[0]; - result[1] = v0[1] * v1[1]; - return result; +mint_t *vec2i_multiply_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] * i; + result[1] = v0[1] * i; + return result; } -mint_t *vec2i_multiply_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] * i; - result[1] = v0[1] * i; - return result; +mint_t *vec2i_divide(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] / v1[0]; + result[1] = v0[1] / v1[1]; + return result; } -mint_t *vec2i_divide(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] / v1[0]; - result[1] = v0[1] / v1[1]; - return result; +mint_t *vec2i_divide_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] / i; + result[1] = v0[1] / i; + return result; } -mint_t *vec2i_divide_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] / i; - result[1] = v0[1] / i; - return result; +mint_t *vec2i_snap(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = (v0[0] / v1[0]) * v1[0]; + result[1] = (v0[1] / v1[1]) * v1[1]; + return result; } -mint_t *vec2i_snap(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = (v0[0] / v1[0]) * v1[0]; - result[1] = (v0[1] / v1[1]) * v1[1]; - return result; +mint_t *vec2i_snap_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = (v0[0] / i) * i; + result[1] = (v0[1] / i) * i; + return result; } -mint_t *vec2i_snap_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = (v0[0] / i) * i; - result[1] = (v0[1] / i) * i; - return result; +mint_t *vec2i_negative(mint_t *result, mint_t *v0) { + result[0] = -v0[0]; + result[1] = -v0[1]; + return result; } -mint_t *vec2i_negative(mint_t * result, mint_t * v0) -{ - result[0] = -v0[0]; - result[1] = -v0[1]; - return result; +mint_t *vec2i_abs(mint_t *result, mint_t *v0) { + result[0] = v0[0]; + if (result[0] < 0) { + result[0] = -result[0]; + } + result[1] = v0[1]; + if (result[1] < 0) { + result[1] = -result[1]; + } + return result; } -mint_t *vec2i_abs(mint_t * result, mint_t * v0) -{ +mint_t *vec2i_max(mint_t *result, mint_t *v0, mint_t *v1) { + if (v0[0] > v1[0]) { result[0] = v0[0]; - if (result[0] < 0) { - result[0] = -result[0]; - } + } else { + result[0] = v1[0]; + } + if (v0[1] > v1[1]) { result[1] = v0[1]; - if (result[1] < 0) { - result[1] = -result[1]; - } - return result; + } else { + result[1] = v1[1]; + } + return result; } -mint_t *vec2i_max(mint_t * result, mint_t * v0, mint_t * v1) -{ - if (v0[0] > v1[0]) { - result[0] = v0[0]; - } else { - result[0] = v1[0]; - } - if (v0[1] > v1[1]) { - result[1] = v0[1]; - } else { - result[1] = v1[1]; - } - return result; -} - -mint_t *vec2i_min(mint_t * result, mint_t * v0, mint_t * v1) -{ - if (v0[0] < v1[0]) { - result[0] = v0[0]; - } else { - result[0] = v1[0]; - } - if (v0[1] < v1[1]) { - result[1] = v0[1]; - } else { - result[1] = v1[1]; - } - return result; -} - -mint_t *vec2i_clamp(mint_t * result, mint_t * v0, mint_t * v1, mint_t * v2) -{ - vec2i_min(result, v0, v1); - vec2i_max(result, v0, v2); - return result; -} - -mint_t *vec2i_tangent(mint_t * result, mint_t * v0) -{ - mint_t a0 = v0[0]; - mint_t a1 = v0[1]; - result[0] = a1; - result[1] = -a0; - return result; -} - -bool vec3i_is_zero(mint_t * v0) -{ - return v0[0] == 0 && v0[1] == 0 && v0[2] == 0; -} - -bool vec3i_is_equal(mint_t * v0, mint_t * v1) -{ - return v0[0] == v1[0] && v0[1] == v1[1] && v0[2] == v1[2]; -} - -mint_t *vec3i(mint_t * result, mint_t x, mint_t y, mint_t z) -{ - result[0] = x; - result[1] = y; - result[2] = z; - return result; -} - -mint_t *vec3i_assign(mint_t * result, mint_t * v0) -{ +mint_t *vec2i_min(mint_t *result, mint_t *v0, mint_t *v1) { + if (v0[0] < v1[0]) { result[0] = v0[0]; + } else { + result[0] = v1[0]; + } + if (v0[1] < v1[1]) { result[1] = v0[1]; - result[2] = v0[2]; - return result; + } else { + result[1] = v1[1]; + } + return result; +} + +mint_t *vec2i_clamp(mint_t *result, mint_t *v0, mint_t *v1, mint_t *v2) { + vec2i_min(result, v0, v1); + vec2i_max(result, v0, v2); + return result; +} + +mint_t *vec2i_tangent(mint_t *result, mint_t *v0) { + mint_t a0 = v0[0]; + mint_t a1 = v0[1]; + result[0] = a1; + result[1] = -a0; + return result; +} + +bool vec3i_is_zero(mint_t *v0) { + return v0[0] == 0 && v0[1] == 0 && v0[2] == 0; +} + +bool vec3i_is_equal(mint_t *v0, mint_t *v1) { + return v0[0] == v1[0] && v0[1] == v1[1] && v0[2] == v1[2]; +} + +mint_t *vec3i(mint_t *result, mint_t x, mint_t y, mint_t z) { + result[0] = x; + result[1] = y; + result[2] = z; + return result; +} + +mint_t *vec3i_assign(mint_t *result, mint_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + result[2] = v0[2]; + return result; } #if defined(MATHC_USE_FLOATING_POINT) -mint_t *vec3i_assign_vec3(mint_t * result, mfloat_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - result[2] = v0[2]; - return result; +mint_t *vec3i_assign_vec3(mint_t *result, mfloat_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + result[2] = v0[2]; + return result; } #endif -mint_t *vec3i_zero(mint_t * result) -{ - result[0] = 0; - result[1] = 0; - result[2] = 0; - return result; +mint_t *vec3i_zero(mint_t *result) { + result[0] = 0; + result[1] = 0; + result[2] = 0; + return result; } -mint_t *vec3i_one(mint_t * result) -{ +mint_t *vec3i_one(mint_t *result) { + result[0] = 1; + result[1] = 1; + result[2] = 1; + return result; +} + +mint_t *vec3i_sign(mint_t *result, mint_t *v0) { + if (v0[0] > 0) { result[0] = 1; + } else if (v0[0] < 0) { + result[0] = -1; + } else { + result[0] = 0; + } + if (v0[1] > 0) { result[1] = 1; + } else if (v0[1] < 0) { + result[1] = -1; + } else { + result[1] = 0; + } + if (v0[2] > 0) { result[2] = 1; - return result; + } else if (v0[2] < 0) { + result[2] = -1; + } else { + result[2] = 0; + } + return result; } -mint_t *vec3i_sign(mint_t * result, mint_t * v0) -{ - if (v0[0] > 0) { - result[0] = 1; - } else if (v0[0] < 0) { - result[0] = -1; - } else { - result[0] = 0; - } - if (v0[1] > 0) { - result[1] = 1; - } else if (v0[1] < 0) { - result[1] = -1; - } else { - result[1] = 0; - } - if (v0[2] > 0) { - result[2] = 1; - } else if (v0[2] < 0) { - result[2] = -1; - } else { - result[2] = 0; - } - return result; +mint_t *vec3i_add(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] + v1[0]; + result[1] = v0[1] + v1[1]; + result[2] = v0[2] + v1[2]; + return result; } -mint_t *vec3i_add(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] + v1[0]; - result[1] = v0[1] + v1[1]; - result[2] = v0[2] + v1[2]; - return result; +mint_t *vec3i_add_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] + i; + result[1] = v0[1] + i; + result[2] = v0[2] + i; + return result; } -mint_t *vec3i_add_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] + i; - result[1] = v0[1] + i; - result[2] = v0[2] + i; - return result; +mint_t *vec3i_subtract(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] - v1[0]; + result[1] = v0[1] - v1[1]; + result[2] = v0[2] - v1[2]; + return result; } -mint_t *vec3i_subtract(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] - v1[0]; - result[1] = v0[1] - v1[1]; - result[2] = v0[2] - v1[2]; - return result; +mint_t *vec3i_subtract_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] - i; + result[1] = v0[1] - i; + result[2] = v0[2] - i; + return result; } -mint_t *vec3i_subtract_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] - i; - result[1] = v0[1] - i; - result[2] = v0[2] - i; - return result; +mint_t *vec3i_multiply(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] * v1[0]; + result[1] = v0[1] * v1[1]; + result[2] = v0[2] * v1[2]; + return result; } -mint_t *vec3i_multiply(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] * v1[0]; - result[1] = v0[1] * v1[1]; - result[2] = v0[2] * v1[2]; - return result; +mint_t *vec3i_multiply_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] * i; + result[1] = v0[1] * i; + result[2] = v0[2] * i; + return result; } -mint_t *vec3i_multiply_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] * i; - result[1] = v0[1] * i; - result[2] = v0[2] * i; - return result; +mint_t *vec3i_divide(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] / v1[0]; + result[1] = v0[1] / v1[1]; + result[2] = v0[2] / v1[2]; + return result; } -mint_t *vec3i_divide(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] / v1[0]; - result[1] = v0[1] / v1[1]; - result[2] = v0[2] / v1[2]; - return result; +mint_t *vec3i_divide_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] / i; + result[1] = v0[1] / i; + result[2] = v0[2] / i; + return result; } -mint_t *vec3i_divide_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] / i; - result[1] = v0[1] / i; - result[2] = v0[2] / i; - return result; +mint_t *vec3i_snap(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = (v0[0] / v1[0]) * v1[0]; + result[1] = (v0[1] / v1[1]) * v1[1]; + result[2] = (v0[2] / v1[2]) * v1[2]; + return result; } -mint_t *vec3i_snap(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = (v0[0] / v1[0]) * v1[0]; - result[1] = (v0[1] / v1[1]) * v1[1]; - result[2] = (v0[2] / v1[2]) * v1[2]; - return result; +mint_t *vec3i_snap_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = (v0[0] / i) * i; + result[1] = (v0[1] / i) * i; + result[2] = (v0[2] / i) * i; + return result; } -mint_t *vec3i_snap_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = (v0[0] / i) * i; - result[1] = (v0[1] / i) * i; - result[2] = (v0[2] / i) * i; - return result; +mint_t *vec3i_cross(mint_t *result, mint_t *v0, mint_t *v1) { + mint_t cross[VEC3_SIZE]; + cross[0] = v0[1] * v1[2] - v0[2] * v1[1]; + cross[1] = v0[2] * v1[0] - v0[0] * v1[2]; + cross[2] = v0[0] * v1[1] - v0[1] * v1[0]; + result[0] = cross[0]; + result[1] = cross[1]; + result[2] = cross[2]; + return result; } -mint_t *vec3i_cross(mint_t * result, mint_t * v0, mint_t * v1) -{ - mint_t cross[VEC3_SIZE]; - cross[0] = v0[1] * v1[2] - v0[2] * v1[1]; - cross[1] = v0[2] * v1[0] - v0[0] * v1[2]; - cross[2] = v0[0] * v1[1] - v0[1] * v1[0]; - result[0] = cross[0]; - result[1] = cross[1]; - result[2] = cross[2]; - return result; +mint_t *vec3i_negative(mint_t *result, mint_t *v0) { + result[0] = -v0[0]; + result[1] = -v0[1]; + result[2] = -v0[2]; + return result; } -mint_t *vec3i_negative(mint_t * result, mint_t * v0) -{ - result[0] = -v0[0]; - result[1] = -v0[1]; - result[2] = -v0[2]; - return result; +mint_t *vec3i_abs(mint_t *result, mint_t *v0) { + result[0] = v0[0]; + if (result[0] < 0) { + result[0] = -result[0]; + } + result[1] = v0[1]; + if (result[1] < 0) { + result[1] = -result[1]; + } + result[2] = v0[2]; + if (result[2] < 0) { + result[2] = -result[2]; + } + return result; } -mint_t *vec3i_abs(mint_t * result, mint_t * v0) -{ +mint_t *vec3i_max(mint_t *result, mint_t *v0, mint_t *v1) { + if (v0[0] > v1[0]) { result[0] = v0[0]; - if (result[0] < 0) { - result[0] = -result[0]; - } + } else { + result[0] = v1[0]; + } + if (v0[1] > v1[1]) { result[1] = v0[1]; - if (result[1] < 0) { - result[1] = -result[1]; - } + } else { + result[1] = v1[1]; + } + if (v0[2] > v1[2]) { result[2] = v0[2]; - if (result[2] < 0) { - result[2] = -result[2]; - } - return result; + } else { + result[2] = v1[2]; + } + return result; } -mint_t *vec3i_max(mint_t * result, mint_t * v0, mint_t * v1) -{ - if (v0[0] > v1[0]) { - result[0] = v0[0]; - } else { - result[0] = v1[0]; - } - if (v0[1] > v1[1]) { - result[1] = v0[1]; - } else { - result[1] = v1[1]; - } - if (v0[2] > v1[2]) { - result[2] = v0[2]; - } else { - result[2] = v1[2]; - } - return result; -} - -mint_t *vec3i_min(mint_t * result, mint_t * v0, mint_t * v1) -{ - if (v0[0] < v1[0]) { - result[0] = v0[0]; - } else { - result[0] = v1[0]; - } - if (v0[1] < v1[1]) { - result[1] = v0[1]; - } else { - result[1] = v1[1]; - } - if (v0[2] < v1[2]) { - result[2] = v0[2]; - } else { - result[2] = v1[2]; - } - return result; -} - -mint_t *vec3i_clamp(mint_t * result, mint_t * v0, mint_t * v1, mint_t * v2) -{ - vec3i_min(result, v0, v1); - vec3i_max(result, v0, v2); - return result; -} - -bool vec4i_is_zero(mint_t * v0) -{ - return v0[0] == 0 && v0[1] == 0 && v0[2] == 0 && v0[3] == 0; -} - -bool vec4i_is_equal(mint_t * v0, mint_t * v1) -{ - return v0[0] == v1[0] && v0[1] == v1[1] && v0[2] == v1[2] - && v0[3] == v1[3]; -} - -mint_t *vec4i(mint_t * result, mint_t x, mint_t y, mint_t z, mint_t w) -{ - result[0] = x; - result[1] = y; - result[2] = z; - result[3] = w; - return result; -} - -mint_t *vec4i_assign(mint_t * result, mint_t * v0) -{ +mint_t *vec3i_min(mint_t *result, mint_t *v0, mint_t *v1) { + if (v0[0] < v1[0]) { result[0] = v0[0]; + } else { + result[0] = v1[0]; + } + if (v0[1] < v1[1]) { result[1] = v0[1]; + } else { + result[1] = v1[1]; + } + if (v0[2] < v1[2]) { result[2] = v0[2]; - result[3] = v0[3]; - return result; + } else { + result[2] = v1[2]; + } + return result; +} + +mint_t *vec3i_clamp(mint_t *result, mint_t *v0, mint_t *v1, mint_t *v2) { + vec3i_min(result, v0, v1); + vec3i_max(result, v0, v2); + return result; +} + +bool vec4i_is_zero(mint_t *v0) { + return v0[0] == 0 && v0[1] == 0 && v0[2] == 0 && v0[3] == 0; +} + +bool vec4i_is_equal(mint_t *v0, mint_t *v1) { + return v0[0] == v1[0] && v0[1] == v1[1] && v0[2] == v1[2] && v0[3] == v1[3]; +} + +mint_t *vec4i(mint_t *result, mint_t x, mint_t y, mint_t z, mint_t w) { + result[0] = x; + result[1] = y; + result[2] = z; + result[3] = w; + return result; +} + +mint_t *vec4i_assign(mint_t *result, mint_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + result[2] = v0[2]; + result[3] = v0[3]; + return result; } #if defined(MATHC_USE_FLOATING_POINT) -mint_t *vec4i_assign_vec4(mint_t * result, mfloat_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - result[2] = v0[2]; - result[3] = v0[3]; - return result; +mint_t *vec4i_assign_vec4(mint_t *result, mfloat_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + result[2] = v0[2]; + result[3] = v0[3]; + return result; } #endif -mint_t *vec4i_zero(mint_t * result) -{ - result[0] = 0; - result[1] = 0; - result[2] = 0; - result[3] = 0; - return result; +mint_t *vec4i_zero(mint_t *result) { + result[0] = 0; + result[1] = 0; + result[2] = 0; + result[3] = 0; + return result; } -mint_t *vec4i_one(mint_t * result) -{ +mint_t *vec4i_one(mint_t *result) { + result[0] = 1; + result[1] = 1; + result[2] = 1; + result[3] = 1; + return result; +} + +mint_t *vec4i_sign(mint_t *result, mint_t *v0) { + if (v0[0] > 0) { result[0] = 1; + } else if (v0[0] < 0) { + result[0] = -1; + } else { + result[0] = 0; + } + if (v0[1] > 0) { result[1] = 1; + } else if (v0[1] < 0) { + result[1] = -1; + } else { + result[1] = 0; + } + if (v0[2] > 0) { result[2] = 1; + } else if (v0[2] < 0) { + result[2] = -1; + } else { + result[2] = 0; + } + if (v0[3] > 0) { result[3] = 1; - return result; + } else if (v0[3] < 0) { + result[3] = -1; + } else { + result[3] = 0; + } + return result; } -mint_t *vec4i_sign(mint_t * result, mint_t * v0) -{ - if (v0[0] > 0) { - result[0] = 1; - } else if (v0[0] < 0) { - result[0] = -1; - } else { - result[0] = 0; - } - if (v0[1] > 0) { - result[1] = 1; - } else if (v0[1] < 0) { - result[1] = -1; - } else { - result[1] = 0; - } - if (v0[2] > 0) { - result[2] = 1; - } else if (v0[2] < 0) { - result[2] = -1; - } else { - result[2] = 0; - } - if (v0[3] > 0) { - result[3] = 1; - } else if (v0[3] < 0) { - result[3] = -1; - } else { - result[3] = 0; - } - return result; +mint_t *vec4i_add(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] + v1[0]; + result[1] = v0[1] + v1[1]; + result[2] = v0[2] + v1[2]; + result[3] = v0[3] + v1[3]; + return result; } -mint_t *vec4i_add(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] + v1[0]; - result[1] = v0[1] + v1[1]; - result[2] = v0[2] + v1[2]; - result[3] = v0[3] + v1[3]; - return result; +mint_t *vec4i_add_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] + i; + result[1] = v0[1] + i; + result[2] = v0[2] + i; + result[3] = v0[3] + i; + return result; } -mint_t *vec4i_add_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] + i; - result[1] = v0[1] + i; - result[2] = v0[2] + i; - result[3] = v0[3] + i; - return result; +mint_t *vec4i_subtract(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] - v1[0]; + result[1] = v0[1] - v1[1]; + result[2] = v0[2] - v1[2]; + result[3] = v0[3] - v1[3]; + return result; } -mint_t *vec4i_subtract(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] - v1[0]; - result[1] = v0[1] - v1[1]; - result[2] = v0[2] - v1[2]; - result[3] = v0[3] - v1[3]; - return result; +mint_t *vec4i_subtract_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] - i; + result[1] = v0[1] - i; + result[2] = v0[2] - i; + result[3] = v0[3] - i; + return result; } -mint_t *vec4i_subtract_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] - i; - result[1] = v0[1] - i; - result[2] = v0[2] - i; - result[3] = v0[3] - i; - return result; +mint_t *vec4i_multiply(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] * v1[0]; + result[1] = v0[1] * v1[1]; + result[2] = v0[2] * v1[2]; + result[3] = v0[3] * v1[3]; + return result; } -mint_t *vec4i_multiply(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] * v1[0]; - result[1] = v0[1] * v1[1]; - result[2] = v0[2] * v1[2]; - result[3] = v0[3] * v1[3]; - return result; +mint_t *vec4i_multiply_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] * i; + result[1] = v0[1] * i; + result[2] = v0[2] * i; + result[3] = v0[3] * i; + return result; } -mint_t *vec4i_multiply_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] * i; - result[1] = v0[1] * i; - result[2] = v0[2] * i; - result[3] = v0[3] * i; - return result; +mint_t *vec4i_divide(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = v0[0] / v1[0]; + result[1] = v0[1] / v1[1]; + result[2] = v0[2] / v1[2]; + result[3] = v0[3] / v1[3]; + return result; } -mint_t *vec4i_divide(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = v0[0] / v1[0]; - result[1] = v0[1] / v1[1]; - result[2] = v0[2] / v1[2]; - result[3] = v0[3] / v1[3]; - return result; +mint_t *vec4i_divide_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = v0[0] / i; + result[1] = v0[1] / i; + result[2] = v0[2] / i; + result[3] = v0[3] / i; + return result; } -mint_t *vec4i_divide_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = v0[0] / i; - result[1] = v0[1] / i; - result[2] = v0[2] / i; - result[3] = v0[3] / i; - return result; +mint_t *vec4i_snap(mint_t *result, mint_t *v0, mint_t *v1) { + result[0] = (v0[0] / v1[0]) * v1[0]; + result[1] = (v0[1] / v1[1]) * v1[1]; + result[2] = (v0[2] / v1[2]) * v1[2]; + result[3] = (v0[3] / v1[3]) * v1[3]; + return result; } -mint_t *vec4i_snap(mint_t * result, mint_t * v0, mint_t * v1) -{ - result[0] = (v0[0] / v1[0]) * v1[0]; - result[1] = (v0[1] / v1[1]) * v1[1]; - result[2] = (v0[2] / v1[2]) * v1[2]; - result[3] = (v0[3] / v1[3]) * v1[3]; - return result; +mint_t *vec4i_snap_i(mint_t *result, mint_t *v0, mint_t i) { + result[0] = (v0[0] / i) * i; + result[1] = (v0[1] / i) * i; + result[2] = (v0[2] / i) * i; + result[3] = (v0[3] / i) * i; + return result; } -mint_t *vec4i_snap_i(mint_t * result, mint_t * v0, mint_t i) -{ - result[0] = (v0[0] / i) * i; - result[1] = (v0[1] / i) * i; - result[2] = (v0[2] / i) * i; - result[3] = (v0[3] / i) * i; - return result; +mint_t *vec4i_negative(mint_t *result, mint_t *v0) { + result[0] = -v0[0]; + result[1] = -v0[1]; + result[2] = -v0[2]; + result[3] = -v0[3]; + return result; } -mint_t *vec4i_negative(mint_t * result, mint_t * v0) -{ - result[0] = -v0[0]; - result[1] = -v0[1]; - result[2] = -v0[2]; - result[3] = -v0[3]; - return result; +mint_t *vec4i_abs(mint_t *result, mint_t *v0) { + result[0] = v0[0]; + if (result[0] < 0) { + result[0] = -result[0]; + } + result[1] = v0[1]; + if (result[1] < 0) { + result[1] = -result[1]; + } + result[2] = v0[2]; + if (result[2] < 0) { + result[2] = -result[2]; + } + result[3] = v0[3]; + if (result[3] < 0) { + result[3] = -result[3]; + } + return result; } -mint_t *vec4i_abs(mint_t * result, mint_t * v0) -{ +mint_t *vec4i_max(mint_t *result, mint_t *v0, mint_t *v1) { + if (v0[0] > v1[0]) { result[0] = v0[0]; - if (result[0] < 0) { - result[0] = -result[0]; - } + } else { + result[0] = v1[0]; + } + if (v0[1] > v1[1]) { result[1] = v0[1]; - if (result[1] < 0) { - result[1] = -result[1]; - } + } else { + result[1] = v1[1]; + } + if (v0[2] > v1[2]) { result[2] = v0[2]; - if (result[2] < 0) { - result[2] = -result[2]; - } + } else { + result[2] = v1[2]; + } + if (v0[3] > v1[3]) { result[3] = v0[3]; - if (result[3] < 0) { - result[3] = -result[3]; - } - return result; + } else { + result[3] = v1[3]; + } + return result; } -mint_t *vec4i_max(mint_t * result, mint_t * v0, mint_t * v1) -{ - if (v0[0] > v1[0]) { - result[0] = v0[0]; - } else { - result[0] = v1[0]; - } - if (v0[1] > v1[1]) { - result[1] = v0[1]; - } else { - result[1] = v1[1]; - } - if (v0[2] > v1[2]) { - result[2] = v0[2]; - } else { - result[2] = v1[2]; - } - if (v0[3] > v1[3]) { - result[3] = v0[3]; - } else { - result[3] = v1[3]; - } - return result; +mint_t *vec4i_min(mint_t *result, mint_t *v0, mint_t *v1) { + if (v0[0] < v1[0]) { + result[0] = v0[0]; + } else { + result[0] = v1[0]; + } + if (v0[1] < v1[1]) { + result[1] = v0[1]; + } else { + result[1] = v1[1]; + } + if (v0[2] < v1[2]) { + result[2] = v0[2]; + } else { + result[2] = v1[2]; + } + if (v0[3] < v1[3]) { + result[3] = v0[3]; + } else { + result[3] = v1[3]; + } + return result; } -mint_t *vec4i_min(mint_t * result, mint_t * v0, mint_t * v1) -{ - if (v0[0] < v1[0]) { - result[0] = v0[0]; - } else { - result[0] = v1[0]; - } - if (v0[1] < v1[1]) { - result[1] = v0[1]; - } else { - result[1] = v1[1]; - } - if (v0[2] < v1[2]) { - result[2] = v0[2]; - } else { - result[2] = v1[2]; - } - if (v0[3] < v1[3]) { - result[3] = v0[3]; - } else { - result[3] = v1[3]; - } - return result; -} - -mint_t *vec4i_clamp(mint_t * result, mint_t * v0, mint_t * v1, mint_t * v2) -{ - vec4i_min(result, v0, v1); - vec4i_max(result, v0, v2); - return result; +mint_t *vec4i_clamp(mint_t *result, mint_t *v0, mint_t *v1, mint_t *v2) { + vec4i_min(result, v0, v1); + vec4i_max(result, v0, v2); + return result; } #endif #if defined(MATHC_USE_FLOATING_POINT) -bool vec2_is_zero(mfloat_t * v0) -{ - return MFABS(v0[0]) < MFLT_EPSILON && MFABS(v0[1]) < MFLT_EPSILON; +bool vec2_is_zero(mfloat_t *v0) { + return MFABS(v0[0]) < MFLT_EPSILON && MFABS(v0[1]) < MFLT_EPSILON; } -bool vec2_is_equal(mfloat_t * v0, mfloat_t * v1) -{ - return MFABS(v0[0] - v1[0]) < MFLT_EPSILON - && MFABS(v0[1] - v1[1]) < MFLT_EPSILON; +bool vec2_is_equal(mfloat_t *v0, mfloat_t *v1) { + return MFABS(v0[0] - v1[0]) < MFLT_EPSILON && MFABS(v0[1] - v1[1]) < MFLT_EPSILON; } -mfloat_t *vec2(mfloat_t * result, mfloat_t x, mfloat_t y) -{ - result[0] = x; - result[1] = y; - return result; +mfloat_t *vec2(mfloat_t *result, mfloat_t x, mfloat_t y) { + result[0] = x; + result[1] = y; + return result; } -mfloat_t *vec2_assign(mfloat_t * result, mfloat_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - return result; +mfloat_t *vec2_assign(mfloat_t *result, mfloat_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + return result; } #if defined(MATHC_USE_INT) -mfloat_t *vec2_assign_vec2i(mfloat_t * result, mint_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - return result; +mfloat_t *vec2_assign_vec2i(mfloat_t *result, mint_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + return result; } #endif -mfloat_t *vec2_zero(mfloat_t * result) -{ - result[0] = MFLOAT_C(0.0); - result[1] = MFLOAT_C(0.0); - return result; +mfloat_t *vec2_zero(mfloat_t *result) { + result[0] = MFLOAT_C(0.0); + result[1] = MFLOAT_C(0.0); + return result; } -mfloat_t *vec2_one(mfloat_t * result) -{ +mfloat_t *vec2_one(mfloat_t *result) { + result[0] = MFLOAT_C(1.0); + result[1] = MFLOAT_C(1.0); + return result; +} + +mfloat_t *vec2_sign(mfloat_t *result, mfloat_t *v0) { + if (v0[0] > MFLOAT_C(0.0)) { result[0] = MFLOAT_C(1.0); + } else if (v0[0] < MFLOAT_C(0.0)) { + result[0] = -MFLOAT_C(1.0); + } else { + result[0] = MFLOAT_C(0.0); + } + if (v0[1] > MFLOAT_C(0.0)) { result[1] = MFLOAT_C(1.0); - return result; + } else if (v0[1] < MFLOAT_C(0.0)) { + result[1] = -MFLOAT_C(1.0); + } else { + result[1] = MFLOAT_C(0.0); + } + return result; } -mfloat_t *vec2_sign(mfloat_t * result, mfloat_t * v0) -{ - if (v0[0] > MFLOAT_C(0.0)) { - result[0] = MFLOAT_C(1.0); - } else if (v0[0] < MFLOAT_C(0.0)) { - result[0] = -MFLOAT_C(1.0); - } else { - result[0] = MFLOAT_C(0.0); - } - if (v0[1] > MFLOAT_C(0.0)) { - result[1] = MFLOAT_C(1.0); - } else if (v0[1] < MFLOAT_C(0.0)) { - result[1] = -MFLOAT_C(1.0); - } else { - result[1] = MFLOAT_C(0.0); - } - return result; +mfloat_t *vec2_add(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] + v1[0]; + result[1] = v0[1] + v1[1]; + return result; } -mfloat_t *vec2_add(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] + v1[0]; - result[1] = v0[1] + v1[1]; - return result; +mfloat_t *vec2_add_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] + f; + result[1] = v0[1] + f; + return result; } -mfloat_t *vec2_add_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] + f; - result[1] = v0[1] + f; - return result; +mfloat_t *vec2_subtract(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] - v1[0]; + result[1] = v0[1] - v1[1]; + return result; } -mfloat_t *vec2_subtract(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] - v1[0]; - result[1] = v0[1] - v1[1]; - return result; +mfloat_t *vec2_subtract_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] - f; + result[1] = v0[1] - f; + return result; } -mfloat_t *vec2_subtract_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] - f; - result[1] = v0[1] - f; - return result; +mfloat_t *vec2_multiply(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] * v1[0]; + result[1] = v0[1] * v1[1]; + return result; } -mfloat_t *vec2_multiply(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] * v1[0]; - result[1] = v0[1] * v1[1]; - return result; +mfloat_t *vec2_multiply_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] * f; + result[1] = v0[1] * f; + return result; } -mfloat_t *vec2_multiply_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] * f; - result[1] = v0[1] * f; - return result; +mfloat_t *vec2_multiply_mat2(mfloat_t *result, mfloat_t *v0, + mfloat_t *m0) { + mfloat_t x = v0[0]; + mfloat_t y = v0[1]; + result[0] = m0[0] * x + m0[2] * y; + result[1] = m0[1] * x + m0[3] * y; + return result; } -mfloat_t *vec2_multiply_mat2(mfloat_t * result, mfloat_t * v0, - mfloat_t * m0) -{ - mfloat_t x = v0[0]; - mfloat_t y = v0[1]; - result[0] = m0[0] * x + m0[2] * y; - result[1] = m0[1] * x + m0[3] * y; - return result; +mfloat_t *vec2_divide(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] / v1[0]; + result[1] = v0[1] / v1[1]; + return result; } -mfloat_t *vec2_divide(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] / v1[0]; - result[1] = v0[1] / v1[1]; - return result; +mfloat_t *vec2_divide_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] / f; + result[1] = v0[1] / f; + return result; } -mfloat_t *vec2_divide_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] / f; - result[1] = v0[1] / f; - return result; +mfloat_t *vec2_snap(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFLOOR(v0[0] / v1[0]) * v1[0]; + result[1] = MFLOOR(v0[1] / v1[1]) * v1[1]; + return result; } -mfloat_t *vec2_snap(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFLOOR(v0[0] / v1[0]) * v1[0]; - result[1] = MFLOOR(v0[1] / v1[1]) * v1[1]; - return result; +mfloat_t *vec2_snap_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = MFLOOR(v0[0] / f) * f; + result[1] = MFLOOR(v0[1] / f) * f; + return result; } -mfloat_t *vec2_snap_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = MFLOOR(v0[0] / f) * f; - result[1] = MFLOOR(v0[1] / f) * f; - return result; +mfloat_t *vec2_negative(mfloat_t *result, mfloat_t *v0) { + result[0] = -v0[0]; + result[1] = -v0[1]; + return result; } -mfloat_t *vec2_negative(mfloat_t * result, mfloat_t * v0) -{ - result[0] = -v0[0]; - result[1] = -v0[1]; - return result; +mfloat_t *vec2_abs(mfloat_t *result, mfloat_t *v0) { + result[0] = MFABS(v0[0]); + result[1] = MFABS(v0[1]); + return result; } -mfloat_t *vec2_abs(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MFABS(v0[0]); - result[1] = MFABS(v0[1]); - return result; +mfloat_t *vec2_floor(mfloat_t *result, mfloat_t *v0) { + result[0] = MFLOOR(v0[0]); + result[1] = MFLOOR(v0[1]); + return result; } -mfloat_t *vec2_floor(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MFLOOR(v0[0]); - result[1] = MFLOOR(v0[1]); - return result; +mfloat_t *vec2_ceil(mfloat_t *result, mfloat_t *v0) { + result[0] = MCEIL(v0[0]); + result[1] = MCEIL(v0[1]); + return result; } -mfloat_t *vec2_ceil(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MCEIL(v0[0]); - result[1] = MCEIL(v0[1]); - return result; +mfloat_t *vec2_round(mfloat_t *result, mfloat_t *v0) { + result[0] = MROUND(v0[0]); + result[1] = MROUND(v0[1]); + return result; } -mfloat_t *vec2_round(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MROUND(v0[0]); - result[1] = MROUND(v0[1]); - return result; +mfloat_t *vec2_max(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFMAX(v0[0], v1[0]); + result[1] = MFMAX(v0[1], v1[1]); + return result; } -mfloat_t *vec2_max(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFMAX(v0[0], v1[0]); - result[1] = MFMAX(v0[1], v1[1]); - return result; +mfloat_t *vec2_min(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFMIN(v0[0], v1[0]); + result[1] = MFMIN(v0[1], v1[1]); + return result; } -mfloat_t *vec2_min(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFMIN(v0[0], v1[0]); - result[1] = MFMIN(v0[1], v1[1]); - return result; +mfloat_t *vec2_clamp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2) { + vec2_min(result, v0, v1); + vec2_max(result, v0, v2); + return result; } -mfloat_t *vec2_clamp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2) -{ - vec2_min(result, v0, v1); - vec2_max(result, v0, v2); - return result; +mfloat_t *vec2_normalize(mfloat_t *result, mfloat_t *v0) { + mfloat_t l = MSQRT(v0[0] * v0[0] + v0[1] * v0[1]); + result[0] = v0[0] / l; + result[1] = v0[1] / l; + return result; } -mfloat_t *vec2_normalize(mfloat_t * result, mfloat_t * v0) -{ - mfloat_t l = MSQRT(v0[0] * v0[0] + v0[1] * v0[1]); - result[0] = v0[0] / l; - result[1] = v0[1] / l; - return result; +mfloat_t vec2_dot(mfloat_t *v0, mfloat_t *v1) { + return v0[0] * v1[0] + v0[1] * v1[1]; } -mfloat_t vec2_dot(mfloat_t * v0, mfloat_t * v1) -{ - return v0[0] * v1[0] + v0[1] * v1[1]; +mfloat_t *vec2_project(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + mfloat_t d = vec2_dot(v1, v1); + mfloat_t s = vec2_dot(v0, v1) / d; + result[0] = v1[0] * s; + result[1] = v1[1] * s; + return result; } -mfloat_t *vec2_project(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - mfloat_t d = vec2_dot(v1, v1); - mfloat_t s = vec2_dot(v0, v1) / d; - result[0] = v1[0] * s; - result[1] = v1[1] * s; - return result; +mfloat_t *vec2_slide(mfloat_t *result, mfloat_t *v0, mfloat_t *normal) { + mfloat_t d = vec2_dot(v0, normal); + result[0] = v0[0] - normal[0] * d; + result[1] = v0[1] - normal[1] * d; + return result; } -mfloat_t *vec2_slide(mfloat_t * result, mfloat_t * v0, mfloat_t * normal) -{ - mfloat_t d = vec2_dot(v0, normal); - result[0] = v0[0] - normal[0] * d; - result[1] = v0[1] - normal[1] * d; - return result; +mfloat_t *vec2_reflect(mfloat_t *result, mfloat_t *v0, mfloat_t *normal) { + mfloat_t d = MFLOAT_C(2.0) * vec2_dot(v0, normal); + result[0] = normal[0] * d - v0[0]; + result[1] = normal[1] * d - v0[1]; + return result; } -mfloat_t *vec2_reflect(mfloat_t * result, mfloat_t * v0, mfloat_t * normal) -{ - mfloat_t d = MFLOAT_C(2.0) * vec2_dot(v0, normal); - result[0] = normal[0] * d - v0[0]; - result[1] = normal[1] * d - v0[1]; - return result; +mfloat_t *vec2_tangent(mfloat_t *result, mfloat_t *v0) { + mfloat_t a0 = v0[0]; + mfloat_t a1 = v0[1]; + result[0] = a1; + result[1] = -a0; + return result; } -mfloat_t *vec2_tangent(mfloat_t * result, mfloat_t * v0) -{ - mfloat_t a0 = v0[0]; - mfloat_t a1 = v0[1]; - result[0] = a1; - result[1] = -a0; - return result; +mfloat_t *vec2_rotate(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + mfloat_t cs = MCOS(f); + mfloat_t sn = MSIN(f); + mfloat_t x = v0[0]; + mfloat_t y = v0[1]; + result[0] = x * cs - y * sn; + result[1] = x * sn + y * cs; + return result; } -mfloat_t *vec2_rotate(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - mfloat_t cs = MCOS(f); - mfloat_t sn = MSIN(f); - mfloat_t x = v0[0]; - mfloat_t y = v0[1]; - result[0] = x * cs - y * sn; - result[1] = x * sn + y * cs; - return result; +mfloat_t *vec2_lerp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t f) { + result[0] = v0[0] + (v1[0] - v0[0]) * f; + result[1] = v0[1] + (v1[1] - v0[1]) * f; + return result; } -mfloat_t *vec2_lerp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t f) -{ - result[0] = v0[0] + (v1[0] - v0[0]) * f; - result[1] = v0[1] + (v1[1] - v0[1]) * f; - return result; +mfloat_t *vec2_bezier3(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2, mfloat_t f) { + mfloat_t tmp0[VEC2_SIZE]; + mfloat_t tmp1[VEC2_SIZE]; + vec2_lerp(tmp0, v0, v1, f); + vec2_lerp(tmp1, v1, v2, f); + vec2_lerp(result, tmp0, tmp1, f); + return result; } -mfloat_t *vec2_bezier3(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2, mfloat_t f) -{ - mfloat_t tmp0[VEC2_SIZE]; - mfloat_t tmp1[VEC2_SIZE]; - vec2_lerp(tmp0, v0, v1, f); - vec2_lerp(tmp1, v1, v2, f); - vec2_lerp(result, tmp0, tmp1, f); - return result; +mfloat_t *vec2_bezier4(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2, mfloat_t *v3, mfloat_t f) { + mfloat_t tmp0[VEC2_SIZE]; + mfloat_t tmp1[VEC2_SIZE]; + mfloat_t tmp2[VEC2_SIZE]; + mfloat_t tmp3[VEC2_SIZE]; + mfloat_t tmp4[VEC2_SIZE]; + vec2_lerp(tmp0, v0, v1, f); + vec2_lerp(tmp1, v1, v2, f); + vec2_lerp(tmp2, v2, v3, f); + vec2_lerp(tmp3, tmp0, tmp1, f); + vec2_lerp(tmp4, tmp1, tmp2, f); + vec2_lerp(result, tmp3, tmp4, f); + return result; } -mfloat_t *vec2_bezier4(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2, mfloat_t * v3, mfloat_t f) -{ - mfloat_t tmp0[VEC2_SIZE]; - mfloat_t tmp1[VEC2_SIZE]; - mfloat_t tmp2[VEC2_SIZE]; - mfloat_t tmp3[VEC2_SIZE]; - mfloat_t tmp4[VEC2_SIZE]; - vec2_lerp(tmp0, v0, v1, f); - vec2_lerp(tmp1, v1, v2, f); - vec2_lerp(tmp2, v2, v3, f); - vec2_lerp(tmp3, tmp0, tmp1, f); - vec2_lerp(tmp4, tmp1, tmp2, f); - vec2_lerp(result, tmp3, tmp4, f); - return result; +mfloat_t vec2_angle(mfloat_t *v0) { + return MATAN2(v0[1], v0[0]); } -mfloat_t vec2_angle(mfloat_t * v0) -{ - return MATAN2(v0[1], v0[0]); +mfloat_t vec2_length(mfloat_t *v0) { + return MSQRT(v0[0] * v0[0] + v0[1] * v0[1]); } -mfloat_t vec2_length(mfloat_t * v0) -{ - return MSQRT(v0[0] * v0[0] + v0[1] * v0[1]); +mfloat_t vec2_length_squared(mfloat_t *v0) { + return v0[0] * v0[0] + v0[1] * v0[1]; } -mfloat_t vec2_length_squared(mfloat_t * v0) -{ - return v0[0] * v0[0] + v0[1] * v0[1]; +mfloat_t vec2_distance(mfloat_t *v0, mfloat_t *v1) { + return MSQRT((v0[0] - v1[0]) * (v0[0] - v1[0]) + + (v0[1] - v1[1]) * (v0[1] - v1[1])); } -mfloat_t vec2_distance(mfloat_t * v0, mfloat_t * v1) -{ - return MSQRT((v0[0] - v1[0]) * (v0[0] - v1[0]) + - (v0[1] - v1[1]) * (v0[1] - v1[1])); +mfloat_t vec2_distance_squared(mfloat_t *v0, mfloat_t *v1) { + return (v0[0] - v1[0]) * (v0[0] - v1[0]) + (v0[1] - v1[1]) * (v0[1] - + v1[1]); } -mfloat_t vec2_distance_squared(mfloat_t * v0, mfloat_t * v1) -{ - return (v0[0] - v1[0]) * (v0[0] - v1[0]) + (v0[1] - v1[1]) * (v0[1] - - v1[1]); -} - -bool vec2_linear_independent(mfloat_t * v0, mfloat_t * v1) -{ - return (v0[0] * v1[1] - v1[0] * v0[1]) != 0; +bool vec2_linear_independent(mfloat_t *v0, mfloat_t *v1) { + return (v0[0] * v1[1] - v1[0] * v0[1]) != 0; } mfloat_t **vec2_orthonormalization(mfloat_t result[2][2], - mfloat_t basis[2][2]) -{ - mfloat_t v0[2]; - mfloat_t v1[2]; + mfloat_t basis[2][2]) { + mfloat_t v0[2]; + mfloat_t v1[2]; - for (int32_t i = 0; i < 2; ++i) { - v0[i] = basis[0][i]; - v1[i] = basis[1][i]; - } + for (int32_t i = 0; i < 2; ++i) { + v0[i] = basis[0][i]; + v1[i] = basis[1][i]; + } - if (!vec2_linear_independent(v0, v1)) { - return (mfloat_t **) result; - } + if (!vec2_linear_independent(v0, v1)) { + return (mfloat_t **)result; + } - mfloat_t proju1[2]; - mfloat_t u0[2]; - mfloat_t u1[2]; + mfloat_t proju1[2]; + mfloat_t u0[2]; + mfloat_t u1[2]; - for (int32_t i = 0; i < 2; ++i) { - u0[i] = v0[i]; - } + for (int32_t i = 0; i < 2; ++i) { + u0[i] = v0[i]; + } - vec2_project(proju1, v1, v0); - vec2_subtract(u1, v1, proju1); - vec2_normalize(result[0], u0); - vec2_normalize(result[1], u1); + vec2_project(proju1, v1, v0); + vec2_subtract(u1, v1, proju1); + vec2_normalize(result[0], u0); + vec2_normalize(result[1], u1); - return (mfloat_t **) result; + return (mfloat_t **)result; } -bool vec3_is_zero(mfloat_t * v0) -{ - return MFABS(v0[0]) < MFLT_EPSILON && MFABS(v0[1]) < MFLT_EPSILON - && MFABS(v0[2]) < MFLT_EPSILON; +bool vec3_is_zero(mfloat_t *v0) { + return MFABS(v0[0]) < MFLT_EPSILON && MFABS(v0[1]) < MFLT_EPSILON && MFABS(v0[2]) < MFLT_EPSILON; } -bool vec3_is_equal(mfloat_t * v0, mfloat_t * v1) -{ - return MFABS(v0[0] - v1[0]) < MFLT_EPSILON - && MFABS(v0[1] - v1[1]) < MFLT_EPSILON - && MFABS(v0[2] - v1[2]) < MFLT_EPSILON; +bool vec3_is_equal(mfloat_t *v0, mfloat_t *v1) { + return MFABS(v0[0] - v1[0]) < MFLT_EPSILON && MFABS(v0[1] - v1[1]) < MFLT_EPSILON && MFABS(v0[2] - v1[2]) < MFLT_EPSILON; } -mfloat_t *vec3(mfloat_t * result, mfloat_t x, mfloat_t y, mfloat_t z) -{ - result[0] = x; - result[1] = y; - result[2] = z; - return result; +mfloat_t *vec3(mfloat_t *result, mfloat_t x, mfloat_t y, mfloat_t z) { + result[0] = x; + result[1] = y; + result[2] = z; + return result; } -mfloat_t *vec3_assign(mfloat_t * result, mfloat_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - result[2] = v0[2]; - return result; +mfloat_t *vec3_assign(mfloat_t *result, mfloat_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + result[2] = v0[2]; + return result; } #if defined(MATHC_USE_INT) -mfloat_t *vec3_assign_vec3i(mfloat_t * result, mint_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - result[2] = v0[2]; - return result; +mfloat_t *vec3_assign_vec3i(mfloat_t *result, mint_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + result[2] = v0[2]; + return result; } #endif -mfloat_t *vec3_zero(mfloat_t * result) -{ - result[0] = MFLOAT_C(0.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - return result; +mfloat_t *vec3_zero(mfloat_t *result) { + result[0] = MFLOAT_C(0.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + return result; } -mfloat_t *vec3_one(mfloat_t * result) -{ +mfloat_t *vec3_one(mfloat_t *result) { + result[0] = MFLOAT_C(1.0); + result[1] = MFLOAT_C(1.0); + result[2] = MFLOAT_C(1.0); + return result; +} + +mfloat_t *vec3_sign(mfloat_t *result, mfloat_t *v0) { + if (v0[0] > MFLOAT_C(0.0)) { result[0] = MFLOAT_C(1.0); + } else if (v0[0] < 0) { + result[0] = -MFLOAT_C(1.0); + } else { + result[0] = MFLOAT_C(0.0); + } + if (v0[1] > MFLOAT_C(0.0)) { result[1] = MFLOAT_C(1.0); + } else if (v0[1] < 0) { + result[1] = -MFLOAT_C(1.0); + } else { + result[1] = MFLOAT_C(0.0); + } + if (v0[2] > MFLOAT_C(0.0)) { result[2] = MFLOAT_C(1.0); - return result; + } else if (v0[2] < 0) { + result[2] = -MFLOAT_C(1.0); + } else { + result[2] = MFLOAT_C(0.0); + } + return result; } -mfloat_t *vec3_sign(mfloat_t * result, mfloat_t * v0) -{ - if (v0[0] > MFLOAT_C(0.0)) { - result[0] = MFLOAT_C(1.0); - } else if (v0[0] < 0) { - result[0] = -MFLOAT_C(1.0); - } else { - result[0] = MFLOAT_C(0.0); - } - if (v0[1] > MFLOAT_C(0.0)) { - result[1] = MFLOAT_C(1.0); - } else if (v0[1] < 0) { - result[1] = -MFLOAT_C(1.0); - } else { - result[1] = MFLOAT_C(0.0); - } - if (v0[2] > MFLOAT_C(0.0)) { - result[2] = MFLOAT_C(1.0); - } else if (v0[2] < 0) { - result[2] = -MFLOAT_C(1.0); - } else { - result[2] = MFLOAT_C(0.0); - } - return result; +mfloat_t *vec3_add(mfloat_t *result, const mfloat_t *v0, + const mfloat_t *v1) { + result[0] = v0[0] + v1[0]; + result[1] = v0[1] + v1[1]; + result[2] = v0[2] + v1[2]; + return result; } -mfloat_t *vec3_add(mfloat_t * result, const mfloat_t * v0, - const mfloat_t * v1) -{ - result[0] = v0[0] + v1[0]; - result[1] = v0[1] + v1[1]; - result[2] = v0[2] + v1[2]; - return result; +mfloat_t *vec3_add_f(mfloat_t *result, const mfloat_t *v0, + const mfloat_t f) { + result[0] = v0[0] + f; + result[1] = v0[1] + f; + result[2] = v0[2] + f; + return result; } -mfloat_t *vec3_add_f(mfloat_t * result, const mfloat_t * v0, - const mfloat_t f) -{ - result[0] = v0[0] + f; - result[1] = v0[1] + f; - result[2] = v0[2] + f; - return result; +mfloat_t *vec3_subtract(mfloat_t *result, const mfloat_t *v0, + const mfloat_t *v1) { + result[0] = v0[0] - v1[0]; + result[1] = v0[1] - v1[1]; + result[2] = v0[2] - v1[2]; + return result; } -mfloat_t *vec3_subtract(mfloat_t * result, const mfloat_t * v0, - const mfloat_t * v1) -{ - result[0] = v0[0] - v1[0]; - result[1] = v0[1] - v1[1]; - result[2] = v0[2] - v1[2]; - return result; +mfloat_t *vec3_subtract_f(mfloat_t *result, const mfloat_t *v0, + const mfloat_t f) { + result[0] = v0[0] - f; + result[1] = v0[1] - f; + result[2] = v0[2] - f; + return result; } -mfloat_t *vec3_subtract_f(mfloat_t * result, const mfloat_t * v0, - const mfloat_t f) -{ - result[0] = v0[0] - f; - result[1] = v0[1] - f; - result[2] = v0[2] - f; - return result; +mfloat_t *vec3_multiply(mfloat_t *result, const mfloat_t *v0, + const mfloat_t *v1) { + result[0] = v0[0] * v1[0]; + result[1] = v0[1] * v1[1]; + result[2] = v0[2] * v1[2]; + return result; } -mfloat_t *vec3_multiply(mfloat_t * result, const mfloat_t * v0, - const mfloat_t * v1) -{ - result[0] = v0[0] * v1[0]; - result[1] = v0[1] * v1[1]; - result[2] = v0[2] * v1[2]; - return result; +mfloat_t *vec3_multiply_f(mfloat_t *result, const mfloat_t *v0, + const mfloat_t f) { + result[0] = v0[0] * f; + result[1] = v0[1] * f; + result[2] = v0[2] * f; + return result; } -mfloat_t *vec3_multiply_f(mfloat_t * result, const mfloat_t * v0, - const mfloat_t f) -{ - result[0] = v0[0] * f; - result[1] = v0[1] * f; - result[2] = v0[2] * f; - return result; +mfloat_t *vec3_multiply_mat3(mfloat_t *result, mfloat_t *v0, + mfloat_t *m0) { + mfloat_t x = v0[0]; + mfloat_t y = v0[1]; + mfloat_t z = v0[2]; + result[0] = m0[0] * x + m0[3] * y + m0[6] * z; + result[1] = m0[1] * x + m0[4] * y + m0[7] * z; + result[2] = m0[2] * x + m0[5] * y + m0[8] * z; + return result; } -mfloat_t *vec3_multiply_mat3(mfloat_t * result, mfloat_t * v0, - mfloat_t * m0) -{ - mfloat_t x = v0[0]; - mfloat_t y = v0[1]; - mfloat_t z = v0[2]; - result[0] = m0[0] * x + m0[3] * y + m0[6] * z; - result[1] = m0[1] * x + m0[4] * y + m0[7] * z; - result[2] = m0[2] * x + m0[5] * y + m0[8] * z; - return result; +mfloat_t *vec3_divide(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] / v1[0]; + result[1] = v0[1] / v1[1]; + result[2] = v0[2] / v1[2]; + return result; } -mfloat_t *vec3_divide(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] / v1[0]; - result[1] = v0[1] / v1[1]; - result[2] = v0[2] / v1[2]; - return result; +mfloat_t *vec3_divide_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] / f; + result[1] = v0[1] / f; + result[2] = v0[2] / f; + return result; } -mfloat_t *vec3_divide_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] / f; - result[1] = v0[1] / f; - result[2] = v0[2] / f; - return result; +mfloat_t *vec3_snap(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFLOOR(v0[0] / v1[0]) * v1[0]; + result[1] = MFLOOR(v0[1] / v1[1]) * v1[1]; + result[2] = MFLOOR(v0[2] / v1[2]) * v1[2]; + return result; } -mfloat_t *vec3_snap(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFLOOR(v0[0] / v1[0]) * v1[0]; - result[1] = MFLOOR(v0[1] / v1[1]) * v1[1]; - result[2] = MFLOOR(v0[2] / v1[2]) * v1[2]; - return result; +mfloat_t *vec3_snap_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = MFLOOR(v0[0] / f) * f; + result[1] = MFLOOR(v0[1] / f) * f; + result[2] = MFLOOR(v0[2] / f) * f; + return result; } -mfloat_t *vec3_snap_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = MFLOOR(v0[0] / f) * f; - result[1] = MFLOOR(v0[1] / f) * f; - result[2] = MFLOOR(v0[2] / f) * f; - return result; +mfloat_t *vec3_negative(mfloat_t *result, mfloat_t *v0) { + result[0] = -v0[0]; + result[1] = -v0[1]; + result[2] = -v0[2]; + return result; } -mfloat_t *vec3_negative(mfloat_t * result, mfloat_t * v0) -{ - result[0] = -v0[0]; - result[1] = -v0[1]; - result[2] = -v0[2]; - return result; +mfloat_t *vec3_abs(mfloat_t *result, mfloat_t *v0) { + result[0] = MFABS(v0[0]); + result[1] = MFABS(v0[1]); + result[2] = MFABS(v0[2]); + return result; } -mfloat_t *vec3_abs(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MFABS(v0[0]); - result[1] = MFABS(v0[1]); - result[2] = MFABS(v0[2]); - return result; +mfloat_t *vec3_floor(mfloat_t *result, mfloat_t *v0) { + result[0] = MFLOOR(v0[0]); + result[1] = MFLOOR(v0[1]); + result[2] = MFLOOR(v0[2]); + return result; } -mfloat_t *vec3_floor(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MFLOOR(v0[0]); - result[1] = MFLOOR(v0[1]); - result[2] = MFLOOR(v0[2]); - return result; +mfloat_t *vec3_ceil(mfloat_t *result, mfloat_t *v0) { + result[0] = MCEIL(v0[0]); + result[1] = MCEIL(v0[1]); + result[2] = MCEIL(v0[2]); + return result; } -mfloat_t *vec3_ceil(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MCEIL(v0[0]); - result[1] = MCEIL(v0[1]); - result[2] = MCEIL(v0[2]); - return result; +mfloat_t *vec3_round(mfloat_t *result, mfloat_t *v0) { + result[0] = MROUND(v0[0]); + result[1] = MROUND(v0[1]); + result[2] = MROUND(v0[2]); + return result; } -mfloat_t *vec3_round(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MROUND(v0[0]); - result[1] = MROUND(v0[1]); - result[2] = MROUND(v0[2]); - return result; +mfloat_t *vec3_max(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFMAX(v0[0], v1[0]); + result[1] = MFMAX(v0[1], v1[1]); + result[2] = MFMAX(v0[2], v1[2]); + return result; } -mfloat_t *vec3_max(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFMAX(v0[0], v1[0]); - result[1] = MFMAX(v0[1], v1[1]); - result[2] = MFMAX(v0[2], v1[2]); - return result; +mfloat_t *vec3_min(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFMIN(v0[0], v1[0]); + result[1] = MFMIN(v0[1], v1[1]); + result[2] = MFMIN(v0[2], v1[2]); + return result; } -mfloat_t *vec3_min(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFMIN(v0[0], v1[0]); - result[1] = MFMIN(v0[1], v1[1]); - result[2] = MFMIN(v0[2], v1[2]); - return result; +mfloat_t *vec3_clamp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2) { + vec3_min(result, v0, v1); + vec3_max(result, v0, v2); + return result; } -mfloat_t *vec3_clamp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2) -{ - vec3_min(result, v0, v1); - vec3_max(result, v0, v2); - return result; +mfloat_t *vec3_cross(mfloat_t *result, const mfloat_t *v0, + const mfloat_t *v1) { + + result[0] = v0[1] * v1[2] - v0[2] * v1[1]; + result[1] = v0[2] * v1[0] - v0[0] * v1[2]; + result[2] = v0[0] * v1[1] - v0[1] * v1[0]; + return result; } -mfloat_t *vec3_cross(mfloat_t * result, const mfloat_t * v0, - const mfloat_t * v1) -{ - - result[0] = v0[1] * v1[2] - v0[2] * v1[1]; - result[1] = v0[2] * v1[0] - v0[0] * v1[2]; - result[2] = v0[0] * v1[1] - v0[1] * v1[0]; - return result; +mfloat_t *vec3_normalize(mfloat_t *result, mfloat_t *v0) { + mfloat_t l = MSQRT(v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2]); + result[0] = v0[0] / l; + result[1] = v0[1] / l; + result[2] = v0[2] / l; + return result; } -mfloat_t *vec3_normalize(mfloat_t * result, mfloat_t * v0) -{ - mfloat_t l = MSQRT(v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2]); - result[0] = v0[0] / l; - result[1] = v0[1] / l; - result[2] = v0[2] / l; - return result; +mfloat_t vec3_dot(const mfloat_t *v0, const mfloat_t *v1) { + return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2]; } -mfloat_t vec3_dot(const mfloat_t * v0, const mfloat_t * v1) -{ - return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2]; +mfloat_t *vec3_project(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + mfloat_t d = vec3_dot(v1, v1); + mfloat_t s = vec3_dot(v0, v1) / d; + result[0] = v1[0] * s; + result[1] = v1[1] * s; + result[2] = v1[2] * s; + return result; } -mfloat_t *vec3_project(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - mfloat_t d = vec3_dot(v1, v1); - mfloat_t s = vec3_dot(v0, v1) / d; - result[0] = v1[0] * s; - result[1] = v1[1] * s; - result[2] = v1[2] * s; - return result; +mfloat_t *vec3_slide(mfloat_t *result, mfloat_t *v0, mfloat_t *normal) { + mfloat_t d = vec3_dot(v0, normal); + result[0] = v0[0] - normal[0] * d; + result[1] = v0[1] - normal[1] * d; + result[2] = v0[2] - normal[2] * d; + return result; } -mfloat_t *vec3_slide(mfloat_t * result, mfloat_t * v0, mfloat_t * normal) -{ - mfloat_t d = vec3_dot(v0, normal); - result[0] = v0[0] - normal[0] * d; - result[1] = v0[1] - normal[1] * d; - result[2] = v0[2] - normal[2] * d; - return result; +mfloat_t *vec3_reflect(mfloat_t *result, mfloat_t *v0, mfloat_t *normal) { + mfloat_t d = MFLOAT_C(2.0) * vec3_dot(v0, normal); + result[0] = normal[0] * d - v0[0]; + result[1] = normal[1] * d - v0[1]; + result[2] = normal[2] * d - v0[2]; + return result; } -mfloat_t *vec3_reflect(mfloat_t * result, mfloat_t * v0, mfloat_t * normal) -{ - mfloat_t d = MFLOAT_C(2.0) * vec3_dot(v0, normal); - result[0] = normal[0] * d - v0[0]; - result[1] = normal[1] * d - v0[1]; - result[2] = normal[2] * d - v0[2]; - return result; +mfloat_t *vec3_rotate(mfloat_t *result, mfloat_t *v0, mfloat_t *ra, + mfloat_t f) { + mfloat_t cs; + mfloat_t sn; + mfloat_t x; + mfloat_t y; + mfloat_t z; + mfloat_t rx; + mfloat_t ry; + mfloat_t rz; + cs = MCOS(f); + sn = MSIN(f); + x = v0[0]; + y = v0[1]; + z = v0[2]; + vec3_normalize(ra, ra); + rx = ra[0]; + ry = ra[1]; + rz = ra[2]; + result[0] = + x * (cs + rx * rx * (1 - cs)) + y * (rx * ry * (1 - cs) - rz * sn) + z * (rx * rz * (1 - cs) + ry * sn); + result[1] = + x * (ry * rx * (1 - cs) + rz * sn) + y * (cs + ry * ry * (1 - cs)) + + z * (ry * rz * (1 - cs) - rx * sn); + result[2] = + x * (rz * rx * (1 - cs) - ry * sn) + y * (rz * ry * (1 - cs) + rx * sn) + z * (cs + rz * rz * (1 - cs)); + return result; } -mfloat_t *vec3_rotate(mfloat_t * result, mfloat_t * v0, mfloat_t * ra, - mfloat_t f) -{ - mfloat_t cs; - mfloat_t sn; - mfloat_t x; - mfloat_t y; - mfloat_t z; - mfloat_t rx; - mfloat_t ry; - mfloat_t rz; - cs = MCOS(f); - sn = MSIN(f); - x = v0[0]; - y = v0[1]; - z = v0[2]; - vec3_normalize(ra, ra); - rx = ra[0]; - ry = ra[1]; - rz = ra[2]; - result[0] = - x * (cs + rx * rx * (1 - cs)) + y * (rx * ry * (1 - cs) - - rz * sn) + z * (rx * rz * (1 - - cs) - + ry * sn); - result[1] = - x * (ry * rx * (1 - cs) + rz * sn) + y * (cs + - ry * ry * (1 - cs)) + - z * (ry * rz * (1 - cs) - rx * sn); - result[2] = - x * (rz * rx * (1 - cs) - ry * sn) + y * (rz * ry * (1 - cs) + - rx * sn) + z * (cs + - rz * rz * - (1 - - cs)); - return result; +mfloat_t *vec3_lerp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t f) { + result[0] = v0[0] + (v1[0] - v0[0]) * f; + result[1] = v0[1] + (v1[1] - v0[1]) * f; + result[2] = v0[2] + (v1[2] - v0[2]) * f; + return result; } -mfloat_t *vec3_lerp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t f) -{ - result[0] = v0[0] + (v1[0] - v0[0]) * f; - result[1] = v0[1] + (v1[1] - v0[1]) * f; - result[2] = v0[2] + (v1[2] - v0[2]) * f; - return result; +mfloat_t *vec3_bezier3(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2, mfloat_t f) { + mfloat_t tmp0[VEC3_SIZE]; + mfloat_t tmp1[VEC3_SIZE]; + vec3_lerp(tmp0, v0, v1, f); + vec3_lerp(tmp1, v1, v2, f); + vec3_lerp(result, tmp0, tmp1, f); + return result; } -mfloat_t *vec3_bezier3(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2, mfloat_t f) -{ - mfloat_t tmp0[VEC3_SIZE]; - mfloat_t tmp1[VEC3_SIZE]; - vec3_lerp(tmp0, v0, v1, f); - vec3_lerp(tmp1, v1, v2, f); - vec3_lerp(result, tmp0, tmp1, f); - return result; +mfloat_t *vec3_bezier4(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2, mfloat_t *v3, mfloat_t f) { + mfloat_t tmp0[VEC3_SIZE]; + mfloat_t tmp1[VEC3_SIZE]; + mfloat_t tmp2[VEC3_SIZE]; + mfloat_t tmp3[VEC3_SIZE]; + mfloat_t tmp4[VEC3_SIZE]; + vec3_lerp(tmp0, v0, v1, f); + vec3_lerp(tmp1, v1, v2, f); + vec3_lerp(tmp2, v2, v3, f); + vec3_lerp(tmp3, tmp0, tmp1, f); + vec3_lerp(tmp4, tmp1, tmp2, f); + vec3_lerp(result, tmp3, tmp4, f); + return result; } -mfloat_t *vec3_bezier4(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2, mfloat_t * v3, mfloat_t f) -{ - mfloat_t tmp0[VEC3_SIZE]; - mfloat_t tmp1[VEC3_SIZE]; - mfloat_t tmp2[VEC3_SIZE]; - mfloat_t tmp3[VEC3_SIZE]; - mfloat_t tmp4[VEC3_SIZE]; - vec3_lerp(tmp0, v0, v1, f); - vec3_lerp(tmp1, v1, v2, f); - vec3_lerp(tmp2, v2, v3, f); - vec3_lerp(tmp3, tmp0, tmp1, f); - vec3_lerp(tmp4, tmp1, tmp2, f); - vec3_lerp(result, tmp3, tmp4, f); - return result; +mfloat_t vec3_length(mfloat_t *v0) { + return MSQRT(v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2]); } -mfloat_t vec3_length(mfloat_t * v0) -{ - return MSQRT(v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2]); +mfloat_t vec3_length_squared(mfloat_t *v0) { + return v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2]; } -mfloat_t vec3_length_squared(mfloat_t * v0) -{ - return v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2]; +mfloat_t vec3_distance(mfloat_t *v0, mfloat_t *v1) { + return MSQRT((v0[0] - v1[0]) * (v0[0] - v1[0]) + + (v0[1] - v1[1]) * (v0[1] - v1[1]) + (v0[2] - v1[2]) * (v0[2] - v1[2])); } -mfloat_t vec3_distance(mfloat_t * v0, mfloat_t * v1) -{ - return MSQRT((v0[0] - v1[0]) * (v0[0] - v1[0]) + - (v0[1] - v1[1]) * (v0[1] - v1[1]) + (v0[2] - - v1[2]) * (v0[2] - - v1[2])); +mfloat_t vec3_distance_squared(mfloat_t *v0, mfloat_t *v1) { + return (v0[0] - v1[0]) * (v0[0] - v1[0]) + (v0[1] - v1[1]) * (v0[1] - v1[1]) + + (v0[2] - v1[2]) * (v0[2] - v1[2]); } -mfloat_t vec3_distance_squared(mfloat_t * v0, mfloat_t * v1) -{ - return (v0[0] - v1[0]) * (v0[0] - v1[0]) + (v0[1] - v1[1]) * (v0[1] - - v1[1]) + - (v0[2] - v1[2]) * (v0[2] - v1[2]); -} - -bool vec3_linear_independent(mfloat_t * v0, mfloat_t * v1, mfloat_t * v2) -{ - return v0[0] * v1[1] * v2[2] + v0[1] * v1[2] * v2[0] + - v0[2] * v1[0] * v2[1] - - v0[2] * v1[1] * v2[0] - v0[1] * v1[0] * v2[2] - - v0[0] * v1[2] * v2[1]; +bool vec3_linear_independent(mfloat_t *v0, mfloat_t *v1, mfloat_t *v2) { + return v0[0] * v1[1] * v2[2] + v0[1] * v1[2] * v2[0] + + v0[2] * v1[0] * v2[1] - v0[2] * v1[1] * v2[0] - v0[1] * v1[0] * v2[2] - + v0[0] * v1[2] * v2[1]; } mfloat_t **vec3_orthonormalization(mfloat_t result[3][3], - mfloat_t basis[3][3]) -{ - mfloat_t v0[3]; - mfloat_t v1[3]; - mfloat_t v2[3]; + mfloat_t basis[3][3]) { + mfloat_t v0[3]; + mfloat_t v1[3]; + mfloat_t v2[3]; - for (int32_t i = 0; i < 3; ++i) { - v0[i] = basis[0][i]; - v1[i] = basis[1][i]; - v2[i] = basis[2][i]; - } + for (int32_t i = 0; i < 3; ++i) { + v0[i] = basis[0][i]; + v1[i] = basis[1][i]; + v2[i] = basis[2][i]; + } - if (!vec3_linear_independent(v0, v1, v2)) { - return (mfloat_t **) result; - } + if (!vec3_linear_independent(v0, v1, v2)) { + return (mfloat_t **)result; + } - mfloat_t proj[3]; - mfloat_t u0[3]; - mfloat_t u1[3]; - mfloat_t u2[3]; + mfloat_t proj[3]; + mfloat_t u0[3]; + mfloat_t u1[3]; + mfloat_t u2[3]; - for (int32_t i = 0; i < 3; ++i) { - u0[i] = v0[i]; - } + for (int32_t i = 0; i < 3; ++i) { + u0[i] = v0[i]; + } - vec3_project(proj, v1, u0); - vec3_subtract(u1, v1, proj); + vec3_project(proj, v1, u0); + vec3_subtract(u1, v1, proj); - vec3_project(proj, v2, u0); - vec3_subtract(u2, v2, proj); - vec3_project(proj, v2, u1); - vec3_subtract(u2, u2, proj); + vec3_project(proj, v2, u0); + vec3_subtract(u2, v2, proj); + vec3_project(proj, v2, u1); + vec3_subtract(u2, u2, proj); - vec3_normalize(result[0], u0); - vec3_normalize(result[1], u1); - vec3_normalize(result[2], u2); + vec3_normalize(result[0], u0); + vec3_normalize(result[1], u1); + vec3_normalize(result[2], u2); - return (mfloat_t **) result; + return (mfloat_t **)result; } +mfloat_t *vec3_rotate_quat(mfloat_t *result, const mfloat_t *v, + const mfloat_t *q) { + mfloat_t qi[4]; + quat_conjugate(qi, q); -mfloat_t *vec3_rotate_quat(mfloat_t * result, const mfloat_t * v, - const mfloat_t * q) -{ - mfloat_t qi[4]; - quat_conjugate(qi, q); + mfloat_t vq[4] = {0}; + vq[0] = v[0]; + vq[1] = v[1]; + vq[2] = v[2]; - mfloat_t vq[4] = { 0 }; - vq[0] = v[0]; - vq[1] = v[1]; - vq[2] = v[2]; + quat_multiply(vq, q, vq); + quat_multiply(vq, vq, qi); - quat_multiply(vq, q, vq); - quat_multiply(vq, vq, qi); - - result[0] = vq[0]; - result[1] = vq[1]; - result[2] = vq[2]; - return result; + result[0] = vq[0]; + result[1] = vq[1]; + result[2] = vq[2]; + return result; } - -bool vec4_is_zero(mfloat_t * v0) -{ - return MFABS(v0[0]) < MFLT_EPSILON && MFABS(v0[1]) < MFLT_EPSILON - && MFABS(v0[2]) < MFLT_EPSILON && MFABS(v0[3]) < MFLT_EPSILON; +bool vec4_is_zero(mfloat_t *v0) { + return MFABS(v0[0]) < MFLT_EPSILON && MFABS(v0[1]) < MFLT_EPSILON && MFABS(v0[2]) < MFLT_EPSILON && MFABS(v0[3]) < MFLT_EPSILON; } -bool vec4_is_equal(mfloat_t * v0, mfloat_t * v1) -{ - return MFABS(v0[0] - v1[0]) < MFLT_EPSILON - && MFABS(v0[1] - v1[1]) < MFLT_EPSILON - && MFABS(v0[2] - v1[2]) < MFLT_EPSILON - && MFABS(v0[3] - v1[3]) < MFLT_EPSILON; +bool vec4_is_equal(mfloat_t *v0, mfloat_t *v1) { + return MFABS(v0[0] - v1[0]) < MFLT_EPSILON && MFABS(v0[1] - v1[1]) < MFLT_EPSILON && MFABS(v0[2] - v1[2]) < MFLT_EPSILON && MFABS(v0[3] - v1[3]) < MFLT_EPSILON; } -mfloat_t *vec4(mfloat_t * result, mfloat_t x, mfloat_t y, mfloat_t z, - mfloat_t w) -{ - result[0] = x; - result[1] = y; - result[2] = z; - result[3] = w; - return result; +mfloat_t *vec4(mfloat_t *result, mfloat_t x, mfloat_t y, mfloat_t z, + mfloat_t w) { + result[0] = x; + result[1] = y; + result[2] = z; + result[3] = w; + return result; } -mfloat_t *vec4_assign(mfloat_t * result, mfloat_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - result[2] = v0[2]; - result[3] = v0[3]; - return result; +mfloat_t *vec4_assign(mfloat_t *result, mfloat_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + result[2] = v0[2]; + result[3] = v0[3]; + return result; } #if defined(MATHC_USE_INT) -mfloat_t *vec4_assign_vec4i(mfloat_t * result, mint_t * v0) -{ - result[0] = v0[0]; - result[1] = v0[1]; - result[2] = v0[2]; - result[3] = v0[3]; - return result; +mfloat_t *vec4_assign_vec4i(mfloat_t *result, mint_t *v0) { + result[0] = v0[0]; + result[1] = v0[1]; + result[2] = v0[2]; + result[3] = v0[3]; + return result; } #endif -mfloat_t *vec4_zero(mfloat_t * result) -{ - result[0] = MFLOAT_C(0.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - return result; +mfloat_t *vec4_zero(mfloat_t *result) { + result[0] = MFLOAT_C(0.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + return result; } -mfloat_t *vec4_one(mfloat_t * result) -{ +mfloat_t *vec4_one(mfloat_t *result) { + result[0] = MFLOAT_C(1.0); + result[1] = MFLOAT_C(1.0); + result[2] = MFLOAT_C(1.0); + result[3] = MFLOAT_C(1.0); + return result; +} + +mfloat_t *vec4_sign(mfloat_t *result, mfloat_t *v0) { + if (v0[0] > MFLOAT_C(0.0)) { result[0] = MFLOAT_C(1.0); + } else if (v0[0] < 0) { + result[0] = -MFLOAT_C(1.0); + } else { + result[0] = MFLOAT_C(0.0); + } + if (v0[1] > MFLOAT_C(0.0)) { result[1] = MFLOAT_C(1.0); + } else if (v0[1] < 0) { + result[1] = -MFLOAT_C(1.0); + } else { + result[1] = MFLOAT_C(0.0); + } + if (v0[2] > MFLOAT_C(0.0)) { result[2] = MFLOAT_C(1.0); - result[3] = MFLOAT_C(1.0); - return result; -} - -mfloat_t *vec4_sign(mfloat_t * result, mfloat_t * v0) -{ - if (v0[0] > MFLOAT_C(0.0)) { - result[0] = MFLOAT_C(1.0); - } else if (v0[0] < 0) { - result[0] = -MFLOAT_C(1.0); - } else { - result[0] = MFLOAT_C(0.0); - } - if (v0[1] > MFLOAT_C(0.0)) { - result[1] = MFLOAT_C(1.0); - } else if (v0[1] < 0) { - result[1] = -MFLOAT_C(1.0); - } else { - result[1] = MFLOAT_C(0.0); - } - if (v0[2] > MFLOAT_C(0.0)) { - result[2] = MFLOAT_C(1.0); - } else if (v0[2] < 0) { - result[2] = -MFLOAT_C(1.0); - } else { - result[2] = MFLOAT_C(0.0); - } - if (v0[3] > MFLOAT_C(0.0)) { - result[3] = MFLOAT_C(1.0); - } else if (v0[3] < 0) { - result[3] = -MFLOAT_C(1.0); - } else { - result[3] = MFLOAT_C(0.0); - } - return result; -} - -mfloat_t *vec4_add(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] + v1[0]; - result[1] = v0[1] + v1[1]; - result[2] = v0[2] + v1[2]; - result[3] = v0[3] + v1[3]; - return result; -} - -mfloat_t *vec4_add_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] + f; - result[1] = v0[1] + f; - result[2] = v0[2] + f; - result[3] = v0[3] + f; - return result; -} - -mfloat_t *vec4_subtract(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] - v1[0]; - result[1] = v0[1] - v1[1]; - result[2] = v0[2] - v1[2]; - result[3] = v0[3] - v1[3]; - return result; -} - -mfloat_t *vec4_subtract_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] - f; - result[1] = v0[1] - f; - result[2] = v0[2] - f; - result[3] = v0[3] - f; - return result; -} - -mfloat_t *vec4_multiply(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] * v1[0]; - result[1] = v0[1] * v1[1]; - result[2] = v0[2] * v1[2]; - result[3] = v0[3] * v1[3]; - return result; -} - -mfloat_t *vec4_multiply_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] * f; - result[1] = v0[1] * f; - result[2] = v0[2] * f; - result[3] = v0[3] * f; - return result; -} - -mfloat_t *vec4_multiply_mat4(mfloat_t * result, mfloat_t * v0, - mfloat_t * m0) -{ - mfloat_t x = v0[0]; - mfloat_t y = v0[1]; - mfloat_t z = v0[2]; - mfloat_t w = v0[3]; - result[0] = m0[0] * x + m0[4] * y + m0[8] * z + m0[12] * w; - result[1] = m0[1] * x + m0[5] * y + m0[9] * z + m0[13] * w; - result[2] = m0[2] * x + m0[6] * y + m0[10] * z + m0[14] * w; - result[3] = m0[3] * x + m0[7] * y + m0[11] * z + m0[15] * w; - return result; -} - -mfloat_t *vec4_divide(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = v0[0] / v1[0]; - result[1] = v0[1] / v1[1]; - result[2] = v0[2] / v1[2]; - result[3] = v0[3] / v1[3]; - return result; -} - -mfloat_t *vec4_divide_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = v0[0] / f; - result[1] = v0[1] / f; - result[2] = v0[2] / f; - result[3] = v0[3] / f; - return result; -} - -mfloat_t *vec4_snap(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFLOOR(v0[0] / v1[0]) * v1[0]; - result[1] = MFLOOR(v0[1] / v1[1]) * v1[1]; - result[2] = MFLOOR(v0[2] / v1[2]) * v1[2]; - result[3] = MFLOOR(v0[3] / v1[3]) * v1[3]; - return result; -} - -mfloat_t *vec4_snap_f(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - result[0] = MFLOOR(v0[0] / f) * f; - result[1] = MFLOOR(v0[1] / f) * f; - result[2] = MFLOOR(v0[2] / f) * f; - result[3] = MFLOOR(v0[3] / f) * f; - return result; -} - -mfloat_t *vec4_negative(mfloat_t * result, mfloat_t * v0) -{ - result[0] = -v0[0]; - result[1] = -v0[1]; - result[2] = -v0[2]; - result[3] = -v0[3]; - return result; -} - -mfloat_t *vec4_abs(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MFABS(v0[0]); - result[1] = MFABS(v0[1]); - result[2] = MFABS(v0[2]); - result[3] = MFABS(v0[3]); - return result; -} - -mfloat_t *vec4_floor(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MFLOOR(v0[0]); - result[1] = MFLOOR(v0[1]); - result[2] = MFLOOR(v0[2]); - result[3] = MFLOOR(v0[3]); - return result; -} - -mfloat_t *vec4_ceil(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MCEIL(v0[0]); - result[1] = MCEIL(v0[1]); - result[2] = MCEIL(v0[2]); - result[3] = MCEIL(v0[3]); - return result; -} - -mfloat_t *vec4_round(mfloat_t * result, mfloat_t * v0) -{ - result[0] = MROUND(v0[0]); - result[1] = MROUND(v0[1]); - result[2] = MROUND(v0[2]); - result[3] = MROUND(v0[3]); - return result; -} - -mfloat_t *vec4_max(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFMAX(v0[0], v1[0]); - result[1] = MFMAX(v0[1], v1[1]); - result[2] = MFMAX(v0[2], v1[2]); - result[3] = MFMAX(v0[3], v1[3]); - return result; -} - -mfloat_t *vec4_min(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - result[0] = MFMIN(v0[0], v1[0]); - result[1] = MFMIN(v0[1], v1[1]); - result[2] = MFMIN(v0[2], v1[2]); - result[3] = MFMIN(v0[3], v1[3]); - return result; -} - -mfloat_t *vec4_clamp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2) -{ - vec4_min(result, v0, v1); - vec4_max(result, v0, v2); - return result; -} - -mfloat_t *vec4_normalize(mfloat_t * result, mfloat_t * v0) -{ - mfloat_t l = - MSQRT(v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2] + - v0[3] * v0[3]); - result[0] = v0[0] / l; - result[1] = v0[1] / l; - result[2] = v0[2] / l; - result[3] = v0[3] / l; - return result; -} - -mfloat_t *vec4_lerp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t f) -{ - result[0] = v0[0] + (v1[0] - v0[0]) * f; - result[1] = v0[1] + (v1[1] - v0[1]) * f; - result[2] = v0[2] + (v1[2] - v0[2]) * f; - result[3] = v0[3] + (v1[3] - v0[3]) * f; - return result; -} - -bool quat_is_zero(mfloat_t * q0) -{ - return MFABS(q0[0]) < MFLT_EPSILON && MFABS(q0[1]) < MFLT_EPSILON - && MFABS(q0[2]) < MFLT_EPSILON && MFABS(q0[3]) < MFLT_EPSILON; -} - -bool quat_is_equal(mfloat_t * q0, mfloat_t * q1) -{ - return MFABS(q0[0] - q1[0]) < MFLT_EPSILON - && MFABS(q0[1] - q1[1]) < MFLT_EPSILON - && MFABS(q0[2] - q1[2]) < MFLT_EPSILON - && MFABS(q0[3] - q1[3]) < MFLT_EPSILON; -} - -mfloat_t *quat(mfloat_t * result, mfloat_t x, mfloat_t y, mfloat_t z, - mfloat_t w) -{ - result[0] = x; - result[1] = y; - result[2] = z; - result[3] = w; - return result; -} - -mfloat_t *quat_assign(mfloat_t * result, mfloat_t * q0) -{ - result[0] = q0[0]; - result[1] = q0[1]; - result[2] = q0[2]; - result[3] = q0[3]; - return result; -} - -mfloat_t *quat_zero(mfloat_t * result) -{ - result[0] = MFLOAT_C(0.0); - result[1] = MFLOAT_C(0.0); + } else if (v0[2] < 0) { + result[2] = -MFLOAT_C(1.0); + } else { result[2] = MFLOAT_C(0.0); + } + if (v0[3] > MFLOAT_C(0.0)) { + result[3] = MFLOAT_C(1.0); + } else if (v0[3] < 0) { + result[3] = -MFLOAT_C(1.0); + } else { result[3] = MFLOAT_C(0.0); - return result; + } + return result; } -mfloat_t *quat_null(mfloat_t * result) -{ - result[0] = MFLOAT_C(0.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(1.0); - return result; +mfloat_t *vec4_add(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] + v1[0]; + result[1] = v0[1] + v1[1]; + result[2] = v0[2] + v1[2]; + result[3] = v0[3] + v1[3]; + return result; +} + +mfloat_t *vec4_add_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] + f; + result[1] = v0[1] + f; + result[2] = v0[2] + f; + result[3] = v0[3] + f; + return result; +} + +mfloat_t *vec4_subtract(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] - v1[0]; + result[1] = v0[1] - v1[1]; + result[2] = v0[2] - v1[2]; + result[3] = v0[3] - v1[3]; + return result; +} + +mfloat_t *vec4_subtract_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] - f; + result[1] = v0[1] - f; + result[2] = v0[2] - f; + result[3] = v0[3] - f; + return result; +} + +mfloat_t *vec4_multiply(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] * v1[0]; + result[1] = v0[1] * v1[1]; + result[2] = v0[2] * v1[2]; + result[3] = v0[3] * v1[3]; + return result; +} + +mfloat_t *vec4_multiply_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] * f; + result[1] = v0[1] * f; + result[2] = v0[2] * f; + result[3] = v0[3] * f; + return result; +} + +mfloat_t *vec4_multiply_mat4(mfloat_t *result, mfloat_t *v0, + mfloat_t *m0) { + mfloat_t x = v0[0]; + mfloat_t y = v0[1]; + mfloat_t z = v0[2]; + mfloat_t w = v0[3]; + result[0] = m0[0] * x + m0[4] * y + m0[8] * z + m0[12] * w; + result[1] = m0[1] * x + m0[5] * y + m0[9] * z + m0[13] * w; + result[2] = m0[2] * x + m0[6] * y + m0[10] * z + m0[14] * w; + result[3] = m0[3] * x + m0[7] * y + m0[11] * z + m0[15] * w; + return result; +} + +mfloat_t *vec4_divide(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = v0[0] / v1[0]; + result[1] = v0[1] / v1[1]; + result[2] = v0[2] / v1[2]; + result[3] = v0[3] / v1[3]; + return result; +} + +mfloat_t *vec4_divide_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = v0[0] / f; + result[1] = v0[1] / f; + result[2] = v0[2] / f; + result[3] = v0[3] / f; + return result; +} + +mfloat_t *vec4_snap(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFLOOR(v0[0] / v1[0]) * v1[0]; + result[1] = MFLOOR(v0[1] / v1[1]) * v1[1]; + result[2] = MFLOOR(v0[2] / v1[2]) * v1[2]; + result[3] = MFLOOR(v0[3] / v1[3]) * v1[3]; + return result; +} + +mfloat_t *vec4_snap_f(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + result[0] = MFLOOR(v0[0] / f) * f; + result[1] = MFLOOR(v0[1] / f) * f; + result[2] = MFLOOR(v0[2] / f) * f; + result[3] = MFLOOR(v0[3] / f) * f; + return result; +} + +mfloat_t *vec4_negative(mfloat_t *result, mfloat_t *v0) { + result[0] = -v0[0]; + result[1] = -v0[1]; + result[2] = -v0[2]; + result[3] = -v0[3]; + return result; +} + +mfloat_t *vec4_abs(mfloat_t *result, mfloat_t *v0) { + result[0] = MFABS(v0[0]); + result[1] = MFABS(v0[1]); + result[2] = MFABS(v0[2]); + result[3] = MFABS(v0[3]); + return result; +} + +mfloat_t *vec4_floor(mfloat_t *result, mfloat_t *v0) { + result[0] = MFLOOR(v0[0]); + result[1] = MFLOOR(v0[1]); + result[2] = MFLOOR(v0[2]); + result[3] = MFLOOR(v0[3]); + return result; +} + +mfloat_t *vec4_ceil(mfloat_t *result, mfloat_t *v0) { + result[0] = MCEIL(v0[0]); + result[1] = MCEIL(v0[1]); + result[2] = MCEIL(v0[2]); + result[3] = MCEIL(v0[3]); + return result; +} + +mfloat_t *vec4_round(mfloat_t *result, mfloat_t *v0) { + result[0] = MROUND(v0[0]); + result[1] = MROUND(v0[1]); + result[2] = MROUND(v0[2]); + result[3] = MROUND(v0[3]); + return result; +} + +mfloat_t *vec4_max(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFMAX(v0[0], v1[0]); + result[1] = MFMAX(v0[1], v1[1]); + result[2] = MFMAX(v0[2], v1[2]); + result[3] = MFMAX(v0[3], v1[3]); + return result; +} + +mfloat_t *vec4_min(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + result[0] = MFMIN(v0[0], v1[0]); + result[1] = MFMIN(v0[1], v1[1]); + result[2] = MFMIN(v0[2], v1[2]); + result[3] = MFMIN(v0[3], v1[3]); + return result; +} + +mfloat_t *vec4_clamp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2) { + vec4_min(result, v0, v1); + vec4_max(result, v0, v2); + return result; +} + +mfloat_t *vec4_normalize(mfloat_t *result, mfloat_t *v0) { + mfloat_t l = + MSQRT(v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2] + + v0[3] * v0[3]); + result[0] = v0[0] / l; + result[1] = v0[1] / l; + result[2] = v0[2] / l; + result[3] = v0[3] / l; + return result; +} + +mfloat_t *vec4_lerp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t f) { + result[0] = v0[0] + (v1[0] - v0[0]) * f; + result[1] = v0[1] + (v1[1] - v0[1]) * f; + result[2] = v0[2] + (v1[2] - v0[2]) * f; + result[3] = v0[3] + (v1[3] - v0[3]) * f; + return result; +} + +bool quat_is_zero(mfloat_t *q0) { + return MFABS(q0[0]) < MFLT_EPSILON && MFABS(q0[1]) < MFLT_EPSILON && MFABS(q0[2]) < MFLT_EPSILON && MFABS(q0[3]) < MFLT_EPSILON; +} + +bool quat_is_equal(mfloat_t *q0, mfloat_t *q1) { + return MFABS(q0[0] - q1[0]) < MFLT_EPSILON && MFABS(q0[1] - q1[1]) < MFLT_EPSILON && MFABS(q0[2] - q1[2]) < MFLT_EPSILON && MFABS(q0[3] - q1[3]) < MFLT_EPSILON; +} + +mfloat_t *quat(mfloat_t *result, mfloat_t x, mfloat_t y, mfloat_t z, + mfloat_t w) { + result[0] = x; + result[1] = y; + result[2] = z; + result[3] = w; + return result; +} + +mfloat_t *quat_assign(mfloat_t *result, mfloat_t *q0) { + result[0] = q0[0]; + result[1] = q0[1]; + result[2] = q0[2]; + result[3] = q0[3]; + return result; +} + +mfloat_t *quat_zero(mfloat_t *result) { + result[0] = MFLOAT_C(0.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + return result; +} + +mfloat_t *quat_null(mfloat_t *result) { + result[0] = MFLOAT_C(0.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(1.0); + return result; } /* Grassman product */ -mfloat_t *quat_multiply(mfloat_t * result, const mfloat_t * q0, - const mfloat_t * q1) -{ - result[0] = - q0[3] * q1[0] + q0[0] * q1[3] + q0[1] * q1[2] - q0[2] * q1[1]; - result[1] = - q0[3] * q1[1] + q0[1] * q1[3] + q0[2] * q1[0] - q0[0] * q1[2]; - result[2] = - q0[3] * q1[2] + q0[2] * q1[3] + q0[0] * q1[1] - q0[1] * q1[0]; - result[3] = - q0[3] * q1[3] - q0[0] * q1[0] - q0[1] * q1[1] - q0[2] * q1[2]; - return result; +mfloat_t *quat_multiply(mfloat_t *result, const mfloat_t *q0, + const mfloat_t *q1) { + result[0] = + q0[3] * q1[0] + q0[0] * q1[3] + q0[1] * q1[2] - q0[2] * q1[1]; + result[1] = + q0[3] * q1[1] + q0[1] * q1[3] + q0[2] * q1[0] - q0[0] * q1[2]; + result[2] = + q0[3] * q1[2] + q0[2] * q1[3] + q0[0] * q1[1] - q0[1] * q1[0]; + result[3] = + q0[3] * q1[3] - q0[0] * q1[0] - q0[1] * q1[1] - q0[2] * q1[2]; + return result; } -mfloat_t *quat_mult_dir3(mfloat_t * result, const mfloat_t * q, - const mfloat_t * v) -{ - result[0] = q[3] * v[0] + q[0] + q[1] * v[2] - q[2] * v[1]; - result[1] = q[3] * v[1] + q[1] + q[2] * v[0] - q[0] * v[2]; - result[2] = q[3] * v[2] + q[2] + q[0] * v[1] - q[1] * v[0]; - result[3] = q[3] - q[0] * v[0] - q[1] * v[1] - q[2] * v[2]; - return result; +mfloat_t *quat_mult_dir3(mfloat_t *result, const mfloat_t *q, + const mfloat_t *v) { + result[0] = q[3] * v[0] + q[0] + q[1] * v[2] - q[2] * v[1]; + result[1] = q[3] * v[1] + q[1] + q[2] * v[0] - q[0] * v[2]; + result[2] = q[3] * v[2] + q[2] + q[0] * v[1] - q[1] * v[0]; + result[3] = q[3] - q[0] * v[0] - q[1] * v[1] - q[2] * v[2]; + return result; } -mfloat_t *quat_mult_3d(mfloat_t * result, const mfloat_t * q, - const mfloat_t * p) -{ - result[0] = q[3] * p[0] + q[1] * p[2] - q[2] * p[1]; - result[1] = q[3] * p[1] + q[2] * p[0] - q[0] * p[2]; - result[2] = q[3] * p[2] + q[0] * p[1] - q[1] * p[0]; - result[3] = 0 - q[0] * p[0] - q[1] * p[1] - q[2] * p[2]; - return result; +mfloat_t *quat_mult_3d(mfloat_t *result, const mfloat_t *q, + const mfloat_t *p) { + result[0] = q[3] * p[0] + q[1] * p[2] - q[2] * p[1]; + result[1] = q[3] * p[1] + q[2] * p[0] - q[0] * p[2]; + result[2] = q[3] * p[2] + q[0] * p[1] - q[1] * p[0]; + result[3] = 0 - q[0] * p[0] - q[1] * p[1] - q[2] * p[2]; + return result; } -mfloat_t *quat_multiply_f(mfloat_t * result, mfloat_t * q0, mfloat_t f) -{ - result[0] = q0[0] * f; - result[1] = q0[1] * f; - result[2] = q0[2] * f; - result[3] = q0[3] * f; - return result; +mfloat_t *quat_multiply_f(mfloat_t *result, mfloat_t *q0, mfloat_t f) { + result[0] = q0[0] * f; + result[1] = q0[1] * f; + result[2] = q0[2] * f; + result[3] = q0[3] * f; + return result; } -mfloat_t *quat_divide(mfloat_t * result, mfloat_t * q0, mfloat_t * q1) -{ - mfloat_t x = q0[0]; - mfloat_t y = q0[1]; - mfloat_t z = q0[2]; - mfloat_t w = q0[3]; - mfloat_t ls = - q1[0] * q1[0] + q1[1] * q1[1] + q1[8] * q1[8] + q1[3] * q1[3]; - mfloat_t normalized_x = -q1[0] / ls; - mfloat_t normalized_y = -q1[1] / ls; - mfloat_t normalized_z = -q1[8] / ls; - mfloat_t normalized_w = q1[3] / ls; - result[0] = - x * normalized_w + normalized_x * w + (y * normalized_z - - z * normalized_y); - result[1] = - y * normalized_w + normalized_y * w + (z * normalized_x - - x * normalized_z); - result[2] = - z * normalized_w + normalized_z * w + (x * normalized_y - - y * normalized_x); - result[3] = - w * normalized_w - (x * normalized_x + y * normalized_y + - z * normalized_z); - return result; +mfloat_t *quat_divide(mfloat_t *result, mfloat_t *q0, mfloat_t *q1) { + mfloat_t x = q0[0]; + mfloat_t y = q0[1]; + mfloat_t z = q0[2]; + mfloat_t w = q0[3]; + mfloat_t ls = + q1[0] * q1[0] + q1[1] * q1[1] + q1[8] * q1[8] + q1[3] * q1[3]; + mfloat_t normalized_x = -q1[0] / ls; + mfloat_t normalized_y = -q1[1] / ls; + mfloat_t normalized_z = -q1[8] / ls; + mfloat_t normalized_w = q1[3] / ls; + result[0] = + x * normalized_w + normalized_x * w + (y * normalized_z - z * normalized_y); + result[1] = + y * normalized_w + normalized_y * w + (z * normalized_x - x * normalized_z); + result[2] = + z * normalized_w + normalized_z * w + (x * normalized_y - y * normalized_x); + result[3] = + w * normalized_w - (x * normalized_x + y * normalized_y + + z * normalized_z); + return result; } -mfloat_t *quat_divide_f(mfloat_t * result, mfloat_t * q0, mfloat_t f) -{ - result[0] = q0[0] / f; - result[1] = q0[1] / f; - result[2] = q0[2] / f; - result[3] = q0[3] / f; - return result; +mfloat_t *quat_divide_f(mfloat_t *result, mfloat_t *q0, mfloat_t f) { + result[0] = q0[0] / f; + result[1] = q0[1] / f; + result[2] = q0[2] / f; + result[3] = q0[3] / f; + return result; } -mfloat_t *quat_negative(mfloat_t * result, mfloat_t * q0) -{ - result[0] = -q0[0]; - result[1] = -q0[1]; - result[2] = -q0[2]; - result[3] = -q0[3]; - return result; +mfloat_t *quat_negative(mfloat_t *result, mfloat_t *q0) { + result[0] = -q0[0]; + result[1] = -q0[1]; + result[2] = -q0[2]; + result[3] = -q0[3]; + return result; } -mfloat_t *quat_conjugate(mfloat_t * result, const mfloat_t * q0) -{ - result[0] = -q0[0]; - result[1] = -q0[1]; - result[2] = -q0[2]; +mfloat_t *quat_conjugate(mfloat_t *result, const mfloat_t *q0) { + result[0] = -q0[0]; + result[1] = -q0[1]; + result[2] = -q0[2]; + result[3] = q0[3]; + return result; +} + +mfloat_t *quat_inverse(mfloat_t *result, mfloat_t *q0) { + mfloat_t l = + MFLOAT_C(1.0) / (q0[0] * q0[0] + q0[1] * q0[1] + q0[2] * q0[2] + + q0[3] * q0[3]); + result[0] = -q0[0] * l; + result[1] = -q0[1] * l; + result[2] = -q0[2] * l; + result[3] = q0[3] * l; + return result; +} + +mfloat_t *quat_normalize(mfloat_t *result, mfloat_t *q0) { + mfloat_t l = + MFLOAT_C(1.0) / MSQRT(q0[0] * q0[0] + q0[1] * q0[1] + + q0[2] * q0[2] + q0[3] * q0[3]); + result[0] = q0[0] * l; + result[1] = q0[1] * l; + result[2] = q0[2] * l; + result[3] = q0[3] * l; + return result; +} + +mfloat_t quat_dot(mfloat_t *q0, mfloat_t *q1) { + return q0[0] * q1[0] + q0[1] * q1[1] + q0[2] * q1[2] + q0[3] * q1[3]; +} + +mfloat_t *quat_power(mfloat_t *result, mfloat_t *q0, mfloat_t exponent) { + if (MFABS(q0[3]) < MFLOAT_C(1.0) - MFLT_EPSILON) { + mfloat_t alpha = MACOS(q0[3]); + mfloat_t new_alpha = alpha * exponent; + mfloat_t s = MSIN(new_alpha) / MSIN(alpha); + result[0] = result[0] * s; + result[1] = result[1] * s; + result[2] = result[2] * s; + result[3] = MCOS(new_alpha); + } else { + result[0] = q0[0]; + result[1] = q0[1]; + result[2] = q0[1]; result[3] = q0[3]; - return result; -} - -mfloat_t *quat_inverse(mfloat_t * result, mfloat_t * q0) -{ - mfloat_t l = - MFLOAT_C(1.0) / (q0[0] * q0[0] + q0[1] * q0[1] + q0[2] * q0[2] + - q0[3] * q0[3]); - result[0] = -q0[0] * l; - result[1] = -q0[1] * l; - result[2] = -q0[2] * l; - result[3] = q0[3] * l; - return result; -} - -mfloat_t *quat_normalize(mfloat_t * result, mfloat_t * q0) -{ - mfloat_t l = - MFLOAT_C(1.0) / MSQRT(q0[0] * q0[0] + q0[1] * q0[1] + - q0[2] * q0[2] + q0[3] * q0[3]); - result[0] = q0[0] * l; - result[1] = q0[1] * l; - result[2] = q0[2] * l; - result[3] = q0[3] * l; - return result; -} - -mfloat_t quat_dot(mfloat_t * q0, mfloat_t * q1) -{ - return q0[0] * q1[0] + q0[1] * q1[1] + q0[2] * q1[2] + q0[3] * q1[3]; -} - -mfloat_t *quat_power(mfloat_t * result, mfloat_t * q0, mfloat_t exponent) -{ - if (MFABS(q0[3]) < MFLOAT_C(1.0) - MFLT_EPSILON) { - mfloat_t alpha = MACOS(q0[3]); - mfloat_t new_alpha = alpha * exponent; - mfloat_t s = MSIN(new_alpha) / MSIN(alpha); - result[0] = result[0] * s; - result[1] = result[1] * s; - result[2] = result[2] * s; - result[3] = MCOS(new_alpha); - } else { - result[0] = q0[0]; - result[1] = q0[1]; - result[2] = q0[1]; - result[3] = q0[3]; - } - return result; -} - -mfloat_t *quat_from_axis_angle(mfloat_t * result, const mfloat_t * v0, - const mfloat_t angle) -{ - mfloat_t half = angle * MFLOAT_C(0.5); - mfloat_t s = MSIN(half); - result[0] = v0[0] * s; - result[1] = v0[1] * s; - result[2] = v0[2] * s; - result[3] = MCOS(half); - return result; -} - -mfloat_t *quat_from_vec3(mfloat_t * result, mfloat_t * v0, mfloat_t * v1) -{ - mfloat_t cross[VEC3_SIZE]; - mfloat_t d = vec3_dot(v0, v1); - mfloat_t a_ls = vec3_length_squared(v0); - mfloat_t b_ls = vec3_length_squared(v0); - vec3_cross(cross, v0, v1); - quat(result, cross[0], cross[1], cross[1], d + MSQRT(a_ls * b_ls)); - quat_normalize(result, result); - return result; -} - -mfloat_t *quat_from_euler(mfloat_t * q, const mfloat_t * euler) -{ - mfloat_t qx[4], qy[4], qz[4]; - quat_from_axis_angle(qx, RIGHT, euler[0]); - quat_from_axis_angle(qy, UP, euler[1]); - quat_from_axis_angle(qz, FORWARD, euler[2]); - return quat_multiply(q, qx, quat_multiply(q, qy, qz)); -} - -mfloat_t *quat_from_mat4(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t scale = m0[0] + m0[5] + m0[10]; - if (scale > MFLOAT_C(0.0)) { - mfloat_t sr = MSQRT(scale + MFLOAT_C(1.0)); - result[3] = sr * MFLOAT_C(0.5); - sr = MFLOAT_C(0.5) / sr; - result[0] = (m0[9] - m0[6]) * sr; - result[1] = (m0[2] - m0[8]) * sr; - result[2] = (m0[4] - m0[1]) * sr; - } else if ((m0[0] >= m0[5]) && (m0[0] >= m0[10])) { - mfloat_t sr = MSQRT(MFLOAT_C(1.0) + m0[0] - m0[5] - m0[10]); - mfloat_t half = MFLOAT_C(0.5) / sr; - result[0] = MFLOAT_C(0.5) * sr; - result[1] = (m0[4] + m0[1]) * half; - result[2] = (m0[8] + m0[2]) * half; - result[3] = (m0[9] - m0[6]) * half; - } else if (m0[5] > m0[10]) { - mfloat_t sr = MSQRT(MFLOAT_C(1.0) + m0[5] - m0[0] - m0[10]); - mfloat_t half = MFLOAT_C(0.5) / sr; - result[0] = (m0[1] + m0[4]) * half; - result[1] = MFLOAT_C(0.5) * sr; - result[2] = (m0[6] + m0[9]) * half; - result[3] = (m0[2] - m0[8]) * half; - } else { - mfloat_t sr = MSQRT(MFLOAT_C(1.0) + m0[10] - m0[0] - m0[5]); - mfloat_t half = MFLOAT_C(0.5) / sr; - result[0] = (m0[2] + m0[8]) * half; - result[1] = (m0[6] + m0[9]) * half; - result[2] = MFLOAT_C(0.5) * sr; - result[3] = (m0[4] - m0[1]) * half; - } - return result; -} - -mfloat_t *quat_lerp(mfloat_t * result, mfloat_t * q0, mfloat_t * q1, - mfloat_t f) -{ - result[0] = q0[0] + (q1[0] - q0[0]) * f; - result[1] = q0[1] + (q1[1] - q0[1]) * f; - result[2] = q0[2] + (q1[2] - q0[2]) * f; - result[3] = q0[3] + (q1[3] - q0[3]) * f; - return result; -} - -mfloat_t *quat_slerp(mfloat_t * result, mfloat_t * q0, mfloat_t * q1, - mfloat_t f) -{ - mfloat_t tmp1[QUAT_SIZE]; - mfloat_t d = quat_dot(q0, q1); - mfloat_t f0; - mfloat_t f1; - quat_assign(tmp1, q1); - if (d < MFLOAT_C(0.0)) { - quat_negative(tmp1, tmp1); - d = -d; - } - if (d > MFLOAT_C(0.9995)) { - f0 = MFLOAT_C(1.0) - f; - f1 = f; - } else { - mfloat_t theta = MACOS(d); - mfloat_t sin_theta = MSIN(theta); - f0 = MSIN((MFLOAT_C(1.0) - f) * theta) / sin_theta; - f1 = MSIN(f * theta) / sin_theta; - } - result[0] = q0[0] * f0 + tmp1[0] * f1; - result[1] = q0[1] * f0 + tmp1[1] * f1; - result[2] = q0[2] * f0 + tmp1[2] * f1; - result[3] = q0[3] * f0 + tmp1[3] * f1; - return result; -} - -mfloat_t quat_length(mfloat_t * q0) -{ - return MSQRT(q0[0] * q0[0] + q0[1] * q0[1] + q0[2] * q0[2] + - q0[3] * q0[3]); -} - -mfloat_t quat_length_squared(mfloat_t * q0) -{ - return q0[0] * q0[0] + q0[1] * q0[1] + q0[2] * q0[2] + q0[3] * q0[3]; -} - -mfloat_t quat_angle(mfloat_t * q0, mfloat_t * q1) -{ - mfloat_t s = MSQRT(quat_length_squared(q0) * quat_length_squared(q1)); - s = MFLOAT_C(1.0) / s; - return MACOS(quat_dot(q0, q1) * s); -} - -mfloat_t *mat2(mfloat_t * result, mfloat_t m11, mfloat_t m12, mfloat_t m21, - mfloat_t m22) -{ - result[0] = m11; - result[1] = m21; - result[2] = m12; - result[3] = m22; - return result; -} - -mfloat_t *mat2_zero(mfloat_t * result) -{ - result[0] = MFLOAT_C(0.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - return result; -} - -mfloat_t *mat2_identity(mfloat_t * result) -{ - result[0] = MFLOAT_C(1.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(1.0); - return result; -} - -mfloat_t mat2_determinant(mfloat_t * m0) -{ - return m0[0] * m0[3] - m0[2] * m0[1]; -} - -mfloat_t *mat2_assign(mfloat_t * result, mfloat_t * m0) -{ - result[0] = m0[0]; - result[1] = m0[1]; - result[2] = m0[2]; - result[3] = m0[3]; - return result; -} - -mfloat_t *mat2_negative(mfloat_t * result, mfloat_t * m0) -{ - result[0] = -m0[0]; - result[1] = -m0[1]; - result[2] = -m0[2]; - result[3] = -m0[3]; - return result; -} - -mfloat_t *mat2_transpose(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t transposed[MAT2_SIZE]; - transposed[0] = m0[0]; - transposed[1] = m0[2]; - transposed[2] = m0[1]; - transposed[3] = m0[3]; - result[0] = transposed[0]; - result[1] = transposed[1]; - result[2] = transposed[2]; - result[3] = transposed[3]; - return result; -} - -mfloat_t *mat2_cofactor(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t cofactor[MAT2_SIZE]; - cofactor[0] = m0[3]; - cofactor[1] = -m0[2]; - cofactor[2] = -m0[1]; - cofactor[3] = m0[0]; - result[0] = cofactor[0]; - result[1] = cofactor[1]; - result[2] = cofactor[2]; - result[3] = cofactor[3]; - return result; -} - -mfloat_t *mat2_adjugate(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t adjugate[MAT2_SIZE]; - adjugate[0] = m0[3]; - adjugate[1] = -m0[1]; - adjugate[2] = -m0[2]; - adjugate[3] = m0[0]; - result[0] = adjugate[0]; - result[1] = adjugate[1]; - result[2] = adjugate[2]; - result[3] = adjugate[3]; - return result; -} - -mfloat_t *mat2_multiply(mfloat_t * result, mfloat_t * m0, mfloat_t * m1) -{ - mfloat_t multiplied[MAT3_SIZE]; - multiplied[0] = m0[0] * m1[0] + m0[2] * m1[1]; - multiplied[1] = m0[1] * m1[0] + m0[3] * m1[1]; - multiplied[2] = m0[0] * m1[2] + m0[2] * m1[3]; - multiplied[3] = m0[1] * m1[2] + m0[3] * m1[3]; - result[0] = multiplied[0]; - result[1] = multiplied[1]; - result[2] = multiplied[2]; - result[3] = multiplied[3]; - return result; -} - -mfloat_t *mat2_multiply_f(mfloat_t * result, mfloat_t * m0, mfloat_t f) -{ - result[0] = m0[0] * f; - result[1] = m0[1] * f; - result[2] = m0[2] * f; - result[3] = m0[3] * f; - return result; -} - -mfloat_t *mat2_inverse(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t inverse[MAT2_SIZE]; - mfloat_t det = mat2_determinant(m0); - mat2_cofactor(inverse, m0); - mat2_multiply_f(inverse, inverse, MFLOAT_C(1.0) / det); - result[0] = inverse[0]; - result[1] = inverse[1]; - result[2] = inverse[2]; - result[3] = inverse[3]; - return result; -} - -mfloat_t *mat2_scaling(mfloat_t * result, mfloat_t * v0) -{ - result[0] = v0[0]; - result[3] = v0[1]; - return result; -} - -mfloat_t *mat2_scale(mfloat_t * result, mfloat_t * m0, mfloat_t * v0) -{ - result[0] = m0[0] * v0[0]; - result[3] = m0[3] * v0[1]; - return result; -} - -mfloat_t *mat2_rotation_z(mfloat_t * result, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - result[0] = c; - result[1] = s; - result[2] = -s; - result[3] = c; - return result; -} - -mfloat_t *mat2_lerp(mfloat_t * result, mfloat_t * m0, mfloat_t * m1, - mfloat_t f) -{ - result[0] = m0[0] + (m1[0] - m0[0]) * f; - result[1] = m0[1] + (m1[1] - m0[1]) * f; - result[2] = m0[2] + (m1[2] - m0[2]) * f; - result[3] = m0[3] + (m1[3] - m0[3]) * f; - return result; -} - -mfloat_t *mat3(mfloat_t * result, mfloat_t m11, mfloat_t m12, mfloat_t m13, - mfloat_t m21, mfloat_t m22, mfloat_t m23, mfloat_t m31, - mfloat_t m32, mfloat_t m33) -{ - result[0] = m11; - result[1] = m21; - result[2] = m31; - result[3] = m12; - result[4] = m22; - result[5] = m32; - result[6] = m13; - result[7] = m23; - result[8] = m33; - return result; -} - -mfloat_t *mat3_zero(mfloat_t * result) -{ - result[0] = MFLOAT_C(0.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(0.0); - result[5] = MFLOAT_C(0.0); - result[6] = MFLOAT_C(0.0); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(0.0); - return result; -} - -mfloat_t *mat3_identity(mfloat_t * result) -{ - result[0] = MFLOAT_C(1.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(1.0); - result[5] = MFLOAT_C(0.0); - result[6] = MFLOAT_C(0.0); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(1.0); - return result; -} - -mfloat_t mat3_determinant(mfloat_t * m0) -{ - mfloat_t m11 = m0[0]; - mfloat_t m21 = m0[1]; - mfloat_t m31 = m0[2]; - mfloat_t m12 = m0[3]; - mfloat_t m22 = m0[4]; - mfloat_t m32 = m0[5]; - mfloat_t m13 = m0[6]; - mfloat_t m23 = m0[7]; - mfloat_t m33 = m0[8]; - mfloat_t determinant = m11 * m22 * m33 - + m12 * m23 * m31 - + m13 * m21 * m32 - - m11 * m23 * m32 - m12 * m21 * m33 - m13 * m22 * m31; - return determinant; -} - -mfloat_t *mat3_assign(mfloat_t * result, mfloat_t * m0) -{ - result[0] = m0[0]; - result[1] = m0[1]; - result[2] = m0[2]; - result[3] = m0[3]; - result[4] = m0[4]; - result[5] = m0[5]; - result[6] = m0[6]; - result[7] = m0[7]; - result[8] = m0[8]; - return result; -} - -mfloat_t *mat3_negative(mfloat_t * result, mfloat_t * m0) -{ - result[0] = -m0[0]; - result[1] = -m0[1]; - result[2] = -m0[2]; - result[3] = -m0[3]; - result[4] = -m0[4]; - result[5] = -m0[5]; - result[6] = -m0[6]; - result[7] = -m0[7]; - result[8] = -m0[8]; - return result; -} - -mfloat_t *mat3_transpose(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t transposed[MAT4_SIZE]; - transposed[0] = m0[0]; - transposed[1] = m0[3]; - transposed[2] = m0[6]; - transposed[3] = m0[1]; - transposed[4] = m0[4]; - transposed[5] = m0[7]; - transposed[6] = m0[2]; - transposed[7] = m0[5]; - transposed[8] = m0[8]; - result[0] = transposed[0]; - result[1] = transposed[1]; - result[2] = transposed[2]; - result[3] = transposed[3]; - result[4] = transposed[4]; - result[5] = transposed[5]; - result[6] = transposed[6]; - result[7] = transposed[7]; - result[8] = transposed[8]; - return result; -} - -mfloat_t *mat3_cofactor(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t cofactor[MAT3_SIZE]; - mfloat_t minor[MAT2_SIZE]; - minor[0] = m0[4]; - minor[1] = m0[5]; - minor[2] = m0[7]; - minor[3] = m0[8]; - cofactor[0] = mat2_determinant(minor); - minor[0] = m0[3]; - minor[1] = m0[5]; - minor[2] = m0[6]; - minor[3] = m0[8]; - cofactor[1] = -mat2_determinant(minor); - minor[0] = m0[3]; - minor[1] = m0[4]; - minor[2] = m0[6]; - minor[3] = m0[7]; - cofactor[2] = mat2_determinant(minor); - minor[0] = m0[1]; - minor[1] = m0[2]; - minor[2] = m0[7]; - minor[3] = m0[8]; - cofactor[3] = -mat2_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[2]; - minor[2] = m0[6]; - minor[3] = m0[8]; - cofactor[4] = mat2_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[1]; - minor[2] = m0[6]; - minor[3] = m0[7]; - cofactor[5] = -mat2_determinant(minor); - minor[0] = m0[1]; - minor[1] = m0[2]; - minor[2] = m0[4]; - minor[3] = m0[5]; - cofactor[6] = mat2_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[2]; - minor[2] = m0[3]; - minor[3] = m0[5]; - cofactor[7] = -mat2_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[1]; - minor[2] = m0[3]; - minor[3] = m0[4]; - cofactor[8] = mat2_determinant(minor); - result[0] = cofactor[0]; - result[1] = cofactor[1]; - result[2] = cofactor[2]; - result[3] = cofactor[3]; - result[4] = cofactor[4]; - result[5] = cofactor[5]; - result[6] = cofactor[6]; - result[7] = cofactor[7]; - result[8] = cofactor[8]; - return result; -} - -mfloat_t *mat3_multiply(mfloat_t * result, mfloat_t * m0, mfloat_t * m1) -{ - mfloat_t multiplied[MAT3_SIZE]; - multiplied[0] = m0[0] * m1[0] + m0[3] * m1[1] + m0[6] * m1[2]; - multiplied[1] = m0[1] * m1[0] + m0[4] * m1[1] + m0[7] * m1[2]; - multiplied[2] = m0[2] * m1[0] + m0[5] * m1[1] + m0[8] * m1[2]; - multiplied[3] = m0[0] * m1[3] + m0[3] * m1[4] + m0[6] * m1[5]; - multiplied[4] = m0[1] * m1[3] + m0[4] * m1[4] + m0[7] * m1[5]; - multiplied[5] = m0[2] * m1[3] + m0[5] * m1[4] + m0[8] * m1[5]; - multiplied[6] = m0[0] * m1[6] + m0[3] * m1[7] + m0[6] * m1[8]; - multiplied[7] = m0[1] * m1[6] + m0[4] * m1[7] + m0[7] * m1[8]; - multiplied[8] = m0[2] * m1[6] + m0[5] * m1[7] + m0[8] * m1[8]; - result[0] = multiplied[0]; - result[1] = multiplied[1]; - result[2] = multiplied[2]; - result[3] = multiplied[3]; - result[4] = multiplied[4]; - result[5] = multiplied[5]; - result[6] = multiplied[6]; - result[7] = multiplied[7]; - result[8] = multiplied[8]; - return result; -} - -mfloat_t *mat3_multiply_f(mfloat_t * result, mfloat_t * m0, mfloat_t f) -{ - result[0] = m0[0] * f; - result[1] = m0[1] * f; - result[2] = m0[2] * f; - result[3] = m0[3] * f; - result[4] = m0[4] * f; - result[5] = m0[5] * f; - result[6] = m0[6] * f; - result[7] = m0[7] * f; - result[8] = m0[8] * f; - return result; -} - -mfloat_t *mat3_inverse(mfloat_t * result, mfloat_t * m0) -{ - result = m0; - return result; -} - -mfloat_t *mat3_scaling(mfloat_t * result, mfloat_t * v0) -{ - result[0] = v0[0]; - result[4] = v0[1]; - result[8] = v0[2]; - return result; -} - -mfloat_t *mat3_scale(mfloat_t * result, mfloat_t * m0, mfloat_t * v0) -{ - result[0] = m0[0] * v0[0]; - result[4] = m0[4] * v0[1]; - result[8] = m0[8] * v0[2]; - return result; -} - -mfloat_t *mat3_rotation_x(mfloat_t * result, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - result[4] = c; - result[5] = s; - result[7] = -s; - result[8] = c; - return result; -} - -mfloat_t *mat3_rotation_y(mfloat_t * result, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - result[0] = c; - result[2] = -s; - result[6] = s; - result[8] = c; - return result; -} - -mfloat_t *mat3_rotation_z(mfloat_t * result, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - result[0] = c; - result[1] = s; - result[3] = -s; - result[4] = c; - return result; -} - -mfloat_t *mat3_rotation_axis(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - mfloat_t one_c = MFLOAT_C(1.0) - c; - mfloat_t x = v0[0]; - mfloat_t y = v0[4]; - mfloat_t z = v0[8]; - mfloat_t xx = x * x; - mfloat_t xy = x * y; - mfloat_t xz = x * z; - mfloat_t yy = y * y; - mfloat_t yz = y * z; - mfloat_t zz = z * z; - mfloat_t l = xx + yy + zz; - mfloat_t sqrt_l = MSQRT(l); - result[0] = (xx + (yy + zz) * c) / l; - result[1] = (xy * one_c + v0[2] * sqrt_l * s) / l; - result[2] = (xz * one_c - v0[1] * sqrt_l * s) / l; - result[3] = (xy * one_c - v0[2] * sqrt_l * s) / l; - result[4] = (yy + (xx + zz) * c) / l; - result[5] = (yz * one_c + v0[0] * sqrt_l * s) / l; - result[6] = (xz * one_c + v0[1] * sqrt_l * s) / l; - result[7] = (yz * one_c - v0[0] * sqrt_l * s) / l; - result[8] = (zz + (xx + yy) * c) / l; - return result; -} - -mfloat_t *mat3_rotation_quat(mfloat_t * result, mfloat_t * q0) -{ - mfloat_t xx = q0[0] * q0[0]; - mfloat_t yy = q0[1] * q0[1]; - mfloat_t zz = q0[2] * q0[2]; - mfloat_t xy = q0[0] * q0[1]; - mfloat_t zw = q0[2] * q0[3]; - mfloat_t xz = q0[8] * q0[0]; - mfloat_t yw = q0[1] * q0[3]; - mfloat_t yz = q0[1] * q0[2]; - mfloat_t xw = q0[0] * q0[3]; - result[0] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (yy - zz); - result[1] = MFLOAT_C(2.0) * (xy + zw); - result[2] = MFLOAT_C(2.0) * (xz - yw); - result[3] = MFLOAT_C(2.0) * (xy - zw); - result[4] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (xx - zz); - result[5] = MFLOAT_C(2.0) * (yz + xw); - result[6] = MFLOAT_C(2.0) * (xz + yw); - result[7] = MFLOAT_C(2.0) * (yz - xw); - result[8] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (xx - yy); - return result; -} - -mfloat_t *mat3_lerp(mfloat_t * result, mfloat_t * m0, mfloat_t * m1, - mfloat_t f) -{ - result[0] = m0[0] + (m1[0] - m0[0]) * f; - result[1] = m0[1] + (m1[1] - m0[1]) * f; - result[2] = m0[2] + (m1[2] - m0[2]) * f; - result[3] = m0[3] + (m1[3] - m0[3]) * f; - result[4] = m0[4] + (m1[4] - m0[4]) * f; - result[5] = m0[5] + (m1[5] - m0[5]) * f; - result[6] = m0[6] + (m1[6] - m0[6]) * f; - result[7] = m0[7] + (m1[7] - m0[7]) * f; - result[8] = m0[8] + (m1[8] - m0[8]) * f; - return result; -} - -mfloat_t *mat4(mfloat_t * result, mfloat_t m11, mfloat_t m12, mfloat_t m13, - mfloat_t m14, mfloat_t m21, mfloat_t m22, mfloat_t m23, - mfloat_t m24, mfloat_t m31, mfloat_t m32, mfloat_t m33, - mfloat_t m34, mfloat_t m41, mfloat_t m42, mfloat_t m43, - mfloat_t m44) -{ - result[0] = m11; - result[1] = m21; - result[2] = m31; - result[3] = m41; - result[4] = m12; - result[5] = m22; - result[6] = m32; - result[7] = m42; - result[8] = m13; - result[9] = m23; - result[10] = m33; - result[11] = m43; - result[12] = m14; - result[13] = m24; - result[14] = m34; - result[15] = m44; - return result; -} - -mfloat_t *mat4_zero(mfloat_t * result) -{ - result[0] = MFLOAT_C(0.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(0.0); - result[5] = MFLOAT_C(0.0); - result[6] = MFLOAT_C(0.0); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(0.0); - result[9] = MFLOAT_C(0.0); - result[10] = MFLOAT_C(0.0); - result[11] = MFLOAT_C(0.0); - result[12] = MFLOAT_C(0.0); - result[13] = MFLOAT_C(0.0); - result[14] = MFLOAT_C(0.0); - result[15] = MFLOAT_C(0.0); - return result; -} - -mfloat_t *mat4_identity(mfloat_t * result) -{ - result[0] = MFLOAT_C(1.0); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(0.0); - result[5] = MFLOAT_C(1.0); - result[6] = MFLOAT_C(0.0); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(0.0); - result[9] = MFLOAT_C(0.0); - result[10] = MFLOAT_C(1.0); - result[11] = MFLOAT_C(0.0); - result[12] = MFLOAT_C(0.0); - result[13] = MFLOAT_C(0.0); - result[14] = MFLOAT_C(0.0); - result[15] = MFLOAT_C(1.0); - return result; -} - -mfloat_t mat4_determinant(mfloat_t * m0) -{ - mfloat_t m11 = m0[0]; - mfloat_t m21 = m0[1]; - mfloat_t m31 = m0[2]; - mfloat_t m41 = m0[3]; - mfloat_t m12 = m0[4]; - mfloat_t m22 = m0[5]; - mfloat_t m32 = m0[6]; - mfloat_t m42 = m0[7]; - mfloat_t m13 = m0[8]; - mfloat_t m23 = m0[9]; - mfloat_t m33 = m0[10]; - mfloat_t m43 = m0[11]; - mfloat_t m14 = m0[12]; - mfloat_t m24 = m0[13]; - mfloat_t m34 = m0[14]; - mfloat_t m44 = m0[15]; - mfloat_t determinant = m14 * m23 * m32 * m41 - m13 * m24 * m32 * m41 - - m14 * m22 * m33 * m41 + m12 * m24 * m33 * m41 - + m13 * m22 * m34 * m41 - m12 * m23 * m34 * m41 - - m14 * m23 * m31 * m42 + m13 * m24 * m31 * m42 - + m14 * m21 * m33 * m42 - m11 * m24 * m33 * m42 - - m13 * m21 * m34 * m42 + m11 * m23 * m34 * m42 - + m14 * m22 * m31 * m43 - m12 * m24 * m31 * m43 - - m14 * m21 * m32 * m43 + m11 * m24 * m32 * m43 - + m12 * m21 * m34 * m43 - m11 * m22 * m34 * m43 - - m13 * m22 * m31 * m44 + m12 * m23 * m31 * m44 - + m13 * m21 * m32 * m44 - m11 * m23 * m32 * m44 - - m12 * m21 * m33 * m44 + m11 * m22 * m33 * m44; - return determinant; -} - -mfloat_t *mat4_assign(mfloat_t * result, mfloat_t * m0) -{ - result[0] = m0[0]; - result[1] = m0[1]; - result[2] = m0[2]; - result[3] = m0[3]; - result[4] = m0[4]; - result[5] = m0[5]; - result[6] = m0[6]; - result[7] = m0[7]; - result[8] = m0[8]; - result[9] = m0[9]; - result[10] = m0[10]; - result[11] = m0[11]; - result[12] = m0[12]; - result[13] = m0[13]; - result[14] = m0[14]; - result[15] = m0[15]; - return result; -} - -mfloat_t *mat4_negative(mfloat_t * result, mfloat_t * m0) -{ - result[0] = -m0[0]; - result[1] = -m0[1]; - result[2] = -m0[2]; - result[3] = -m0[3]; - result[4] = -m0[4]; - result[5] = -m0[5]; - result[6] = -m0[6]; - result[7] = -m0[7]; - result[8] = -m0[8]; - result[9] = -m0[9]; - result[10] = -m0[10]; - result[11] = -m0[11]; - result[12] = -m0[12]; - result[13] = -m0[13]; - result[14] = -m0[14]; - result[15] = -m0[15]; - return result; -} - -mfloat_t *mat4_transpose(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t transposed[MAT4_SIZE]; - transposed[0] = m0[0]; - transposed[1] = m0[4]; - transposed[2] = m0[8]; - transposed[3] = m0[12]; - transposed[4] = m0[1]; - transposed[5] = m0[5]; - transposed[6] = m0[9]; - transposed[7] = m0[13]; - transposed[8] = m0[2]; - transposed[9] = m0[6]; - transposed[10] = m0[10]; - transposed[11] = m0[14]; - transposed[12] = m0[3]; - transposed[13] = m0[7]; - transposed[14] = m0[11]; - transposed[15] = m0[15]; - result[0] = transposed[0]; - result[1] = transposed[1]; - result[2] = transposed[2]; - result[3] = transposed[3]; - result[4] = transposed[4]; - result[5] = transposed[5]; - result[6] = transposed[6]; - result[7] = transposed[7]; - result[8] = transposed[8]; - result[9] = transposed[9]; - result[10] = transposed[10]; - result[11] = transposed[11]; - result[12] = transposed[12]; - result[13] = transposed[13]; - result[14] = transposed[14]; - result[15] = transposed[15]; - return result; -} - -mfloat_t *mat4_cofactor(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t cofactor[MAT4_SIZE]; - mfloat_t minor[MAT3_SIZE]; - minor[0] = m0[5]; - minor[1] = m0[6]; - minor[2] = m0[7]; - minor[3] = m0[9]; - minor[4] = m0[10]; - minor[5] = m0[11]; - minor[6] = m0[13]; - minor[7] = m0[14]; - minor[8] = m0[15]; - cofactor[0] = mat3_determinant(minor); - minor[0] = m0[4]; - minor[1] = m0[6]; - minor[2] = m0[7]; - minor[3] = m0[8]; - minor[4] = m0[10]; - minor[5] = m0[11]; - minor[6] = m0[12]; - minor[7] = m0[14]; - minor[8] = m0[15]; - cofactor[1] = -mat3_determinant(minor); - minor[0] = m0[4]; - minor[1] = m0[5]; - minor[2] = m0[7]; - minor[3] = m0[8]; - minor[4] = m0[9]; - minor[5] = m0[11]; - minor[6] = m0[12]; - minor[7] = m0[13]; - minor[8] = m0[15]; - cofactor[2] = mat3_determinant(minor); - minor[0] = m0[4]; - minor[1] = m0[5]; - minor[2] = m0[6]; - minor[3] = m0[8]; - minor[4] = m0[9]; - minor[5] = m0[10]; - minor[6] = m0[12]; - minor[7] = m0[13]; - minor[8] = m0[14]; - cofactor[3] = -mat3_determinant(minor); - minor[0] = m0[1]; - minor[1] = m0[2]; - minor[2] = m0[3]; - minor[3] = m0[9]; - minor[4] = m0[10]; - minor[5] = m0[11]; - minor[6] = m0[13]; - minor[7] = m0[14]; - minor[8] = m0[15]; - cofactor[4] = -mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[2]; - minor[2] = m0[3]; - minor[3] = m0[8]; - minor[4] = m0[10]; - minor[5] = m0[11]; - minor[6] = m0[12]; - minor[7] = m0[14]; - minor[8] = m0[15]; - cofactor[5] = mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[1]; - minor[2] = m0[3]; - minor[3] = m0[8]; - minor[4] = m0[9]; - minor[5] = m0[11]; - minor[6] = m0[12]; - minor[7] = m0[13]; - minor[8] = m0[15]; - cofactor[6] = -mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[1]; - minor[2] = m0[2]; - minor[3] = m0[8]; - minor[4] = m0[9]; - minor[5] = m0[10]; - minor[6] = m0[12]; - minor[7] = m0[13]; - minor[8] = m0[14]; - cofactor[7] = mat3_determinant(minor); - minor[0] = m0[1]; - minor[1] = m0[2]; - minor[2] = m0[3]; - minor[3] = m0[5]; - minor[4] = m0[6]; - minor[5] = m0[7]; - minor[6] = m0[13]; - minor[7] = m0[14]; - minor[8] = m0[15]; - cofactor[8] = mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[2]; - minor[2] = m0[3]; - minor[3] = m0[4]; - minor[4] = m0[6]; - minor[5] = m0[7]; - minor[6] = m0[12]; - minor[7] = m0[14]; - minor[8] = m0[15]; - cofactor[9] = -mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[1]; - minor[2] = m0[3]; - minor[3] = m0[4]; - minor[4] = m0[5]; - minor[5] = m0[7]; - minor[6] = m0[12]; - minor[7] = m0[13]; - minor[8] = m0[15]; - cofactor[10] = mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[1]; - minor[2] = m0[2]; - minor[3] = m0[4]; - minor[4] = m0[5]; - minor[5] = m0[6]; - minor[6] = m0[12]; - minor[7] = m0[13]; - minor[8] = m0[14]; - cofactor[11] = -mat3_determinant(minor); - minor[0] = m0[1]; - minor[1] = m0[2]; - minor[2] = m0[3]; - minor[3] = m0[5]; - minor[4] = m0[6]; - minor[5] = m0[7]; - minor[6] = m0[9]; - minor[7] = m0[10]; - minor[8] = m0[11]; - cofactor[12] = -mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[2]; - minor[2] = m0[3]; - minor[3] = m0[4]; - minor[4] = m0[6]; - minor[5] = m0[7]; - minor[6] = m0[8]; - minor[7] = m0[10]; - minor[8] = m0[11]; - cofactor[13] = mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[1]; - minor[2] = m0[3]; - minor[3] = m0[4]; - minor[4] = m0[5]; - minor[5] = m0[7]; - minor[6] = m0[8]; - minor[7] = m0[9]; - minor[8] = m0[11]; - cofactor[14] = -mat3_determinant(minor); - minor[0] = m0[0]; - minor[1] = m0[1]; - minor[2] = m0[2]; - minor[3] = m0[4]; - minor[4] = m0[5]; - minor[5] = m0[6]; - minor[6] = m0[8]; - minor[7] = m0[9]; - minor[8] = m0[10]; - cofactor[15] = mat3_determinant(minor); - result[0] = cofactor[0]; - result[1] = cofactor[1]; - result[2] = cofactor[2]; - result[3] = cofactor[3]; - result[4] = cofactor[4]; - result[5] = cofactor[5]; - result[6] = cofactor[6]; - result[7] = cofactor[7]; - result[8] = cofactor[8]; - result[9] = cofactor[9]; - result[10] = cofactor[10]; - result[11] = cofactor[11]; - result[12] = cofactor[12]; - result[13] = cofactor[13]; - result[14] = cofactor[14]; - result[15] = cofactor[15]; - return result; -} - -mfloat_t *mat4_rotation_x(mfloat_t * result, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - result[5] = c; - result[6] = s; - result[9] = -s; - result[10] = c; - return result; -} - -mfloat_t *mat4_rotation_y(mfloat_t * result, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - result[0] = c; - result[2] = -s; - result[8] = s; - result[10] = c; - return result; -} - -mfloat_t *mat4_rotation_z(mfloat_t * result, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - result[0] = c; - result[1] = s; - result[4] = -s; - result[5] = c; - return result; -} - -mfloat_t *mat4_rotation_axis(mfloat_t * result, mfloat_t * v0, mfloat_t f) -{ - mfloat_t c = MCOS(f); - mfloat_t s = MSIN(f); - mfloat_t one_c = MFLOAT_C(1.0) - c; - mfloat_t x = v0[0]; - mfloat_t y = v0[1]; - mfloat_t z = v0[2]; - mfloat_t xx = x * x; - mfloat_t xy = x * y; - mfloat_t xz = x * z; - mfloat_t yy = y * y; - mfloat_t yz = y * z; - mfloat_t zz = z * z; - mfloat_t l = xx + yy + zz; - mfloat_t sqrt_l = MSQRT(l); - result[0] = (xx + (yy + zz) * c) / l; - result[1] = (xy * one_c + v0[2] * sqrt_l * s) / l; - result[2] = (xz * one_c - v0[1] * sqrt_l * s) / l; - result[3] = MFLOAT_C(0.0); - result[4] = (xy * one_c - v0[2] * sqrt_l * s) / l; - result[5] = (yy + (xx + zz) * c) / l; - result[6] = (yz * one_c + v0[0] * sqrt_l * s) / l; - result[7] = MFLOAT_C(0.0); - result[8] = (xz * one_c + v0[1] * sqrt_l * s) / l; - result[9] = (yz * one_c - v0[0] * sqrt_l * s) / l; - result[10] = (zz + (xx + yy) * c) / l; - result[11] = MFLOAT_C(0.0); - result[12] = MFLOAT_C(0.0); - result[13] = MFLOAT_C(0.0); - result[14] = MFLOAT_C(0.0); - result[15] = MFLOAT_C(1.0); - return result; -} - -mfloat_t *mat4_rotation_quat(mfloat_t * result, mfloat_t * q0) -{ - mfloat_t xx = q0[0] * q0[0]; - mfloat_t yy = q0[1] * q0[1]; - mfloat_t zz = q0[2] * q0[2]; - mfloat_t xy = q0[0] * q0[1]; - mfloat_t zw = q0[2] * q0[3]; - mfloat_t xz = q0[0] * q0[2]; - mfloat_t yw = q0[1] * q0[3]; - mfloat_t yz = q0[1] * q0[2]; - mfloat_t xw = q0[0] * q0[3]; - result[0] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (yy + zz); - result[1] = MFLOAT_C(2.0) * (xy + zw); - result[2] = MFLOAT_C(2.0) * (xz - yw); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(2.0) * (xy - zw); - result[5] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (xx + zz); - result[6] = MFLOAT_C(2.0) * (yz + xw); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(2.0) * (xz + yw); - result[9] = MFLOAT_C(2.0) * (yz - xw); - result[10] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (xx + yy); - result[11] = MFLOAT_C(0.0); - result[12] = MFLOAT_C(0.0); - result[13] = MFLOAT_C(0.0); - result[14] = MFLOAT_C(0.0); - result[15] = MFLOAT_C(1.0); - return result; -} - -mfloat_t *mat4_translation(mfloat_t * result, mfloat_t * m0, mfloat_t * v0) -{ - result[0] = m0[0]; - result[1] = m0[1]; - result[2] = m0[2]; - result[3] = m0[3]; - result[4] = m0[4]; - result[5] = m0[5]; - result[6] = m0[6]; - result[7] = m0[7]; - result[8] = m0[8]; - result[9] = m0[9]; - result[10] = m0[10]; - result[11] = m0[11]; - result[12] = v0[0]; - result[13] = v0[1]; - result[14] = v0[2]; - result[15] = m0[15]; - return result; -} - -mfloat_t *mat4_translate(mfloat_t * result, mfloat_t * m0, mfloat_t * v0) -{ - result[0] = m0[0]; - result[1] = m0[1]; - result[2] = m0[2]; - result[3] = m0[3]; - result[4] = m0[4]; - result[5] = m0[5]; - result[6] = m0[6]; - result[7] = m0[7]; - result[8] = m0[8]; - result[9] = m0[9]; - result[10] = m0[10]; - result[11] = m0[11]; - result[12] = m0[12] + v0[0]; - result[13] = m0[13] + v0[1]; - result[14] = m0[14] + v0[2]; - result[15] = m0[15]; - return result; -} - -mfloat_t *mat4_translate_vec2(mfloat_t * mat4, mfloat_t * vec2) -{ - mat4[12] += vec2[0]; - mat4[13] += vec2[1]; - return mat4; -} - -mfloat_t *mat4_translate_vec3(mfloat_t * mat4, mfloat_t * vec3) -{ - mat4[12] += vec3[0]; - mat4[13] += vec3[1]; - mat4[14] += vec3[2]; - return mat4; -} - - -mfloat_t *mat4_scaling(mfloat_t * result, mfloat_t * m0, mfloat_t * v0) -{ - result[0] = v0[0]; - result[1] = m0[1]; - result[2] = m0[2]; - result[3] = m0[3]; - result[4] = m0[4]; - result[5] = v0[1]; - result[6] = m0[6]; - result[7] = m0[7]; - result[8] = m0[8]; - result[9] = m0[9]; - result[10] = v0[2]; - result[11] = m0[11]; - result[12] = m0[12]; - result[13] = m0[13]; - result[14] = m0[14]; - result[15] = m0[15]; - return result; -} - -mfloat_t *mat4_scale(mfloat_t * result, mfloat_t * m0, mfloat_t * v0) -{ - result[0] = m0[0] * v0[0]; - result[1] = m0[1]; - result[2] = m0[2]; - result[3] = m0[3]; - result[4] = m0[4]; - result[5] = m0[5] * v0[1]; - result[6] = m0[6]; - result[7] = m0[7]; - result[8] = m0[8]; - result[9] = m0[9]; - result[10] = m0[10] * v0[2]; - result[11] = m0[11]; - result[12] = m0[12]; - result[13] = m0[13]; - result[14] = m0[14]; - result[15] = m0[15]; - return result; -} - -mfloat_t *mat4_scale_vec2(mfloat_t * mat4, mfloat_t * vec2) -{ - mat4[0] *= vec2[0]; - mat4[5] *= vec2[1]; - return mat4; -} - -mfloat_t *mat4_scale_vec2f(mfloat_t * mat4, mfloat_t f) -{ - mat4[0] *= f; - mat4[5] *= f; - return mat4; -} - -mfloat_t *mat4_scale_vec3(mfloat_t * mat4, mfloat_t * vec3) -{ - mat4[0] *= vec3[0]; - mat4[5] *= vec3[1]; - mat4[10] *= vec3[2]; - return mat4; -} - -mfloat_t *mat4_scale_vec3f(mfloat_t * mat4, mfloat_t f) -{ - mat4[0] *= f; - mat4[5] *= f; - mat4[10] *= f; - return mat4; -} - - -mfloat_t *mat4_multiply(mfloat_t * result, mfloat_t * m0, mfloat_t * m1) -{ - mfloat_t multiplied[MAT4_SIZE]; - multiplied[0] = - m0[0] * m1[0] + m0[4] * m1[1] + m0[8] * m1[2] + m0[12] * m1[3]; - multiplied[1] = - m0[1] * m1[0] + m0[5] * m1[1] + m0[9] * m1[2] + m0[13] * m1[3]; - multiplied[2] = - m0[2] * m1[0] + m0[6] * m1[1] + m0[10] * m1[2] + m0[14] * m1[3]; - multiplied[3] = - m0[3] * m1[0] + m0[7] * m1[1] + m0[11] * m1[2] + m0[15] * m1[3]; - multiplied[4] = - m0[0] * m1[4] + m0[4] * m1[5] + m0[8] * m1[6] + m0[12] * m1[7]; - multiplied[5] = - m0[1] * m1[4] + m0[5] * m1[5] + m0[9] * m1[6] + m0[13] * m1[7]; - multiplied[6] = - m0[2] * m1[4] + m0[6] * m1[5] + m0[10] * m1[6] + m0[14] * m1[7]; - multiplied[7] = - m0[3] * m1[4] + m0[7] * m1[5] + m0[11] * m1[6] + m0[15] * m1[7]; - multiplied[8] = - m0[0] * m1[8] + m0[4] * m1[9] + m0[8] * m1[10] + m0[12] * m1[11]; - multiplied[9] = - m0[1] * m1[8] + m0[5] * m1[9] + m0[9] * m1[10] + m0[13] * m1[11]; - multiplied[10] = - m0[2] * m1[8] + m0[6] * m1[9] + m0[10] * m1[10] + m0[14] * m1[11]; - multiplied[11] = - m0[3] * m1[8] + m0[7] * m1[9] + m0[11] * m1[10] + m0[15] * m1[11]; - multiplied[12] = - m0[0] * m1[12] + m0[4] * m1[13] + m0[8] * m1[14] + m0[12] * m1[15]; - multiplied[13] = - m0[1] * m1[12] + m0[5] * m1[13] + m0[9] * m1[14] + m0[13] * m1[15]; - multiplied[14] = - m0[2] * m1[12] + m0[6] * m1[13] + m0[10] * m1[14] + - m0[14] * m1[15]; - multiplied[15] = - m0[3] * m1[12] + m0[7] * m1[13] + m0[11] * m1[14] + - m0[15] * m1[15]; - result[0] = multiplied[0]; - result[1] = multiplied[1]; - result[2] = multiplied[2]; - result[3] = multiplied[3]; - result[4] = multiplied[4]; - result[5] = multiplied[5]; - result[6] = multiplied[6]; - result[7] = multiplied[7]; - result[8] = multiplied[8]; - result[9] = multiplied[9]; - result[10] = multiplied[10]; - result[11] = multiplied[11]; - result[12] = multiplied[12]; - result[13] = multiplied[13]; - result[14] = multiplied[14]; - result[15] = multiplied[15]; - return result; -} - -mfloat_t *mat4_multiply_f(mfloat_t * result, mfloat_t * m0, mfloat_t f) -{ - result[0] = m0[0] * f; - result[1] = m0[1] * f; - result[2] = m0[2] * f; - result[3] = m0[3] * f; - result[4] = m0[4] * f; - result[5] = m0[5] * f; - result[6] = m0[6] * f; - result[7] = m0[7] * f; - result[8] = m0[8] * f; - result[9] = m0[9] * f; - result[10] = m0[10] * f; - result[11] = m0[11] * f; - result[12] = m0[12] * f; - result[13] = m0[13] * f; - result[14] = m0[14] * f; - result[15] = m0[15] * f; - return result; -} - -mfloat_t *mat4_inverse(mfloat_t * result, mfloat_t * m0) -{ - mfloat_t inverse[MAT4_SIZE]; - mfloat_t inverted_determinant; - mfloat_t m11 = m0[0]; - mfloat_t m21 = m0[1]; - mfloat_t m31 = m0[2]; - mfloat_t m41 = m0[3]; - mfloat_t m12 = m0[4]; - mfloat_t m22 = m0[5]; - mfloat_t m32 = m0[6]; - mfloat_t m42 = m0[7]; - mfloat_t m13 = m0[8]; - mfloat_t m23 = m0[9]; - mfloat_t m33 = m0[10]; - mfloat_t m43 = m0[11]; - mfloat_t m14 = m0[12]; - mfloat_t m24 = m0[13]; - mfloat_t m34 = m0[14]; - mfloat_t m44 = m0[15]; - inverse[0] = m22 * m33 * m44 - - m22 * m43 * m34 - - m23 * m32 * m44 - + m23 * m42 * m34 + m24 * m32 * m43 - m24 * m42 * m33; - inverse[4] = -m12 * m33 * m44 - + m12 * m43 * m34 - + m13 * m32 * m44 - - m13 * m42 * m34 - m14 * m32 * m43 + m14 * m42 * m33; - inverse[8] = m12 * m23 * m44 - - m12 * m43 * m24 - - m13 * m22 * m44 - + m13 * m42 * m24 + m14 * m22 * m43 - m14 * m42 * m23; - inverse[12] = -m12 * m23 * m34 - + m12 * m33 * m24 - + m13 * m22 * m34 - - m13 * m32 * m24 - m14 * m22 * m33 + m14 * m32 * m23; - inverse[1] = -m21 * m33 * m44 - + m21 * m43 * m34 - + m23 * m31 * m44 - - m23 * m41 * m34 - m24 * m31 * m43 + m24 * m41 * m33; - inverse[5] = m11 * m33 * m44 - - m11 * m43 * m34 - - m13 * m31 * m44 - + m13 * m41 * m34 + m14 * m31 * m43 - m14 * m41 * m33; - inverse[9] = -m11 * m23 * m44 - + m11 * m43 * m24 - + m13 * m21 * m44 - - m13 * m41 * m24 - m14 * m21 * m43 + m14 * m41 * m23; - inverse[13] = m11 * m23 * m34 - - m11 * m33 * m24 - - m13 * m21 * m34 - + m13 * m31 * m24 + m14 * m21 * m33 - m14 * m31 * m23; - inverse[2] = m21 * m32 * m44 - - m21 * m42 * m34 - - m22 * m31 * m44 - + m22 * m41 * m34 + m24 * m31 * m42 - m24 * m41 * m32; - inverse[6] = -m11 * m32 * m44 - + m11 * m42 * m34 - + m12 * m31 * m44 - - m12 * m41 * m34 - m14 * m31 * m42 + m14 * m41 * m32; - inverse[10] = m11 * m22 * m44 - - m11 * m42 * m24 - - m12 * m21 * m44 - + m12 * m41 * m24 + m14 * m21 * m42 - m14 * m41 * m22; - inverse[14] = -m11 * m22 * m34 - + m11 * m32 * m24 - + m12 * m21 * m34 - - m12 * m31 * m24 - m14 * m21 * m32 + m14 * m31 * m22; - inverse[3] = -m21 * m32 * m43 - + m21 * m42 * m33 - + m22 * m31 * m43 - - m22 * m41 * m33 - m23 * m31 * m42 + m23 * m41 * m32; - inverse[7] = m11 * m32 * m43 - - m11 * m42 * m33 - - m12 * m31 * m43 - + m12 * m41 * m33 + m13 * m31 * m42 - m13 * m41 * m32; - inverse[11] = -m11 * m22 * m43 - + m11 * m42 * m23 - + m12 * m21 * m43 - - m12 * m41 * m23 - m13 * m21 * m42 + m13 * m41 * m22; - inverse[15] = m11 * m22 * m33 - - m11 * m32 * m23 - - m12 * m21 * m33 - + m12 * m31 * m23 + m13 * m21 * m32 - m13 * m31 * m22; - inverted_determinant = - MFLOAT_C(1.0) / (m11 * inverse[0] + m21 * inverse[4] + - m31 * inverse[8] + m41 * inverse[12]); - result[0] = inverse[0] * inverted_determinant; - result[1] = inverse[1] * inverted_determinant; - result[2] = inverse[2] * inverted_determinant; - result[3] = inverse[3] * inverted_determinant; - result[4] = inverse[4] * inverted_determinant; - result[5] = inverse[5] * inverted_determinant; - result[6] = inverse[6] * inverted_determinant; - result[7] = inverse[7] * inverted_determinant; - result[8] = inverse[8] * inverted_determinant; - result[9] = inverse[9] * inverted_determinant; - result[10] = inverse[10] * inverted_determinant; - result[11] = inverse[11] * inverted_determinant; - result[12] = inverse[12] * inverted_determinant; - result[13] = inverse[13] * inverted_determinant; - result[14] = inverse[14] * inverted_determinant; - result[15] = inverse[15] * inverted_determinant; - return result; -} - -mfloat_t *mat4_lerp(mfloat_t * result, mfloat_t * m0, mfloat_t * m1, - mfloat_t f) -{ - result[0] = m0[0] + (m1[0] - m0[0]) * f; - result[1] = m0[1] + (m1[1] - m0[1]) * f; - result[2] = m0[2] + (m1[2] - m0[2]) * f; - result[3] = m0[3] + (m1[3] - m0[3]) * f; - result[4] = m0[4] + (m1[4] - m0[4]) * f; - result[5] = m0[5] + (m1[5] - m0[5]) * f; - result[6] = m0[6] + (m1[6] - m0[6]) * f; - result[7] = m0[7] + (m1[7] - m0[7]) * f; - result[8] = m0[8] + (m1[8] - m0[8]) * f; - result[9] = m0[9] + (m1[9] - m0[9]) * f; - result[10] = m0[10] + (m1[10] - m0[10]) * f; - result[11] = m0[11] + (m1[11] - m0[11]) * f; - result[12] = m0[12] + (m1[12] - m0[12]) * f; - result[13] = m0[13] + (m1[13] - m0[13]) * f; - result[14] = m0[14] + (m1[14] - m0[14]) * f; - result[15] = m0[15] + (m1[15] - m0[15]) * f; - return result; -} - -mfloat_t *mat4_look_at(mfloat_t * result, const mfloat_t * position, - const mfloat_t * target, const mfloat_t * up) -{ - mfloat_t tmp_forward[VEC3_SIZE] = { 0.f }; - mfloat_t tmp_side[VEC3_SIZE] = { 0.f }; - mfloat_t tmp_up[VEC3_SIZE] = { 0.f }; - vec3_subtract(tmp_forward, target, position); - vec3_normalize(tmp_forward, tmp_forward); - vec3_cross(tmp_side, tmp_forward, up); - vec3_normalize(tmp_side, tmp_side); - vec3_cross(tmp_up, tmp_side, tmp_forward); - result[0] = tmp_side[0]; - result[1] = tmp_up[0]; - result[2] = -tmp_forward[0]; - result[3] = MFLOAT_C(0.0); - result[4] = tmp_side[1]; - result[5] = tmp_up[1]; - result[6] = -tmp_forward[1]; - result[7] = MFLOAT_C(0.0); - result[8] = tmp_side[2]; - result[9] = tmp_up[2]; - result[10] = -tmp_forward[2]; - result[11] = MFLOAT_C(0.0); - result[12] = -vec3_dot(tmp_side, position); - result[13] = -vec3_dot(tmp_up, position); - result[14] = vec3_dot(tmp_forward, position); - result[15] = MFLOAT_C(1.0); - return result; -} - -mfloat_t *mat4_ortho(mfloat_t * result, mfloat_t l, mfloat_t r, mfloat_t b, - mfloat_t t, mfloat_t n, mfloat_t f) -{ - result[0] = MFLOAT_C(2.0) / (r - l); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(0.0); - result[5] = MFLOAT_C(2.0) / (t - b); - result[6] = MFLOAT_C(0.0); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(0.0); - result[9] = MFLOAT_C(0.0); - result[10] = -MFLOAT_C(2.0) / (f - n); - result[11] = MFLOAT_C(0.0); - result[12] = -((r + l) / (r - l)); - result[13] = -((t + b) / (t - b)); - result[14] = -((f + n) / (f - n)); - result[15] = MFLOAT_C(1.0); - return result; -} - -mfloat_t *mat4_perspective(mfloat_t * result, mfloat_t fov_y, - mfloat_t aspect, mfloat_t n, mfloat_t f) -{ - mfloat_t tan_half_fov_y = MFLOAT_C(1.0) / MTAN(fov_y * MFLOAT_C(0.5)); - result[0] = MFLOAT_C(1.0) / aspect * tan_half_fov_y; - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(0.0); - result[5] = MFLOAT_C(1.0) / tan_half_fov_y; - result[6] = MFLOAT_C(0.0); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(0.0); - result[9] = MFLOAT_C(0.0); - result[10] = f / (n - f); - result[11] = -MFLOAT_C(1.0); - result[12] = MFLOAT_C(0.0); - result[13] = MFLOAT_C(0.0); - result[14] = -(f * n) / (f - n); - result[15] = MFLOAT_C(0.0); - return result; -} - -mfloat_t *mat4_perspective_fov(mfloat_t * result, mfloat_t fov, mfloat_t w, - mfloat_t h, mfloat_t n, mfloat_t f) -{ - mfloat_t h2 = MCOS(fov * MFLOAT_C(0.5)) / MSIN(fov * MFLOAT_C(0.5)); - mfloat_t w2 = h2 * h / w; - result[0] = w2; - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(0.0); - result[5] = h2; - result[6] = MFLOAT_C(0.0); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(0.0); - result[9] = MFLOAT_C(0.0); - result[10] = f / (n - f); - result[11] = -MFLOAT_C(1.0); - result[12] = MFLOAT_C(0.0); - result[13] = MFLOAT_C(0.0); - result[14] = -(f * n) / (f - n); - result[15] = MFLOAT_C(0.0); - return result; -} - -mfloat_t *mat4_perspective_infinite(mfloat_t * result, mfloat_t fov_y, - mfloat_t aspect, mfloat_t n) -{ - mfloat_t range = MTAN(fov_y * MFLOAT_C(0.5)) * n; - mfloat_t left = -range * aspect; - mfloat_t right = range * aspect; - mfloat_t top = range; - mfloat_t bottom = -range; - result[0] = MFLOAT_C(2.0) * n / (right - left); - result[1] = MFLOAT_C(0.0); - result[2] = MFLOAT_C(0.0); - result[3] = MFLOAT_C(0.0); - result[4] = MFLOAT_C(0.0); - result[5] = MFLOAT_C(2.0) * n / (top - bottom); - result[6] = MFLOAT_C(0.0); - result[7] = MFLOAT_C(0.0); - result[8] = MFLOAT_C(0.0); - result[9] = MFLOAT_C(0.0); - result[10] = -MFLOAT_C(1.0); - result[11] = -MFLOAT_C(1.0); - result[12] = MFLOAT_C(0.0); - result[13] = MFLOAT_C(0.0); - result[14] = -MFLOAT_C(2.0) * n; - result[15] = MFLOAT_C(0.0); - return result; + } + return result; +} + +mfloat_t *quat_from_axis_angle(mfloat_t *result, const mfloat_t *v0, + const mfloat_t angle) { + mfloat_t half = angle * MFLOAT_C(0.5); + mfloat_t s = MSIN(half); + result[0] = v0[0] * s; + result[1] = v0[1] * s; + result[2] = v0[2] * s; + result[3] = MCOS(half); + return result; +} + +mfloat_t *quat_from_vec3(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) { + mfloat_t cross[VEC3_SIZE]; + mfloat_t d = vec3_dot(v0, v1); + mfloat_t a_ls = vec3_length_squared(v0); + mfloat_t b_ls = vec3_length_squared(v0); + vec3_cross(cross, v0, v1); + quat(result, cross[0], cross[1], cross[1], d + MSQRT(a_ls * b_ls)); + quat_normalize(result, result); + return result; +} + +mfloat_t *quat_from_euler(mfloat_t *q, const mfloat_t *euler) { + mfloat_t qx[4], qy[4], qz[4]; + quat_from_axis_angle(qx, RIGHT, euler[0]); + quat_from_axis_angle(qy, UP, euler[1]); + quat_from_axis_angle(qz, FORWARD, euler[2]); + return quat_multiply(q, qx, quat_multiply(q, qy, qz)); +} + +mfloat_t *quat_from_mat4(mfloat_t *result, mfloat_t *m0) { + mfloat_t scale = m0[0] + m0[5] + m0[10]; + if (scale > MFLOAT_C(0.0)) { + mfloat_t sr = MSQRT(scale + MFLOAT_C(1.0)); + result[3] = sr * MFLOAT_C(0.5); + sr = MFLOAT_C(0.5) / sr; + result[0] = (m0[9] - m0[6]) * sr; + result[1] = (m0[2] - m0[8]) * sr; + result[2] = (m0[4] - m0[1]) * sr; + } else if ((m0[0] >= m0[5]) && (m0[0] >= m0[10])) { + mfloat_t sr = MSQRT(MFLOAT_C(1.0) + m0[0] - m0[5] - m0[10]); + mfloat_t half = MFLOAT_C(0.5) / sr; + result[0] = MFLOAT_C(0.5) * sr; + result[1] = (m0[4] + m0[1]) * half; + result[2] = (m0[8] + m0[2]) * half; + result[3] = (m0[9] - m0[6]) * half; + } else if (m0[5] > m0[10]) { + mfloat_t sr = MSQRT(MFLOAT_C(1.0) + m0[5] - m0[0] - m0[10]); + mfloat_t half = MFLOAT_C(0.5) / sr; + result[0] = (m0[1] + m0[4]) * half; + result[1] = MFLOAT_C(0.5) * sr; + result[2] = (m0[6] + m0[9]) * half; + result[3] = (m0[2] - m0[8]) * half; + } else { + mfloat_t sr = MSQRT(MFLOAT_C(1.0) + m0[10] - m0[0] - m0[5]); + mfloat_t half = MFLOAT_C(0.5) / sr; + result[0] = (m0[2] + m0[8]) * half; + result[1] = (m0[6] + m0[9]) * half; + result[2] = MFLOAT_C(0.5) * sr; + result[3] = (m0[4] - m0[1]) * half; + } + return result; +} + +mfloat_t *quat_lerp(mfloat_t *result, mfloat_t *q0, mfloat_t *q1, + mfloat_t f) { + result[0] = q0[0] + (q1[0] - q0[0]) * f; + result[1] = q0[1] + (q1[1] - q0[1]) * f; + result[2] = q0[2] + (q1[2] - q0[2]) * f; + result[3] = q0[3] + (q1[3] - q0[3]) * f; + return result; +} + +mfloat_t *quat_slerp(mfloat_t *result, mfloat_t *q0, mfloat_t *q1, + mfloat_t f) { + mfloat_t tmp1[QUAT_SIZE]; + mfloat_t d = quat_dot(q0, q1); + mfloat_t f0; + mfloat_t f1; + quat_assign(tmp1, q1); + if (d < MFLOAT_C(0.0)) { + quat_negative(tmp1, tmp1); + d = -d; + } + if (d > MFLOAT_C(0.9995)) { + f0 = MFLOAT_C(1.0) - f; + f1 = f; + } else { + mfloat_t theta = MACOS(d); + mfloat_t sin_theta = MSIN(theta); + f0 = MSIN((MFLOAT_C(1.0) - f) * theta) / sin_theta; + f1 = MSIN(f * theta) / sin_theta; + } + result[0] = q0[0] * f0 + tmp1[0] * f1; + result[1] = q0[1] * f0 + tmp1[1] * f1; + result[2] = q0[2] * f0 + tmp1[2] * f1; + result[3] = q0[3] * f0 + tmp1[3] * f1; + return result; +} + +mfloat_t quat_length(mfloat_t *q0) { + return MSQRT(q0[0] * q0[0] + q0[1] * q0[1] + q0[2] * q0[2] + + q0[3] * q0[3]); +} + +mfloat_t quat_length_squared(mfloat_t *q0) { + return q0[0] * q0[0] + q0[1] * q0[1] + q0[2] * q0[2] + q0[3] * q0[3]; +} + +mfloat_t quat_angle(mfloat_t *q0, mfloat_t *q1) { + mfloat_t s = MSQRT(quat_length_squared(q0) * quat_length_squared(q1)); + s = MFLOAT_C(1.0) / s; + return MACOS(quat_dot(q0, q1) * s); +} + +mfloat_t *mat2(mfloat_t *result, mfloat_t m11, mfloat_t m12, mfloat_t m21, + mfloat_t m22) { + result[0] = m11; + result[1] = m21; + result[2] = m12; + result[3] = m22; + return result; +} + +mfloat_t *mat2_zero(mfloat_t *result) { + result[0] = MFLOAT_C(0.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + return result; +} + +mfloat_t *mat2_identity(mfloat_t *result) { + result[0] = MFLOAT_C(1.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(1.0); + return result; +} + +mfloat_t mat2_determinant(mfloat_t *m0) { + return m0[0] * m0[3] - m0[2] * m0[1]; +} + +mfloat_t *mat2_assign(mfloat_t *result, mfloat_t *m0) { + result[0] = m0[0]; + result[1] = m0[1]; + result[2] = m0[2]; + result[3] = m0[3]; + return result; +} + +mfloat_t *mat2_negative(mfloat_t *result, mfloat_t *m0) { + result[0] = -m0[0]; + result[1] = -m0[1]; + result[2] = -m0[2]; + result[3] = -m0[3]; + return result; +} + +mfloat_t *mat2_transpose(mfloat_t *result, mfloat_t *m0) { + mfloat_t transposed[MAT2_SIZE]; + transposed[0] = m0[0]; + transposed[1] = m0[2]; + transposed[2] = m0[1]; + transposed[3] = m0[3]; + result[0] = transposed[0]; + result[1] = transposed[1]; + result[2] = transposed[2]; + result[3] = transposed[3]; + return result; +} + +mfloat_t *mat2_cofactor(mfloat_t *result, mfloat_t *m0) { + mfloat_t cofactor[MAT2_SIZE]; + cofactor[0] = m0[3]; + cofactor[1] = -m0[2]; + cofactor[2] = -m0[1]; + cofactor[3] = m0[0]; + result[0] = cofactor[0]; + result[1] = cofactor[1]; + result[2] = cofactor[2]; + result[3] = cofactor[3]; + return result; +} + +mfloat_t *mat2_adjugate(mfloat_t *result, mfloat_t *m0) { + mfloat_t adjugate[MAT2_SIZE]; + adjugate[0] = m0[3]; + adjugate[1] = -m0[1]; + adjugate[2] = -m0[2]; + adjugate[3] = m0[0]; + result[0] = adjugate[0]; + result[1] = adjugate[1]; + result[2] = adjugate[2]; + result[3] = adjugate[3]; + return result; +} + +mfloat_t *mat2_multiply(mfloat_t *result, mfloat_t *m0, mfloat_t *m1) { + mfloat_t multiplied[MAT3_SIZE]; + multiplied[0] = m0[0] * m1[0] + m0[2] * m1[1]; + multiplied[1] = m0[1] * m1[0] + m0[3] * m1[1]; + multiplied[2] = m0[0] * m1[2] + m0[2] * m1[3]; + multiplied[3] = m0[1] * m1[2] + m0[3] * m1[3]; + result[0] = multiplied[0]; + result[1] = multiplied[1]; + result[2] = multiplied[2]; + result[3] = multiplied[3]; + return result; +} + +mfloat_t *mat2_multiply_f(mfloat_t *result, mfloat_t *m0, mfloat_t f) { + result[0] = m0[0] * f; + result[1] = m0[1] * f; + result[2] = m0[2] * f; + result[3] = m0[3] * f; + return result; +} + +mfloat_t *mat2_inverse(mfloat_t *result, mfloat_t *m0) { + mfloat_t inverse[MAT2_SIZE]; + mfloat_t det = mat2_determinant(m0); + mat2_cofactor(inverse, m0); + mat2_multiply_f(inverse, inverse, MFLOAT_C(1.0) / det); + result[0] = inverse[0]; + result[1] = inverse[1]; + result[2] = inverse[2]; + result[3] = inverse[3]; + return result; +} + +mfloat_t *mat2_scaling(mfloat_t *result, mfloat_t *v0) { + result[0] = v0[0]; + result[3] = v0[1]; + return result; +} + +mfloat_t *mat2_scale(mfloat_t *result, mfloat_t *m0, mfloat_t *v0) { + result[0] = m0[0] * v0[0]; + result[3] = m0[3] * v0[1]; + return result; +} + +mfloat_t *mat2_rotation_z(mfloat_t *result, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + result[0] = c; + result[1] = s; + result[2] = -s; + result[3] = c; + return result; +} + +mfloat_t *mat2_lerp(mfloat_t *result, mfloat_t *m0, mfloat_t *m1, + mfloat_t f) { + result[0] = m0[0] + (m1[0] - m0[0]) * f; + result[1] = m0[1] + (m1[1] - m0[1]) * f; + result[2] = m0[2] + (m1[2] - m0[2]) * f; + result[3] = m0[3] + (m1[3] - m0[3]) * f; + return result; +} + +mfloat_t *mat3(mfloat_t *result, mfloat_t m11, mfloat_t m12, mfloat_t m13, + mfloat_t m21, mfloat_t m22, mfloat_t m23, mfloat_t m31, + mfloat_t m32, mfloat_t m33) { + result[0] = m11; + result[1] = m21; + result[2] = m31; + result[3] = m12; + result[4] = m22; + result[5] = m32; + result[6] = m13; + result[7] = m23; + result[8] = m33; + return result; +} + +mfloat_t *mat3_zero(mfloat_t *result) { + result[0] = MFLOAT_C(0.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(0.0); + result[5] = MFLOAT_C(0.0); + result[6] = MFLOAT_C(0.0); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(0.0); + return result; +} + +mfloat_t *mat3_identity(mfloat_t *result) { + result[0] = MFLOAT_C(1.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(1.0); + result[5] = MFLOAT_C(0.0); + result[6] = MFLOAT_C(0.0); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(1.0); + return result; +} + +mfloat_t mat3_determinant(mfloat_t *m0) { + mfloat_t m11 = m0[0]; + mfloat_t m21 = m0[1]; + mfloat_t m31 = m0[2]; + mfloat_t m12 = m0[3]; + mfloat_t m22 = m0[4]; + mfloat_t m32 = m0[5]; + mfloat_t m13 = m0[6]; + mfloat_t m23 = m0[7]; + mfloat_t m33 = m0[8]; + mfloat_t determinant = m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32 - m11 * m23 * m32 - m12 * m21 * m33 - m13 * m22 * m31; + return determinant; +} + +mfloat_t *mat3_assign(mfloat_t *result, mfloat_t *m0) { + result[0] = m0[0]; + result[1] = m0[1]; + result[2] = m0[2]; + result[3] = m0[3]; + result[4] = m0[4]; + result[5] = m0[5]; + result[6] = m0[6]; + result[7] = m0[7]; + result[8] = m0[8]; + return result; +} + +mfloat_t *mat3_negative(mfloat_t *result, mfloat_t *m0) { + result[0] = -m0[0]; + result[1] = -m0[1]; + result[2] = -m0[2]; + result[3] = -m0[3]; + result[4] = -m0[4]; + result[5] = -m0[5]; + result[6] = -m0[6]; + result[7] = -m0[7]; + result[8] = -m0[8]; + return result; +} + +mfloat_t *mat3_transpose(mfloat_t *result, mfloat_t *m0) { + mfloat_t transposed[MAT4_SIZE]; + transposed[0] = m0[0]; + transposed[1] = m0[3]; + transposed[2] = m0[6]; + transposed[3] = m0[1]; + transposed[4] = m0[4]; + transposed[5] = m0[7]; + transposed[6] = m0[2]; + transposed[7] = m0[5]; + transposed[8] = m0[8]; + result[0] = transposed[0]; + result[1] = transposed[1]; + result[2] = transposed[2]; + result[3] = transposed[3]; + result[4] = transposed[4]; + result[5] = transposed[5]; + result[6] = transposed[6]; + result[7] = transposed[7]; + result[8] = transposed[8]; + return result; +} + +mfloat_t *mat3_cofactor(mfloat_t *result, mfloat_t *m0) { + mfloat_t cofactor[MAT3_SIZE]; + mfloat_t minor[MAT2_SIZE]; + minor[0] = m0[4]; + minor[1] = m0[5]; + minor[2] = m0[7]; + minor[3] = m0[8]; + cofactor[0] = mat2_determinant(minor); + minor[0] = m0[3]; + minor[1] = m0[5]; + minor[2] = m0[6]; + minor[3] = m0[8]; + cofactor[1] = -mat2_determinant(minor); + minor[0] = m0[3]; + minor[1] = m0[4]; + minor[2] = m0[6]; + minor[3] = m0[7]; + cofactor[2] = mat2_determinant(minor); + minor[0] = m0[1]; + minor[1] = m0[2]; + minor[2] = m0[7]; + minor[3] = m0[8]; + cofactor[3] = -mat2_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[2]; + minor[2] = m0[6]; + minor[3] = m0[8]; + cofactor[4] = mat2_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[1]; + minor[2] = m0[6]; + minor[3] = m0[7]; + cofactor[5] = -mat2_determinant(minor); + minor[0] = m0[1]; + minor[1] = m0[2]; + minor[2] = m0[4]; + minor[3] = m0[5]; + cofactor[6] = mat2_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[2]; + minor[2] = m0[3]; + minor[3] = m0[5]; + cofactor[7] = -mat2_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[1]; + minor[2] = m0[3]; + minor[3] = m0[4]; + cofactor[8] = mat2_determinant(minor); + result[0] = cofactor[0]; + result[1] = cofactor[1]; + result[2] = cofactor[2]; + result[3] = cofactor[3]; + result[4] = cofactor[4]; + result[5] = cofactor[5]; + result[6] = cofactor[6]; + result[7] = cofactor[7]; + result[8] = cofactor[8]; + return result; +} + +mfloat_t *mat3_multiply(mfloat_t *result, mfloat_t *m0, mfloat_t *m1) { + mfloat_t multiplied[MAT3_SIZE]; + multiplied[0] = m0[0] * m1[0] + m0[3] * m1[1] + m0[6] * m1[2]; + multiplied[1] = m0[1] * m1[0] + m0[4] * m1[1] + m0[7] * m1[2]; + multiplied[2] = m0[2] * m1[0] + m0[5] * m1[1] + m0[8] * m1[2]; + multiplied[3] = m0[0] * m1[3] + m0[3] * m1[4] + m0[6] * m1[5]; + multiplied[4] = m0[1] * m1[3] + m0[4] * m1[4] + m0[7] * m1[5]; + multiplied[5] = m0[2] * m1[3] + m0[5] * m1[4] + m0[8] * m1[5]; + multiplied[6] = m0[0] * m1[6] + m0[3] * m1[7] + m0[6] * m1[8]; + multiplied[7] = m0[1] * m1[6] + m0[4] * m1[7] + m0[7] * m1[8]; + multiplied[8] = m0[2] * m1[6] + m0[5] * m1[7] + m0[8] * m1[8]; + result[0] = multiplied[0]; + result[1] = multiplied[1]; + result[2] = multiplied[2]; + result[3] = multiplied[3]; + result[4] = multiplied[4]; + result[5] = multiplied[5]; + result[6] = multiplied[6]; + result[7] = multiplied[7]; + result[8] = multiplied[8]; + return result; +} + +mfloat_t *mat3_multiply_f(mfloat_t *result, mfloat_t *m0, mfloat_t f) { + result[0] = m0[0] * f; + result[1] = m0[1] * f; + result[2] = m0[2] * f; + result[3] = m0[3] * f; + result[4] = m0[4] * f; + result[5] = m0[5] * f; + result[6] = m0[6] * f; + result[7] = m0[7] * f; + result[8] = m0[8] * f; + return result; +} + +mfloat_t *mat3_inverse(mfloat_t *result, mfloat_t *m0) { + result = m0; + return result; +} + +mfloat_t *mat3_scaling(mfloat_t *result, mfloat_t *v0) { + result[0] = v0[0]; + result[4] = v0[1]; + result[8] = v0[2]; + return result; +} + +mfloat_t *mat3_scale(mfloat_t *result, mfloat_t *m0, mfloat_t *v0) { + result[0] = m0[0] * v0[0]; + result[4] = m0[4] * v0[1]; + result[8] = m0[8] * v0[2]; + return result; +} + +mfloat_t *mat3_rotation_x(mfloat_t *result, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + result[4] = c; + result[5] = s; + result[7] = -s; + result[8] = c; + return result; +} + +mfloat_t *mat3_rotation_y(mfloat_t *result, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + result[0] = c; + result[2] = -s; + result[6] = s; + result[8] = c; + return result; +} + +mfloat_t *mat3_rotation_z(mfloat_t *result, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + result[0] = c; + result[1] = s; + result[3] = -s; + result[4] = c; + return result; +} + +mfloat_t *mat3_rotation_axis(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + mfloat_t one_c = MFLOAT_C(1.0) - c; + mfloat_t x = v0[0]; + mfloat_t y = v0[4]; + mfloat_t z = v0[8]; + mfloat_t xx = x * x; + mfloat_t xy = x * y; + mfloat_t xz = x * z; + mfloat_t yy = y * y; + mfloat_t yz = y * z; + mfloat_t zz = z * z; + mfloat_t l = xx + yy + zz; + mfloat_t sqrt_l = MSQRT(l); + result[0] = (xx + (yy + zz) * c) / l; + result[1] = (xy * one_c + v0[2] * sqrt_l * s) / l; + result[2] = (xz * one_c - v0[1] * sqrt_l * s) / l; + result[3] = (xy * one_c - v0[2] * sqrt_l * s) / l; + result[4] = (yy + (xx + zz) * c) / l; + result[5] = (yz * one_c + v0[0] * sqrt_l * s) / l; + result[6] = (xz * one_c + v0[1] * sqrt_l * s) / l; + result[7] = (yz * one_c - v0[0] * sqrt_l * s) / l; + result[8] = (zz + (xx + yy) * c) / l; + return result; +} + +mfloat_t *mat3_rotation_quat(mfloat_t *result, mfloat_t *q0) { + mfloat_t xx = q0[0] * q0[0]; + mfloat_t yy = q0[1] * q0[1]; + mfloat_t zz = q0[2] * q0[2]; + mfloat_t xy = q0[0] * q0[1]; + mfloat_t zw = q0[2] * q0[3]; + mfloat_t xz = q0[8] * q0[0]; + mfloat_t yw = q0[1] * q0[3]; + mfloat_t yz = q0[1] * q0[2]; + mfloat_t xw = q0[0] * q0[3]; + result[0] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (yy - zz); + result[1] = MFLOAT_C(2.0) * (xy + zw); + result[2] = MFLOAT_C(2.0) * (xz - yw); + result[3] = MFLOAT_C(2.0) * (xy - zw); + result[4] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (xx - zz); + result[5] = MFLOAT_C(2.0) * (yz + xw); + result[6] = MFLOAT_C(2.0) * (xz + yw); + result[7] = MFLOAT_C(2.0) * (yz - xw); + result[8] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (xx - yy); + return result; +} + +mfloat_t *mat3_lerp(mfloat_t *result, mfloat_t *m0, mfloat_t *m1, + mfloat_t f) { + result[0] = m0[0] + (m1[0] - m0[0]) * f; + result[1] = m0[1] + (m1[1] - m0[1]) * f; + result[2] = m0[2] + (m1[2] - m0[2]) * f; + result[3] = m0[3] + (m1[3] - m0[3]) * f; + result[4] = m0[4] + (m1[4] - m0[4]) * f; + result[5] = m0[5] + (m1[5] - m0[5]) * f; + result[6] = m0[6] + (m1[6] - m0[6]) * f; + result[7] = m0[7] + (m1[7] - m0[7]) * f; + result[8] = m0[8] + (m1[8] - m0[8]) * f; + return result; +} + +mfloat_t *mat4(mfloat_t *result, mfloat_t m11, mfloat_t m12, mfloat_t m13, + mfloat_t m14, mfloat_t m21, mfloat_t m22, mfloat_t m23, + mfloat_t m24, mfloat_t m31, mfloat_t m32, mfloat_t m33, + mfloat_t m34, mfloat_t m41, mfloat_t m42, mfloat_t m43, + mfloat_t m44) { + result[0] = m11; + result[1] = m21; + result[2] = m31; + result[3] = m41; + result[4] = m12; + result[5] = m22; + result[6] = m32; + result[7] = m42; + result[8] = m13; + result[9] = m23; + result[10] = m33; + result[11] = m43; + result[12] = m14; + result[13] = m24; + result[14] = m34; + result[15] = m44; + return result; +} + +mfloat_t *mat4_zero(mfloat_t *result) { + result[0] = MFLOAT_C(0.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(0.0); + result[5] = MFLOAT_C(0.0); + result[6] = MFLOAT_C(0.0); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(0.0); + result[9] = MFLOAT_C(0.0); + result[10] = MFLOAT_C(0.0); + result[11] = MFLOAT_C(0.0); + result[12] = MFLOAT_C(0.0); + result[13] = MFLOAT_C(0.0); + result[14] = MFLOAT_C(0.0); + result[15] = MFLOAT_C(0.0); + return result; +} + +mfloat_t *mat4_identity(mfloat_t *result) { + result[0] = MFLOAT_C(1.0); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(0.0); + result[5] = MFLOAT_C(1.0); + result[6] = MFLOAT_C(0.0); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(0.0); + result[9] = MFLOAT_C(0.0); + result[10] = MFLOAT_C(1.0); + result[11] = MFLOAT_C(0.0); + result[12] = MFLOAT_C(0.0); + result[13] = MFLOAT_C(0.0); + result[14] = MFLOAT_C(0.0); + result[15] = MFLOAT_C(1.0); + return result; +} + +mfloat_t mat4_determinant(mfloat_t *m0) { + mfloat_t m11 = m0[0]; + mfloat_t m21 = m0[1]; + mfloat_t m31 = m0[2]; + mfloat_t m41 = m0[3]; + mfloat_t m12 = m0[4]; + mfloat_t m22 = m0[5]; + mfloat_t m32 = m0[6]; + mfloat_t m42 = m0[7]; + mfloat_t m13 = m0[8]; + mfloat_t m23 = m0[9]; + mfloat_t m33 = m0[10]; + mfloat_t m43 = m0[11]; + mfloat_t m14 = m0[12]; + mfloat_t m24 = m0[13]; + mfloat_t m34 = m0[14]; + mfloat_t m44 = m0[15]; + mfloat_t determinant = m14 * m23 * m32 * m41 - m13 * m24 * m32 * m41 - m14 * m22 * m33 * m41 + m12 * m24 * m33 * m41 + m13 * m22 * m34 * m41 - m12 * m23 * m34 * m41 - m14 * m23 * m31 * m42 + m13 * m24 * m31 * m42 + m14 * m21 * m33 * m42 - m11 * m24 * m33 * m42 - m13 * m21 * m34 * m42 + m11 * m23 * m34 * m42 + m14 * m22 * m31 * m43 - m12 * m24 * m31 * m43 - m14 * m21 * m32 * m43 + m11 * m24 * m32 * m43 + m12 * m21 * m34 * m43 - m11 * m22 * m34 * m43 - m13 * m22 * m31 * m44 + m12 * m23 * m31 * m44 + m13 * m21 * m32 * m44 - m11 * m23 * m32 * m44 - m12 * m21 * m33 * m44 + m11 * m22 * m33 * m44; + return determinant; +} + +mfloat_t *mat4_assign(mfloat_t *result, mfloat_t *m0) { + result[0] = m0[0]; + result[1] = m0[1]; + result[2] = m0[2]; + result[3] = m0[3]; + result[4] = m0[4]; + result[5] = m0[5]; + result[6] = m0[6]; + result[7] = m0[7]; + result[8] = m0[8]; + result[9] = m0[9]; + result[10] = m0[10]; + result[11] = m0[11]; + result[12] = m0[12]; + result[13] = m0[13]; + result[14] = m0[14]; + result[15] = m0[15]; + return result; +} + +mfloat_t *mat4_negative(mfloat_t *result, mfloat_t *m0) { + result[0] = -m0[0]; + result[1] = -m0[1]; + result[2] = -m0[2]; + result[3] = -m0[3]; + result[4] = -m0[4]; + result[5] = -m0[5]; + result[6] = -m0[6]; + result[7] = -m0[7]; + result[8] = -m0[8]; + result[9] = -m0[9]; + result[10] = -m0[10]; + result[11] = -m0[11]; + result[12] = -m0[12]; + result[13] = -m0[13]; + result[14] = -m0[14]; + result[15] = -m0[15]; + return result; +} + +mfloat_t *mat4_transpose(mfloat_t *result, mfloat_t *m0) { + mfloat_t transposed[MAT4_SIZE]; + transposed[0] = m0[0]; + transposed[1] = m0[4]; + transposed[2] = m0[8]; + transposed[3] = m0[12]; + transposed[4] = m0[1]; + transposed[5] = m0[5]; + transposed[6] = m0[9]; + transposed[7] = m0[13]; + transposed[8] = m0[2]; + transposed[9] = m0[6]; + transposed[10] = m0[10]; + transposed[11] = m0[14]; + transposed[12] = m0[3]; + transposed[13] = m0[7]; + transposed[14] = m0[11]; + transposed[15] = m0[15]; + result[0] = transposed[0]; + result[1] = transposed[1]; + result[2] = transposed[2]; + result[3] = transposed[3]; + result[4] = transposed[4]; + result[5] = transposed[5]; + result[6] = transposed[6]; + result[7] = transposed[7]; + result[8] = transposed[8]; + result[9] = transposed[9]; + result[10] = transposed[10]; + result[11] = transposed[11]; + result[12] = transposed[12]; + result[13] = transposed[13]; + result[14] = transposed[14]; + result[15] = transposed[15]; + return result; +} + +mfloat_t *mat4_cofactor(mfloat_t *result, mfloat_t *m0) { + mfloat_t cofactor[MAT4_SIZE]; + mfloat_t minor[MAT3_SIZE]; + minor[0] = m0[5]; + minor[1] = m0[6]; + minor[2] = m0[7]; + minor[3] = m0[9]; + minor[4] = m0[10]; + minor[5] = m0[11]; + minor[6] = m0[13]; + minor[7] = m0[14]; + minor[8] = m0[15]; + cofactor[0] = mat3_determinant(minor); + minor[0] = m0[4]; + minor[1] = m0[6]; + minor[2] = m0[7]; + minor[3] = m0[8]; + minor[4] = m0[10]; + minor[5] = m0[11]; + minor[6] = m0[12]; + minor[7] = m0[14]; + minor[8] = m0[15]; + cofactor[1] = -mat3_determinant(minor); + minor[0] = m0[4]; + minor[1] = m0[5]; + minor[2] = m0[7]; + minor[3] = m0[8]; + minor[4] = m0[9]; + minor[5] = m0[11]; + minor[6] = m0[12]; + minor[7] = m0[13]; + minor[8] = m0[15]; + cofactor[2] = mat3_determinant(minor); + minor[0] = m0[4]; + minor[1] = m0[5]; + minor[2] = m0[6]; + minor[3] = m0[8]; + minor[4] = m0[9]; + minor[5] = m0[10]; + minor[6] = m0[12]; + minor[7] = m0[13]; + minor[8] = m0[14]; + cofactor[3] = -mat3_determinant(minor); + minor[0] = m0[1]; + minor[1] = m0[2]; + minor[2] = m0[3]; + minor[3] = m0[9]; + minor[4] = m0[10]; + minor[5] = m0[11]; + minor[6] = m0[13]; + minor[7] = m0[14]; + minor[8] = m0[15]; + cofactor[4] = -mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[2]; + minor[2] = m0[3]; + minor[3] = m0[8]; + minor[4] = m0[10]; + minor[5] = m0[11]; + minor[6] = m0[12]; + minor[7] = m0[14]; + minor[8] = m0[15]; + cofactor[5] = mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[1]; + minor[2] = m0[3]; + minor[3] = m0[8]; + minor[4] = m0[9]; + minor[5] = m0[11]; + minor[6] = m0[12]; + minor[7] = m0[13]; + minor[8] = m0[15]; + cofactor[6] = -mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[1]; + minor[2] = m0[2]; + minor[3] = m0[8]; + minor[4] = m0[9]; + minor[5] = m0[10]; + minor[6] = m0[12]; + minor[7] = m0[13]; + minor[8] = m0[14]; + cofactor[7] = mat3_determinant(minor); + minor[0] = m0[1]; + minor[1] = m0[2]; + minor[2] = m0[3]; + minor[3] = m0[5]; + minor[4] = m0[6]; + minor[5] = m0[7]; + minor[6] = m0[13]; + minor[7] = m0[14]; + minor[8] = m0[15]; + cofactor[8] = mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[2]; + minor[2] = m0[3]; + minor[3] = m0[4]; + minor[4] = m0[6]; + minor[5] = m0[7]; + minor[6] = m0[12]; + minor[7] = m0[14]; + minor[8] = m0[15]; + cofactor[9] = -mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[1]; + minor[2] = m0[3]; + minor[3] = m0[4]; + minor[4] = m0[5]; + minor[5] = m0[7]; + minor[6] = m0[12]; + minor[7] = m0[13]; + minor[8] = m0[15]; + cofactor[10] = mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[1]; + minor[2] = m0[2]; + minor[3] = m0[4]; + minor[4] = m0[5]; + minor[5] = m0[6]; + minor[6] = m0[12]; + minor[7] = m0[13]; + minor[8] = m0[14]; + cofactor[11] = -mat3_determinant(minor); + minor[0] = m0[1]; + minor[1] = m0[2]; + minor[2] = m0[3]; + minor[3] = m0[5]; + minor[4] = m0[6]; + minor[5] = m0[7]; + minor[6] = m0[9]; + minor[7] = m0[10]; + minor[8] = m0[11]; + cofactor[12] = -mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[2]; + minor[2] = m0[3]; + minor[3] = m0[4]; + minor[4] = m0[6]; + minor[5] = m0[7]; + minor[6] = m0[8]; + minor[7] = m0[10]; + minor[8] = m0[11]; + cofactor[13] = mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[1]; + minor[2] = m0[3]; + minor[3] = m0[4]; + minor[4] = m0[5]; + minor[5] = m0[7]; + minor[6] = m0[8]; + minor[7] = m0[9]; + minor[8] = m0[11]; + cofactor[14] = -mat3_determinant(minor); + minor[0] = m0[0]; + minor[1] = m0[1]; + minor[2] = m0[2]; + minor[3] = m0[4]; + minor[4] = m0[5]; + minor[5] = m0[6]; + minor[6] = m0[8]; + minor[7] = m0[9]; + minor[8] = m0[10]; + cofactor[15] = mat3_determinant(minor); + result[0] = cofactor[0]; + result[1] = cofactor[1]; + result[2] = cofactor[2]; + result[3] = cofactor[3]; + result[4] = cofactor[4]; + result[5] = cofactor[5]; + result[6] = cofactor[6]; + result[7] = cofactor[7]; + result[8] = cofactor[8]; + result[9] = cofactor[9]; + result[10] = cofactor[10]; + result[11] = cofactor[11]; + result[12] = cofactor[12]; + result[13] = cofactor[13]; + result[14] = cofactor[14]; + result[15] = cofactor[15]; + return result; +} + +mfloat_t *mat4_rotation_x(mfloat_t *result, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + result[5] = c; + result[6] = s; + result[9] = -s; + result[10] = c; + return result; +} + +mfloat_t *mat4_rotation_y(mfloat_t *result, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + result[0] = c; + result[2] = -s; + result[8] = s; + result[10] = c; + return result; +} + +mfloat_t *mat4_rotation_z(mfloat_t *result, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + result[0] = c; + result[1] = s; + result[4] = -s; + result[5] = c; + return result; +} + +mfloat_t *mat4_rotation_axis(mfloat_t *result, mfloat_t *v0, mfloat_t f) { + mfloat_t c = MCOS(f); + mfloat_t s = MSIN(f); + mfloat_t one_c = MFLOAT_C(1.0) - c; + mfloat_t x = v0[0]; + mfloat_t y = v0[1]; + mfloat_t z = v0[2]; + mfloat_t xx = x * x; + mfloat_t xy = x * y; + mfloat_t xz = x * z; + mfloat_t yy = y * y; + mfloat_t yz = y * z; + mfloat_t zz = z * z; + mfloat_t l = xx + yy + zz; + mfloat_t sqrt_l = MSQRT(l); + result[0] = (xx + (yy + zz) * c) / l; + result[1] = (xy * one_c + v0[2] * sqrt_l * s) / l; + result[2] = (xz * one_c - v0[1] * sqrt_l * s) / l; + result[3] = MFLOAT_C(0.0); + result[4] = (xy * one_c - v0[2] * sqrt_l * s) / l; + result[5] = (yy + (xx + zz) * c) / l; + result[6] = (yz * one_c + v0[0] * sqrt_l * s) / l; + result[7] = MFLOAT_C(0.0); + result[8] = (xz * one_c + v0[1] * sqrt_l * s) / l; + result[9] = (yz * one_c - v0[0] * sqrt_l * s) / l; + result[10] = (zz + (xx + yy) * c) / l; + result[11] = MFLOAT_C(0.0); + result[12] = MFLOAT_C(0.0); + result[13] = MFLOAT_C(0.0); + result[14] = MFLOAT_C(0.0); + result[15] = MFLOAT_C(1.0); + return result; +} + +mfloat_t *mat4_rotation_quat(mfloat_t *result, mfloat_t *q0) { + mfloat_t xx = q0[0] * q0[0]; + mfloat_t yy = q0[1] * q0[1]; + mfloat_t zz = q0[2] * q0[2]; + mfloat_t xy = q0[0] * q0[1]; + mfloat_t zw = q0[2] * q0[3]; + mfloat_t xz = q0[0] * q0[2]; + mfloat_t yw = q0[1] * q0[3]; + mfloat_t yz = q0[1] * q0[2]; + mfloat_t xw = q0[0] * q0[3]; + result[0] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (yy + zz); + result[1] = MFLOAT_C(2.0) * (xy + zw); + result[2] = MFLOAT_C(2.0) * (xz - yw); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(2.0) * (xy - zw); + result[5] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (xx + zz); + result[6] = MFLOAT_C(2.0) * (yz + xw); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(2.0) * (xz + yw); + result[9] = MFLOAT_C(2.0) * (yz - xw); + result[10] = MFLOAT_C(1.0) - MFLOAT_C(2.0) * (xx + yy); + result[11] = MFLOAT_C(0.0); + result[12] = MFLOAT_C(0.0); + result[13] = MFLOAT_C(0.0); + result[14] = MFLOAT_C(0.0); + result[15] = MFLOAT_C(1.0); + return result; +} + +mfloat_t *mat4_translation(mfloat_t *result, mfloat_t *m0, mfloat_t *v0) { + result[0] = m0[0]; + result[1] = m0[1]; + result[2] = m0[2]; + result[3] = m0[3]; + result[4] = m0[4]; + result[5] = m0[5]; + result[6] = m0[6]; + result[7] = m0[7]; + result[8] = m0[8]; + result[9] = m0[9]; + result[10] = m0[10]; + result[11] = m0[11]; + result[12] = v0[0]; + result[13] = v0[1]; + result[14] = v0[2]; + result[15] = m0[15]; + return result; +} + +mfloat_t *mat4_translate(mfloat_t *result, mfloat_t *m0, mfloat_t *v0) { + result[0] = m0[0]; + result[1] = m0[1]; + result[2] = m0[2]; + result[3] = m0[3]; + result[4] = m0[4]; + result[5] = m0[5]; + result[6] = m0[6]; + result[7] = m0[7]; + result[8] = m0[8]; + result[9] = m0[9]; + result[10] = m0[10]; + result[11] = m0[11]; + result[12] = m0[12] + v0[0]; + result[13] = m0[13] + v0[1]; + result[14] = m0[14] + v0[2]; + result[15] = m0[15]; + return result; +} + +mfloat_t *mat4_translate_vec2(mfloat_t *mat4, mfloat_t *vec2) { + mat4[12] += vec2[0]; + mat4[13] += vec2[1]; + return mat4; +} + +mfloat_t *mat4_translate_vec3(mfloat_t *mat4, mfloat_t *vec3) { + mat4[12] += vec3[0]; + mat4[13] += vec3[1]; + mat4[14] += vec3[2]; + return mat4; +} + +mfloat_t *mat4_scaling(mfloat_t *result, mfloat_t *m0, mfloat_t *v0) { + result[0] = v0[0]; + result[1] = m0[1]; + result[2] = m0[2]; + result[3] = m0[3]; + result[4] = m0[4]; + result[5] = v0[1]; + result[6] = m0[6]; + result[7] = m0[7]; + result[8] = m0[8]; + result[9] = m0[9]; + result[10] = v0[2]; + result[11] = m0[11]; + result[12] = m0[12]; + result[13] = m0[13]; + result[14] = m0[14]; + result[15] = m0[15]; + return result; +} + +mfloat_t *mat4_scale(mfloat_t *result, mfloat_t *m0, mfloat_t *v0) { + result[0] = m0[0] * v0[0]; + result[1] = m0[1]; + result[2] = m0[2]; + result[3] = m0[3]; + result[4] = m0[4]; + result[5] = m0[5] * v0[1]; + result[6] = m0[6]; + result[7] = m0[7]; + result[8] = m0[8]; + result[9] = m0[9]; + result[10] = m0[10] * v0[2]; + result[11] = m0[11]; + result[12] = m0[12]; + result[13] = m0[13]; + result[14] = m0[14]; + result[15] = m0[15]; + return result; +} + +mfloat_t *mat4_scale_vec2(mfloat_t *mat4, mfloat_t *vec2) { + mat4[0] *= vec2[0]; + mat4[5] *= vec2[1]; + return mat4; +} + +mfloat_t *mat4_scale_vec2f(mfloat_t *mat4, mfloat_t f) { + mat4[0] *= f; + mat4[5] *= f; + return mat4; +} + +mfloat_t *mat4_scale_vec3(mfloat_t *mat4, mfloat_t *vec3) { + mat4[0] *= vec3[0]; + mat4[5] *= vec3[1]; + mat4[10] *= vec3[2]; + return mat4; +} + +mfloat_t *mat4_scale_vec3f(mfloat_t *mat4, mfloat_t f) { + mat4[0] *= f; + mat4[5] *= f; + mat4[10] *= f; + return mat4; +} + +mfloat_t *mat4_multiply(mfloat_t *result, mfloat_t *m0, mfloat_t *m1) { + mfloat_t multiplied[MAT4_SIZE]; + multiplied[0] = + m0[0] * m1[0] + m0[4] * m1[1] + m0[8] * m1[2] + m0[12] * m1[3]; + multiplied[1] = + m0[1] * m1[0] + m0[5] * m1[1] + m0[9] * m1[2] + m0[13] * m1[3]; + multiplied[2] = + m0[2] * m1[0] + m0[6] * m1[1] + m0[10] * m1[2] + m0[14] * m1[3]; + multiplied[3] = + m0[3] * m1[0] + m0[7] * m1[1] + m0[11] * m1[2] + m0[15] * m1[3]; + multiplied[4] = + m0[0] * m1[4] + m0[4] * m1[5] + m0[8] * m1[6] + m0[12] * m1[7]; + multiplied[5] = + m0[1] * m1[4] + m0[5] * m1[5] + m0[9] * m1[6] + m0[13] * m1[7]; + multiplied[6] = + m0[2] * m1[4] + m0[6] * m1[5] + m0[10] * m1[6] + m0[14] * m1[7]; + multiplied[7] = + m0[3] * m1[4] + m0[7] * m1[5] + m0[11] * m1[6] + m0[15] * m1[7]; + multiplied[8] = + m0[0] * m1[8] + m0[4] * m1[9] + m0[8] * m1[10] + m0[12] * m1[11]; + multiplied[9] = + m0[1] * m1[8] + m0[5] * m1[9] + m0[9] * m1[10] + m0[13] * m1[11]; + multiplied[10] = + m0[2] * m1[8] + m0[6] * m1[9] + m0[10] * m1[10] + m0[14] * m1[11]; + multiplied[11] = + m0[3] * m1[8] + m0[7] * m1[9] + m0[11] * m1[10] + m0[15] * m1[11]; + multiplied[12] = + m0[0] * m1[12] + m0[4] * m1[13] + m0[8] * m1[14] + m0[12] * m1[15]; + multiplied[13] = + m0[1] * m1[12] + m0[5] * m1[13] + m0[9] * m1[14] + m0[13] * m1[15]; + multiplied[14] = + m0[2] * m1[12] + m0[6] * m1[13] + m0[10] * m1[14] + + m0[14] * m1[15]; + multiplied[15] = + m0[3] * m1[12] + m0[7] * m1[13] + m0[11] * m1[14] + + m0[15] * m1[15]; + result[0] = multiplied[0]; + result[1] = multiplied[1]; + result[2] = multiplied[2]; + result[3] = multiplied[3]; + result[4] = multiplied[4]; + result[5] = multiplied[5]; + result[6] = multiplied[6]; + result[7] = multiplied[7]; + result[8] = multiplied[8]; + result[9] = multiplied[9]; + result[10] = multiplied[10]; + result[11] = multiplied[11]; + result[12] = multiplied[12]; + result[13] = multiplied[13]; + result[14] = multiplied[14]; + result[15] = multiplied[15]; + return result; +} + +mfloat_t *mat4_multiply_f(mfloat_t *result, mfloat_t *m0, mfloat_t f) { + result[0] = m0[0] * f; + result[1] = m0[1] * f; + result[2] = m0[2] * f; + result[3] = m0[3] * f; + result[4] = m0[4] * f; + result[5] = m0[5] * f; + result[6] = m0[6] * f; + result[7] = m0[7] * f; + result[8] = m0[8] * f; + result[9] = m0[9] * f; + result[10] = m0[10] * f; + result[11] = m0[11] * f; + result[12] = m0[12] * f; + result[13] = m0[13] * f; + result[14] = m0[14] * f; + result[15] = m0[15] * f; + return result; +} + +mfloat_t *mat4_inverse(mfloat_t *result, mfloat_t *m0) { + mfloat_t inverse[MAT4_SIZE]; + mfloat_t inverted_determinant; + mfloat_t m11 = m0[0]; + mfloat_t m21 = m0[1]; + mfloat_t m31 = m0[2]; + mfloat_t m41 = m0[3]; + mfloat_t m12 = m0[4]; + mfloat_t m22 = m0[5]; + mfloat_t m32 = m0[6]; + mfloat_t m42 = m0[7]; + mfloat_t m13 = m0[8]; + mfloat_t m23 = m0[9]; + mfloat_t m33 = m0[10]; + mfloat_t m43 = m0[11]; + mfloat_t m14 = m0[12]; + mfloat_t m24 = m0[13]; + mfloat_t m34 = m0[14]; + mfloat_t m44 = m0[15]; + inverse[0] = m22 * m33 * m44 - m22 * m43 * m34 - m23 * m32 * m44 + m23 * m42 * m34 + m24 * m32 * m43 - m24 * m42 * m33; + inverse[4] = -m12 * m33 * m44 + m12 * m43 * m34 + m13 * m32 * m44 - m13 * m42 * m34 - m14 * m32 * m43 + m14 * m42 * m33; + inverse[8] = m12 * m23 * m44 - m12 * m43 * m24 - m13 * m22 * m44 + m13 * m42 * m24 + m14 * m22 * m43 - m14 * m42 * m23; + inverse[12] = -m12 * m23 * m34 + m12 * m33 * m24 + m13 * m22 * m34 - m13 * m32 * m24 - m14 * m22 * m33 + m14 * m32 * m23; + inverse[1] = -m21 * m33 * m44 + m21 * m43 * m34 + m23 * m31 * m44 - m23 * m41 * m34 - m24 * m31 * m43 + m24 * m41 * m33; + inverse[5] = m11 * m33 * m44 - m11 * m43 * m34 - m13 * m31 * m44 + m13 * m41 * m34 + m14 * m31 * m43 - m14 * m41 * m33; + inverse[9] = -m11 * m23 * m44 + m11 * m43 * m24 + m13 * m21 * m44 - m13 * m41 * m24 - m14 * m21 * m43 + m14 * m41 * m23; + inverse[13] = m11 * m23 * m34 - m11 * m33 * m24 - m13 * m21 * m34 + m13 * m31 * m24 + m14 * m21 * m33 - m14 * m31 * m23; + inverse[2] = m21 * m32 * m44 - m21 * m42 * m34 - m22 * m31 * m44 + m22 * m41 * m34 + m24 * m31 * m42 - m24 * m41 * m32; + inverse[6] = -m11 * m32 * m44 + m11 * m42 * m34 + m12 * m31 * m44 - m12 * m41 * m34 - m14 * m31 * m42 + m14 * m41 * m32; + inverse[10] = m11 * m22 * m44 - m11 * m42 * m24 - m12 * m21 * m44 + m12 * m41 * m24 + m14 * m21 * m42 - m14 * m41 * m22; + inverse[14] = -m11 * m22 * m34 + m11 * m32 * m24 + m12 * m21 * m34 - m12 * m31 * m24 - m14 * m21 * m32 + m14 * m31 * m22; + inverse[3] = -m21 * m32 * m43 + m21 * m42 * m33 + m22 * m31 * m43 - m22 * m41 * m33 - m23 * m31 * m42 + m23 * m41 * m32; + inverse[7] = m11 * m32 * m43 - m11 * m42 * m33 - m12 * m31 * m43 + m12 * m41 * m33 + m13 * m31 * m42 - m13 * m41 * m32; + inverse[11] = -m11 * m22 * m43 + m11 * m42 * m23 + m12 * m21 * m43 - m12 * m41 * m23 - m13 * m21 * m42 + m13 * m41 * m22; + inverse[15] = m11 * m22 * m33 - m11 * m32 * m23 - m12 * m21 * m33 + m12 * m31 * m23 + m13 * m21 * m32 - m13 * m31 * m22; + inverted_determinant = + MFLOAT_C(1.0) / (m11 * inverse[0] + m21 * inverse[4] + + m31 * inverse[8] + m41 * inverse[12]); + result[0] = inverse[0] * inverted_determinant; + result[1] = inverse[1] * inverted_determinant; + result[2] = inverse[2] * inverted_determinant; + result[3] = inverse[3] * inverted_determinant; + result[4] = inverse[4] * inverted_determinant; + result[5] = inverse[5] * inverted_determinant; + result[6] = inverse[6] * inverted_determinant; + result[7] = inverse[7] * inverted_determinant; + result[8] = inverse[8] * inverted_determinant; + result[9] = inverse[9] * inverted_determinant; + result[10] = inverse[10] * inverted_determinant; + result[11] = inverse[11] * inverted_determinant; + result[12] = inverse[12] * inverted_determinant; + result[13] = inverse[13] * inverted_determinant; + result[14] = inverse[14] * inverted_determinant; + result[15] = inverse[15] * inverted_determinant; + return result; +} + +mfloat_t *mat4_lerp(mfloat_t *result, mfloat_t *m0, mfloat_t *m1, + mfloat_t f) { + result[0] = m0[0] + (m1[0] - m0[0]) * f; + result[1] = m0[1] + (m1[1] - m0[1]) * f; + result[2] = m0[2] + (m1[2] - m0[2]) * f; + result[3] = m0[3] + (m1[3] - m0[3]) * f; + result[4] = m0[4] + (m1[4] - m0[4]) * f; + result[5] = m0[5] + (m1[5] - m0[5]) * f; + result[6] = m0[6] + (m1[6] - m0[6]) * f; + result[7] = m0[7] + (m1[7] - m0[7]) * f; + result[8] = m0[8] + (m1[8] - m0[8]) * f; + result[9] = m0[9] + (m1[9] - m0[9]) * f; + result[10] = m0[10] + (m1[10] - m0[10]) * f; + result[11] = m0[11] + (m1[11] - m0[11]) * f; + result[12] = m0[12] + (m1[12] - m0[12]) * f; + result[13] = m0[13] + (m1[13] - m0[13]) * f; + result[14] = m0[14] + (m1[14] - m0[14]) * f; + result[15] = m0[15] + (m1[15] - m0[15]) * f; + return result; +} + +mfloat_t *mat4_look_at(mfloat_t *result, const mfloat_t *position, + const mfloat_t *target, const mfloat_t *up) { + mfloat_t tmp_forward[VEC3_SIZE] = {0.f}; + mfloat_t tmp_side[VEC3_SIZE] = {0.f}; + mfloat_t tmp_up[VEC3_SIZE] = {0.f}; + vec3_subtract(tmp_forward, target, position); + vec3_normalize(tmp_forward, tmp_forward); + vec3_cross(tmp_side, tmp_forward, up); + vec3_normalize(tmp_side, tmp_side); + vec3_cross(tmp_up, tmp_side, tmp_forward); + result[0] = tmp_side[0]; + result[1] = tmp_up[0]; + result[2] = -tmp_forward[0]; + result[3] = MFLOAT_C(0.0); + result[4] = tmp_side[1]; + result[5] = tmp_up[1]; + result[6] = -tmp_forward[1]; + result[7] = MFLOAT_C(0.0); + result[8] = tmp_side[2]; + result[9] = tmp_up[2]; + result[10] = -tmp_forward[2]; + result[11] = MFLOAT_C(0.0); + result[12] = -vec3_dot(tmp_side, position); + result[13] = -vec3_dot(tmp_up, position); + result[14] = vec3_dot(tmp_forward, position); + result[15] = MFLOAT_C(1.0); + return result; +} + +mfloat_t *mat4_ortho(mfloat_t *result, mfloat_t l, mfloat_t r, mfloat_t b, + mfloat_t t, mfloat_t n, mfloat_t f) { + result[0] = MFLOAT_C(2.0) / (r - l); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(0.0); + result[5] = MFLOAT_C(2.0) / (t - b); + result[6] = MFLOAT_C(0.0); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(0.0); + result[9] = MFLOAT_C(0.0); + result[10] = -MFLOAT_C(2.0) / (f - n); + result[11] = MFLOAT_C(0.0); + result[12] = -((r + l) / (r - l)); + result[13] = -((t + b) / (t - b)); + result[14] = -((f + n) / (f - n)); + result[15] = MFLOAT_C(1.0); + return result; +} + +mfloat_t *mat4_perspective(mfloat_t *result, mfloat_t fov_y, + mfloat_t aspect, mfloat_t n, mfloat_t f) { + mfloat_t tan_half_fov_y = MFLOAT_C(1.0) / MTAN(fov_y * MFLOAT_C(0.5)); + result[0] = MFLOAT_C(1.0) / aspect * tan_half_fov_y; + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(0.0); + result[5] = MFLOAT_C(1.0) / tan_half_fov_y; + result[6] = MFLOAT_C(0.0); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(0.0); + result[9] = MFLOAT_C(0.0); + result[10] = f / (n - f); + result[11] = -MFLOAT_C(1.0); + result[12] = MFLOAT_C(0.0); + result[13] = MFLOAT_C(0.0); + result[14] = -(f * n) / (f - n); + result[15] = MFLOAT_C(0.0); + return result; +} + +mfloat_t *mat4_perspective_fov(mfloat_t *result, mfloat_t fov, mfloat_t w, + mfloat_t h, mfloat_t n, mfloat_t f) { + mfloat_t h2 = MCOS(fov * MFLOAT_C(0.5)) / MSIN(fov * MFLOAT_C(0.5)); + mfloat_t w2 = h2 * h / w; + result[0] = w2; + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(0.0); + result[5] = h2; + result[6] = MFLOAT_C(0.0); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(0.0); + result[9] = MFLOAT_C(0.0); + result[10] = f / (n - f); + result[11] = -MFLOAT_C(1.0); + result[12] = MFLOAT_C(0.0); + result[13] = MFLOAT_C(0.0); + result[14] = -(f * n) / (f - n); + result[15] = MFLOAT_C(0.0); + return result; +} + +mfloat_t *mat4_perspective_infinite(mfloat_t *result, mfloat_t fov_y, + mfloat_t aspect, mfloat_t n) { + mfloat_t range = MTAN(fov_y * MFLOAT_C(0.5)) * n; + mfloat_t left = -range * aspect; + mfloat_t right = range * aspect; + mfloat_t top = range; + mfloat_t bottom = -range; + result[0] = MFLOAT_C(2.0) * n / (right - left); + result[1] = MFLOAT_C(0.0); + result[2] = MFLOAT_C(0.0); + result[3] = MFLOAT_C(0.0); + result[4] = MFLOAT_C(0.0); + result[5] = MFLOAT_C(2.0) * n / (top - bottom); + result[6] = MFLOAT_C(0.0); + result[7] = MFLOAT_C(0.0); + result[8] = MFLOAT_C(0.0); + result[9] = MFLOAT_C(0.0); + result[10] = -MFLOAT_C(1.0); + result[11] = -MFLOAT_C(1.0); + result[12] = MFLOAT_C(0.0); + result[13] = MFLOAT_C(0.0); + result[14] = -MFLOAT_C(2.0) * n; + result[15] = MFLOAT_C(0.0); + return result; } #endif #if defined(MATHC_USE_STRUCT_FUNCTIONS) #if defined(MATHC_USE_INT) -bool svec2i_is_zero(struct vec2i v0) -{ - return vec2i_is_zero((mint_t *) & v0); +bool svec2i_is_zero(struct vec2i v0) { + return vec2i_is_zero((mint_t *)&v0); } -bool svec2i_is_equal(struct vec2i v0, struct vec2i v1) -{ - return vec2i_is_equal((mint_t *) & v0, (mint_t *) & v1); +bool svec2i_is_equal(struct vec2i v0, struct vec2i v1) { + return vec2i_is_equal((mint_t *)&v0, (mint_t *)&v1); } -struct vec2i svec2i(mint_t x, mint_t y) -{ - struct vec2i result; - vec2i((mint_t *) & result, x, y); - return result; +struct vec2i svec2i(mint_t x, mint_t y) { + struct vec2i result; + vec2i((mint_t *)&result, x, y); + return result; } -struct vec2i svec2i_assign(struct vec2i v0) -{ - struct vec2i result; - vec2i_assign((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec2i svec2i_assign(struct vec2i v0) { + struct vec2i result; + vec2i_assign((mint_t *)&result, (mint_t *)&v0); + return result; } #if defined(MATHC_USE_FLOATING_POINT) -struct vec2i svec2i_assign_vec2(struct vec2 v0) -{ - struct vec2i result; - vec2i_assign_vec2((mint_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2i svec2i_assign_vec2(struct vec2 v0) { + struct vec2i result; + vec2i_assign_vec2((mint_t *)&result, (mfloat_t *)&v0); + return result; } #endif -struct vec2i svec2i_zero(void) -{ - struct vec2i result; - vec2i_zero((mint_t *) & result); - return result; +struct vec2i svec2i_zero(void) { + struct vec2i result; + vec2i_zero((mint_t *)&result); + return result; } -struct vec2i svec2i_one(void) -{ - struct vec2i result; - vec2i_one((mint_t *) & result); - return result; +struct vec2i svec2i_one(void) { + struct vec2i result; + vec2i_one((mint_t *)&result); + return result; } -struct vec2i svec2i_sign(struct vec2i v0) -{ - struct vec2i result; - vec2i_sign((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec2i svec2i_sign(struct vec2i v0) { + struct vec2i result; + vec2i_sign((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec2i svec2i_add(struct vec2i v0, struct vec2i v1) -{ - struct vec2i result; - vec2i_add((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec2i svec2i_add(struct vec2i v0, struct vec2i v1) { + struct vec2i result; + vec2i_add((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec2i svec2i_add_i(struct vec2i v0, mint_t i) -{ - struct vec2i result; - vec2i_add_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec2i svec2i_add_i(struct vec2i v0, mint_t i) { + struct vec2i result; + vec2i_add_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec2i svec2i_subtract(struct vec2i v0, struct vec2i v1) -{ - struct vec2i result; - vec2i_subtract((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec2i svec2i_subtract(struct vec2i v0, struct vec2i v1) { + struct vec2i result; + vec2i_subtract((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec2i svec2i_subtract_i(struct vec2i v0, mint_t i) -{ - struct vec2i result; - vec2i_subtract_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec2i svec2i_subtract_i(struct vec2i v0, mint_t i) { + struct vec2i result; + vec2i_subtract_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec2i svec2i_multiply(struct vec2i v0, struct vec2i v1) -{ - struct vec2i result; - vec2i_multiply((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec2i svec2i_multiply(struct vec2i v0, struct vec2i v1) { + struct vec2i result; + vec2i_multiply((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec2i svec2i_multiply_i(struct vec2i v0, mint_t i) -{ - struct vec2i result; - vec2i_multiply_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec2i svec2i_multiply_i(struct vec2i v0, mint_t i) { + struct vec2i result; + vec2i_multiply_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec2i svec2i_divide(struct vec2i v0, struct vec2i v1) -{ - struct vec2i result; - vec2i_divide((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec2i svec2i_divide(struct vec2i v0, struct vec2i v1) { + struct vec2i result; + vec2i_divide((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec2i svec2i_divide_i(struct vec2i v0, mint_t i) -{ - struct vec2i result; - vec2i_divide_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec2i svec2i_divide_i(struct vec2i v0, mint_t i) { + struct vec2i result; + vec2i_divide_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec2i svec2i_snap(struct vec2i v0, struct vec2i v1) -{ - struct vec2i result; - vec2i_snap((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec2i svec2i_snap(struct vec2i v0, struct vec2i v1) { + struct vec2i result; + vec2i_snap((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec2i svec2i_snap_i(struct vec2i v0, mint_t i) -{ - struct vec2i result; - vec2i_snap_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec2i svec2i_snap_i(struct vec2i v0, mint_t i) { + struct vec2i result; + vec2i_snap_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec2i svec2i_negative(struct vec2i v0) -{ - struct vec2i result; - vec2i_negative((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec2i svec2i_negative(struct vec2i v0) { + struct vec2i result; + vec2i_negative((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec2i svec2i_abs(struct vec2i v0) -{ - struct vec2i result; - vec2i_abs((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec2i svec2i_abs(struct vec2i v0) { + struct vec2i result; + vec2i_abs((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec2i svec2i_max(struct vec2i v0, struct vec2i v1) -{ - struct vec2i result; - vec2i_max((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec2i svec2i_max(struct vec2i v0, struct vec2i v1) { + struct vec2i result; + vec2i_max((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec2i svec2i_min(struct vec2i v0, struct vec2i v1) -{ - struct vec2i result; - vec2i_min((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec2i svec2i_min(struct vec2i v0, struct vec2i v1) { + struct vec2i result; + vec2i_min((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } struct vec2i svec2i_clamp(struct vec2i v0, struct vec2i v1, - struct vec2i v2) -{ - struct vec2i result; - vec2i_clamp((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1, - (mint_t *) & v2); - return result; + struct vec2i v2) { + struct vec2i result; + vec2i_clamp((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1, + (mint_t *)&v2); + return result; } -struct vec2i svec2i_tangent(struct vec2i v0) -{ - struct vec2i result; - vec2i_tangent((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec2i svec2i_tangent(struct vec2i v0) { + struct vec2i result; + vec2i_tangent((mint_t *)&result, (mint_t *)&v0); + return result; } -bool svec3i_is_zero(struct vec3i v0) -{ - return vec3i_is_zero((mint_t *) & v0); +bool svec3i_is_zero(struct vec3i v0) { + return vec3i_is_zero((mint_t *)&v0); } -bool svec3i_is_equal(struct vec3i v0, struct vec3i v1) -{ - return vec3i_is_equal((mint_t *) & v0, (mint_t *) & v1); +bool svec3i_is_equal(struct vec3i v0, struct vec3i v1) { + return vec3i_is_equal((mint_t *)&v0, (mint_t *)&v1); } -struct vec3i svec3i(mint_t x, mint_t y, mint_t z) -{ - struct vec3i result; - vec3i((mint_t *) & result, x, y, z); - return result; +struct vec3i svec3i(mint_t x, mint_t y, mint_t z) { + struct vec3i result; + vec3i((mint_t *)&result, x, y, z); + return result; } -struct vec3i svec3i_assign(struct vec3i v0) -{ - struct vec3i result; - vec3i_assign((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec3i svec3i_assign(struct vec3i v0) { + struct vec3i result; + vec3i_assign((mint_t *)&result, (mint_t *)&v0); + return result; } #if defined(MATHC_USE_FLOATING_POINT) -struct vec3i svec3i_assign_vec3(struct vec3 v0) -{ - struct vec3i result; - vec3i_assign_vec3((mint_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3i svec3i_assign_vec3(struct vec3 v0) { + struct vec3i result; + vec3i_assign_vec3((mint_t *)&result, (mfloat_t *)&v0); + return result; } #endif -struct vec3i svec3i_zero(void) -{ - struct vec3i result; - vec3i_zero((mint_t *) & result); - return result; +struct vec3i svec3i_zero(void) { + struct vec3i result; + vec3i_zero((mint_t *)&result); + return result; } -struct vec3i svec3i_one(void) -{ - struct vec3i result; - vec3i_one((mint_t *) & result); - return result; +struct vec3i svec3i_one(void) { + struct vec3i result; + vec3i_one((mint_t *)&result); + return result; } -struct vec3i svec3i_sign(struct vec3i v0) -{ - struct vec3i result; - vec3i_sign((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec3i svec3i_sign(struct vec3i v0) { + struct vec3i result; + vec3i_sign((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec3i svec3i_add(struct vec3i v0, struct vec3i v1) -{ - struct vec3i result; - vec3i_add((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec3i svec3i_add(struct vec3i v0, struct vec3i v1) { + struct vec3i result; + vec3i_add((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec3i svec3i_add_i(struct vec3i v0, mint_t i) -{ - struct vec3i result; - vec3i_add_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec3i svec3i_add_i(struct vec3i v0, mint_t i) { + struct vec3i result; + vec3i_add_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec3i svec3i_subtract(struct vec3i v0, struct vec3i v1) -{ - struct vec3i result; - vec3i_subtract((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec3i svec3i_subtract(struct vec3i v0, struct vec3i v1) { + struct vec3i result; + vec3i_subtract((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec3i svec3i_subtract_i(struct vec3i v0, mint_t i) -{ - struct vec3i result; - vec3i_subtract_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec3i svec3i_subtract_i(struct vec3i v0, mint_t i) { + struct vec3i result; + vec3i_subtract_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec3i svec3i_multiply(struct vec3i v0, struct vec3i v1) -{ - struct vec3i result; - vec3i_multiply((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec3i svec3i_multiply(struct vec3i v0, struct vec3i v1) { + struct vec3i result; + vec3i_multiply((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec3i svec3i_multiply_i(struct vec3i v0, mint_t i) -{ - struct vec3i result; - vec3i_multiply_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec3i svec3i_multiply_i(struct vec3i v0, mint_t i) { + struct vec3i result; + vec3i_multiply_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec3i svec3i_divide(struct vec3i v0, struct vec3i v1) -{ - struct vec3i result; - vec3i_divide((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec3i svec3i_divide(struct vec3i v0, struct vec3i v1) { + struct vec3i result; + vec3i_divide((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec3i svec3i_divide_i(struct vec3i v0, mint_t i) -{ - struct vec3i result; - vec3i_divide_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec3i svec3i_divide_i(struct vec3i v0, mint_t i) { + struct vec3i result; + vec3i_divide_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec3i svec3i_snap(struct vec3i v0, struct vec3i v1) -{ - struct vec3i result; - vec3i_snap((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec3i svec3i_snap(struct vec3i v0, struct vec3i v1) { + struct vec3i result; + vec3i_snap((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec3i svec3i_snap_i(struct vec3i v0, mint_t i) -{ - struct vec3i result; - vec3i_snap_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec3i svec3i_snap_i(struct vec3i v0, mint_t i) { + struct vec3i result; + vec3i_snap_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec3i svec3i_cross(struct vec3i v0, struct vec3i v1) -{ - struct vec3i result; - vec3i_cross((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec3i svec3i_cross(struct vec3i v0, struct vec3i v1) { + struct vec3i result; + vec3i_cross((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec3i svec3i_negative(struct vec3i v0) -{ - struct vec3i result; - vec3i_negative((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec3i svec3i_negative(struct vec3i v0) { + struct vec3i result; + vec3i_negative((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec3i svec3i_abs(struct vec3i v0) -{ - struct vec3i result; - vec3i_abs((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec3i svec3i_abs(struct vec3i v0) { + struct vec3i result; + vec3i_abs((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec3i svec3i_max(struct vec3i v0, struct vec3i v1) -{ - struct vec3i result; - vec3i_max((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec3i svec3i_max(struct vec3i v0, struct vec3i v1) { + struct vec3i result; + vec3i_max((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec3i svec3i_min(struct vec3i v0, struct vec3i v1) -{ - struct vec3i result; - vec3i_min((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec3i svec3i_min(struct vec3i v0, struct vec3i v1) { + struct vec3i result; + vec3i_min((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } struct vec3i svec3i_clamp(struct vec3i v0, struct vec3i v1, - struct vec3i v2) -{ - struct vec3i result; - vec3i_clamp((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1, - (mint_t *) & v2); - return result; + struct vec3i v2) { + struct vec3i result; + vec3i_clamp((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1, + (mint_t *)&v2); + return result; } -bool svec4i_is_zero(struct vec4i v0) -{ - return vec4i_is_zero((mint_t *) & v0); +bool svec4i_is_zero(struct vec4i v0) { + return vec4i_is_zero((mint_t *)&v0); } -bool svec4i_is_equal(struct vec4i v0, struct vec4i v1) -{ - return vec4i_is_equal((mint_t *) & v0, (mint_t *) & v1); +bool svec4i_is_equal(struct vec4i v0, struct vec4i v1) { + return vec4i_is_equal((mint_t *)&v0, (mint_t *)&v1); } -struct vec4i svec4i(mint_t x, mint_t y, mint_t z, mint_t w) -{ - struct vec4i result; - vec4i((mint_t *) & result, x, y, z, w); - return result; +struct vec4i svec4i(mint_t x, mint_t y, mint_t z, mint_t w) { + struct vec4i result; + vec4i((mint_t *)&result, x, y, z, w); + return result; } -struct vec4i svec4i_assign(struct vec4i v0) -{ - struct vec4i result; - vec4i_assign((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec4i svec4i_assign(struct vec4i v0) { + struct vec4i result; + vec4i_assign((mint_t *)&result, (mint_t *)&v0); + return result; } #if defined(MATHC_USE_FLOATING_POINT) -struct vec4i svec4i_assign_vec4(struct vec4 v0) -{ - struct vec4i result; - vec4i_assign_vec4((mint_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4i svec4i_assign_vec4(struct vec4 v0) { + struct vec4i result; + vec4i_assign_vec4((mint_t *)&result, (mfloat_t *)&v0); + return result; } #endif -struct vec4i svec4i_zero(void) -{ - struct vec4i result; - vec4i_zero((mint_t *) & result); - return result; +struct vec4i svec4i_zero(void) { + struct vec4i result; + vec4i_zero((mint_t *)&result); + return result; } -struct vec4i svec4i_one(void) -{ - struct vec4i result; - vec4i_one((mint_t *) & result); - return result; +struct vec4i svec4i_one(void) { + struct vec4i result; + vec4i_one((mint_t *)&result); + return result; } -struct vec4i svec4i_sign(struct vec4i v0) -{ - struct vec4i result; - vec4i_sign((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec4i svec4i_sign(struct vec4i v0) { + struct vec4i result; + vec4i_sign((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec4i svec4i_add(struct vec4i v0, struct vec4i v1) -{ - struct vec4i result; - vec4i_add((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec4i svec4i_add(struct vec4i v0, struct vec4i v1) { + struct vec4i result; + vec4i_add((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec4i svec4i_add_i(struct vec4i v0, mint_t i) -{ - struct vec4i result; - vec4i_add_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec4i svec4i_add_i(struct vec4i v0, mint_t i) { + struct vec4i result; + vec4i_add_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec4i svec4i_subtract(struct vec4i v0, struct vec4i v1) -{ - struct vec4i result; - vec4i_subtract((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec4i svec4i_subtract(struct vec4i v0, struct vec4i v1) { + struct vec4i result; + vec4i_subtract((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec4i svec4i_subtract_i(struct vec4i v0, mint_t i) -{ - struct vec4i result; - vec4i_subtract_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec4i svec4i_subtract_i(struct vec4i v0, mint_t i) { + struct vec4i result; + vec4i_subtract_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec4i svec4i_multiply(struct vec4i v0, struct vec4i v1) -{ - struct vec4i result; - vec4i_multiply((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec4i svec4i_multiply(struct vec4i v0, struct vec4i v1) { + struct vec4i result; + vec4i_multiply((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec4i svec4i_multiply_i(struct vec4i v0, mint_t i) -{ - struct vec4i result; - vec4i_multiply_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec4i svec4i_multiply_i(struct vec4i v0, mint_t i) { + struct vec4i result; + vec4i_multiply_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec4i svec4i_divide(struct vec4i v0, struct vec4i v1) -{ - struct vec4i result; - vec4i_divide((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec4i svec4i_divide(struct vec4i v0, struct vec4i v1) { + struct vec4i result; + vec4i_divide((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec4i svec4i_divide_i(struct vec4i v0, mint_t i) -{ - struct vec4i result; - vec4i_divide_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec4i svec4i_divide_i(struct vec4i v0, mint_t i) { + struct vec4i result; + vec4i_divide_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec4i svec4i_snap(struct vec4i v0, struct vec4i v1) -{ - struct vec4i result; - vec4i_snap((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec4i svec4i_snap(struct vec4i v0, struct vec4i v1) { + struct vec4i result; + vec4i_snap((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec4i svec4i_snap_i(struct vec4i v0, mint_t i) -{ - struct vec4i result; - vec4i_snap_i((mint_t *) & result, (mint_t *) & v0, i); - return result; +struct vec4i svec4i_snap_i(struct vec4i v0, mint_t i) { + struct vec4i result; + vec4i_snap_i((mint_t *)&result, (mint_t *)&v0, i); + return result; } -struct vec4i svec4i_negative(struct vec4i v0) -{ - struct vec4i result; - vec4i_negative((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec4i svec4i_negative(struct vec4i v0) { + struct vec4i result; + vec4i_negative((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec4i svec4i_abs(struct vec4i v0) -{ - struct vec4i result; - vec4i_abs((mint_t *) & result, (mint_t *) & v0); - return result; +struct vec4i svec4i_abs(struct vec4i v0) { + struct vec4i result; + vec4i_abs((mint_t *)&result, (mint_t *)&v0); + return result; } -struct vec4i svec4i_max(struct vec4i v0, struct vec4i v1) -{ - struct vec4i result; - vec4i_max((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec4i svec4i_max(struct vec4i v0, struct vec4i v1) { + struct vec4i result; + vec4i_max((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } -struct vec4i svec4i_min(struct vec4i v0, struct vec4i v1) -{ - struct vec4i result; - vec4i_min((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1); - return result; +struct vec4i svec4i_min(struct vec4i v0, struct vec4i v1) { + struct vec4i result; + vec4i_min((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1); + return result; } struct vec4i svec4i_clamp(struct vec4i v0, struct vec4i v1, - struct vec4i v2) -{ - struct vec4i result; - vec4i_clamp((mint_t *) & result, (mint_t *) & v0, (mint_t *) & v1, - (mint_t *) & v2); - return result; + struct vec4i v2) { + struct vec4i result; + vec4i_clamp((mint_t *)&result, (mint_t *)&v0, (mint_t *)&v1, + (mint_t *)&v2); + return result; } #endif #if defined(MATHC_USE_FLOATING_POINT) -bool svec2_is_zero(struct vec2 v0) -{ - return vec2_is_zero((mfloat_t *) & v0); +bool svec2_is_zero(struct vec2 v0) { + return vec2_is_zero((mfloat_t *)&v0); } -bool svec2_is_equal(struct vec2 v0, struct vec2 v1) -{ - return vec2_is_equal((mfloat_t *) & v0, (mfloat_t *) & v1); +bool svec2_is_equal(struct vec2 v0, struct vec2 v1) { + return vec2_is_equal((mfloat_t *)&v0, (mfloat_t *)&v1); } -struct vec2 svec2(mfloat_t x, mfloat_t y) -{ - struct vec2 result; - vec2((mfloat_t *) & result, x, y); - return result; +struct vec2 svec2(mfloat_t x, mfloat_t y) { + struct vec2 result; + vec2((mfloat_t *)&result, x, y); + return result; } -struct vec2 svec2_assign(struct vec2 v0) -{ - struct vec2 result; - vec2_assign((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_assign(struct vec2 v0) { + struct vec2 result; + vec2_assign((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } #if defined(MATHC_USE_INT) -struct vec2 svec2_assign_vec2i(struct vec2i v0) -{ - struct vec2 result; - vec2_assign_vec2i((mfloat_t *) & result, (mint_t *) & v0); - return result; +struct vec2 svec2_assign_vec2i(struct vec2i v0) { + struct vec2 result; + vec2_assign_vec2i((mfloat_t *)&result, (mint_t *)&v0); + return result; } #endif -struct vec2 svec2_zero(void) -{ - struct vec2 result; - vec2_zero((mfloat_t *) & result); - return result; +struct vec2 svec2_zero(void) { + struct vec2 result; + vec2_zero((mfloat_t *)&result); + return result; } -struct vec2 svec2_one(void) -{ - struct vec2 result; - vec2_one((mfloat_t *) & result); - return result; +struct vec2 svec2_one(void) { + struct vec2 result; + vec2_one((mfloat_t *)&result); + return result; } -struct vec2 svec2_sign(struct vec2 v0) -{ - struct vec2 result; - vec2_sign((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_sign(struct vec2 v0) { + struct vec2 result; + vec2_sign((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec2 svec2_add(struct vec2 v0, struct vec2 v1) -{ - struct vec2 result; - vec2_add((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec2 svec2_add(struct vec2 v0, struct vec2 v1) { + struct vec2 result; + vec2_add((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec2 svec2_add_f(struct vec2 v0, mfloat_t f) -{ - struct vec2 result; - vec2_add_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec2 svec2_add_f(struct vec2 v0, mfloat_t f) { + struct vec2 result; + vec2_add_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec2 svec2_subtract(struct vec2 v0, struct vec2 v1) -{ - struct vec2 result; - vec2_subtract((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec2 svec2_subtract(struct vec2 v0, struct vec2 v1) { + struct vec2 result; + vec2_subtract((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec2 svec2_subtract_f(struct vec2 v0, mfloat_t f) -{ - struct vec2 result; - vec2_subtract_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec2 svec2_subtract_f(struct vec2 v0, mfloat_t f) { + struct vec2 result; + vec2_subtract_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec2 svec2_multiply(struct vec2 v0, struct vec2 v1) -{ - struct vec2 result; - vec2_multiply((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec2 svec2_multiply(struct vec2 v0, struct vec2 v1) { + struct vec2 result; + vec2_multiply((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec2 svec2_multiply_f(struct vec2 v0, mfloat_t f) -{ - struct vec2 result; - vec2_multiply_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec2 svec2_multiply_f(struct vec2 v0, mfloat_t f) { + struct vec2 result; + vec2_multiply_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec2 svec2_multiply_mat2(struct vec2 v0, struct mat2 m0) -{ - struct vec2 result; - vec2_multiply_mat2((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & m0); - return result; +struct vec2 svec2_multiply_mat2(struct vec2 v0, struct mat2 m0) { + struct vec2 result; + vec2_multiply_mat2((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&m0); + return result; } -struct vec2 svec2_divide(struct vec2 v0, struct vec2 v1) -{ - struct vec2 result; - vec2_divide((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec2 svec2_divide(struct vec2 v0, struct vec2 v1) { + struct vec2 result; + vec2_divide((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec2 svec2_divide_f(struct vec2 v0, mfloat_t f) -{ - struct vec2 result; - vec2_divide_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec2 svec2_divide_f(struct vec2 v0, mfloat_t f) { + struct vec2 result; + vec2_divide_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec2 svec2_snap(struct vec2 v0, struct vec2 v1) -{ - struct vec2 result; - vec2_snap((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec2 svec2_snap(struct vec2 v0, struct vec2 v1) { + struct vec2 result; + vec2_snap((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec2 svec2_snap_f(struct vec2 v0, mfloat_t f) -{ - struct vec2 result; - vec2_snap_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec2 svec2_snap_f(struct vec2 v0, mfloat_t f) { + struct vec2 result; + vec2_snap_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec2 svec2_negative(struct vec2 v0) -{ - struct vec2 result; - vec2_negative((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_negative(struct vec2 v0) { + struct vec2 result; + vec2_negative((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec2 svec2_abs(struct vec2 v0) -{ - struct vec2 result; - vec2_abs((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_abs(struct vec2 v0) { + struct vec2 result; + vec2_abs((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec2 svec2_floor(struct vec2 v0) -{ - struct vec2 result; - vec2_floor((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_floor(struct vec2 v0) { + struct vec2 result; + vec2_floor((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec2 svec2_ceil(struct vec2 v0) -{ - struct vec2 result; - vec2_ceil((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_ceil(struct vec2 v0) { + struct vec2 result; + vec2_ceil((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec2 svec2_round(struct vec2 v0) -{ - struct vec2 result; - vec2_round((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_round(struct vec2 v0) { + struct vec2 result; + vec2_round((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec2 svec2_max(struct vec2 v0, struct vec2 v1) -{ - struct vec2 result; - vec2_max((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec2 svec2_max(struct vec2 v0, struct vec2 v1) { + struct vec2 result; + vec2_max((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec2 svec2_min(struct vec2 v0, struct vec2 v1) -{ - struct vec2 result; - vec2_min((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec2 svec2_min(struct vec2 v0, struct vec2 v1) { + struct vec2 result; + vec2_min((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec2 svec2_clamp(struct vec2 v0, struct vec2 v1, struct vec2 v2) -{ - struct vec2 result; - vec2_clamp((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1, - (mfloat_t *) & v2); - return result; +struct vec2 svec2_clamp(struct vec2 v0, struct vec2 v1, struct vec2 v2) { + struct vec2 result; + vec2_clamp((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1, + (mfloat_t *)&v2); + return result; } -struct vec2 svec2_normalize(struct vec2 v0) -{ - struct vec2 result; - vec2_normalize((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_normalize(struct vec2 v0) { + struct vec2 result; + vec2_normalize((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -mfloat_t svec2_dot(struct vec2 v0, struct vec2 v1) -{ - return vec2_dot((mfloat_t *) & v0, (mfloat_t *) & v1); +mfloat_t svec2_dot(struct vec2 v0, struct vec2 v1) { + return vec2_dot((mfloat_t *)&v0, (mfloat_t *)&v1); } -struct vec2 svec2_project(struct vec2 v0, struct vec2 v1) -{ - struct vec2 result; - vec2_project((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec2 svec2_project(struct vec2 v0, struct vec2 v1) { + struct vec2 result; + vec2_project((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec2 svec2_slide(struct vec2 v0, struct vec2 normal) -{ - struct vec2 result; - vec2_slide((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & normal); - return result; +struct vec2 svec2_slide(struct vec2 v0, struct vec2 normal) { + struct vec2 result; + vec2_slide((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&normal); + return result; } -struct vec2 svec2_reflect(struct vec2 v0, struct vec2 normal) -{ - struct vec2 result; - vec2_reflect((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & normal); - return result; +struct vec2 svec2_reflect(struct vec2 v0, struct vec2 normal) { + struct vec2 result; + vec2_reflect((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&normal); + return result; } -struct vec2 svec2_tangent(struct vec2 v0) -{ - struct vec2 result; - vec2_tangent((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec2 svec2_tangent(struct vec2 v0) { + struct vec2 result; + vec2_tangent((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec2 svec2_rotate(struct vec2 v0, mfloat_t f) -{ - struct vec2 result; - vec2_rotate((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec2 svec2_rotate(struct vec2 v0, mfloat_t f) { + struct vec2 result; + vec2_rotate((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec2 svec2_lerp(struct vec2 v0, struct vec2 v1, mfloat_t f) -{ - struct vec2 result; - vec2_lerp((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1, - f); - return result; +struct vec2 svec2_lerp(struct vec2 v0, struct vec2 v1, mfloat_t f) { + struct vec2 result; + vec2_lerp((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1, + f); + return result; } struct vec2 svec2_bezier3(struct vec2 v0, struct vec2 v1, struct vec2 v2, - mfloat_t f) -{ - struct vec2 result; - vec2_bezier3((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1, (mfloat_t *) & v2, f); - return result; + mfloat_t f) { + struct vec2 result; + vec2_bezier3((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1, (mfloat_t *)&v2, f); + return result; } struct vec2 svec2_bezier4(struct vec2 v0, struct vec2 v1, struct vec2 v2, - struct vec2 v3, mfloat_t f) -{ - struct vec2 result; - vec2_bezier4((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1, (mfloat_t *) & v2, (mfloat_t *) & v3, - f); - return result; + struct vec2 v3, mfloat_t f) { + struct vec2 result; + vec2_bezier4((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1, (mfloat_t *)&v2, (mfloat_t *)&v3, + f); + return result; } -mfloat_t svec2_angle(struct vec2 v0) -{ - return vec2_angle((mfloat_t *) & v0); +mfloat_t svec2_angle(struct vec2 v0) { + return vec2_angle((mfloat_t *)&v0); } -mfloat_t svec2_length(struct vec2 v0) -{ - return vec2_length((mfloat_t *) & v0); +mfloat_t svec2_length(struct vec2 v0) { + return vec2_length((mfloat_t *)&v0); } -mfloat_t svec2_length_squared(struct vec2 v0) -{ - return vec2_length_squared((mfloat_t *) & v0); +mfloat_t svec2_length_squared(struct vec2 v0) { + return vec2_length_squared((mfloat_t *)&v0); } -mfloat_t svec2_distance(struct vec2 v0, struct vec2 v1) -{ - return vec2_distance((mfloat_t *) & v0, (mfloat_t *) & v1); +mfloat_t svec2_distance(struct vec2 v0, struct vec2 v1) { + return vec2_distance((mfloat_t *)&v0, (mfloat_t *)&v1); } -mfloat_t svec2_distance_squared(struct vec2 v0, struct vec2 v1) -{ - return vec2_distance_squared((mfloat_t *) & v0, (mfloat_t *) & v1); +mfloat_t svec2_distance_squared(struct vec2 v0, struct vec2 v1) { + return vec2_distance_squared((mfloat_t *)&v0, (mfloat_t *)&v1); } -bool svec3_is_zero(struct vec3 v0) -{ - return vec3_is_zero((mfloat_t *) & v0); +bool svec3_is_zero(struct vec3 v0) { + return vec3_is_zero((mfloat_t *)&v0); } -bool svec3_is_equal(struct vec3 v0, struct vec3 v1) -{ - return vec3_is_equal((mfloat_t *) & v0, (mfloat_t *) & v1); +bool svec3_is_equal(struct vec3 v0, struct vec3 v1) { + return vec3_is_equal((mfloat_t *)&v0, (mfloat_t *)&v1); } -struct vec3 svec3(mfloat_t x, mfloat_t y, mfloat_t z) -{ - struct vec3 result; - vec3((mfloat_t *) & result, x, y, z); - return result; +struct vec3 svec3(mfloat_t x, mfloat_t y, mfloat_t z) { + struct vec3 result; + vec3((mfloat_t *)&result, x, y, z); + return result; } -struct vec3 svec3_assign(struct vec3 v0) -{ - struct vec3 result; - vec3_assign((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3 svec3_assign(struct vec3 v0) { + struct vec3 result; + vec3_assign((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } #if defined(MATHC_USE_INT) -struct vec3 svec3_assign_vec3i(struct vec3i v0) -{ - struct vec3 result; - vec3_assign_vec3i((mfloat_t *) & result, (mint_t *) & v0); - return result; +struct vec3 svec3_assign_vec3i(struct vec3i v0) { + struct vec3 result; + vec3_assign_vec3i((mfloat_t *)&result, (mint_t *)&v0); + return result; } #endif -struct vec3 svec3_zero(void) -{ - struct vec3 result; - vec3_zero((mfloat_t *) & result); - return result; +struct vec3 svec3_zero(void) { + struct vec3 result; + vec3_zero((mfloat_t *)&result); + return result; } -struct vec3 svec3_one(void) -{ - struct vec3 result; - vec3_one((mfloat_t *) & result); - return result; +struct vec3 svec3_one(void) { + struct vec3 result; + vec3_one((mfloat_t *)&result); + return result; } -struct vec3 svec3_sign(struct vec3 v0) -{ - struct vec3 result; - vec3_sign((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3 svec3_sign(struct vec3 v0) { + struct vec3 result; + vec3_sign((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec3 svec3_add(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_add((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec3 svec3_add(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_add((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec3 svec3_add_f(struct vec3 v0, mfloat_t f) -{ - struct vec3 result; - vec3_add_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec3 svec3_add_f(struct vec3 v0, mfloat_t f) { + struct vec3 result; + vec3_add_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec3 svec3_subtract(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_subtract((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec3 svec3_subtract(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_subtract((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec3 svec3_subtract_f(struct vec3 v0, mfloat_t f) -{ - struct vec3 result; - vec3_subtract_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec3 svec3_subtract_f(struct vec3 v0, mfloat_t f) { + struct vec3 result; + vec3_subtract_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec3 svec3_multiply(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_multiply((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec3 svec3_multiply(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_multiply((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec3 svec3_multiply_f(struct vec3 v0, mfloat_t f) -{ - struct vec3 result; - vec3_multiply_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec3 svec3_multiply_f(struct vec3 v0, mfloat_t f) { + struct vec3 result; + vec3_multiply_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec3 svec3_multiply_mat3(struct vec3 v0, struct mat3 m0) -{ - struct vec3 result; - vec3_multiply_mat3((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & m0); - return result; +struct vec3 svec3_multiply_mat3(struct vec3 v0, struct mat3 m0) { + struct vec3 result; + vec3_multiply_mat3((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&m0); + return result; } -struct vec3 svec3_divide(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_divide((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec3 svec3_divide(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_divide((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec3 svec3_divide_f(struct vec3 v0, mfloat_t f) -{ - struct vec3 result; - vec3_divide_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec3 svec3_divide_f(struct vec3 v0, mfloat_t f) { + struct vec3 result; + vec3_divide_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec3 svec3_snap(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_snap((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec3 svec3_snap(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_snap((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec3 svec3_snap_f(struct vec3 v0, mfloat_t f) -{ - struct vec3 result; - vec3_snap_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec3 svec3_snap_f(struct vec3 v0, mfloat_t f) { + struct vec3 result; + vec3_snap_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec3 svec3_negative(struct vec3 v0) -{ - struct vec3 result; - vec3_negative((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3 svec3_negative(struct vec3 v0) { + struct vec3 result; + vec3_negative((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec3 svec3_abs(struct vec3 v0) -{ - struct vec3 result; - vec3_abs((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3 svec3_abs(struct vec3 v0) { + struct vec3 result; + vec3_abs((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec3 svec3_floor(struct vec3 v0) -{ - struct vec3 result; - vec3_floor((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3 svec3_floor(struct vec3 v0) { + struct vec3 result; + vec3_floor((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec3 svec3_ceil(struct vec3 v0) -{ - struct vec3 result; - vec3_ceil((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3 svec3_ceil(struct vec3 v0) { + struct vec3 result; + vec3_ceil((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec3 svec3_round(struct vec3 v0) -{ - struct vec3 result; - vec3_round((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3 svec3_round(struct vec3 v0) { + struct vec3 result; + vec3_round((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec3 svec3_max(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_max((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec3 svec3_max(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_max((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec3 svec3_min(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_min((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec3 svec3_min(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_min((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec3 svec3_clamp(struct vec3 v0, struct vec3 v1, struct vec3 v2) -{ - struct vec3 result; - vec3_clamp((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1, - (mfloat_t *) & v2); - return result; +struct vec3 svec3_clamp(struct vec3 v0, struct vec3 v1, struct vec3 v2) { + struct vec3 result; + vec3_clamp((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1, + (mfloat_t *)&v2); + return result; } -struct vec3 svec3_cross(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_cross((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec3 svec3_cross(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_cross((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec3 svec3_normalize(struct vec3 v0) -{ - struct vec3 result; - vec3_normalize((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec3 svec3_normalize(struct vec3 v0) { + struct vec3 result; + vec3_normalize((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -mfloat_t svec3_dot(struct vec3 v0, struct vec3 v1) -{ - return vec3_dot((mfloat_t *) & v0, (mfloat_t *) & v1); +mfloat_t svec3_dot(struct vec3 v0, struct vec3 v1) { + return vec3_dot((mfloat_t *)&v0, (mfloat_t *)&v1); } -struct vec3 svec3_project(struct vec3 v0, struct vec3 v1) -{ - struct vec3 result; - vec3_project((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec3 svec3_project(struct vec3 v0, struct vec3 v1) { + struct vec3 result; + vec3_project((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec3 svec3_slide(struct vec3 v0, struct vec3 normal) -{ - struct vec3 result; - vec3_slide((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & normal); - return result; +struct vec3 svec3_slide(struct vec3 v0, struct vec3 normal) { + struct vec3 result; + vec3_slide((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&normal); + return result; } -struct vec3 svec3_reflect(struct vec3 v0, struct vec3 normal) -{ - struct vec3 result; - vec3_reflect((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & normal); - return result; +struct vec3 svec3_reflect(struct vec3 v0, struct vec3 normal) { + struct vec3 result; + vec3_reflect((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&normal); + return result; } -struct vec3 svec3_rotate(struct vec3 v0, struct vec3 ra, mfloat_t f) -{ - struct vec3 result; - vec3_lerp((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & ra, - f); - return result; +struct vec3 svec3_rotate(struct vec3 v0, struct vec3 ra, mfloat_t f) { + struct vec3 result; + vec3_lerp((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&ra, + f); + return result; } -struct vec3 svec3_lerp(struct vec3 v0, struct vec3 v1, mfloat_t f) -{ - struct vec3 result; - vec3_lerp((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1, - f); - return result; +struct vec3 svec3_lerp(struct vec3 v0, struct vec3 v1, mfloat_t f) { + struct vec3 result; + vec3_lerp((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1, + f); + return result; } struct vec3 svec3_bezier3(struct vec3 v0, struct vec3 v1, struct vec3 v2, - mfloat_t f) -{ - struct vec3 result; - vec3_bezier3((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1, (mfloat_t *) & v2, f); - return result; + mfloat_t f) { + struct vec3 result; + vec3_bezier3((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1, (mfloat_t *)&v2, f); + return result; } struct vec3 svec3_bezier4(struct vec3 v0, struct vec3 v1, struct vec3 v2, - struct vec3 v3, mfloat_t f) -{ - struct vec3 result; - vec3_bezier4((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1, (mfloat_t *) & v2, (mfloat_t *) & v3, - f); - return result; + struct vec3 v3, mfloat_t f) { + struct vec3 result; + vec3_bezier4((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1, (mfloat_t *)&v2, (mfloat_t *)&v3, + f); + return result; } -mfloat_t svec3_length(struct vec3 v0) -{ - return vec3_length((mfloat_t *) & v0); +mfloat_t svec3_length(struct vec3 v0) { + return vec3_length((mfloat_t *)&v0); } -mfloat_t svec3_length_squared(struct vec3 v0) -{ - return vec3_length_squared((mfloat_t *) & v0); +mfloat_t svec3_length_squared(struct vec3 v0) { + return vec3_length_squared((mfloat_t *)&v0); } -mfloat_t svec3_distance(struct vec3 v0, struct vec3 v1) -{ - return vec3_distance((mfloat_t *) & v0, (mfloat_t *) & v1); +mfloat_t svec3_distance(struct vec3 v0, struct vec3 v1) { + return vec3_distance((mfloat_t *)&v0, (mfloat_t *)&v1); } -mfloat_t svec3_distance_squared(struct vec3 v0, struct vec3 v1) -{ - return vec3_distance_squared((mfloat_t *) & v0, (mfloat_t *) & v1); +mfloat_t svec3_distance_squared(struct vec3 v0, struct vec3 v1) { + return vec3_distance_squared((mfloat_t *)&v0, (mfloat_t *)&v1); } -bool svec4_is_zero(struct vec4 v0) -{ - return vec4_is_zero((mfloat_t *) & v0); +bool svec4_is_zero(struct vec4 v0) { + return vec4_is_zero((mfloat_t *)&v0); } -bool svec4_is_equal(struct vec4 v0, struct vec4 v1) -{ - return vec4_is_equal((mfloat_t *) & v0, (mfloat_t *) & v1); +bool svec4_is_equal(struct vec4 v0, struct vec4 v1) { + return vec4_is_equal((mfloat_t *)&v0, (mfloat_t *)&v1); } -struct vec4 svec4(mfloat_t x, mfloat_t y, mfloat_t z, mfloat_t w) -{ - struct vec4 result; - vec4((mfloat_t *) & result, x, y, z, w); - return result; +struct vec4 svec4(mfloat_t x, mfloat_t y, mfloat_t z, mfloat_t w) { + struct vec4 result; + vec4((mfloat_t *)&result, x, y, z, w); + return result; } -struct vec4 svec4_assign(struct vec4 v0) -{ - struct vec4 result; - vec4_assign((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4 svec4_assign(struct vec4 v0) { + struct vec4 result; + vec4_assign((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } #if defined(MATHC_USE_INT) -struct vec4 svec4_assign_vec4i(struct vec4i v0) -{ - struct vec4 result; - vec4_assign_vec4i((mfloat_t *) & result, (mint_t *) & v0); - return result; +struct vec4 svec4_assign_vec4i(struct vec4i v0) { + struct vec4 result; + vec4_assign_vec4i((mfloat_t *)&result, (mint_t *)&v0); + return result; } #endif -struct vec4 svec4_zero(void) -{ - struct vec4 result; - vec4_zero((mfloat_t *) & result); - return result; +struct vec4 svec4_zero(void) { + struct vec4 result; + vec4_zero((mfloat_t *)&result); + return result; } -struct vec4 svec4_one(void) -{ - struct vec4 result; - vec4_one((mfloat_t *) & result); - return result; +struct vec4 svec4_one(void) { + struct vec4 result; + vec4_one((mfloat_t *)&result); + return result; } -struct vec4 svec4_sign(struct vec4 v0) -{ - struct vec4 result; - vec4_sign((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4 svec4_sign(struct vec4 v0) { + struct vec4 result; + vec4_sign((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec4 svec4_add(struct vec4 v0, struct vec4 v1) -{ - struct vec4 result; - vec4_add((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec4 svec4_add(struct vec4 v0, struct vec4 v1) { + struct vec4 result; + vec4_add((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec4 svec4_add_f(struct vec4 v0, mfloat_t f) -{ - struct vec4 result; - vec4_add_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec4 svec4_add_f(struct vec4 v0, mfloat_t f) { + struct vec4 result; + vec4_add_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec4 svec4_subtract(struct vec4 v0, struct vec4 v1) -{ - struct vec4 result; - vec4_subtract((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec4 svec4_subtract(struct vec4 v0, struct vec4 v1) { + struct vec4 result; + vec4_subtract((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec4 svec4_subtract_f(struct vec4 v0, mfloat_t f) -{ - struct vec4 result; - vec4_subtract_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec4 svec4_subtract_f(struct vec4 v0, mfloat_t f) { + struct vec4 result; + vec4_subtract_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec4 svec4_multiply(struct vec4 v0, struct vec4 v1) -{ - struct vec4 result; - vec4_multiply((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec4 svec4_multiply(struct vec4 v0, struct vec4 v1) { + struct vec4 result; + vec4_multiply((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec4 svec4_multiply_f(struct vec4 v0, mfloat_t f) -{ - struct vec4 result; - vec4_multiply_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec4 svec4_multiply_f(struct vec4 v0, mfloat_t f) { + struct vec4 result; + vec4_multiply_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec4 svec4_multiply_mat4(struct vec4 v0, struct mat4 m0) -{ - struct vec4 result; - vec4_multiply_mat4((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & m0); - return result; +struct vec4 svec4_multiply_mat4(struct vec4 v0, struct mat4 m0) { + struct vec4 result; + vec4_multiply_mat4((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&m0); + return result; } -struct vec4 svec4_divide(struct vec4 v0, struct vec4 v1) -{ - struct vec4 result; - vec4_divide((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct vec4 svec4_divide(struct vec4 v0, struct vec4 v1) { + struct vec4 result; + vec4_divide((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct vec4 svec4_divide_f(struct vec4 v0, mfloat_t f) -{ - struct vec4 result; - vec4_divide_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec4 svec4_divide_f(struct vec4 v0, mfloat_t f) { + struct vec4 result; + vec4_divide_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec4 svec4_snap(struct vec4 v0, struct vec4 v1) -{ - struct vec4 result; - vec4_snap((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec4 svec4_snap(struct vec4 v0, struct vec4 v1) { + struct vec4 result; + vec4_snap((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec4 svec4_snap_f(struct vec4 v0, mfloat_t f) -{ - struct vec4 result; - vec4_snap_f((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct vec4 svec4_snap_f(struct vec4 v0, mfloat_t f) { + struct vec4 result; + vec4_snap_f((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct vec4 svec4_negative(struct vec4 v0) -{ - struct vec4 result; - vec4_negative((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4 svec4_negative(struct vec4 v0) { + struct vec4 result; + vec4_negative((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec4 svec4_abs(struct vec4 v0) -{ - struct vec4 result; - vec4_abs((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4 svec4_abs(struct vec4 v0) { + struct vec4 result; + vec4_abs((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec4 svec4_floor(struct vec4 v0) -{ - struct vec4 result; - vec4_floor((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4 svec4_floor(struct vec4 v0) { + struct vec4 result; + vec4_floor((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec4 svec4_ceil(struct vec4 v0) -{ - struct vec4 result; - vec4_ceil((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4 svec4_ceil(struct vec4 v0) { + struct vec4 result; + vec4_ceil((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec4 svec4_round(struct vec4 v0) -{ - struct vec4 result; - vec4_round((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4 svec4_round(struct vec4 v0) { + struct vec4 result; + vec4_round((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec4 svec4_max(struct vec4 v0, struct vec4 v1) -{ - struct vec4 result; - vec4_max((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec4 svec4_max(struct vec4 v0, struct vec4 v1) { + struct vec4 result; + vec4_max((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec4 svec4_min(struct vec4 v0, struct vec4 v1) -{ - struct vec4 result; - vec4_min((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1); - return result; +struct vec4 svec4_min(struct vec4 v0, struct vec4 v1) { + struct vec4 result; + vec4_min((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1); + return result; } -struct vec4 svec4_clamp(struct vec4 v0, struct vec4 v1, struct vec4 v2) -{ - struct vec4 result; - vec4_clamp((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1, - (mfloat_t *) & v2); - return result; +struct vec4 svec4_clamp(struct vec4 v0, struct vec4 v1, struct vec4 v2) { + struct vec4 result; + vec4_clamp((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1, + (mfloat_t *)&v2); + return result; } -struct vec4 svec4_normalize(struct vec4 v0) -{ - struct vec4 result; - vec4_normalize((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct vec4 svec4_normalize(struct vec4 v0) { + struct vec4 result; + vec4_normalize((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct vec4 svec4_lerp(struct vec4 v0, struct vec4 v1, mfloat_t f) -{ - struct vec4 result; - vec4_lerp((mfloat_t *) & result, (mfloat_t *) & v0, (mfloat_t *) & v1, - f); - return result; +struct vec4 svec4_lerp(struct vec4 v0, struct vec4 v1, mfloat_t f) { + struct vec4 result; + vec4_lerp((mfloat_t *)&result, (mfloat_t *)&v0, (mfloat_t *)&v1, + f); + return result; } -bool squat_is_zero(struct quat q0) -{ - return quat_is_zero((mfloat_t *) & q0); +bool squat_is_zero(struct quat q0) { + return quat_is_zero((mfloat_t *)&q0); } -bool squat_is_equal(struct quat q0, struct quat q1) -{ - return quat_is_equal((mfloat_t *) & q0, (mfloat_t *) & q1); +bool squat_is_equal(struct quat q0, struct quat q1) { + return quat_is_equal((mfloat_t *)&q0, (mfloat_t *)&q1); } // TODO: Implement -struct quat squat_from_euler(mfloat_t x, mfloat_t y, mfloat_t z) -{ - struct quat result = {0}; +struct quat squat_from_euler(mfloat_t x, mfloat_t y, mfloat_t z) { + struct quat result = {0}; - return result; + return result; } -struct quat squat(mfloat_t x, mfloat_t y, mfloat_t z, mfloat_t w) -{ - struct quat result; - quat((mfloat_t *) & result, x, y, z, w); - return result; +struct quat squat(mfloat_t x, mfloat_t y, mfloat_t z, mfloat_t w) { + struct quat result; + quat((mfloat_t *)&result, x, y, z, w); + return result; } -struct quat squat_assign(struct quat q0) -{ - struct quat result; - quat_assign((mfloat_t *) & result, (mfloat_t *) & q0); - return result; +struct quat squat_assign(struct quat q0) { + struct quat result; + quat_assign((mfloat_t *)&result, (mfloat_t *)&q0); + return result; } -struct quat squat_zero(void) -{ - struct quat result; - quat_zero((mfloat_t *) & result); - return result; +struct quat squat_zero(void) { + struct quat result; + quat_zero((mfloat_t *)&result); + return result; } -struct quat squat_null(void) -{ - struct quat result; - quat_null((mfloat_t *) & result); - return result; +struct quat squat_null(void) { + struct quat result; + quat_null((mfloat_t *)&result); + return result; } -struct quat squat_multiply(struct quat q0, struct quat q1) -{ - struct quat result; - quat_multiply((mfloat_t *) & result, (mfloat_t *) & q0, - (mfloat_t *) & q1); - return result; +struct quat squat_multiply(struct quat q0, struct quat q1) { + struct quat result; + quat_multiply((mfloat_t *)&result, (mfloat_t *)&q0, + (mfloat_t *)&q1); + return result; } -struct quat squat_multiply_f(struct quat q0, mfloat_t f) -{ - struct quat result; - quat_multiply_f((mfloat_t *) & result, (mfloat_t *) & q0, f); - return result; +struct quat squat_multiply_f(struct quat q0, mfloat_t f) { + struct quat result; + quat_multiply_f((mfloat_t *)&result, (mfloat_t *)&q0, f); + return result; } -struct quat squat_divide(struct quat q0, struct quat q1) -{ - struct quat result; - quat_divide((mfloat_t *) & result, (mfloat_t *) & q0, - (mfloat_t *) & q1); - return result; +struct quat squat_divide(struct quat q0, struct quat q1) { + struct quat result; + quat_divide((mfloat_t *)&result, (mfloat_t *)&q0, + (mfloat_t *)&q1); + return result; } -struct quat squat_divide_f(struct quat q0, mfloat_t f) -{ - struct quat result; - quat_divide_f((mfloat_t *) & result, (mfloat_t *) & q0, f); - return result; +struct quat squat_divide_f(struct quat q0, mfloat_t f) { + struct quat result; + quat_divide_f((mfloat_t *)&result, (mfloat_t *)&q0, f); + return result; } -struct quat squat_negative(struct quat q0) -{ - struct quat result; - quat_negative((mfloat_t *) & result, (mfloat_t *) & q0); - return result; +struct quat squat_negative(struct quat q0) { + struct quat result; + quat_negative((mfloat_t *)&result, (mfloat_t *)&q0); + return result; } -struct quat squat_conjugate(struct quat q0) -{ - struct quat result; - quat_conjugate((mfloat_t *) & result, (mfloat_t *) & q0); - return result; +struct quat squat_conjugate(struct quat q0) { + struct quat result; + quat_conjugate((mfloat_t *)&result, (mfloat_t *)&q0); + return result; } -struct quat squat_inverse(struct quat q0) -{ - struct quat result; - quat_inverse((mfloat_t *) & result, (mfloat_t *) & q0); - return result; +struct quat squat_inverse(struct quat q0) { + struct quat result; + quat_inverse((mfloat_t *)&result, (mfloat_t *)&q0); + return result; } -struct quat squat_normalize(struct quat q0) -{ - struct quat result; - quat_normalize((mfloat_t *) & result, (mfloat_t *) & q0); - return result; +struct quat squat_normalize(struct quat q0) { + struct quat result; + quat_normalize((mfloat_t *)&result, (mfloat_t *)&q0); + return result; } -mfloat_t squat_dot(struct quat q0, struct quat q1) -{ - return quat_dot((mfloat_t *) & q0, (mfloat_t *) & q1); +mfloat_t squat_dot(struct quat q0, struct quat q1) { + return quat_dot((mfloat_t *)&q0, (mfloat_t *)&q1); } -struct quat squat_power(struct quat q0, mfloat_t exponent) -{ - struct quat result; - quat_power((mfloat_t *) & result, (mfloat_t *) & q0, exponent); - return result; +struct quat squat_power(struct quat q0, mfloat_t exponent) { + struct quat result; + quat_power((mfloat_t *)&result, (mfloat_t *)&q0, exponent); + return result; } -struct quat squat_from_axis_angle(struct vec3 v0, mfloat_t angle) -{ - struct quat result; - quat_from_axis_angle((mfloat_t *) & result, (mfloat_t *) & v0, angle); - return result; +struct quat squat_from_axis_angle(struct vec3 v0, mfloat_t angle) { + struct quat result; + quat_from_axis_angle((mfloat_t *)&result, (mfloat_t *)&v0, angle); + return result; } -struct quat squat_from_vec3(struct vec3 v0, struct vec3 v1) -{ - struct quat result; - quat_from_vec3((mfloat_t *) & result, (mfloat_t *) & v0, - (mfloat_t *) & v1); - return result; +struct quat squat_from_vec3(struct vec3 v0, struct vec3 v1) { + struct quat result; + quat_from_vec3((mfloat_t *)&result, (mfloat_t *)&v0, + (mfloat_t *)&v1); + return result; } -struct quat squat_from_mat4(struct mat4 m0) -{ - struct quat result; - quat_from_mat4((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct quat squat_from_mat4(struct mat4 m0) { + struct quat result; + quat_from_mat4((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct quat squat_lerp(struct quat q0, struct quat q1, mfloat_t f) -{ - struct quat result; - quat_lerp((mfloat_t *) & result, (mfloat_t *) & q0, (mfloat_t *) & q1, - f); - return result; +struct quat squat_lerp(struct quat q0, struct quat q1, mfloat_t f) { + struct quat result; + quat_lerp((mfloat_t *)&result, (mfloat_t *)&q0, (mfloat_t *)&q1, + f); + return result; } -struct quat squat_slerp(struct quat q0, struct quat q1, mfloat_t f) -{ - struct quat result; - quat_slerp((mfloat_t *) & result, (mfloat_t *) & q0, (mfloat_t *) & q1, - f); - return result; +struct quat squat_slerp(struct quat q0, struct quat q1, mfloat_t f) { + struct quat result; + quat_slerp((mfloat_t *)&result, (mfloat_t *)&q0, (mfloat_t *)&q1, + f); + return result; } -mfloat_t squat_length(struct quat q0) -{ - return quat_length((mfloat_t *) & q0); +mfloat_t squat_length(struct quat q0) { + return quat_length((mfloat_t *)&q0); } -mfloat_t squat_length_squared(struct quat q0) -{ - return quat_length_squared((mfloat_t *) & q0); +mfloat_t squat_length_squared(struct quat q0) { + return quat_length_squared((mfloat_t *)&q0); } -mfloat_t squat_angle(struct quat q0, struct quat q1) -{ - return quat_angle((mfloat_t *) & q0, (mfloat_t *) & q1); +mfloat_t squat_angle(struct quat q0, struct quat q1) { + return quat_angle((mfloat_t *)&q0, (mfloat_t *)&q1); } -struct mat2 smat2(mfloat_t m11, mfloat_t m12, mfloat_t m21, mfloat_t m22) -{ - struct mat2 result; - mat2((mfloat_t *) & result, m11, m12, m21, m22); - return result; +struct mat2 smat2(mfloat_t m11, mfloat_t m12, mfloat_t m21, mfloat_t m22) { + struct mat2 result; + mat2((mfloat_t *)&result, m11, m12, m21, m22); + return result; } -struct mat2 smat2_zero(void) -{ - struct mat2 result; - mat2_zero((mfloat_t *) & result); - return result; +struct mat2 smat2_zero(void) { + struct mat2 result; + mat2_zero((mfloat_t *)&result); + return result; } -struct mat2 smat2_identity(void) -{ - struct mat2 result; - mat2_identity((mfloat_t *) & result); - return result; +struct mat2 smat2_identity(void) { + struct mat2 result; + mat2_identity((mfloat_t *)&result); + return result; } -mfloat_t smat2_determinant(struct mat2 m0) -{ - return mat2_determinant((mfloat_t *) & m0); +mfloat_t smat2_determinant(struct mat2 m0) { + return mat2_determinant((mfloat_t *)&m0); } -struct mat2 smat2_assign(struct mat2 m0) -{ - struct mat2 result; - mat2_assign((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat2 smat2_assign(struct mat2 m0) { + struct mat2 result; + mat2_assign((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat2 smat2_negative(struct mat2 m0) -{ - struct mat2 result; - mat2_negative((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat2 smat2_negative(struct mat2 m0) { + struct mat2 result; + mat2_negative((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat2 smat2_transpose(struct mat2 m0) -{ - struct mat2 result; - mat2_transpose((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat2 smat2_transpose(struct mat2 m0) { + struct mat2 result; + mat2_transpose((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat2 smat2_cofactor(struct mat2 m0) -{ - struct mat2 result; - mat2_cofactor((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat2 smat2_cofactor(struct mat2 m0) { + struct mat2 result; + mat2_cofactor((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat2 smat2_adjugate(struct mat2 m0) -{ - struct mat2 result; - mat2_adjugate((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat2 smat2_adjugate(struct mat2 m0) { + struct mat2 result; + mat2_adjugate((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat2 smat2_multiply(struct mat2 m0, struct mat2 m1) -{ - struct mat2 result; - mat2_multiply((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & m1); - return result; +struct mat2 smat2_multiply(struct mat2 m0, struct mat2 m1) { + struct mat2 result; + mat2_multiply((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&m1); + return result; } -struct mat2 smat2_multiply_f(struct mat2 m0, mfloat_t f) -{ - struct mat2 result; - mat2_multiply_f((mfloat_t *) & result, (mfloat_t *) & m0, f); - return result; +struct mat2 smat2_multiply_f(struct mat2 m0, mfloat_t f) { + struct mat2 result; + mat2_multiply_f((mfloat_t *)&result, (mfloat_t *)&m0, f); + return result; } -struct mat2 smat2_inverse(struct mat2 m0) -{ - struct mat2 result; - mat2_inverse((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat2 smat2_inverse(struct mat2 m0) { + struct mat2 result; + mat2_inverse((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat2 smat2_scaling(struct vec2 v0) -{ - struct mat2 result; - mat2_scaling((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct mat2 smat2_scaling(struct vec2 v0) { + struct mat2 result; + mat2_scaling((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct mat2 smat2_scale(struct mat2 m0, struct vec2 v0) -{ - struct mat2 result; - mat2_scale((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & v0); - return result; +struct mat2 smat2_scale(struct mat2 m0, struct vec2 v0) { + struct mat2 result; + mat2_scale((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&v0); + return result; } -struct mat2 smat2_rotation_z(mfloat_t f) -{ - struct mat2 result; - mat2_rotation_z((mfloat_t *) & result, f); - return result; +struct mat2 smat2_rotation_z(mfloat_t f) { + struct mat2 result; + mat2_rotation_z((mfloat_t *)&result, f); + return result; } -struct mat2 smat2_lerp(struct mat2 m0, struct mat2 m1, mfloat_t f) -{ - struct mat2 result; - mat2_lerp((mfloat_t *) & result, (mfloat_t *) & m0, (mfloat_t *) & m1, - f); - return result; +struct mat2 smat2_lerp(struct mat2 m0, struct mat2 m1, mfloat_t f) { + struct mat2 result; + mat2_lerp((mfloat_t *)&result, (mfloat_t *)&m0, (mfloat_t *)&m1, + f); + return result; } struct mat3 smat3(mfloat_t m11, mfloat_t m12, mfloat_t m13, mfloat_t m21, - mfloat_t m22, mfloat_t m23, mfloat_t m31, mfloat_t m32, - mfloat_t m33) -{ - struct mat3 result; - mat3((mfloat_t *) & result, m11, m12, m13, m21, m22, m23, m31, m32, - m33); - return result; + mfloat_t m22, mfloat_t m23, mfloat_t m31, mfloat_t m32, + mfloat_t m33) { + struct mat3 result; + mat3((mfloat_t *)&result, m11, m12, m13, m21, m22, m23, m31, m32, + m33); + return result; } -struct mat3 smat3_zero(void) -{ - struct mat3 result; - mat3_zero((mfloat_t *) & result); - return result; +struct mat3 smat3_zero(void) { + struct mat3 result; + mat3_zero((mfloat_t *)&result); + return result; } -struct mat3 smat3_identity(void) -{ - struct mat3 result; - mat3_identity((mfloat_t *) & result); - return result; +struct mat3 smat3_identity(void) { + struct mat3 result; + mat3_identity((mfloat_t *)&result); + return result; } -mfloat_t smat3_determinant(struct mat3 m0) -{ - return mat3_determinant((mfloat_t *) & m0); +mfloat_t smat3_determinant(struct mat3 m0) { + return mat3_determinant((mfloat_t *)&m0); } -struct mat3 smat3_assign(struct mat3 m0) -{ - struct mat3 result; - mat3_assign((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat3 smat3_assign(struct mat3 m0) { + struct mat3 result; + mat3_assign((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat3 smat3_negative(struct mat3 m0) -{ - struct mat3 result; - mat3_negative((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat3 smat3_negative(struct mat3 m0) { + struct mat3 result; + mat3_negative((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat3 smat3_transpose(struct mat3 m0) -{ - struct mat3 result; - mat3_transpose((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat3 smat3_transpose(struct mat3 m0) { + struct mat3 result; + mat3_transpose((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat3 smat3_cofactor(struct mat3 m0) -{ - struct mat3 result; - mat3_cofactor((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat3 smat3_cofactor(struct mat3 m0) { + struct mat3 result; + mat3_cofactor((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat3 smat3_multiply(struct mat3 m0, struct mat3 m1) -{ - struct mat3 result; - mat3_multiply((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & m1); - return result; +struct mat3 smat3_multiply(struct mat3 m0, struct mat3 m1) { + struct mat3 result; + mat3_multiply((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&m1); + return result; } -struct mat3 smat3_multiply_f(struct mat3 m0, mfloat_t f) -{ - struct mat3 result; - mat3_multiply_f((mfloat_t *) & result, (mfloat_t *) & m0, f); - return result; +struct mat3 smat3_multiply_f(struct mat3 m0, mfloat_t f) { + struct mat3 result; + mat3_multiply_f((mfloat_t *)&result, (mfloat_t *)&m0, f); + return result; } -struct mat3 smat3_inverse(struct mat3 m0) -{ - struct mat3 result; - mat3_inverse((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat3 smat3_inverse(struct mat3 m0) { + struct mat3 result; + mat3_inverse((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat3 smat3_scaling(struct vec3 v0) -{ - struct mat3 result; - mat3_scaling((mfloat_t *) & result, (mfloat_t *) & v0); - return result; +struct mat3 smat3_scaling(struct vec3 v0) { + struct mat3 result; + mat3_scaling((mfloat_t *)&result, (mfloat_t *)&v0); + return result; } -struct mat3 smat3_scale(struct mat3 m0, struct vec3 v0) -{ - struct mat3 result; - mat3_scale((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & v0); - return result; +struct mat3 smat3_scale(struct mat3 m0, struct vec3 v0) { + struct mat3 result; + mat3_scale((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&v0); + return result; } -struct mat3 smat3_rotation_x(mfloat_t f) -{ - struct mat3 result; - mat3_rotation_x((mfloat_t *) & result, f); - return result; +struct mat3 smat3_rotation_x(mfloat_t f) { + struct mat3 result; + mat3_rotation_x((mfloat_t *)&result, f); + return result; } -struct mat3 smat3_rotation_y(mfloat_t f) -{ - struct mat3 result; - mat3_rotation_y((mfloat_t *) & result, f); - return result; +struct mat3 smat3_rotation_y(mfloat_t f) { + struct mat3 result; + mat3_rotation_y((mfloat_t *)&result, f); + return result; } -struct mat3 smat3_rotation_z(mfloat_t f) -{ - struct mat3 result; - mat3_rotation_z((mfloat_t *) & result, f); - return result; +struct mat3 smat3_rotation_z(mfloat_t f) { + struct mat3 result; + mat3_rotation_z((mfloat_t *)&result, f); + return result; } -struct mat3 smat3_rotation_axis(struct vec3 v0, mfloat_t f) -{ - struct mat3 result; - mat3_rotation_axis((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct mat3 smat3_rotation_axis(struct vec3 v0, mfloat_t f) { + struct mat3 result; + mat3_rotation_axis((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct mat3 smat3_rotation_quat(struct quat q0) -{ - struct mat3 result; - mat3_rotation_quat((mfloat_t *) & result, (mfloat_t *) & q0); - return result; +struct mat3 smat3_rotation_quat(struct quat q0) { + struct mat3 result; + mat3_rotation_quat((mfloat_t *)&result, (mfloat_t *)&q0); + return result; } -struct mat3 smat3_lerp(struct mat3 m0, struct mat3 m1, mfloat_t f) -{ - struct mat3 result; - mat3_lerp((mfloat_t *) & result, (mfloat_t *) & m0, (mfloat_t *) & m1, - f); - return result; +struct mat3 smat3_lerp(struct mat3 m0, struct mat3 m1, mfloat_t f) { + struct mat3 result; + mat3_lerp((mfloat_t *)&result, (mfloat_t *)&m0, (mfloat_t *)&m1, + f); + return result; } struct mat4 smat4(mfloat_t m11, mfloat_t m12, mfloat_t m13, mfloat_t m14, - mfloat_t m21, mfloat_t m22, mfloat_t m23, mfloat_t m24, - mfloat_t m31, mfloat_t m32, mfloat_t m33, mfloat_t m34, - mfloat_t m41, mfloat_t m42, mfloat_t m43, mfloat_t m44) -{ - struct mat4 result; - mat4((mfloat_t *) & result, m11, m12, m13, m14, m21, m22, m23, m24, - m31, m32, m33, m34, m41, m42, m43, m44); - return result; + mfloat_t m21, mfloat_t m22, mfloat_t m23, mfloat_t m24, + mfloat_t m31, mfloat_t m32, mfloat_t m33, mfloat_t m34, + mfloat_t m41, mfloat_t m42, mfloat_t m43, mfloat_t m44) { + struct mat4 result; + mat4((mfloat_t *)&result, m11, m12, m13, m14, m21, m22, m23, m24, + m31, m32, m33, m34, m41, m42, m43, m44); + return result; } -struct mat4 smat4_zero(void) -{ - struct mat4 result; - mat4_zero((mfloat_t *) & result); - return result; +struct mat4 smat4_zero(void) { + struct mat4 result; + mat4_zero((mfloat_t *)&result); + return result; } -struct mat4 smat4_identity(void) -{ - struct mat4 result; - mat4_identity((mfloat_t *) & result); - return result; +struct mat4 smat4_identity(void) { + struct mat4 result; + mat4_identity((mfloat_t *)&result); + return result; } -mfloat_t smat4_determinant(struct mat4 m0) -{ - return mat4_determinant((mfloat_t *) & m0); +mfloat_t smat4_determinant(struct mat4 m0) { + return mat4_determinant((mfloat_t *)&m0); } -struct mat4 smat4_assign(struct mat4 m0) -{ - struct mat4 result; - mat4_assign((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat4 smat4_assign(struct mat4 m0) { + struct mat4 result; + mat4_assign((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat4 smat4_negative(struct mat4 m0) -{ - struct mat4 result; - mat4_negative((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat4 smat4_negative(struct mat4 m0) { + struct mat4 result; + mat4_negative((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat4 smat4_transpose(struct mat4 m0) -{ - struct mat4 result; - mat4_transpose((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat4 smat4_transpose(struct mat4 m0) { + struct mat4 result; + mat4_transpose((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat4 smat4_cofactor(struct mat4 m0) -{ - struct mat4 result; - mat4_cofactor((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat4 smat4_cofactor(struct mat4 m0) { + struct mat4 result; + mat4_cofactor((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat4 smat4_rotation_x(mfloat_t f) -{ - struct mat4 result; - mat4_rotation_x((mfloat_t *) & result, f); - return result; +struct mat4 smat4_rotation_x(mfloat_t f) { + struct mat4 result; + mat4_rotation_x((mfloat_t *)&result, f); + return result; } -struct mat4 smat4_rotation_y(mfloat_t f) -{ - struct mat4 result; - mat4_rotation_y((mfloat_t *) & result, f); - return result; +struct mat4 smat4_rotation_y(mfloat_t f) { + struct mat4 result; + mat4_rotation_y((mfloat_t *)&result, f); + return result; } -struct mat4 smat4_rotation_z(mfloat_t f) -{ - struct mat4 result; - mat4_rotation_z((mfloat_t *) & result, f); - return result; +struct mat4 smat4_rotation_z(mfloat_t f) { + struct mat4 result; + mat4_rotation_z((mfloat_t *)&result, f); + return result; } -struct mat4 smat4_rotation_axis(struct vec3 v0, mfloat_t f) -{ - struct mat4 result; - mat4_rotation_axis((mfloat_t *) & result, (mfloat_t *) & v0, f); - return result; +struct mat4 smat4_rotation_axis(struct vec3 v0, mfloat_t f) { + struct mat4 result; + mat4_rotation_axis((mfloat_t *)&result, (mfloat_t *)&v0, f); + return result; } -struct mat4 smat4_rotation_quat(struct quat q0) -{ - struct mat4 result; - mat4_rotation_quat((mfloat_t *) & result, (mfloat_t *) & q0); - return result; +struct mat4 smat4_rotation_quat(struct quat q0) { + struct mat4 result; + mat4_rotation_quat((mfloat_t *)&result, (mfloat_t *)&q0); + return result; } -struct mat4 smat4_translation(struct mat4 m0, struct vec3 v0) -{ - struct mat4 result; - mat4_translation((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & v0); - return result; +struct mat4 smat4_translation(struct mat4 m0, struct vec3 v0) { + struct mat4 result; + mat4_translation((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&v0); + return result; } -struct mat4 smat4_translate(struct mat4 m0, struct vec3 v0) -{ - struct mat4 result; - mat4_translate((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & v0); - return result; +struct mat4 smat4_translate(struct mat4 m0, struct vec3 v0) { + struct mat4 result; + mat4_translate((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&v0); + return result; } -struct mat4 smat4_scaling(struct mat4 m0, struct vec3 v0) -{ - struct mat4 result; - mat4_scaling((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & v0); - return result; +struct mat4 smat4_scaling(struct mat4 m0, struct vec3 v0) { + struct mat4 result; + mat4_scaling((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&v0); + return result; } -struct mat4 smat4_scale(struct mat4 m0, struct vec3 v0) -{ - struct mat4 result; - mat4_scale((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & v0); - return result; +struct mat4 smat4_scale(struct mat4 m0, struct vec3 v0) { + struct mat4 result; + mat4_scale((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&v0); + return result; } -struct mat4 smat4_multiply(struct mat4 m0, struct mat4 m1) -{ - struct mat4 result; - mat4_multiply((mfloat_t *) & result, (mfloat_t *) & m0, - (mfloat_t *) & m1); - return result; +struct mat4 smat4_multiply(struct mat4 m0, struct mat4 m1) { + struct mat4 result; + mat4_multiply((mfloat_t *)&result, (mfloat_t *)&m0, + (mfloat_t *)&m1); + return result; } -struct mat4 smat4_multiply_f(struct mat4 m0, mfloat_t f) -{ - struct mat4 result; - mat4_multiply_f((mfloat_t *) & result, (mfloat_t *) & m0, f); - return result; +struct mat4 smat4_multiply_f(struct mat4 m0, mfloat_t f) { + struct mat4 result; + mat4_multiply_f((mfloat_t *)&result, (mfloat_t *)&m0, f); + return result; } -struct mat4 smat4_inverse(struct mat4 m0) -{ - struct mat4 result; - mat4_inverse((mfloat_t *) & result, (mfloat_t *) & m0); - return result; +struct mat4 smat4_inverse(struct mat4 m0) { + struct mat4 result; + mat4_inverse((mfloat_t *)&result, (mfloat_t *)&m0); + return result; } -struct mat4 smat4_lerp(struct mat4 m0, struct mat4 m1, mfloat_t f) -{ - struct mat4 result; - mat4_lerp((mfloat_t *) & result, (mfloat_t *) & m0, (mfloat_t *) & m1, - f); - return result; +struct mat4 smat4_lerp(struct mat4 m0, struct mat4 m1, mfloat_t f) { + struct mat4 result; + mat4_lerp((mfloat_t *)&result, (mfloat_t *)&m0, (mfloat_t *)&m1, + f); + return result; } struct mat4 smat4_look_at(struct vec3 position, struct vec3 target, - struct vec3 up) -{ - struct mat4 result; - mat4_look_at((mfloat_t *) & result, (mfloat_t *) & position, - (mfloat_t *) & target, (mfloat_t *) & up); - return result; + struct vec3 up) { + struct mat4 result; + mat4_look_at((mfloat_t *)&result, (mfloat_t *)&position, + (mfloat_t *)&target, (mfloat_t *)&up); + return result; } struct mat4 smat4_ortho(mfloat_t l, mfloat_t r, mfloat_t b, mfloat_t t, - mfloat_t n, mfloat_t f) -{ - struct mat4 result; - mat4_ortho((mfloat_t *) & result, l, r, b, t, n, f); - return result; + mfloat_t n, mfloat_t f) { + struct mat4 result; + mat4_ortho((mfloat_t *)&result, l, r, b, t, n, f); + return result; } struct mat4 smat4_perspective(mfloat_t fov_y, mfloat_t aspect, mfloat_t n, - mfloat_t f) -{ - struct mat4 result; - mat4_perspective((mfloat_t *) & result, fov_y, aspect, n, f); - return result; + mfloat_t f) { + struct mat4 result; + mat4_perspective((mfloat_t *)&result, fov_y, aspect, n, f); + return result; } struct mat4 smat4_perspective_fov(mfloat_t fov, mfloat_t w, mfloat_t h, - mfloat_t n, mfloat_t f) -{ - struct mat4 result; - mat4_perspective_fov((mfloat_t *) & result, fov, w, h, n, f); - return result; + mfloat_t n, mfloat_t f) { + struct mat4 result; + mat4_perspective_fov((mfloat_t *)&result, fov, w, h, n, f); + return result; } struct mat4 smat4_perspective_infinite(mfloat_t fov_y, mfloat_t aspect, - mfloat_t n) -{ - struct mat4 result; - mat4_perspective_infinite((mfloat_t *) & result, fov_y, aspect, n); - return result; + mfloat_t n) { + struct mat4 result; + mat4_perspective_infinite((mfloat_t *)&result, fov_y, aspect, n); + return result; } #endif #endif #if defined(MATHC_USE_POINTER_STRUCT_FUNCTIONS) #if defined(MATHC_USE_INT) -bool psvec2i_is_zero(struct vec2i *v0) -{ - return vec2i_is_zero((mint_t *) v0); +bool psvec2i_is_zero(struct vec2i *v0) { + return vec2i_is_zero((mint_t *)v0); } -bool psvec2i_is_equal(struct vec2i *v0, struct vec2i *v1) -{ - return vec2i_is_equal((mint_t *) v0, (mint_t *) v1); +bool psvec2i_is_equal(struct vec2i *v0, struct vec2i *v1) { + return vec2i_is_equal((mint_t *)v0, (mint_t *)v1); } -struct vec2i *psvec2i(struct vec2i *result, mint_t x, mint_t y) -{ - return (struct vec2i *) vec2i((mint_t *) result, x, y); +struct vec2i *psvec2i(struct vec2i *result, mint_t x, mint_t y) { + return (struct vec2i *)vec2i((mint_t *)result, x, y); } -struct vec2i *psvec2i_assign(struct vec2i *result, struct vec2i *v0) -{ - return (struct vec2i *) vec2i_assign((mint_t *) result, (mint_t *) v0); +struct vec2i *psvec2i_assign(struct vec2i *result, struct vec2i *v0) { + return (struct vec2i *)vec2i_assign((mint_t *)result, (mint_t *)v0); } #if defined(MATHC_USE_FLOATING_POINT) -struct vec2i *psvec2i_assign_vec2(struct vec2i *result, struct vec2 *v0) -{ - return (struct vec2i *) vec2i_assign_vec2((mint_t *) result, - (mfloat_t *) v0); +struct vec2i *psvec2i_assign_vec2(struct vec2i *result, struct vec2 *v0) { + return (struct vec2i *)vec2i_assign_vec2((mint_t *)result, + (mfloat_t *)v0); } #endif -struct vec2i *psvec2i_zero(struct vec2i *result) -{ - return (struct vec2i *) vec2i_zero((mint_t *) result); +struct vec2i *psvec2i_zero(struct vec2i *result) { + return (struct vec2i *)vec2i_zero((mint_t *)result); } -struct vec2i *psvec2i_one(struct vec2i *result) -{ - return (struct vec2i *) vec2i_one((mint_t *) result); +struct vec2i *psvec2i_one(struct vec2i *result) { + return (struct vec2i *)vec2i_one((mint_t *)result); } -struct vec2i *psvec2i_sign(struct vec2i *result, struct vec2i *v0) -{ - return (struct vec2i *) vec2i_sign((mint_t *) result, (mint_t *) v0); +struct vec2i *psvec2i_sign(struct vec2i *result, struct vec2i *v0) { + return (struct vec2i *)vec2i_sign((mint_t *)result, (mint_t *)v0); } struct vec2i *psvec2i_add(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1) -{ - return (struct vec2i *) vec2i_add((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec2i *v1) { + return (struct vec2i *)vec2i_add((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec2i *psvec2i_add_i(struct vec2i *result, struct vec2i *v0, - mint_t i) -{ - return (struct vec2i *) vec2i_add_i((mint_t *) result, (mint_t *) v0, - i); + mint_t i) { + return (struct vec2i *)vec2i_add_i((mint_t *)result, (mint_t *)v0, + i); } struct vec2i *psvec2i_subtract(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1) -{ - return (struct vec2i *) vec2i_subtract((mint_t *) result, - (mint_t *) v0, (mint_t *) v1); + struct vec2i *v1) { + return (struct vec2i *)vec2i_subtract((mint_t *)result, + (mint_t *)v0, (mint_t *)v1); } struct vec2i *psvec2i_subtract_i(struct vec2i *result, struct vec2i *v0, - mint_t i) -{ - return (struct vec2i *) vec2i_subtract_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec2i *)vec2i_subtract_i((mint_t *)result, + (mint_t *)v0, i); } struct vec2i *psvec2i_multiply(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1) -{ - return (struct vec2i *) vec2i_multiply((mint_t *) result, - (mint_t *) v0, (mint_t *) v1); + struct vec2i *v1) { + return (struct vec2i *)vec2i_multiply((mint_t *)result, + (mint_t *)v0, (mint_t *)v1); } struct vec2i *psvec2i_multiply_i(struct vec2i *result, struct vec2i *v0, - mint_t i) -{ - return (struct vec2i *) vec2i_multiply_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec2i *)vec2i_multiply_i((mint_t *)result, + (mint_t *)v0, i); } struct vec2i *psvec2i_divide(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1) -{ - return (struct vec2i *) vec2i_divide((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec2i *v1) { + return (struct vec2i *)vec2i_divide((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec2i *psvec2i_divide_i(struct vec2i *result, struct vec2i *v0, - mint_t i) -{ - return (struct vec2i *) vec2i_divide_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec2i *)vec2i_divide_i((mint_t *)result, + (mint_t *)v0, i); } struct vec2i *psvec2i_snap(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1) -{ - return (struct vec2i *) vec2i_snap((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec2i *v1) { + return (struct vec2i *)vec2i_snap((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec2i *psvec2i_snap_i(struct vec2i *result, struct vec2i *v0, - mint_t i) -{ - return (struct vec2i *) vec2i_snap_i((mint_t *) result, (mint_t *) v0, - i); + mint_t i) { + return (struct vec2i *)vec2i_snap_i((mint_t *)result, (mint_t *)v0, + i); } -struct vec2i *psvec2i_negative(struct vec2i *result, struct vec2i *v0) -{ - return (struct vec2i *) vec2i_negative((mint_t *) result, - (mint_t *) v0); +struct vec2i *psvec2i_negative(struct vec2i *result, struct vec2i *v0) { + return (struct vec2i *)vec2i_negative((mint_t *)result, + (mint_t *)v0); } -struct vec2i *psvec2i_abs(struct vec2i *result, struct vec2i *v0) -{ - return (struct vec2i *) vec2i_abs((mint_t *) result, (mint_t *) v0); +struct vec2i *psvec2i_abs(struct vec2i *result, struct vec2i *v0) { + return (struct vec2i *)vec2i_abs((mint_t *)result, (mint_t *)v0); } struct vec2i *psvec2i_max(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1) -{ - return (struct vec2i *) vec2i_max((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec2i *v1) { + return (struct vec2i *)vec2i_max((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec2i *psvec2i_min(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1) -{ - return (struct vec2i *) vec2i_min((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec2i *v1) { + return (struct vec2i *)vec2i_min((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec2i *psvec2i_clamp(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1, struct vec2i *v2) -{ - return (struct vec2i *) vec2i_clamp((mint_t *) result, (mint_t *) v0, - (mint_t *) v1, (mint_t *) v2); + struct vec2i *v1, struct vec2i *v2) { + return (struct vec2i *)vec2i_clamp((mint_t *)result, (mint_t *)v0, + (mint_t *)v1, (mint_t *)v2); } -struct vec2i *psvec2i_tangent(struct vec2i *result, struct vec2i *v0) -{ - return (struct vec2i *) vec2i_tangent((mint_t *) result, - (mint_t *) v0); +struct vec2i *psvec2i_tangent(struct vec2i *result, struct vec2i *v0) { + return (struct vec2i *)vec2i_tangent((mint_t *)result, + (mint_t *)v0); } -bool psvec3i_is_zero(struct vec3i *v0) -{ - return vec3i_is_zero((mint_t *) v0); +bool psvec3i_is_zero(struct vec3i *v0) { + return vec3i_is_zero((mint_t *)v0); } -bool psvec3i_is_equal(struct vec3i *v0, struct vec3i *v1) -{ - return vec3i_is_equal((mint_t *) v0, (mint_t *) v1); +bool psvec3i_is_equal(struct vec3i *v0, struct vec3i *v1) { + return vec3i_is_equal((mint_t *)v0, (mint_t *)v1); } -struct vec3i *psvec3i(struct vec3i *result, mint_t x, mint_t y, mint_t z) -{ - return (struct vec3i *) vec3i((mint_t *) result, x, y, z); +struct vec3i *psvec3i(struct vec3i *result, mint_t x, mint_t y, mint_t z) { + return (struct vec3i *)vec3i((mint_t *)result, x, y, z); } -struct vec3i *psvec3i_assign(struct vec3i *result, struct vec3i *v0) -{ - return (struct vec3i *) vec3i_assign((mint_t *) result, (mint_t *) v0); +struct vec3i *psvec3i_assign(struct vec3i *result, struct vec3i *v0) { + return (struct vec3i *)vec3i_assign((mint_t *)result, (mint_t *)v0); } #if defined(MATHC_USE_FLOATING_POINT) -struct vec3i *psvec3i_assign_vec3(struct vec3i *result, struct vec3 *v0) -{ - return (struct vec3i *) vec3i_assign_vec3((mint_t *) result, - (mfloat_t *) v0); +struct vec3i *psvec3i_assign_vec3(struct vec3i *result, struct vec3 *v0) { + return (struct vec3i *)vec3i_assign_vec3((mint_t *)result, + (mfloat_t *)v0); } #endif -struct vec3i *psvec3i_zero(struct vec3i *result) -{ - return (struct vec3i *) vec3i_zero((mint_t *) result); +struct vec3i *psvec3i_zero(struct vec3i *result) { + return (struct vec3i *)vec3i_zero((mint_t *)result); } -struct vec3i *psvec3i_one(struct vec3i *result) -{ - return (struct vec3i *) vec3i_one((mint_t *) result); +struct vec3i *psvec3i_one(struct vec3i *result) { + return (struct vec3i *)vec3i_one((mint_t *)result); } -struct vec3i *psvec3i_sign(struct vec3i *result, struct vec3i *v0) -{ - return (struct vec3i *) vec3i_sign((mint_t *) result, (mint_t *) v0); +struct vec3i *psvec3i_sign(struct vec3i *result, struct vec3i *v0) { + return (struct vec3i *)vec3i_sign((mint_t *)result, (mint_t *)v0); } struct vec3i *psvec3i_add(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1) -{ - return (struct vec3i *) vec3i_add((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec3i *v1) { + return (struct vec3i *)vec3i_add((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec3i *psvec3i_add_i(struct vec3i *result, struct vec3i *v0, - mint_t i) -{ - return (struct vec3i *) vec3i_add_i((mint_t *) result, (mint_t *) v0, - i); + mint_t i) { + return (struct vec3i *)vec3i_add_i((mint_t *)result, (mint_t *)v0, + i); } struct vec3i *psvec3i_subtract(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1) -{ - return (struct vec3i *) vec3i_subtract((mint_t *) result, - (mint_t *) v0, (mint_t *) v1); + struct vec3i *v1) { + return (struct vec3i *)vec3i_subtract((mint_t *)result, + (mint_t *)v0, (mint_t *)v1); } struct vec3i *psvec3i_subtract_i(struct vec3i *result, struct vec3i *v0, - mint_t i) -{ - return (struct vec3i *) vec3i_subtract_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec3i *)vec3i_subtract_i((mint_t *)result, + (mint_t *)v0, i); } struct vec3i *psvec3i_multiply(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1) -{ - return (struct vec3i *) vec3i_multiply((mint_t *) result, - (mint_t *) v0, (mint_t *) v1); + struct vec3i *v1) { + return (struct vec3i *)vec3i_multiply((mint_t *)result, + (mint_t *)v0, (mint_t *)v1); } struct vec3i *psvec3i_multiply_i(struct vec3i *result, struct vec3i *v0, - mint_t i) -{ - return (struct vec3i *) vec3i_multiply_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec3i *)vec3i_multiply_i((mint_t *)result, + (mint_t *)v0, i); } struct vec3i *psvec3i_divide(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1) -{ - return (struct vec3i *) vec3i_divide((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec3i *v1) { + return (struct vec3i *)vec3i_divide((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec3i *psvec3i_divide_i(struct vec3i *result, struct vec3i *v0, - mint_t i) -{ - return (struct vec3i *) vec3i_divide_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec3i *)vec3i_divide_i((mint_t *)result, + (mint_t *)v0, i); } struct vec3i *psvec3i_snap(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1) -{ - return (struct vec3i *) vec3i_snap((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec3i *v1) { + return (struct vec3i *)vec3i_snap((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec3i *psvec3i_snap_i(struct vec3i *result, struct vec3i *v0, - mint_t i) -{ - return (struct vec3i *) vec3i_snap_i((mint_t *) result, (mint_t *) v0, - i); + mint_t i) { + return (struct vec3i *)vec3i_snap_i((mint_t *)result, (mint_t *)v0, + i); } struct vec3i *psvec3i_cross(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1) -{ - return (struct vec3i *) vec3i_cross((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec3i *v1) { + return (struct vec3i *)vec3i_cross((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } -struct vec3i *psvec3i_negative(struct vec3i *result, struct vec3i *v0) -{ - return (struct vec3i *) vec3i_negative((mint_t *) result, - (mint_t *) v0); +struct vec3i *psvec3i_negative(struct vec3i *result, struct vec3i *v0) { + return (struct vec3i *)vec3i_negative((mint_t *)result, + (mint_t *)v0); } -struct vec3i *psvec3i_abs(struct vec3i *result, struct vec3i *v0) -{ - return (struct vec3i *) vec3i_abs((mint_t *) result, (mint_t *) v0); +struct vec3i *psvec3i_abs(struct vec3i *result, struct vec3i *v0) { + return (struct vec3i *)vec3i_abs((mint_t *)result, (mint_t *)v0); } struct vec3i *psvec3i_max(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1) -{ - return (struct vec3i *) vec3i_max((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec3i *v1) { + return (struct vec3i *)vec3i_max((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec3i *psvec3i_min(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1) -{ - return (struct vec3i *) vec3i_min((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec3i *v1) { + return (struct vec3i *)vec3i_min((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec3i *psvec3i_clamp(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1, struct vec3i *v2) -{ - return (struct vec3i *) vec3i_clamp((mint_t *) result, (mint_t *) v0, - (mint_t *) v1, (mint_t *) v2); + struct vec3i *v1, struct vec3i *v2) { + return (struct vec3i *)vec3i_clamp((mint_t *)result, (mint_t *)v0, + (mint_t *)v1, (mint_t *)v2); } -bool psvec4i_is_zero(struct vec4i *v0) -{ - return vec4i_is_zero((mint_t *) v0); +bool psvec4i_is_zero(struct vec4i *v0) { + return vec4i_is_zero((mint_t *)v0); } -bool psvec4i_is_equal(struct vec4i *v0, struct vec4i *v1) -{ - return vec4i_is_equal((mint_t *) v0, (mint_t *) v1); +bool psvec4i_is_equal(struct vec4i *v0, struct vec4i *v1) { + return vec4i_is_equal((mint_t *)v0, (mint_t *)v1); } struct vec4i *psvec4i(struct vec4i *result, mint_t x, mint_t y, mint_t z, - mint_t w) -{ - return (struct vec4i *) vec4i((mint_t *) result, x, y, z, w); + mint_t w) { + return (struct vec4i *)vec4i((mint_t *)result, x, y, z, w); } -struct vec4i *psvec4i_assign(struct vec4i *result, struct vec4i *v0) -{ - return (struct vec4i *) vec4i_assign((mint_t *) result, (mint_t *) v0); +struct vec4i *psvec4i_assign(struct vec4i *result, struct vec4i *v0) { + return (struct vec4i *)vec4i_assign((mint_t *)result, (mint_t *)v0); } #if defined(MATHC_USE_FLOATING_POINT) -struct vec4i *psvec4i_assign_vec4(struct vec4i *result, struct vec4 *v0) -{ - return (struct vec4i *) vec4i_assign_vec4((mint_t *) result, - (mfloat_t *) v0); +struct vec4i *psvec4i_assign_vec4(struct vec4i *result, struct vec4 *v0) { + return (struct vec4i *)vec4i_assign_vec4((mint_t *)result, + (mfloat_t *)v0); } #endif -struct vec4i *psvec4i_zero(struct vec4i *result) -{ - return (struct vec4i *) vec4i_zero((mint_t *) result); +struct vec4i *psvec4i_zero(struct vec4i *result) { + return (struct vec4i *)vec4i_zero((mint_t *)result); } -struct vec4i *psvec4i_one(struct vec4i *result) -{ - return (struct vec4i *) vec4i_one((mint_t *) result); +struct vec4i *psvec4i_one(struct vec4i *result) { + return (struct vec4i *)vec4i_one((mint_t *)result); } -struct vec4i *psvec4i_sign(struct vec4i *result, struct vec4i *v0) -{ - return (struct vec4i *) vec4i_sign((mint_t *) result, (mint_t *) v0); +struct vec4i *psvec4i_sign(struct vec4i *result, struct vec4i *v0) { + return (struct vec4i *)vec4i_sign((mint_t *)result, (mint_t *)v0); } struct vec4i *psvec4i_add(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1) -{ - return (struct vec4i *) vec4i_add((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec4i *v1) { + return (struct vec4i *)vec4i_add((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec4i *psvec4i_add_i(struct vec4i *result, struct vec4i *v0, - mint_t i) -{ - return (struct vec4i *) vec4i_add_i((mint_t *) result, (mint_t *) v0, - i); + mint_t i) { + return (struct vec4i *)vec4i_add_i((mint_t *)result, (mint_t *)v0, + i); } struct vec4i *psvec4i_subtract(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1) -{ - return (struct vec4i *) vec4i_subtract((mint_t *) result, - (mint_t *) v0, (mint_t *) v1); + struct vec4i *v1) { + return (struct vec4i *)vec4i_subtract((mint_t *)result, + (mint_t *)v0, (mint_t *)v1); } struct vec4i *psvec4i_subtract_i(struct vec4i *result, struct vec4i *v0, - mint_t i) -{ - return (struct vec4i *) vec4i_subtract_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec4i *)vec4i_subtract_i((mint_t *)result, + (mint_t *)v0, i); } struct vec4i *psvec4i_multiply(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1) -{ - return (struct vec4i *) vec4i_multiply((mint_t *) result, - (mint_t *) v0, (mint_t *) v1); + struct vec4i *v1) { + return (struct vec4i *)vec4i_multiply((mint_t *)result, + (mint_t *)v0, (mint_t *)v1); } struct vec4i *psvec4i_multiply_i(struct vec4i *result, struct vec4i *v0, - mint_t i) -{ - return (struct vec4i *) vec4i_multiply_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec4i *)vec4i_multiply_i((mint_t *)result, + (mint_t *)v0, i); } struct vec4i *psvec4i_divide(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1) -{ - return (struct vec4i *) vec4i_divide((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec4i *v1) { + return (struct vec4i *)vec4i_divide((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec4i *psvec4i_divide_i(struct vec4i *result, struct vec4i *v0, - mint_t i) -{ - return (struct vec4i *) vec4i_divide_i((mint_t *) result, - (mint_t *) v0, i); + mint_t i) { + return (struct vec4i *)vec4i_divide_i((mint_t *)result, + (mint_t *)v0, i); } struct vec4i *psvec4i_snap(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1) -{ - return (struct vec4i *) vec4i_snap((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec4i *v1) { + return (struct vec4i *)vec4i_snap((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec4i *psvec4i_snap_i(struct vec4i *result, struct vec4i *v0, - mint_t i) -{ - return (struct vec4i *) vec4i_snap_i((mint_t *) result, (mint_t *) v0, - i); + mint_t i) { + return (struct vec4i *)vec4i_snap_i((mint_t *)result, (mint_t *)v0, + i); } -struct vec4i *psvec4i_negative(struct vec4i *result, struct vec4i *v0) -{ - return (struct vec4i *) vec4i_negative((mint_t *) result, - (mint_t *) v0); +struct vec4i *psvec4i_negative(struct vec4i *result, struct vec4i *v0) { + return (struct vec4i *)vec4i_negative((mint_t *)result, + (mint_t *)v0); } -struct vec4i *psvec4i_abs(struct vec4i *result, struct vec4i *v0) -{ - return (struct vec4i *) vec4i_abs((mint_t *) result, (mint_t *) v0); +struct vec4i *psvec4i_abs(struct vec4i *result, struct vec4i *v0) { + return (struct vec4i *)vec4i_abs((mint_t *)result, (mint_t *)v0); } struct vec4i *psvec4i_max(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1) -{ - return (struct vec4i *) vec4i_max((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec4i *v1) { + return (struct vec4i *)vec4i_max((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec4i *psvec4i_min(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1) -{ - return (struct vec4i *) vec4i_min((mint_t *) result, (mint_t *) v0, - (mint_t *) v1); + struct vec4i *v1) { + return (struct vec4i *)vec4i_min((mint_t *)result, (mint_t *)v0, + (mint_t *)v1); } struct vec4i *psvec4i_clamp(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1, struct vec4i *v2) -{ - return (struct vec4i *) vec4i_clamp((mint_t *) result, (mint_t *) v0, - (mint_t *) v1, (mint_t *) v2); + struct vec4i *v1, struct vec4i *v2) { + return (struct vec4i *)vec4i_clamp((mint_t *)result, (mint_t *)v0, + (mint_t *)v1, (mint_t *)v2); } #endif #if defined(MATHC_USE_FLOATING_POINT) -bool psvec2_is_zero(struct vec2 *v0) -{ - return vec2_is_zero((mfloat_t *) v0); +bool psvec2_is_zero(struct vec2 *v0) { + return vec2_is_zero((mfloat_t *)v0); } -bool psvec2_is_equal(struct vec2 *v0, struct vec2 *v1) -{ - return vec2_is_equal((mfloat_t *) v0, (mfloat_t *) v1); +bool psvec2_is_equal(struct vec2 *v0, struct vec2 *v1) { + return vec2_is_equal((mfloat_t *)v0, (mfloat_t *)v1); } -struct vec2 *psvec2(struct vec2 *result, mfloat_t x, mfloat_t y) -{ - return (struct vec2 *) vec2((mfloat_t *) result, x, y); +struct vec2 *psvec2(struct vec2 *result, mfloat_t x, mfloat_t y) { + return (struct vec2 *)vec2((mfloat_t *)result, x, y); } -struct vec2 *psvec2_assign(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_assign((mfloat_t *) result, - (mfloat_t *) v0); +struct vec2 *psvec2_assign(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_assign((mfloat_t *)result, + (mfloat_t *)v0); } #if defined(MATHC_USE_INT) -struct vec2 *psvec2_assign_vec2i(struct vec2 *result, struct vec2i *v0) -{ - return (struct vec2 *) vec2_assign_vec2i((mfloat_t *) result, - (mint_t *) v0); +struct vec2 *psvec2_assign_vec2i(struct vec2 *result, struct vec2i *v0) { + return (struct vec2 *)vec2_assign_vec2i((mfloat_t *)result, + (mint_t *)v0); } #endif -struct vec2 *psvec2_zero(struct vec2 *result) -{ - return (struct vec2 *) vec2_zero((mfloat_t *) result); +struct vec2 *psvec2_zero(struct vec2 *result) { + return (struct vec2 *)vec2_zero((mfloat_t *)result); } -struct vec2 *psvec2_one(struct vec2 *result) -{ - return (struct vec2 *) vec2_one((mfloat_t *) result); +struct vec2 *psvec2_one(struct vec2 *result) { + return (struct vec2 *)vec2_one((mfloat_t *)result); } -struct vec2 *psvec2_sign(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_sign((mfloat_t *) result, (mfloat_t *) v0); +struct vec2 *psvec2_sign(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_sign((mfloat_t *)result, (mfloat_t *)v0); } struct vec2 *psvec2_add(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1) -{ - return (struct vec2 *) vec2_add((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec2 *v1) { + return (struct vec2 *)vec2_add((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } -struct vec2 *psvec2_add_f(struct vec2 *result, struct vec2 *v0, mfloat_t f) -{ - return (struct vec2 *) vec2_add_f((mfloat_t *) result, (mfloat_t *) v0, - f); +struct vec2 *psvec2_add_f(struct vec2 *result, struct vec2 *v0, mfloat_t f) { + return (struct vec2 *)vec2_add_f((mfloat_t *)result, (mfloat_t *)v0, + f); } struct vec2 *psvec2_subtract(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1) -{ - return (struct vec2 *) vec2_subtract((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec2 *v1) { + return (struct vec2 *)vec2_subtract((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec2 *psvec2_subtract_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f) -{ - return (struct vec2 *) vec2_subtract_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec2 *)vec2_subtract_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec2 *psvec2_multiply(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1) -{ - return (struct vec2 *) vec2_multiply((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec2 *v1) { + return (struct vec2 *)vec2_multiply((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec2 *psvec2_multiply_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f) -{ - return (struct vec2 *) vec2_multiply_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec2 *)vec2_multiply_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec2 *psvec2_multiply_mat2(struct vec2 *result, struct vec2 *v0, - struct mat2 *m0) -{ - return (struct vec2 *) vec2_multiply_mat2((mfloat_t *) result, - (mfloat_t *) v0, - (mfloat_t *) m0); + struct mat2 *m0) { + return (struct vec2 *)vec2_multiply_mat2((mfloat_t *)result, + (mfloat_t *)v0, + (mfloat_t *)m0); } struct vec2 *psvec2_divide(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1) -{ - return (struct vec2 *) vec2_divide((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec2 *v1) { + return (struct vec2 *)vec2_divide((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec2 *psvec2_divide_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f) -{ - return (struct vec2 *) vec2_divide_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec2 *)vec2_divide_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec2 *psvec2_snap(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1) -{ - return (struct vec2 *) vec2_snap((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec2 *v1) { + return (struct vec2 *)vec2_snap((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec2 *psvec2_snap_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f) -{ - return (struct vec2 *) vec2_snap_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec2 *)vec2_snap_f((mfloat_t *)result, + (mfloat_t *)v0, f); } -struct vec2 *psvec2_negative(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_negative((mfloat_t *) result, - (mfloat_t *) v0); +struct vec2 *psvec2_negative(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_negative((mfloat_t *)result, + (mfloat_t *)v0); } -struct vec2 *psvec2_abs(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_abs((mfloat_t *) result, (mfloat_t *) v0); +struct vec2 *psvec2_abs(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_abs((mfloat_t *)result, (mfloat_t *)v0); } -struct vec2 *psvec2_floor(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_floor((mfloat_t *) result, - (mfloat_t *) v0); +struct vec2 *psvec2_floor(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_floor((mfloat_t *)result, + (mfloat_t *)v0); } -struct vec2 *psvec2_ceil(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_ceil((mfloat_t *) result, (mfloat_t *) v0); +struct vec2 *psvec2_ceil(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_ceil((mfloat_t *)result, (mfloat_t *)v0); } -struct vec2 *psvec2_round(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_round((mfloat_t *) result, - (mfloat_t *) v0); +struct vec2 *psvec2_round(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_round((mfloat_t *)result, + (mfloat_t *)v0); } struct vec2 *psvec2_max(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1) -{ - return (struct vec2 *) vec2_max((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec2 *v1) { + return (struct vec2 *)vec2_max((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec2 *psvec2_min(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1) -{ - return (struct vec2 *) vec2_min((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec2 *v1) { + return (struct vec2 *)vec2_min((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec2 *psvec2_clamp(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1, struct vec2 *v2) -{ - return (struct vec2 *) vec2_clamp((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1, (mfloat_t *) v2); + struct vec2 *v1, struct vec2 *v2) { + return (struct vec2 *)vec2_clamp((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1, (mfloat_t *)v2); } -struct vec2 *psvec2_normalize(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_normalize((mfloat_t *) result, - (mfloat_t *) v0); +struct vec2 *psvec2_normalize(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_normalize((mfloat_t *)result, + (mfloat_t *)v0); } -mfloat_t psvec2_dot(struct vec2 *v0, struct vec2 *v1) -{ - return vec2_dot((mfloat_t *) v0, (mfloat_t *) v1); +mfloat_t psvec2_dot(struct vec2 *v0, struct vec2 *v1) { + return vec2_dot((mfloat_t *)v0, (mfloat_t *)v1); } struct vec2 *psvec2_project(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1) -{ - return (struct vec2 *) vec2_project((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec2 *v1) { + return (struct vec2 *)vec2_project((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec2 *psvec2_slide(struct vec2 *result, struct vec2 *v0, - struct vec2 *normal) -{ - return (struct vec2 *) vec2_slide((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) normal); + struct vec2 *normal) { + return (struct vec2 *)vec2_slide((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)normal); } struct vec2 *psvec2_reflect(struct vec2 *result, struct vec2 *v0, - struct vec2 *normal) -{ - return (struct vec2 *) vec2_reflect((mfloat_t *) result, - (mfloat_t *) v0, - (mfloat_t *) normal); + struct vec2 *normal) { + return (struct vec2 *)vec2_reflect((mfloat_t *)result, + (mfloat_t *)v0, + (mfloat_t *)normal); } -struct vec2 *psvec2_tangent(struct vec2 *result, struct vec2 *v0) -{ - return (struct vec2 *) vec2_tangent((mfloat_t *) result, - (mfloat_t *) v0); +struct vec2 *psvec2_tangent(struct vec2 *result, struct vec2 *v0) { + return (struct vec2 *)vec2_tangent((mfloat_t *)result, + (mfloat_t *)v0); } struct vec2 *psvec2_rotate(struct vec2 *result, struct vec2 *v0, - mfloat_t f) -{ - return (struct vec2 *) vec2_rotate((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec2 *)vec2_rotate((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec2 *psvec2_lerp(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1, mfloat_t f) -{ - return (struct vec2 *) vec2_lerp((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1, f); + struct vec2 *v1, mfloat_t f) { + return (struct vec2 *)vec2_lerp((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1, f); } struct vec2 *psvec2_bezier3(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1, struct vec2 *v2, mfloat_t f) -{ - return (struct vec2 *) vec2_bezier3((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1, - (mfloat_t *) v2, f); + struct vec2 *v1, struct vec2 *v2, mfloat_t f) { + return (struct vec2 *)vec2_bezier3((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1, + (mfloat_t *)v2, f); } struct vec2 *psvec2_bezier4(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1, struct vec2 *v2, - struct vec2 *v3, mfloat_t f) -{ - return (struct vec2 *) vec2_bezier4((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1, - (mfloat_t *) v2, (mfloat_t *) v3, - f); + struct vec2 *v1, struct vec2 *v2, + struct vec2 *v3, mfloat_t f) { + return (struct vec2 *)vec2_bezier4((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1, + (mfloat_t *)v2, (mfloat_t *)v3, + f); } -mfloat_t psvec2_angle(struct vec2 *v0) -{ - return vec2_angle((mfloat_t *) v0); +mfloat_t psvec2_angle(struct vec2 *v0) { + return vec2_angle((mfloat_t *)v0); } -mfloat_t psvec2_length(struct vec2 *v0) -{ - return vec2_length((mfloat_t *) v0); +mfloat_t psvec2_length(struct vec2 *v0) { + return vec2_length((mfloat_t *)v0); } -mfloat_t psvec2_length_squared(struct vec2 *v0) -{ - return vec2_length_squared((mfloat_t *) v0); +mfloat_t psvec2_length_squared(struct vec2 *v0) { + return vec2_length_squared((mfloat_t *)v0); } -mfloat_t psvec2_distance(struct vec2 *v0, struct vec2 *v1) -{ - return vec2_distance((mfloat_t *) v0, (mfloat_t *) v1); +mfloat_t psvec2_distance(struct vec2 *v0, struct vec2 *v1) { + return vec2_distance((mfloat_t *)v0, (mfloat_t *)v1); } -mfloat_t psvec2_distance_squared(struct vec2 *v0, struct vec2 *v1) -{ - return vec2_distance_squared((mfloat_t *) v0, (mfloat_t *) v1); +mfloat_t psvec2_distance_squared(struct vec2 *v0, struct vec2 *v1) { + return vec2_distance_squared((mfloat_t *)v0, (mfloat_t *)v1); } -bool psvec3_is_zero(struct vec3 *v0) -{ - return vec3_is_zero((mfloat_t *) v0); +bool psvec3_is_zero(struct vec3 *v0) { + return vec3_is_zero((mfloat_t *)v0); } -bool psvec3_is_equal(struct vec3 *v0, struct vec3 *v1) -{ - return vec3_is_equal((mfloat_t *) v0, (mfloat_t *) v1); +bool psvec3_is_equal(struct vec3 *v0, struct vec3 *v1) { + return vec3_is_equal((mfloat_t *)v0, (mfloat_t *)v1); } struct vec3 *psvec3(struct vec3 *result, mfloat_t x, mfloat_t y, - mfloat_t z) -{ - return (struct vec3 *) vec3((mfloat_t *) result, x, y, z); + mfloat_t z) { + return (struct vec3 *)vec3((mfloat_t *)result, x, y, z); } -struct vec3 *psvec3_assign(struct vec3 *result, struct vec3 *v0) -{ - return (struct vec3 *) vec3_assign((mfloat_t *) result, - (mfloat_t *) v0); +struct vec3 *psvec3_assign(struct vec3 *result, struct vec3 *v0) { + return (struct vec3 *)vec3_assign((mfloat_t *)result, + (mfloat_t *)v0); } #if defined(MATHC_USE_INT) -struct vec3 *psvec3_assign_vec3i(struct vec3 *result, struct vec3i *v0) -{ - return (struct vec3 *) vec3_assign_vec3i((mfloat_t *) result, - (mint_t *) v0); +struct vec3 *psvec3_assign_vec3i(struct vec3 *result, struct vec3i *v0) { + return (struct vec3 *)vec3_assign_vec3i((mfloat_t *)result, + (mint_t *)v0); } #endif -struct vec3 *psvec3_zero(struct vec3 *result) -{ - return (struct vec3 *) vec3_zero((mfloat_t *) result); +struct vec3 *psvec3_zero(struct vec3 *result) { + return (struct vec3 *)vec3_zero((mfloat_t *)result); } -struct vec3 *psvec3_one(struct vec3 *result) -{ - return (struct vec3 *) vec3_one((mfloat_t *) result); +struct vec3 *psvec3_one(struct vec3 *result) { + return (struct vec3 *)vec3_one((mfloat_t *)result); } -struct vec3 *psvec3_sign(struct vec3 *result, struct vec3 *v0) -{ - return (struct vec3 *) vec3_sign((mfloat_t *) result, (mfloat_t *) v0); +struct vec3 *psvec3_sign(struct vec3 *result, struct vec3 *v0) { + return (struct vec3 *)vec3_sign((mfloat_t *)result, (mfloat_t *)v0); } struct vec3 *psvec3_add(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_add((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_add((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } -struct vec3 *psvec3_add_f(struct vec3 *result, struct vec3 *v0, mfloat_t f) -{ - return (struct vec3 *) vec3_add_f((mfloat_t *) result, (mfloat_t *) v0, - f); +struct vec3 *psvec3_add_f(struct vec3 *result, struct vec3 *v0, mfloat_t f) { + return (struct vec3 *)vec3_add_f((mfloat_t *)result, (mfloat_t *)v0, + f); } struct vec3 *psvec3_subtract(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_subtract((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_subtract((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec3 *psvec3_subtract_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f) -{ - return (struct vec3 *) vec3_subtract_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec3 *)vec3_subtract_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec3 *psvec3_multiply(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_multiply((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_multiply((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec3 *psvec3_multiply_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f) -{ - return (struct vec3 *) vec3_multiply_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec3 *)vec3_multiply_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec3 *psvec3_multiply_mat3(struct vec3 *result, struct vec3 *v0, - struct mat3 *m0) -{ - return (struct vec3 *) vec3_multiply_mat3((mfloat_t *) result, - (mfloat_t *) v0, - (mfloat_t *) m0); + struct mat3 *m0) { + return (struct vec3 *)vec3_multiply_mat3((mfloat_t *)result, + (mfloat_t *)v0, + (mfloat_t *)m0); } struct vec3 *psvec3_divide(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_divide((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_divide((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec3 *psvec3_divide_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f) -{ - return (struct vec3 *) vec3_divide_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec3 *)vec3_divide_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec3 *psvec3_snap(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_snap((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_snap((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec3 *psvec3_snap_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f) -{ - return (struct vec3 *) vec3_snap_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec3 *)vec3_snap_f((mfloat_t *)result, + (mfloat_t *)v0, f); } -struct vec3 *psvec3_negative(struct vec3 *result, struct vec3 *v0) -{ - return (struct vec3 *) vec3_negative((mfloat_t *) result, - (mfloat_t *) v0); +struct vec3 *psvec3_negative(struct vec3 *result, struct vec3 *v0) { + return (struct vec3 *)vec3_negative((mfloat_t *)result, + (mfloat_t *)v0); } -struct vec3 *psvec3_abs(struct vec3 *result, struct vec3 *v0) -{ - return (struct vec3 *) vec3_abs((mfloat_t *) result, (mfloat_t *) v0); +struct vec3 *psvec3_abs(struct vec3 *result, struct vec3 *v0) { + return (struct vec3 *)vec3_abs((mfloat_t *)result, (mfloat_t *)v0); } -struct vec3 *psvec3_floor(struct vec3 *result, struct vec3 *v0) -{ - return (struct vec3 *) vec3_floor((mfloat_t *) result, - (mfloat_t *) v0); +struct vec3 *psvec3_floor(struct vec3 *result, struct vec3 *v0) { + return (struct vec3 *)vec3_floor((mfloat_t *)result, + (mfloat_t *)v0); } -struct vec3 *psvec3_ceil(struct vec3 *result, struct vec3 *v0) -{ - return (struct vec3 *) vec3_ceil((mfloat_t *) result, (mfloat_t *) v0); +struct vec3 *psvec3_ceil(struct vec3 *result, struct vec3 *v0) { + return (struct vec3 *)vec3_ceil((mfloat_t *)result, (mfloat_t *)v0); } -struct vec3 *psvec3_round(struct vec3 *result, struct vec3 *v0) -{ - return (struct vec3 *) vec3_round((mfloat_t *) result, - (mfloat_t *) v0); +struct vec3 *psvec3_round(struct vec3 *result, struct vec3 *v0) { + return (struct vec3 *)vec3_round((mfloat_t *)result, + (mfloat_t *)v0); } struct vec3 *psvec3_max(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_max((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_max((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec3 *psvec3_min(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_min((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_min((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec3 *psvec3_clamp(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1, struct vec3 *v2) -{ - return (struct vec3 *) vec3_clamp((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1, (mfloat_t *) v2); + struct vec3 *v1, struct vec3 *v2) { + return (struct vec3 *)vec3_clamp((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1, (mfloat_t *)v2); } struct vec3 *psvec3_cross(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_cross((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_cross((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } -struct vec3 *psvec3_normalize(struct vec3 *result, struct vec3 *v0) -{ - return (struct vec3 *) vec3_normalize((mfloat_t *) result, - (mfloat_t *) v0); +struct vec3 *psvec3_normalize(struct vec3 *result, struct vec3 *v0) { + return (struct vec3 *)vec3_normalize((mfloat_t *)result, + (mfloat_t *)v0); } -mfloat_t psvec3_dot(struct vec3 *v0, struct vec3 *v1) -{ - return vec3_dot((mfloat_t *) v0, (mfloat_t *) v1); +mfloat_t psvec3_dot(struct vec3 *v0, struct vec3 *v1) { + return vec3_dot((mfloat_t *)v0, (mfloat_t *)v1); } struct vec3 *psvec3_project(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct vec3 *) vec3_project((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec3 *v1) { + return (struct vec3 *)vec3_project((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec3 *psvec3_slide(struct vec3 *result, struct vec3 *v0, - struct vec3 *normal) -{ - return (struct vec3 *) vec3_slide((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) normal); + struct vec3 *normal) { + return (struct vec3 *)vec3_slide((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)normal); } struct vec3 *psvec3_reflect(struct vec3 *result, struct vec3 *v0, - struct vec3 *normal) -{ - return (struct vec3 *) vec3_reflect((mfloat_t *) result, - (mfloat_t *) v0, - (mfloat_t *) normal); + struct vec3 *normal) { + return (struct vec3 *)vec3_reflect((mfloat_t *)result, + (mfloat_t *)v0, + (mfloat_t *)normal); } struct vec3 *psvec3_rotate(struct vec3 *result, struct vec3 *v0, - struct vec3 *ra, mfloat_t f) -{ - return (struct vec3 *) vec3_lerp((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) ra, f); + struct vec3 *ra, mfloat_t f) { + return (struct vec3 *)vec3_lerp((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)ra, f); } struct vec3 *psvec3_lerp(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1, mfloat_t f) -{ - return (struct vec3 *) vec3_lerp((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1, f); + struct vec3 *v1, mfloat_t f) { + return (struct vec3 *)vec3_lerp((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1, f); } struct vec3 *psvec3_bezier3(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1, struct vec3 *v2, mfloat_t f) -{ - return (struct vec3 *) vec3_bezier3((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1, - (mfloat_t *) v2, f); + struct vec3 *v1, struct vec3 *v2, mfloat_t f) { + return (struct vec3 *)vec3_bezier3((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1, + (mfloat_t *)v2, f); } struct vec3 *psvec3_bezier4(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1, struct vec3 *v2, - struct vec3 *v3, mfloat_t f) -{ - return (struct vec3 *) vec3_bezier4((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1, - (mfloat_t *) v2, (mfloat_t *) v3, - f); + struct vec3 *v1, struct vec3 *v2, + struct vec3 *v3, mfloat_t f) { + return (struct vec3 *)vec3_bezier4((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1, + (mfloat_t *)v2, (mfloat_t *)v3, + f); } -mfloat_t psvec3_length(struct vec3 *v0) -{ - return vec3_length((mfloat_t *) v0); +mfloat_t psvec3_length(struct vec3 *v0) { + return vec3_length((mfloat_t *)v0); } -mfloat_t psvec3_length_squared(struct vec3 *v0) -{ - return vec3_length_squared((mfloat_t *) v0); +mfloat_t psvec3_length_squared(struct vec3 *v0) { + return vec3_length_squared((mfloat_t *)v0); } -mfloat_t psvec3_distance(struct vec3 *v0, struct vec3 *v1) -{ - return vec3_distance((mfloat_t *) v0, (mfloat_t *) v1); +mfloat_t psvec3_distance(struct vec3 *v0, struct vec3 *v1) { + return vec3_distance((mfloat_t *)v0, (mfloat_t *)v1); } -mfloat_t psvec3_distance_squared(struct vec3 *v0, struct vec3 *v1) -{ - return vec3_distance_squared((mfloat_t *) v0, (mfloat_t *) v1); +mfloat_t psvec3_distance_squared(struct vec3 *v0, struct vec3 *v1) { + return vec3_distance_squared((mfloat_t *)v0, (mfloat_t *)v1); } -bool psvec4_is_zero(struct vec4 *v0) -{ - return vec4_is_zero((mfloat_t *) v0); +bool psvec4_is_zero(struct vec4 *v0) { + return vec4_is_zero((mfloat_t *)v0); } -bool psvec4_is_equal(struct vec4 *v0, struct vec4 *v1) -{ - return vec4_is_equal((mfloat_t *) v0, (mfloat_t *) v1); +bool psvec4_is_equal(struct vec4 *v0, struct vec4 *v1) { + return vec4_is_equal((mfloat_t *)v0, (mfloat_t *)v1); } struct vec4 *psvec4(struct vec4 *result, mfloat_t x, mfloat_t y, - mfloat_t z, mfloat_t w) -{ - return (struct vec4 *) vec4((mfloat_t *) result, x, y, z, w); + mfloat_t z, mfloat_t w) { + return (struct vec4 *)vec4((mfloat_t *)result, x, y, z, w); } -struct vec4 *psvec4_assign(struct vec4 *result, struct vec4 *v0) -{ - return (struct vec4 *) vec4_assign((mfloat_t *) result, - (mfloat_t *) v0); +struct vec4 *psvec4_assign(struct vec4 *result, struct vec4 *v0) { + return (struct vec4 *)vec4_assign((mfloat_t *)result, + (mfloat_t *)v0); } #if defined(MATHC_USE_INT) -struct vec4 *psvec4_assign_vec4i(struct vec4 *result, struct vec4i *v0) -{ - return (struct vec4 *) vec4_assign_vec4i((mfloat_t *) result, - (mint_t *) v0); +struct vec4 *psvec4_assign_vec4i(struct vec4 *result, struct vec4i *v0) { + return (struct vec4 *)vec4_assign_vec4i((mfloat_t *)result, + (mint_t *)v0); } #endif -struct vec4 *psvec4_zero(struct vec4 *result) -{ - return (struct vec4 *) vec4_zero((mfloat_t *) result); +struct vec4 *psvec4_zero(struct vec4 *result) { + return (struct vec4 *)vec4_zero((mfloat_t *)result); } -struct vec4 *psvec4_one(struct vec4 *result) -{ - return (struct vec4 *) vec4_one((mfloat_t *) result); +struct vec4 *psvec4_one(struct vec4 *result) { + return (struct vec4 *)vec4_one((mfloat_t *)result); } -struct vec4 *psvec4_sign(struct vec4 *result, struct vec4 *v0) -{ - return (struct vec4 *) vec4_sign((mfloat_t *) result, (mfloat_t *) v0); +struct vec4 *psvec4_sign(struct vec4 *result, struct vec4 *v0) { + return (struct vec4 *)vec4_sign((mfloat_t *)result, (mfloat_t *)v0); } struct vec4 *psvec4_add(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1) -{ - return (struct vec4 *) vec4_add((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec4 *v1) { + return (struct vec4 *)vec4_add((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } -struct vec4 *psvec4_add_f(struct vec4 *result, struct vec4 *v0, mfloat_t f) -{ - return (struct vec4 *) vec4_add_f((mfloat_t *) result, (mfloat_t *) v0, - f); +struct vec4 *psvec4_add_f(struct vec4 *result, struct vec4 *v0, mfloat_t f) { + return (struct vec4 *)vec4_add_f((mfloat_t *)result, (mfloat_t *)v0, + f); } struct vec4 *psvec4_subtract(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1) -{ - return (struct vec4 *) vec4_subtract((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec4 *v1) { + return (struct vec4 *)vec4_subtract((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec4 *psvec4_subtract_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f) -{ - return (struct vec4 *) vec4_subtract_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec4 *)vec4_subtract_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec4 *psvec4_multiply(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1) -{ - return (struct vec4 *) vec4_multiply((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec4 *v1) { + return (struct vec4 *)vec4_multiply((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec4 *psvec4_multiply_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f) -{ - return (struct vec4 *) vec4_multiply_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec4 *)vec4_multiply_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec4 *psvec4_multiply_mat4(struct vec4 *result, struct vec4 *v0, - struct mat4 *m0) -{ - return (struct vec4 *) vec4_multiply_mat4((mfloat_t *) result, - (mfloat_t *) v0, - (mfloat_t *) m0); + struct mat4 *m0) { + return (struct vec4 *)vec4_multiply_mat4((mfloat_t *)result, + (mfloat_t *)v0, + (mfloat_t *)m0); } struct vec4 *psvec4_divide(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1) -{ - return (struct vec4 *) vec4_divide((mfloat_t *) result, - (mfloat_t *) v0, (mfloat_t *) v1); + struct vec4 *v1) { + return (struct vec4 *)vec4_divide((mfloat_t *)result, + (mfloat_t *)v0, (mfloat_t *)v1); } struct vec4 *psvec4_divide_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f) -{ - return (struct vec4 *) vec4_divide_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec4 *)vec4_divide_f((mfloat_t *)result, + (mfloat_t *)v0, f); } struct vec4 *psvec4_snap(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1) -{ - return (struct vec4 *) vec4_snap((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec4 *v1) { + return (struct vec4 *)vec4_snap((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec4 *psvec4_snap_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f) -{ - return (struct vec4 *) vec4_snap_f((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct vec4 *)vec4_snap_f((mfloat_t *)result, + (mfloat_t *)v0, f); } -struct vec4 *psvec4_negative(struct vec4 *result, struct vec4 *v0) -{ - return (struct vec4 *) vec4_negative((mfloat_t *) result, - (mfloat_t *) v0); +struct vec4 *psvec4_negative(struct vec4 *result, struct vec4 *v0) { + return (struct vec4 *)vec4_negative((mfloat_t *)result, + (mfloat_t *)v0); } -struct vec4 *psvec4_abs(struct vec4 *result, struct vec4 *v0) -{ - return (struct vec4 *) vec4_abs((mfloat_t *) result, (mfloat_t *) v0); +struct vec4 *psvec4_abs(struct vec4 *result, struct vec4 *v0) { + return (struct vec4 *)vec4_abs((mfloat_t *)result, (mfloat_t *)v0); } -struct vec4 *psvec4_floor(struct vec4 *result, struct vec4 *v0) -{ - return (struct vec4 *) vec4_floor((mfloat_t *) result, - (mfloat_t *) v0); +struct vec4 *psvec4_floor(struct vec4 *result, struct vec4 *v0) { + return (struct vec4 *)vec4_floor((mfloat_t *)result, + (mfloat_t *)v0); } -struct vec4 *psvec4_ceil(struct vec4 *result, struct vec4 *v0) -{ - return (struct vec4 *) vec4_ceil((mfloat_t *) result, (mfloat_t *) v0); +struct vec4 *psvec4_ceil(struct vec4 *result, struct vec4 *v0) { + return (struct vec4 *)vec4_ceil((mfloat_t *)result, (mfloat_t *)v0); } -struct vec4 *psvec4_round(struct vec4 *result, struct vec4 *v0) -{ - return (struct vec4 *) vec4_round((mfloat_t *) result, - (mfloat_t *) v0); +struct vec4 *psvec4_round(struct vec4 *result, struct vec4 *v0) { + return (struct vec4 *)vec4_round((mfloat_t *)result, + (mfloat_t *)v0); } struct vec4 *psvec4_max(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1) -{ - return (struct vec4 *) vec4_max((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec4 *v1) { + return (struct vec4 *)vec4_max((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec4 *psvec4_min(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1) -{ - return (struct vec4 *) vec4_min((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec4 *v1) { + return (struct vec4 *)vec4_min((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1); } struct vec4 *psvec4_clamp(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1, struct vec4 *v2) -{ - return (struct vec4 *) vec4_clamp((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1, (mfloat_t *) v2); + struct vec4 *v1, struct vec4 *v2) { + return (struct vec4 *)vec4_clamp((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1, (mfloat_t *)v2); } -struct vec4 *psvec4_normalize(struct vec4 *result, struct vec4 *v0) -{ - return (struct vec4 *) vec4_normalize((mfloat_t *) result, - (mfloat_t *) v0); +struct vec4 *psvec4_normalize(struct vec4 *result, struct vec4 *v0) { + return (struct vec4 *)vec4_normalize((mfloat_t *)result, + (mfloat_t *)v0); } struct vec4 *psvec4_lerp(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1, mfloat_t f) -{ - return (struct vec4 *) vec4_lerp((mfloat_t *) result, (mfloat_t *) v0, - (mfloat_t *) v1, f); + struct vec4 *v1, mfloat_t f) { + return (struct vec4 *)vec4_lerp((mfloat_t *)result, (mfloat_t *)v0, + (mfloat_t *)v1, f); } -bool psquat_is_zero(struct quat *q0) -{ - return quat_is_zero((mfloat_t *) q0); +bool psquat_is_zero(struct quat *q0) { + return quat_is_zero((mfloat_t *)q0); } -bool psquat_is_equal(struct quat *q0, struct quat *q1) -{ - return quat_is_equal((mfloat_t *) q0, (mfloat_t *) q1); +bool psquat_is_equal(struct quat *q0, struct quat *q1) { + return quat_is_equal((mfloat_t *)q0, (mfloat_t *)q1); } struct quat *psquat(struct quat *result, mfloat_t x, mfloat_t y, - mfloat_t z, mfloat_t w) -{ - return (struct quat *) quat((mfloat_t *) result, x, y, z, w); + mfloat_t z, mfloat_t w) { + return (struct quat *)quat((mfloat_t *)result, x, y, z, w); } -struct quat *psquat_assign(struct quat *result, struct quat *q0) -{ - return (struct quat *) quat_assign((mfloat_t *) result, - (mfloat_t *) q0); +struct quat *psquat_assign(struct quat *result, struct quat *q0) { + return (struct quat *)quat_assign((mfloat_t *)result, + (mfloat_t *)q0); } -struct quat *psquat_zero(struct quat *result) -{ - return (struct quat *) quat_zero((mfloat_t *) result); +struct quat *psquat_zero(struct quat *result) { + return (struct quat *)quat_zero((mfloat_t *)result); } -struct quat *psquat_null(struct quat *result) -{ - return (struct quat *) quat_null((mfloat_t *) result); +struct quat *psquat_null(struct quat *result) { + return (struct quat *)quat_null((mfloat_t *)result); } struct quat *psquat_multiply(struct quat *result, struct quat *q0, - struct quat *q1) -{ - return (struct quat *) quat_multiply((mfloat_t *) result, - (mfloat_t *) q0, (mfloat_t *) q1); + struct quat *q1) { + return (struct quat *)quat_multiply((mfloat_t *)result, + (mfloat_t *)q0, (mfloat_t *)q1); } struct quat *psquat_multiply_f(struct quat *result, struct quat *q0, - mfloat_t f) -{ - return (struct quat *) quat_multiply_f((mfloat_t *) result, - (mfloat_t *) q0, f); + mfloat_t f) { + return (struct quat *)quat_multiply_f((mfloat_t *)result, + (mfloat_t *)q0, f); } struct quat *psquat_divide(struct quat *result, struct quat *q0, - struct quat *q1) -{ - return (struct quat *) quat_divide((mfloat_t *) result, - (mfloat_t *) q0, (mfloat_t *) q1); + struct quat *q1) { + return (struct quat *)quat_divide((mfloat_t *)result, + (mfloat_t *)q0, (mfloat_t *)q1); } struct quat *psquat_divide_f(struct quat *result, struct quat *q0, - mfloat_t f) -{ - return (struct quat *) quat_divide_f((mfloat_t *) result, - (mfloat_t *) q0, f); + mfloat_t f) { + return (struct quat *)quat_divide_f((mfloat_t *)result, + (mfloat_t *)q0, f); } -struct quat *psquat_negative(struct quat *result, struct quat *q0) -{ - return (struct quat *) quat_negative((mfloat_t *) result, - (mfloat_t *) q0); +struct quat *psquat_negative(struct quat *result, struct quat *q0) { + return (struct quat *)quat_negative((mfloat_t *)result, + (mfloat_t *)q0); } -struct quat *psquat_conjugate(struct quat *result, struct quat *q0) -{ - return (struct quat *) quat_conjugate((mfloat_t *) result, - (mfloat_t *) q0); +struct quat *psquat_conjugate(struct quat *result, struct quat *q0) { + return (struct quat *)quat_conjugate((mfloat_t *)result, + (mfloat_t *)q0); } -struct quat *psquat_inverse(struct quat *result, struct quat *q0) -{ - return (struct quat *) quat_inverse((mfloat_t *) result, - (mfloat_t *) q0); +struct quat *psquat_inverse(struct quat *result, struct quat *q0) { + return (struct quat *)quat_inverse((mfloat_t *)result, + (mfloat_t *)q0); } -struct quat *psquat_normalize(struct quat *result, struct quat *q0) -{ - return (struct quat *) quat_normalize((mfloat_t *) result, - (mfloat_t *) q0); +struct quat *psquat_normalize(struct quat *result, struct quat *q0) { + return (struct quat *)quat_normalize((mfloat_t *)result, + (mfloat_t *)q0); } -mfloat_t psquat_dot(struct quat *q0, struct quat *q1) -{ - return quat_dot((mfloat_t *) q0, (mfloat_t *) q1); +mfloat_t psquat_dot(struct quat *q0, struct quat *q1) { + return quat_dot((mfloat_t *)q0, (mfloat_t *)q1); } struct quat *psquat_power(struct quat *result, struct quat *q0, - mfloat_t exponent) -{ - return (struct quat *) quat_power((mfloat_t *) result, (mfloat_t *) q0, - exponent); + mfloat_t exponent) { + return (struct quat *)quat_power((mfloat_t *)result, (mfloat_t *)q0, + exponent); } struct quat *psquat_from_axis_angle(struct quat *result, struct vec3 *v0, - mfloat_t angle) -{ - return (struct quat *) quat_from_axis_angle((mfloat_t *) result, - (mfloat_t *) v0, angle); + mfloat_t angle) { + return (struct quat *)quat_from_axis_angle((mfloat_t *)result, + (mfloat_t *)v0, angle); } struct quat *psquat_from_vec3(struct quat *result, struct vec3 *v0, - struct vec3 *v1) -{ - return (struct quat *) quat_from_vec3((mfloat_t *) result, - (mfloat_t *) v0, - (mfloat_t *) v1); + struct vec3 *v1) { + return (struct quat *)quat_from_vec3((mfloat_t *)result, + (mfloat_t *)v0, + (mfloat_t *)v1); } -struct quat *psquat_from_mat4(struct quat *result, struct mat4 *m0) -{ - return (struct quat *) quat_from_mat4((mfloat_t *) result, - (mfloat_t *) m0); +struct quat *psquat_from_mat4(struct quat *result, struct mat4 *m0) { + return (struct quat *)quat_from_mat4((mfloat_t *)result, + (mfloat_t *)m0); } struct quat *psquat_lerp(struct quat *result, struct quat *q0, - struct quat *q1, mfloat_t f) -{ - return (struct quat *) quat_lerp((mfloat_t *) result, (mfloat_t *) q0, - (mfloat_t *) q1, f); + struct quat *q1, mfloat_t f) { + return (struct quat *)quat_lerp((mfloat_t *)result, (mfloat_t *)q0, + (mfloat_t *)q1, f); } struct quat *psquat_slerp(struct quat *result, struct quat *q0, - struct quat *q1, mfloat_t f) -{ - return (struct quat *) quat_slerp((mfloat_t *) result, (mfloat_t *) q0, - (mfloat_t *) q1, f); + struct quat *q1, mfloat_t f) { + return (struct quat *)quat_slerp((mfloat_t *)result, (mfloat_t *)q0, + (mfloat_t *)q1, f); } -mfloat_t psquat_length(struct quat *q0) -{ - return quat_length((mfloat_t *) q0); +mfloat_t psquat_length(struct quat *q0) { + return quat_length((mfloat_t *)q0); } -mfloat_t psquat_length_squared(struct quat *q0) -{ - return quat_length_squared((mfloat_t *) q0); +mfloat_t psquat_length_squared(struct quat *q0) { + return quat_length_squared((mfloat_t *)q0); } -mfloat_t psquat_angle(struct quat *q0, struct quat *q1) -{ - return quat_angle((mfloat_t *) q0, (mfloat_t *) q1); +mfloat_t psquat_angle(struct quat *q0, struct quat *q1) { + return quat_angle((mfloat_t *)q0, (mfloat_t *)q1); } struct mat2 *psmat2(struct mat2 *result, mfloat_t m11, mfloat_t m12, - mfloat_t m21, mfloat_t m22) -{ - return (struct mat2 *) mat2((mfloat_t *) result, m11, m12, m21, m22); + mfloat_t m21, mfloat_t m22) { + return (struct mat2 *)mat2((mfloat_t *)result, m11, m12, m21, m22); } -struct mat2 *psmat2_zero(struct mat2 *result) -{ - return (struct mat2 *) mat2_zero((mfloat_t *) result); +struct mat2 *psmat2_zero(struct mat2 *result) { + return (struct mat2 *)mat2_zero((mfloat_t *)result); } -struct mat2 *psmat2_identity(struct mat2 *result) -{ - return (struct mat2 *) mat2_identity((mfloat_t *) result); +struct mat2 *psmat2_identity(struct mat2 *result) { + return (struct mat2 *)mat2_identity((mfloat_t *)result); } -mfloat_t psmat2_determinant(struct mat2 *m0) -{ - return mat2_determinant((mfloat_t *) m0); +mfloat_t psmat2_determinant(struct mat2 *m0) { + return mat2_determinant((mfloat_t *)m0); } -struct mat2 *psmat2_assign(struct mat2 *result, struct mat2 *m0) -{ - return (struct mat2 *) mat2_assign((mfloat_t *) result, - (mfloat_t *) m0); +struct mat2 *psmat2_assign(struct mat2 *result, struct mat2 *m0) { + return (struct mat2 *)mat2_assign((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat2 *psmat2_negative(struct mat2 *result, struct mat2 *m0) -{ - return (struct mat2 *) mat2_negative((mfloat_t *) result, - (mfloat_t *) m0); +struct mat2 *psmat2_negative(struct mat2 *result, struct mat2 *m0) { + return (struct mat2 *)mat2_negative((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat2 *psmat2_transpose(struct mat2 *result, struct mat2 *m0) -{ - return (struct mat2 *) mat2_transpose((mfloat_t *) result, - (mfloat_t *) m0); +struct mat2 *psmat2_transpose(struct mat2 *result, struct mat2 *m0) { + return (struct mat2 *)mat2_transpose((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat2 *psmat2_cofactor(struct mat2 *result, struct mat2 *m0) -{ - return (struct mat2 *) mat2_cofactor((mfloat_t *) result, - (mfloat_t *) m0); +struct mat2 *psmat2_cofactor(struct mat2 *result, struct mat2 *m0) { + return (struct mat2 *)mat2_cofactor((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat2 *psmat2_adjugate(struct mat2 *result, struct mat2 *m0) -{ - return (struct mat2 *) mat2_adjugate((mfloat_t *) result, - (mfloat_t *) m0); +struct mat2 *psmat2_adjugate(struct mat2 *result, struct mat2 *m0) { + return (struct mat2 *)mat2_adjugate((mfloat_t *)result, + (mfloat_t *)m0); } struct mat2 *psmat2_multiply(struct mat2 *result, struct mat2 *m0, - struct mat2 *m1) -{ - return (struct mat2 *) mat2_multiply((mfloat_t *) result, - (mfloat_t *) m0, (mfloat_t *) m1); + struct mat2 *m1) { + return (struct mat2 *)mat2_multiply((mfloat_t *)result, + (mfloat_t *)m0, (mfloat_t *)m1); } struct mat2 *psmat2_multiply_f(struct mat2 *result, struct mat2 *m0, - mfloat_t f) -{ - return (struct mat2 *) mat2_multiply_f((mfloat_t *) result, - (mfloat_t *) m0, f); + mfloat_t f) { + return (struct mat2 *)mat2_multiply_f((mfloat_t *)result, + (mfloat_t *)m0, f); } -struct mat2 *psmat2_inverse(struct mat2 *result, struct mat2 *m0) -{ - return (struct mat2 *) mat2_inverse((mfloat_t *) result, - (mfloat_t *) m0); +struct mat2 *psmat2_inverse(struct mat2 *result, struct mat2 *m0) { + return (struct mat2 *)mat2_inverse((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat2 *psmat2_scaling(struct mat2 *result, struct vec2 *v0) -{ - return (struct mat2 *) mat2_scaling((mfloat_t *) result, - (mfloat_t *) v0); +struct mat2 *psmat2_scaling(struct mat2 *result, struct vec2 *v0) { + return (struct mat2 *)mat2_scaling((mfloat_t *)result, + (mfloat_t *)v0); } struct mat2 *psmat2_scale(struct mat2 *result, struct mat2 *m0, - struct vec2 *v0) -{ - return (struct mat2 *) mat2_scale((mfloat_t *) result, (mfloat_t *) m0, - (mfloat_t *) v0); + struct vec2 *v0) { + return (struct mat2 *)mat2_scale((mfloat_t *)result, (mfloat_t *)m0, + (mfloat_t *)v0); } -struct mat2 *psmat2_rotation_z(struct mat2 *result, mfloat_t f) -{ - return (struct mat2 *) mat2_rotation_z((mfloat_t *) result, f); +struct mat2 *psmat2_rotation_z(struct mat2 *result, mfloat_t f) { + return (struct mat2 *)mat2_rotation_z((mfloat_t *)result, f); } struct mat2 *psmat2_lerp(struct mat2 *result, struct mat2 *m0, - struct mat2 *m1, mfloat_t f) -{ - return (struct mat2 *) mat2_lerp((mfloat_t *) result, (mfloat_t *) m0, - (mfloat_t *) m1, f); + struct mat2 *m1, mfloat_t f) { + return (struct mat2 *)mat2_lerp((mfloat_t *)result, (mfloat_t *)m0, + (mfloat_t *)m1, f); } struct mat3 *psmat3(struct mat3 *result, mfloat_t m11, mfloat_t m12, - mfloat_t m13, mfloat_t m21, mfloat_t m22, mfloat_t m23, - mfloat_t m31, mfloat_t m32, mfloat_t m33) -{ - return (struct mat3 *) mat3((mfloat_t *) result, m11, m12, m13, m21, - m22, m23, m31, m32, m33); + mfloat_t m13, mfloat_t m21, mfloat_t m22, mfloat_t m23, + mfloat_t m31, mfloat_t m32, mfloat_t m33) { + return (struct mat3 *)mat3((mfloat_t *)result, m11, m12, m13, m21, + m22, m23, m31, m32, m33); } -struct mat3 *psmat3_zero(struct mat3 *result) -{ - return (struct mat3 *) mat3_zero((mfloat_t *) result); +struct mat3 *psmat3_zero(struct mat3 *result) { + return (struct mat3 *)mat3_zero((mfloat_t *)result); } -struct mat3 *psmat3_identity(struct mat3 *result) -{ - return (struct mat3 *) mat3_identity((mfloat_t *) result); +struct mat3 *psmat3_identity(struct mat3 *result) { + return (struct mat3 *)mat3_identity((mfloat_t *)result); } -mfloat_t psmat3_determinant(struct mat3 *m0) -{ - return mat3_determinant((mfloat_t *) m0); +mfloat_t psmat3_determinant(struct mat3 *m0) { + return mat3_determinant((mfloat_t *)m0); } -struct mat3 *psmat3_assign(struct mat3 *result, struct mat3 *m0) -{ - return (struct mat3 *) mat3_assign((mfloat_t *) result, - (mfloat_t *) m0); +struct mat3 *psmat3_assign(struct mat3 *result, struct mat3 *m0) { + return (struct mat3 *)mat3_assign((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat3 *psmat3_negative(struct mat3 *result, struct mat3 *m0) -{ - return (struct mat3 *) mat3_negative((mfloat_t *) result, - (mfloat_t *) m0); +struct mat3 *psmat3_negative(struct mat3 *result, struct mat3 *m0) { + return (struct mat3 *)mat3_negative((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat3 *psmat3_transpose(struct mat3 *result, struct mat3 *m0) -{ - return (struct mat3 *) mat3_transpose((mfloat_t *) result, - (mfloat_t *) m0); +struct mat3 *psmat3_transpose(struct mat3 *result, struct mat3 *m0) { + return (struct mat3 *)mat3_transpose((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat3 *psmat3_cofactor(struct mat3 *result, struct mat3 *m0) -{ - return (struct mat3 *) mat3_cofactor((mfloat_t *) result, - (mfloat_t *) m0); +struct mat3 *psmat3_cofactor(struct mat3 *result, struct mat3 *m0) { + return (struct mat3 *)mat3_cofactor((mfloat_t *)result, + (mfloat_t *)m0); } struct mat3 *psmat3_multiply(struct mat3 *result, struct mat3 *m0, - struct mat3 *m1) -{ - return (struct mat3 *) mat3_multiply((mfloat_t *) result, - (mfloat_t *) m0, (mfloat_t *) m1); + struct mat3 *m1) { + return (struct mat3 *)mat3_multiply((mfloat_t *)result, + (mfloat_t *)m0, (mfloat_t *)m1); } struct mat3 *psmat3_multiply_f(struct mat3 *result, struct mat3 *m0, - mfloat_t f) -{ - return (struct mat3 *) mat3_multiply_f((mfloat_t *) result, - (mfloat_t *) m0, f); + mfloat_t f) { + return (struct mat3 *)mat3_multiply_f((mfloat_t *)result, + (mfloat_t *)m0, f); } -struct mat3 *psmat3_inverse(struct mat3 *result, struct mat3 *m0) -{ - return (struct mat3 *) mat3_inverse((mfloat_t *) result, - (mfloat_t *) m0); +struct mat3 *psmat3_inverse(struct mat3 *result, struct mat3 *m0) { + return (struct mat3 *)mat3_inverse((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat3 *psmat3_scaling(struct mat3 *result, struct vec3 *v0) -{ - return (struct mat3 *) mat3_scaling((mfloat_t *) result, - (mfloat_t *) v0); +struct mat3 *psmat3_scaling(struct mat3 *result, struct vec3 *v0) { + return (struct mat3 *)mat3_scaling((mfloat_t *)result, + (mfloat_t *)v0); } struct mat3 *psmat3_scale(struct mat3 *result, struct mat3 *m0, - struct vec3 *v0) -{ - return (struct mat3 *) mat3_scale((mfloat_t *) result, (mfloat_t *) m0, - (mfloat_t *) v0); + struct vec3 *v0) { + return (struct mat3 *)mat3_scale((mfloat_t *)result, (mfloat_t *)m0, + (mfloat_t *)v0); } -struct mat3 *psmat3_rotation_x(struct mat3 *result, mfloat_t f) -{ - return (struct mat3 *) mat3_rotation_x((mfloat_t *) result, f); +struct mat3 *psmat3_rotation_x(struct mat3 *result, mfloat_t f) { + return (struct mat3 *)mat3_rotation_x((mfloat_t *)result, f); } -struct mat3 *psmat3_rotation_y(struct mat3 *result, mfloat_t f) -{ - return (struct mat3 *) mat3_rotation_y((mfloat_t *) result, f); +struct mat3 *psmat3_rotation_y(struct mat3 *result, mfloat_t f) { + return (struct mat3 *)mat3_rotation_y((mfloat_t *)result, f); } -struct mat3 *psmat3_rotation_z(struct mat3 *result, mfloat_t f) -{ - return (struct mat3 *) mat3_rotation_z((mfloat_t *) result, f); +struct mat3 *psmat3_rotation_z(struct mat3 *result, mfloat_t f) { + return (struct mat3 *)mat3_rotation_z((mfloat_t *)result, f); } struct mat3 *psmat3_rotation_axis(struct mat3 *result, struct vec3 *v0, - mfloat_t f) -{ - return (struct mat3 *) mat3_rotation_axis((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct mat3 *)mat3_rotation_axis((mfloat_t *)result, + (mfloat_t *)v0, f); } -struct mat3 *psmat3_rotation_quat(struct mat3 *result, struct quat *q0) -{ - return (struct mat3 *) mat3_rotation_quat((mfloat_t *) result, - (mfloat_t *) q0); +struct mat3 *psmat3_rotation_quat(struct mat3 *result, struct quat *q0) { + return (struct mat3 *)mat3_rotation_quat((mfloat_t *)result, + (mfloat_t *)q0); } struct mat3 *psmat3_lerp(struct mat3 *result, struct mat3 *m0, - struct mat3 *m1, mfloat_t f) -{ - return (struct mat3 *) mat3_lerp((mfloat_t *) result, (mfloat_t *) m0, - (mfloat_t *) m1, f); + struct mat3 *m1, mfloat_t f) { + return (struct mat3 *)mat3_lerp((mfloat_t *)result, (mfloat_t *)m0, + (mfloat_t *)m1, f); } struct mat4 *psmat4(struct mat4 *result, mfloat_t m11, mfloat_t m12, - mfloat_t m13, mfloat_t m14, mfloat_t m21, mfloat_t m22, - mfloat_t m23, mfloat_t m24, mfloat_t m31, mfloat_t m32, - mfloat_t m33, mfloat_t m34, mfloat_t m41, mfloat_t m42, - mfloat_t m43, mfloat_t m44) -{ - return (struct mat4 *) mat4((mfloat_t *) result, m11, m12, m13, m14, - m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44); + mfloat_t m13, mfloat_t m14, mfloat_t m21, mfloat_t m22, + mfloat_t m23, mfloat_t m24, mfloat_t m31, mfloat_t m32, + mfloat_t m33, mfloat_t m34, mfloat_t m41, mfloat_t m42, + mfloat_t m43, mfloat_t m44) { + return (struct mat4 *)mat4((mfloat_t *)result, m11, m12, m13, m14, + m21, m22, m23, m24, m31, m32, m33, m34, + m41, m42, m43, m44); } -struct mat4 *psmat4_zero(struct mat4 *result) -{ - return (struct mat4 *) mat4_zero((mfloat_t *) result); +struct mat4 *psmat4_zero(struct mat4 *result) { + return (struct mat4 *)mat4_zero((mfloat_t *)result); } -struct mat4 *psmat4_identity(struct mat4 *result) -{ - return (struct mat4 *) mat4_identity((mfloat_t *) result); +struct mat4 *psmat4_identity(struct mat4 *result) { + return (struct mat4 *)mat4_identity((mfloat_t *)result); } -mfloat_t psmat4_determinant(struct mat4 *m0) -{ - return mat4_determinant((mfloat_t *) m0); +mfloat_t psmat4_determinant(struct mat4 *m0) { + return mat4_determinant((mfloat_t *)m0); } -struct mat4 *psmat4_assign(struct mat4 *result, struct mat4 *m0) -{ - return (struct mat4 *) mat4_assign((mfloat_t *) result, - (mfloat_t *) m0); +struct mat4 *psmat4_assign(struct mat4 *result, struct mat4 *m0) { + return (struct mat4 *)mat4_assign((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat4 *psmat4_negative(struct mat4 *result, struct mat4 *m0) -{ - return (struct mat4 *) mat4_negative((mfloat_t *) result, - (mfloat_t *) m0); +struct mat4 *psmat4_negative(struct mat4 *result, struct mat4 *m0) { + return (struct mat4 *)mat4_negative((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat4 *psmat4_transpose(struct mat4 *result, struct mat4 *m0) -{ - return (struct mat4 *) mat4_transpose((mfloat_t *) result, - (mfloat_t *) m0); +struct mat4 *psmat4_transpose(struct mat4 *result, struct mat4 *m0) { + return (struct mat4 *)mat4_transpose((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat4 *psmat4_cofactor(struct mat4 *result, struct mat4 *m0) -{ - return (struct mat4 *) mat4_cofactor((mfloat_t *) result, - (mfloat_t *) m0); +struct mat4 *psmat4_cofactor(struct mat4 *result, struct mat4 *m0) { + return (struct mat4 *)mat4_cofactor((mfloat_t *)result, + (mfloat_t *)m0); } -struct mat4 *psmat4_rotation_x(struct mat4 *result, mfloat_t f) -{ - return (struct mat4 *) mat4_rotation_x((mfloat_t *) result, f); +struct mat4 *psmat4_rotation_x(struct mat4 *result, mfloat_t f) { + return (struct mat4 *)mat4_rotation_x((mfloat_t *)result, f); } -struct mat4 *psmat4_rotation_y(struct mat4 *result, mfloat_t f) -{ - return (struct mat4 *) mat4_rotation_y((mfloat_t *) result, f); +struct mat4 *psmat4_rotation_y(struct mat4 *result, mfloat_t f) { + return (struct mat4 *)mat4_rotation_y((mfloat_t *)result, f); } -struct mat4 *psmat4_rotation_z(struct mat4 *result, mfloat_t f) -{ - return (struct mat4 *) mat4_rotation_z((mfloat_t *) result, f); +struct mat4 *psmat4_rotation_z(struct mat4 *result, mfloat_t f) { + return (struct mat4 *)mat4_rotation_z((mfloat_t *)result, f); } struct mat4 *psmat4_rotation_axis(struct mat4 *result, struct vec3 *v0, - mfloat_t f) -{ - return (struct mat4 *) mat4_rotation_axis((mfloat_t *) result, - (mfloat_t *) v0, f); + mfloat_t f) { + return (struct mat4 *)mat4_rotation_axis((mfloat_t *)result, + (mfloat_t *)v0, f); } -struct mat4 *psmat4_rotation_quat(struct mat4 *result, struct quat *q0) -{ - return (struct mat4 *) mat4_rotation_quat((mfloat_t *) result, - (mfloat_t *) q0); +struct mat4 *psmat4_rotation_quat(struct mat4 *result, struct quat *q0) { + return (struct mat4 *)mat4_rotation_quat((mfloat_t *)result, + (mfloat_t *)q0); } struct mat4 *psmat4_translation(struct mat4 *result, struct mat4 *m0, - struct vec3 *v0) -{ - return (struct mat4 *) mat4_translation((mfloat_t *) result, - (mfloat_t *) m0, - (mfloat_t *) v0); + struct vec3 *v0) { + return (struct mat4 *)mat4_translation((mfloat_t *)result, + (mfloat_t *)m0, + (mfloat_t *)v0); } struct mat4 *psmat4_translate(struct mat4 *result, struct mat4 *m0, - struct vec3 *v0) -{ - return (struct mat4 *) mat4_translate((mfloat_t *) result, - (mfloat_t *) m0, - (mfloat_t *) v0); + struct vec3 *v0) { + return (struct mat4 *)mat4_translate((mfloat_t *)result, + (mfloat_t *)m0, + (mfloat_t *)v0); } struct mat4 *psmat4_scaling(struct mat4 *result, struct mat4 *m0, - struct vec3 *v0) -{ - return (struct mat4 *) mat4_scaling((mfloat_t *) result, - (mfloat_t *) m0, (mfloat_t *) v0); + struct vec3 *v0) { + return (struct mat4 *)mat4_scaling((mfloat_t *)result, + (mfloat_t *)m0, (mfloat_t *)v0); } struct mat4 *psmat4_scale(struct mat4 *result, struct mat4 *m0, - struct vec3 *v0) -{ - return (struct mat4 *) mat4_scale((mfloat_t *) result, (mfloat_t *) m0, - (mfloat_t *) v0); + struct vec3 *v0) { + return (struct mat4 *)mat4_scale((mfloat_t *)result, (mfloat_t *)m0, + (mfloat_t *)v0); } struct mat4 *psmat4_multiply(struct mat4 *result, struct mat4 *m0, - struct mat4 *m1) -{ - return (struct mat4 *) mat4_multiply((mfloat_t *) result, - (mfloat_t *) m0, (mfloat_t *) m1); + struct mat4 *m1) { + return (struct mat4 *)mat4_multiply((mfloat_t *)result, + (mfloat_t *)m0, (mfloat_t *)m1); } struct mat4 *psmat4_multiply_f(struct mat4 *result, struct mat4 *m0, - mfloat_t f) -{ - return (struct mat4 *) mat4_multiply_f((mfloat_t *) result, - (mfloat_t *) m0, f); + mfloat_t f) { + return (struct mat4 *)mat4_multiply_f((mfloat_t *)result, + (mfloat_t *)m0, f); } -struct mat4 *psmat4_inverse(struct mat4 *result, struct mat4 *m0) -{ - return (struct mat4 *) mat4_inverse((mfloat_t *) result, - (mfloat_t *) m0); +struct mat4 *psmat4_inverse(struct mat4 *result, struct mat4 *m0) { + return (struct mat4 *)mat4_inverse((mfloat_t *)result, + (mfloat_t *)m0); } struct mat4 *psmat4_lerp(struct mat4 *result, struct mat4 *m0, - struct mat4 *m1, mfloat_t f) -{ - return (struct mat4 *) mat4_lerp((mfloat_t *) result, (mfloat_t *) m0, - (mfloat_t *) m1, f); + struct mat4 *m1, mfloat_t f) { + return (struct mat4 *)mat4_lerp((mfloat_t *)result, (mfloat_t *)m0, + (mfloat_t *)m1, f); } struct mat4 *psmat4_look_at(struct mat4 *result, struct vec3 *position, - struct vec3 *target, struct vec3 *up) -{ - return (struct mat4 *) mat4_look_at((mfloat_t *) result, - (mfloat_t *) position, - (mfloat_t *) target, - (mfloat_t *) up); + struct vec3 *target, struct vec3 *up) { + return (struct mat4 *)mat4_look_at((mfloat_t *)result, + (mfloat_t *)position, + (mfloat_t *)target, + (mfloat_t *)up); } struct mat4 *psmat4_ortho(struct mat4 *result, mfloat_t l, mfloat_t r, - mfloat_t b, mfloat_t t, mfloat_t n, mfloat_t f) -{ - return (struct mat4 *) mat4_ortho((mfloat_t *) result, l, r, b, t, n, - f); + mfloat_t b, mfloat_t t, mfloat_t n, mfloat_t f) { + return (struct mat4 *)mat4_ortho((mfloat_t *)result, l, r, b, t, n, + f); } struct mat4 *psmat4_perspective(struct mat4 *result, mfloat_t fov_y, - mfloat_t aspect, mfloat_t n, mfloat_t f) -{ - return (struct mat4 *) mat4_perspective((mfloat_t *) result, fov_y, - aspect, n, f); + mfloat_t aspect, mfloat_t n, mfloat_t f) { + return (struct mat4 *)mat4_perspective((mfloat_t *)result, fov_y, + aspect, n, f); } struct mat4 *psmat4_perspective_fov(struct mat4 *result, mfloat_t fov, - mfloat_t w, mfloat_t h, mfloat_t n, - mfloat_t f) -{ - return (struct mat4 *) mat4_perspective_fov((mfloat_t *) result, fov, - w, h, n, f); + mfloat_t w, mfloat_t h, mfloat_t n, + mfloat_t f) { + return (struct mat4 *)mat4_perspective_fov((mfloat_t *)result, fov, + w, h, n, f); } struct mat4 *psmat4_perspective_infinite(struct mat4 *result, - mfloat_t fov_y, mfloat_t aspect, - mfloat_t n) -{ - return (struct mat4 *) mat4_perspective_infinite((mfloat_t *) result, - fov_y, aspect, n); + mfloat_t fov_y, mfloat_t aspect, + mfloat_t n) { + return (struct mat4 *)mat4_perspective_infinite((mfloat_t *)result, + fov_y, aspect, n); } #endif #endif #if defined(MATHC_USE_FLOATING_POINT) && defined(MATHC_USE_EASING_FUNCTIONS) -mfloat_t quadratic_ease_out(mfloat_t f) -{ - return -f * (f - MFLOAT_C(2.0)); +mfloat_t quadratic_ease_out(mfloat_t f) { + return -f * (f - MFLOAT_C(2.0)); } -mfloat_t quadratic_ease_in(mfloat_t f) -{ - return f * f; +mfloat_t quadratic_ease_in(mfloat_t f) { + return f * f; } -mfloat_t quadratic_ease_in_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(2.0) * f * f; - } else { - a = -MFLOAT_C(2.0) * f * f + MFLOAT_C(4.0) * f - MFLOAT_C(1.0); - } - return a; +mfloat_t quadratic_ease_in_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(2.0) * f * f; + } else { + a = -MFLOAT_C(2.0) * f * f + MFLOAT_C(4.0) * f - MFLOAT_C(1.0); + } + return a; } -mfloat_t cubic_ease_out(mfloat_t f) -{ - mfloat_t a = f - MFLOAT_C(1.0); - return a * a * a + MFLOAT_C(1.0); +mfloat_t cubic_ease_out(mfloat_t f) { + mfloat_t a = f - MFLOAT_C(1.0); + return a * a * a + MFLOAT_C(1.0); } -mfloat_t cubic_ease_in(mfloat_t f) -{ - return f * f * f; +mfloat_t cubic_ease_in(mfloat_t f) { + return f * f * f; } -mfloat_t cubic_ease_in_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(4.0) * f * f * f; - } else { - a = MFLOAT_C(2.0) * f - MFLOAT_C(2.0); - a = MFLOAT_C(0.5) * a * a * a + MFLOAT_C(1.0); - } - return a; +mfloat_t cubic_ease_in_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(4.0) * f * f * f; + } else { + a = MFLOAT_C(2.0) * f - MFLOAT_C(2.0); + a = MFLOAT_C(0.5) * a * a * a + MFLOAT_C(1.0); + } + return a; } -mfloat_t quartic_ease_out(mfloat_t f) -{ - mfloat_t a = f - MFLOAT_C(1.0); - return a * a * a * (MFLOAT_C(1.0) - f) + MFLOAT_C(1.0); +mfloat_t quartic_ease_out(mfloat_t f) { + mfloat_t a = f - MFLOAT_C(1.0); + return a * a * a * (MFLOAT_C(1.0) - f) + MFLOAT_C(1.0); } -mfloat_t quartic_ease_in(mfloat_t f) -{ - return f * f * f * f; +mfloat_t quartic_ease_in(mfloat_t f) { + return f * f * f * f; } -mfloat_t quartic_ease_in_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(8.0) * f * f * f * f; - } else { - a = f - MFLOAT_C(1.0); - a = -MFLOAT_C(8.0) * a * a * a * a + MFLOAT_C(1.0); - } - return a; +mfloat_t quartic_ease_in_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(8.0) * f * f * f * f; + } else { + a = f - MFLOAT_C(1.0); + a = -MFLOAT_C(8.0) * a * a * a * a + MFLOAT_C(1.0); + } + return a; } -mfloat_t quintic_ease_out(mfloat_t f) -{ - mfloat_t a = f - MFLOAT_C(1.0); - return a * a * a * a * a + MFLOAT_C(1.0); +mfloat_t quintic_ease_out(mfloat_t f) { + mfloat_t a = f - MFLOAT_C(1.0); + return a * a * a * a * a + MFLOAT_C(1.0); } -mfloat_t quintic_ease_in(mfloat_t f) -{ - return f * f * f * f * f; +mfloat_t quintic_ease_in(mfloat_t f) { + return f * f * f * f * f; } -mfloat_t quintic_ease_in_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(16.0) * f * f * f * f * f; - } else { - a = MFLOAT_C(2.0) * f - MFLOAT_C(2.0); - a = MFLOAT_C(0.5) * a * a * a * a * a + MFLOAT_C(1.0); - } - return a; +mfloat_t quintic_ease_in_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(16.0) * f * f * f * f * f; + } else { + a = MFLOAT_C(2.0) * f - MFLOAT_C(2.0); + a = MFLOAT_C(0.5) * a * a * a * a * a + MFLOAT_C(1.0); + } + return a; } -mfloat_t sine_ease_out(mfloat_t f) -{ - return MSIN(f * MPI_2); +mfloat_t sine_ease_out(mfloat_t f) { + return MSIN(f * MPI_2); } -mfloat_t sine_ease_in(mfloat_t f) -{ - return MSIN((f - MFLOAT_C(1.0)) * MPI_2) + MFLOAT_C(1.0); +mfloat_t sine_ease_in(mfloat_t f) { + return MSIN((f - MFLOAT_C(1.0)) * MPI_2) + MFLOAT_C(1.0); } -mfloat_t sine_ease_in_out(mfloat_t f) -{ - return MFLOAT_C(0.5) * (MFLOAT_C(1.0) - MCOS(f * MPI)); +mfloat_t sine_ease_in_out(mfloat_t f) { + return MFLOAT_C(0.5) * (MFLOAT_C(1.0) - MCOS(f * MPI)); } -mfloat_t circular_ease_out(mfloat_t f) -{ - return MSQRT((MFLOAT_C(2.0) - f) * f); +mfloat_t circular_ease_out(mfloat_t f) { + return MSQRT((MFLOAT_C(2.0) - f) * f); } -mfloat_t circular_ease_in(mfloat_t f) -{ - return MFLOAT_C(1.0) - MSQRT(MFLOAT_C(1.0) - (f * f)); +mfloat_t circular_ease_in(mfloat_t f) { + return MFLOAT_C(1.0) - MSQRT(MFLOAT_C(1.0) - (f * f)); } -mfloat_t circular_ease_in_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(0.5) * (MFLOAT_C(1.0) - - MSQRT(MFLOAT_C(1.0) - MFLOAT_C(4.0) * f * f)); - } else { - a = MFLOAT_C(0.5) * - (MSQRT - (-(MFLOAT_C(2.0) * f - MFLOAT_C(3.0)) * - (MFLOAT_C(2.0) * f - MFLOAT_C(1.0))) + MFLOAT_C(1.0)); - } - return a; +mfloat_t circular_ease_in_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(0.5) * (MFLOAT_C(1.0) - + MSQRT(MFLOAT_C(1.0) - MFLOAT_C(4.0) * f * f)); + } else { + a = MFLOAT_C(0.5) * + (MSQRT(-(MFLOAT_C(2.0) * f - MFLOAT_C(3.0)) * + (MFLOAT_C(2.0) * f - MFLOAT_C(1.0))) + + MFLOAT_C(1.0)); + } + return a; } -mfloat_t exponential_ease_out(mfloat_t f) -{ - mfloat_t a = f; - if (MFABS(a) > MFLT_EPSILON) { - a = MFLOAT_C(1.0) - MPOW(MFLOAT_C(2.0), -MFLOAT_C(10.0) * f); - } - return a; +mfloat_t exponential_ease_out(mfloat_t f) { + mfloat_t a = f; + if (MFABS(a) > MFLT_EPSILON) { + a = MFLOAT_C(1.0) - MPOW(MFLOAT_C(2.0), -MFLOAT_C(10.0) * f); + } + return a; } -mfloat_t exponential_ease_in(mfloat_t f) -{ - mfloat_t a = f; - if (MFABS(a) > MFLT_EPSILON) { - a = MPOW(MFLOAT_C(2.0), MFLOAT_C(10.0) * (f - MFLOAT_C(1.0))); - } - return a; +mfloat_t exponential_ease_in(mfloat_t f) { + mfloat_t a = f; + if (MFABS(a) > MFLT_EPSILON) { + a = MPOW(MFLOAT_C(2.0), MFLOAT_C(10.0) * (f - MFLOAT_C(1.0))); + } + return a; } -mfloat_t exponential_ease_in_out(mfloat_t f) -{ - mfloat_t a = f; - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(0.5) * MPOW(MFLOAT_C(2.0), - (MFLOAT_C(20.0) * f) - MFLOAT_C(10.0)); - } else { - a = -MFLOAT_C(0.5) * MPOW(MFLOAT_C(2.0), - -MFLOAT_C(20.0) * f + MFLOAT_C(10.0)) + - MFLOAT_C(1.0); - } - return a; +mfloat_t exponential_ease_in_out(mfloat_t f) { + mfloat_t a = f; + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(0.5) * MPOW(MFLOAT_C(2.0), + (MFLOAT_C(20.0) * f) - MFLOAT_C(10.0)); + } else { + a = -MFLOAT_C(0.5) * MPOW(MFLOAT_C(2.0), + -MFLOAT_C(20.0) * f + MFLOAT_C(10.0)) + + MFLOAT_C(1.0); + } + return a; } -mfloat_t elastic_ease_out(mfloat_t f) -{ - return MSIN(-MFLOAT_C(13.0) * MPI_2 * (f + MFLOAT_C(1.0))) * - MPOW(MFLOAT_C(2.0), -MFLOAT_C(10.0) * f) + MFLOAT_C(1.0); +mfloat_t elastic_ease_out(mfloat_t f) { + return MSIN(-MFLOAT_C(13.0) * MPI_2 * (f + MFLOAT_C(1.0))) * + MPOW(MFLOAT_C(2.0), -MFLOAT_C(10.0) * f) + + MFLOAT_C(1.0); } -mfloat_t elastic_ease_in(mfloat_t f) -{ - return MSIN(MFLOAT_C(13.0) * MPI_2 * f) * MPOW(MFLOAT_C(2.0), - MFLOAT_C(10.0) * (f - - MFLOAT_C - (1.0))); +mfloat_t elastic_ease_in(mfloat_t f) { + return MSIN(MFLOAT_C(13.0) * MPI_2 * f) * MPOW(MFLOAT_C(2.0), + MFLOAT_C(10.0) * (f - + MFLOAT_C(1.0))); } -mfloat_t elastic_ease_in_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(0.5) * MSIN(MFLOAT_C(13.0) * MPI_2 * - (MFLOAT_C(2.0) * f)) * MPOW(MFLOAT_C(2.0), - MFLOAT_C(10.0) - * - ((MFLOAT_C - (2.0) * f) - - MFLOAT_C - (1.0))); - } else { - a = MFLOAT_C(0.5) * - (MSIN - (-MFLOAT_C(13.0) * MPI_2 * - ((MFLOAT_C(2.0) * f - MFLOAT_C(1.0)) + - MFLOAT_C(1.0))) * MPOW(MFLOAT_C(2.0), - -MFLOAT_C(10.0) * (MFLOAT_C(2.0) * - f - - MFLOAT_C(1.0))) + - MFLOAT_C(2.0)); - } - return a; +mfloat_t elastic_ease_in_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(0.5) * MSIN(MFLOAT_C(13.0) * MPI_2 * (MFLOAT_C(2.0) * f)) * MPOW(MFLOAT_C(2.0), MFLOAT_C(10.0) * ((MFLOAT_C(2.0) * f) - MFLOAT_C(1.0))); + } else { + a = MFLOAT_C(0.5) * + (MSIN(-MFLOAT_C(13.0) * MPI_2 * + ((MFLOAT_C(2.0) * f - MFLOAT_C(1.0)) + + MFLOAT_C(1.0))) * + MPOW(MFLOAT_C(2.0), + -MFLOAT_C(10.0) * (MFLOAT_C(2.0) * + f - + MFLOAT_C(1.0))) + + MFLOAT_C(2.0)); + } + return a; } -mfloat_t back_ease_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(1.0) - f; - return MFLOAT_C(1.0) - (a * a * a - a * MSIN(a * MPI)); +mfloat_t back_ease_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(1.0) - f; + return MFLOAT_C(1.0) - (a * a * a - a * MSIN(a * MPI)); } -mfloat_t back_ease_in(mfloat_t f) -{ - return f * f * f - f * MSIN(f * MPI); +mfloat_t back_ease_in(mfloat_t f) { + return f * f * f - f * MSIN(f * MPI); } -mfloat_t back_ease_in_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(2.0) * f; - a = MFLOAT_C(0.5) * (a * a * a - a * MSIN(a * MPI)); - } else { - a = (MFLOAT_C(1.0) - (MFLOAT_C(2.0) * f - MFLOAT_C(1.0))); - a = MFLOAT_C(0.5) * (MFLOAT_C(1.0) - - (a * a * a - a * MSIN(f * MPI))) + - MFLOAT_C(0.5); - } - return a; +mfloat_t back_ease_in_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(2.0) * f; + a = MFLOAT_C(0.5) * (a * a * a - a * MSIN(a * MPI)); + } else { + a = (MFLOAT_C(1.0) - (MFLOAT_C(2.0) * f - MFLOAT_C(1.0))); + a = MFLOAT_C(0.5) * (MFLOAT_C(1.0) - + (a * a * a - a * MSIN(f * MPI))) + + MFLOAT_C(0.5); + } + return a; } -mfloat_t bounce_ease_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(4.0) / MFLOAT_C(11.0)) { - a = (MFLOAT_C(121.0) * f * f) / MFLOAT_C(16.0); - } else if (f < MFLOAT_C(8.0) / MFLOAT_C(11.0)) { - a = (MFLOAT_C(363.0) / MFLOAT_C(40.0) * f * f) - - (MFLOAT_C(99.0) / MFLOAT_C(10.0) * f) + - MFLOAT_C(17.0) / MFLOAT_C(5.0); - } else if (f < MFLOAT_C(9.0) / MFLOAT_C(10.0)) { - a = (MFLOAT_C(4356.0) / MFLOAT_C(361.0) * f * f) - - (MFLOAT_C(35442.0) / MFLOAT_C(1805.0) * f) + - MFLOAT_C(16061.0) / MFLOAT_C(1805.0); - } else { - a = (MFLOAT_C(54.0) / MFLOAT_C(5.0) * f * f) - - (MFLOAT_C(513.0) / MFLOAT_C(25.0) * f) + - MFLOAT_C(268.0) / MFLOAT_C(25.0); - } - return a; +mfloat_t bounce_ease_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(4.0) / MFLOAT_C(11.0)) { + a = (MFLOAT_C(121.0) * f * f) / MFLOAT_C(16.0); + } else if (f < MFLOAT_C(8.0) / MFLOAT_C(11.0)) { + a = (MFLOAT_C(363.0) / MFLOAT_C(40.0) * f * f) - + (MFLOAT_C(99.0) / MFLOAT_C(10.0) * f) + + MFLOAT_C(17.0) / MFLOAT_C(5.0); + } else if (f < MFLOAT_C(9.0) / MFLOAT_C(10.0)) { + a = (MFLOAT_C(4356.0) / MFLOAT_C(361.0) * f * f) - + (MFLOAT_C(35442.0) / MFLOAT_C(1805.0) * f) + + MFLOAT_C(16061.0) / MFLOAT_C(1805.0); + } else { + a = (MFLOAT_C(54.0) / MFLOAT_C(5.0) * f * f) - + (MFLOAT_C(513.0) / MFLOAT_C(25.0) * f) + + MFLOAT_C(268.0) / MFLOAT_C(25.0); + } + return a; } -mfloat_t bounce_ease_in(mfloat_t f) -{ - return MFLOAT_C(1.0) - bounce_ease_out(MFLOAT_C(1.0) - f); +mfloat_t bounce_ease_in(mfloat_t f) { + return MFLOAT_C(1.0) - bounce_ease_out(MFLOAT_C(1.0) - f); } -mfloat_t bounce_ease_in_out(mfloat_t f) -{ - mfloat_t a = MFLOAT_C(0.0); - if (f < MFLOAT_C(0.5)) { - a = MFLOAT_C(0.5) * bounce_ease_in(f * MFLOAT_C(2.0)); - } else { - a = MFLOAT_C(0.5) * bounce_ease_out(f * MFLOAT_C(2.0) - - MFLOAT_C(1.0)) + MFLOAT_C(0.5); - } - return a; +mfloat_t bounce_ease_in_out(mfloat_t f) { + mfloat_t a = MFLOAT_C(0.0); + if (f < MFLOAT_C(0.5)) { + a = MFLOAT_C(0.5) * bounce_ease_in(f * MFLOAT_C(2.0)); + } else { + a = MFLOAT_C(0.5) * bounce_ease_out(f * MFLOAT_C(2.0) - + MFLOAT_C(1.0)) + + MFLOAT_C(0.5); + } + return a; } #endif diff --git a/source/engine/mathc.h b/source/engine/mathc.h index 27df7eb..d9fe8f9 100644 --- a/source/engine/mathc.h +++ b/source/engine/mathc.h @@ -27,15 +27,12 @@ extern "C" { #include - // CONFIG #define MATHC_USE_INT32 #define MATHC_USE_SINGLE_FLOATING_POINT - - -#include #include +#include #define MATHC_VERSION_YYYY 2019 #define MATHC_VERSION_MM 02 @@ -81,35 +78,35 @@ extern const float UNITMAT4[16]; #if defined(MATHC_USE_INT) #if defined(MATHC_INT_TYPE) - typedef MATHC_INT_TYPE mint_t; +typedef MATHC_INT_TYPE mint_t; #endif #if !defined(MATHC_USE_INT8) && !defined(MATHC_USE_INT16) && !defined(MATHC_USE_INT32) && !defined(MATHC_USE_INT64) #define MATHC_USE_INT32 #endif #if defined(MATHC_USE_INT8) #if !defined(MATHC_INT_TYPE) - typedef int8_t mint_t; +typedef int8_t mint_t; #endif #define MINT_MAX INT8_MAX #define MINT_MIN INT8_MIN #endif #if defined(MATHC_USE_INT16) #if !defined(MATHC_INT_TYPE) - typedef int16_t mint_t; +typedef int16_t mint_t; #endif #define MINT_MAX INT16_MAX #define MINT_MIN INT16_MIN #endif #if defined(MATHC_USE_INT32) #if !defined(MATHC_INT_TYPE) - typedef int32_t mint_t; +typedef int32_t mint_t; #endif #define MINT_MAX INT32_MAX #define MINT_MIN INT32_MIN #endif #if defined(MATHC_USE_INT64) #if !defined(MATHC_INT_TYPE) - typedef int64_t mint_t; +typedef int64_t mint_t; #endif #define MINT_MAX INT64_MAX #define MINT_MIN INT64_MIN @@ -118,19 +115,16 @@ extern const float UNITMAT4[16]; #if defined(MATHC_USE_FLOATING_POINT) #if defined(MATHC_FLOATING_POINT_TYPE) - typedef MATHC_FLOATING_POINT_TYPE mfloat_t; +typedef MATHC_FLOATING_POINT_TYPE mfloat_t; #endif #if !defined(MATHC_USE_SINGLE_FLOATING_POINT) && !defined(MATHC_USE_DOUBLE_FLOATING_POINT) #define MATHC_USE_SINGLE_FLOATING_POINT #endif #if defined(MATHC_USE_SINGLE_FLOATING_POINT) #if !defined(MATHC_FLOATING_POINT_TYPE) - typedef float mfloat_t; +typedef float mfloat_t; #endif - - - #define MPI 3.1415926536f #define MPI_2 1.5707963268f #define MPI_4 0.7853981634f @@ -149,11 +143,11 @@ extern const float UNITMAT4[16]; #define MFLOOR floorf #define MCEIL ceilf #define MROUND roundf -#define MFLOAT_C(c) c ## f +#define MFLOAT_C(c) c##f #endif #if defined(MATHC_USE_DOUBLE_FLOATING_POINT) #if !defined(MATHC_FLOATING_POINT_TYPE) - typedef double mfloat_t; +typedef double mfloat_t; #endif #define MPI 3.14159265358979323846 #define MPI_2 1.57079632679489661923 @@ -177,168 +171,163 @@ extern const float UNITMAT4[16]; #endif #endif - /* World constants */ - extern const mfloat_t VEC3ZERO[3]; - extern const mfloat_t UP[3]; - extern const mfloat_t DOWN[3]; - extern const mfloat_t FORWARD[3]; - extern const mfloat_t BACK[3]; - extern const mfloat_t RIGHT[3]; - extern const mfloat_t LEFT[3]; - - - - +extern const mfloat_t VEC3ZERO[3]; +extern const mfloat_t UP[3]; +extern const mfloat_t DOWN[3]; +extern const mfloat_t FORWARD[3]; +extern const mfloat_t BACK[3]; +extern const mfloat_t RIGHT[3]; +extern const mfloat_t LEFT[3]; #if defined(MATHC_USE_STRUCT_FUNCTIONS) || defined(MATHC_USE_POINTER_STRUCT_FUNCTIONS) #if defined(MATHC_USE_INT) - struct vec2i { +struct vec2i { #if defined(MATHC_USE_UNIONS) - union { - struct { - mint_t x; - mint_t y; - }; - mint_t v[VEC2_SIZE]; - }; -#else - mint_t x; - mint_t y; -#endif + union { + struct { + mint_t x; + mint_t y; }; + mint_t v[VEC2_SIZE]; + }; +#else + mint_t x; + mint_t y; +#endif +}; - struct vec3i { +struct vec3i { #if defined(MATHC_USE_UNIONS) - union { - struct { - mint_t x; - mint_t y; - mint_t z; - }; - mint_t v[VEC3_SIZE]; - }; -#else - mint_t x; - mint_t y; - mint_t z; -#endif + union { + struct { + mint_t x; + mint_t y; + mint_t z; }; + mint_t v[VEC3_SIZE]; + }; +#else + mint_t x; + mint_t y; + mint_t z; +#endif +}; - struct vec4i { +struct vec4i { #if defined(MATHC_USE_UNIONS) - union { - struct { - mint_t x; - mint_t y; - mint_t z; - mint_t w; - }; - mint_t v[VEC4_SIZE]; - }; -#else - mint_t x; - mint_t y; - mint_t z; - mint_t w; -#endif + union { + struct { + mint_t x; + mint_t y; + mint_t z; + mint_t w; }; + mint_t v[VEC4_SIZE]; + }; +#else + mint_t x; + mint_t y; + mint_t z; + mint_t w; +#endif +}; #endif #if defined(MATHC_USE_FLOATING_POINT) - struct vec2 { +struct vec2 { #if defined(MATHC_USE_UNIONS) - union { - struct { - mfloat_t x; - mfloat_t y; - }; - mfloat_t v[VEC2_SIZE]; - }; -#else - mfloat_t x; - mfloat_t y; -#endif + union { + struct { + mfloat_t x; + mfloat_t y; }; + mfloat_t v[VEC2_SIZE]; + }; +#else + mfloat_t x; + mfloat_t y; +#endif +}; - struct vec3 { +struct vec3 { #if defined(MATHC_USE_UNIONS) - union { - struct { - mfloat_t x; - mfloat_t y; - mfloat_t z; - }; - mfloat_t v[VEC3_SIZE]; - }; -#else - mfloat_t x; - mfloat_t y; - mfloat_t z; -#endif + union { + struct { + mfloat_t x; + mfloat_t y; + mfloat_t z; }; + mfloat_t v[VEC3_SIZE]; + }; +#else + mfloat_t x; + mfloat_t y; + mfloat_t z; +#endif +}; - struct vec4 { +struct vec4 { #if defined(MATHC_USE_UNIONS) - union { - struct { - mfloat_t x; - mfloat_t y; - mfloat_t z; - mfloat_t w; - }; - mfloat_t v[VEC4_SIZE]; - }; -#else - mfloat_t x; - mfloat_t y; - mfloat_t z; - mfloat_t w; -#endif + union { + struct { + mfloat_t x; + mfloat_t y; + mfloat_t z; + mfloat_t w; }; + mfloat_t v[VEC4_SIZE]; + }; +#else + mfloat_t x; + mfloat_t y; + mfloat_t z; + mfloat_t w; +#endif +}; - struct quat { +struct quat { #if defined(MATHC_USE_UNIONS) - union { - struct { - mfloat_t x; - mfloat_t y; - mfloat_t z; - mfloat_t w; - }; - mfloat_t v[QUAT_SIZE]; - }; -#else - mfloat_t x; - mfloat_t y; - mfloat_t z; - mfloat_t w; -#endif + union { + struct { + mfloat_t x; + mfloat_t y; + mfloat_t z; + mfloat_t w; }; + mfloat_t v[QUAT_SIZE]; + }; +#else + mfloat_t x; + mfloat_t y; + mfloat_t z; + mfloat_t w; +#endif +}; /* Matrix 2×2 representation: 0/m11 2/m12 1/m21 3/m22 */ - struct mat2 { +struct mat2 { #if defined(MATHC_USE_UNIONS) - union { - struct { - mfloat_t m11; - mfloat_t m21; - mfloat_t m12; - mfloat_t m22; - }; - mfloat_t v[MAT2_SIZE]; - }; -#else - mfloat_t m11; - mfloat_t m21; - mfloat_t m12; - mfloat_t m22; -#endif + union { + struct { + mfloat_t m11; + mfloat_t m21; + mfloat_t m12; + mfloat_t m22; }; + mfloat_t v[MAT2_SIZE]; + }; +#else + mfloat_t m11; + mfloat_t m21; + mfloat_t m12; + mfloat_t m22; +#endif +}; /* Matrix 3×3 representation: @@ -346,34 +335,34 @@ Matrix 3×3 representation: 1/m21 4/m22 7/m23 2/m31 5/m32 8/m33 */ - struct mat3 { +struct mat3 { #if defined(MATHC_USE_UNIONS) - union { - struct { - mfloat_t m11; - mfloat_t m21; - mfloat_t m31; - mfloat_t m12; - mfloat_t m22; - mfloat_t m32; - mfloat_t m13; - mfloat_t m23; - mfloat_t m33; - }; - mfloat_t v[MAT3_SIZE]; - }; -#else - mfloat_t m11; - mfloat_t m21; - mfloat_t m31; - mfloat_t m12; - mfloat_t m22; - mfloat_t m32; - mfloat_t m13; - mfloat_t m23; - mfloat_t m33; -#endif + union { + struct { + mfloat_t m11; + mfloat_t m21; + mfloat_t m31; + mfloat_t m12; + mfloat_t m22; + mfloat_t m32; + mfloat_t m13; + mfloat_t m23; + mfloat_t m33; }; + mfloat_t v[MAT3_SIZE]; + }; +#else + mfloat_t m11; + mfloat_t m21; + mfloat_t m31; + mfloat_t m12; + mfloat_t m22; + mfloat_t m32; + mfloat_t m13; + mfloat_t m23; + mfloat_t m33; +#endif +}; /* Matrix 4×4 representation: @@ -382,1276 +371,1260 @@ Matrix 4×4 representation: 2/m31 6/m32 10/m33 14/m34 3/m41 7/m42 11/m43 15/m44 */ - struct mat4 { +struct mat4 { #if defined(MATHC_USE_UNIONS) - union { - struct { - mfloat_t m11; - mfloat_t m21; - mfloat_t m31; - mfloat_t m41; - mfloat_t m12; - mfloat_t m22; - mfloat_t m32; - mfloat_t m42; - mfloat_t m13; - mfloat_t m23; - mfloat_t m33; - mfloat_t m43; - mfloat_t m14; - mfloat_t m24; - mfloat_t m34; - mfloat_t m44; - }; - mfloat_t v[MAT4_SIZE]; - }; -#else - mfloat_t m11; - mfloat_t m21; - mfloat_t m31; - mfloat_t m41; - mfloat_t m12; - mfloat_t m22; - mfloat_t m32; - mfloat_t m42; - mfloat_t m13; - mfloat_t m23; - mfloat_t m33; - mfloat_t m43; - mfloat_t m14; - mfloat_t m24; - mfloat_t m34; - mfloat_t m44; -#endif + union { + struct { + mfloat_t m11; + mfloat_t m21; + mfloat_t m31; + mfloat_t m41; + mfloat_t m12; + mfloat_t m22; + mfloat_t m32; + mfloat_t m42; + mfloat_t m13; + mfloat_t m23; + mfloat_t m33; + mfloat_t m43; + mfloat_t m14; + mfloat_t m24; + mfloat_t m34; + mfloat_t m44; }; + mfloat_t v[MAT4_SIZE]; + }; +#else + mfloat_t m11; + mfloat_t m21; + mfloat_t m31; + mfloat_t m41; + mfloat_t m12; + mfloat_t m22; + mfloat_t m32; + mfloat_t m42; + mfloat_t m13; + mfloat_t m23; + mfloat_t m33; + mfloat_t m43; + mfloat_t m14; + mfloat_t m24; + mfloat_t m34; + mfloat_t m44; +#endif +}; #endif #endif #if defined(MATHC_USE_INT) - mint_t clampi(mint_t value, mint_t min, mint_t max); +mint_t clampi(mint_t value, mint_t min, mint_t max); #endif - /* Standards for easy using */ +/* Standards for easy using */ - extern const mfloat_t VEC2_ZERO[2]; - extern const mint_t VEC2I_ZERO[2]; - extern const mfloat_t VEC3_ZERO[3]; - extern const mint_t VEC3I_ZERO[3]; +extern const mfloat_t VEC2_ZERO[2]; +extern const mint_t VEC2I_ZERO[2]; +extern const mfloat_t VEC3_ZERO[3]; +extern const mint_t VEC3I_ZERO[3]; - extern const mfloat_t VEC2_ONE[2]; - extern const mint_t VEC2I_ONE[2]; - extern const mfloat_t VEC3_ONE[3]; - extern const mint_t VEC3I_ONE[3]; +extern const mfloat_t VEC2_ONE[2]; +extern const mint_t VEC2I_ONE[2]; +extern const mfloat_t VEC3_ONE[3]; +extern const mint_t VEC3I_ONE[3]; #if defined(MATHC_USE_FLOATING_POINT) #define MRADIANS(degrees) (degrees * MPI / MFLOAT_C(180.0)) #define MDEGREES(radians) (radians * MFLOAT_C(180.0) / MPI) - bool nearly_equal(mfloat_t a, mfloat_t b, mfloat_t epsilon); - mfloat_t to_radians(mfloat_t degrees); - mfloat_t to_degrees(mfloat_t radians); - mfloat_t clampf(mfloat_t value, mfloat_t min, mfloat_t max); +bool nearly_equal(mfloat_t a, mfloat_t b, mfloat_t epsilon); +mfloat_t to_radians(mfloat_t degrees); +mfloat_t to_degrees(mfloat_t radians); +mfloat_t clampf(mfloat_t value, mfloat_t min, mfloat_t max); #endif #if defined(MATHC_USE_INT) - bool vec2i_is_zero(mint_t * v0); - bool vec2i_is_equal(mint_t * v0, mint_t * v1); - mint_t *vec2i(mint_t * result, mint_t x, mint_t y); - mint_t *vec2i_assign(mint_t * result, mint_t * v0); +bool vec2i_is_zero(mint_t *v0); +bool vec2i_is_equal(mint_t *v0, mint_t *v1); +mint_t *vec2i(mint_t *result, mint_t x, mint_t y); +mint_t *vec2i_assign(mint_t *result, mint_t *v0); #if defined(MATHC_USE_FLOATING_POINT) - mint_t *vec2i_assign_vec2(mint_t * result, mfloat_t * v0); +mint_t *vec2i_assign_vec2(mint_t *result, mfloat_t *v0); #endif - mint_t *vec2i_zero(mint_t * result); - mint_t *vec2i_one(mint_t * result); - mint_t *vec2i_sign(mint_t * result, mint_t * v0); - mint_t *vec2i_add(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec2i_add_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec2i_subtract(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec2i_subtract_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec2i_multiply(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec2i_multiply_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec2i_divide(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec2i_divide_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec2i_snap(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec2i_snap_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec2i_negative(mint_t * result, mint_t * v0); - mint_t *vec2i_abs(mint_t * result, mint_t * v0); - mint_t *vec2i_max(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec2i_min(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec2i_clamp(mint_t * result, mint_t * v0, mint_t * v1, - mint_t * v2); - mint_t *vec2i_tangent(mint_t * result, mint_t * v0); - bool vec3i_is_zero(mint_t * v0); - bool vec3i_is_equal(mint_t * v0, mint_t * v1); - mint_t *vec3i(mint_t * result, mint_t x, mint_t y, mint_t z); - mint_t *vec3i_assign(mint_t * result, mint_t * v0); +mint_t *vec2i_zero(mint_t *result); +mint_t *vec2i_one(mint_t *result); +mint_t *vec2i_sign(mint_t *result, mint_t *v0); +mint_t *vec2i_add(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec2i_add_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec2i_subtract(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec2i_subtract_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec2i_multiply(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec2i_multiply_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec2i_divide(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec2i_divide_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec2i_snap(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec2i_snap_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec2i_negative(mint_t *result, mint_t *v0); +mint_t *vec2i_abs(mint_t *result, mint_t *v0); +mint_t *vec2i_max(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec2i_min(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec2i_clamp(mint_t *result, mint_t *v0, mint_t *v1, + mint_t *v2); +mint_t *vec2i_tangent(mint_t *result, mint_t *v0); +bool vec3i_is_zero(mint_t *v0); +bool vec3i_is_equal(mint_t *v0, mint_t *v1); +mint_t *vec3i(mint_t *result, mint_t x, mint_t y, mint_t z); +mint_t *vec3i_assign(mint_t *result, mint_t *v0); #if defined(MATHC_USE_FLOATING_POINT) - mint_t *vec3i_assign_vec3(mint_t * result, mfloat_t * v0); +mint_t *vec3i_assign_vec3(mint_t *result, mfloat_t *v0); #endif - mint_t *vec3i_zero(mint_t * result); - mint_t *vec3i_one(mint_t * result); - mint_t *vec3i_sign(mint_t * result, mint_t * v0); - mint_t *vec3i_add(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec3i_add_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec3i_subtract(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec3i_subtract_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec3i_multiply(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec3i_multiply_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec3i_divide(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec3i_divide_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec3i_snap(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec3i_snap_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec3i_cross(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec3i_negative(mint_t * result, mint_t * v0); - mint_t *vec3i_abs(mint_t * result, mint_t * v0); - mint_t *vec3i_max(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec3i_min(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec3i_clamp(mint_t * result, mint_t * v0, mint_t * v1, - mint_t * v2); - bool vec4i_is_zero(mint_t * v0); - bool vec4i_is_equal(mint_t * v0, mint_t * v1); - mint_t *vec4i(mint_t * result, mint_t x, mint_t y, mint_t z, mint_t w); - mint_t *vec4i_assign(mint_t * result, mint_t * v0); +mint_t *vec3i_zero(mint_t *result); +mint_t *vec3i_one(mint_t *result); +mint_t *vec3i_sign(mint_t *result, mint_t *v0); +mint_t *vec3i_add(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec3i_add_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec3i_subtract(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec3i_subtract_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec3i_multiply(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec3i_multiply_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec3i_divide(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec3i_divide_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec3i_snap(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec3i_snap_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec3i_cross(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec3i_negative(mint_t *result, mint_t *v0); +mint_t *vec3i_abs(mint_t *result, mint_t *v0); +mint_t *vec3i_max(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec3i_min(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec3i_clamp(mint_t *result, mint_t *v0, mint_t *v1, + mint_t *v2); +bool vec4i_is_zero(mint_t *v0); +bool vec4i_is_equal(mint_t *v0, mint_t *v1); +mint_t *vec4i(mint_t *result, mint_t x, mint_t y, mint_t z, mint_t w); +mint_t *vec4i_assign(mint_t *result, mint_t *v0); #if defined(MATHC_USE_FLOATING_POINT) - mint_t *vec4i_assign_vec4(mint_t * result, mfloat_t * v0); +mint_t *vec4i_assign_vec4(mint_t *result, mfloat_t *v0); #endif - mint_t *vec4i_zero(mint_t * result); - mint_t *vec4i_one(mint_t * result); - mint_t *vec4i_sign(mint_t * result, mint_t * v0); - mint_t *vec4i_add(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec4i_add_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec4i_subtract(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec4i_subtract_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec4i_multiply(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec4i_multiply_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec4i_divide(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec4i_divide_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec4i_snap(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec4i_snap_i(mint_t * result, mint_t * v0, mint_t i); - mint_t *vec4i_negative(mint_t * result, mint_t * v0); - mint_t *vec4i_abs(mint_t * result, mint_t * v0); - mint_t *vec4i_max(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec4i_min(mint_t * result, mint_t * v0, mint_t * v1); - mint_t *vec4i_clamp(mint_t * result, mint_t * v0, mint_t * v1, - mint_t * v2); +mint_t *vec4i_zero(mint_t *result); +mint_t *vec4i_one(mint_t *result); +mint_t *vec4i_sign(mint_t *result, mint_t *v0); +mint_t *vec4i_add(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec4i_add_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec4i_subtract(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec4i_subtract_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec4i_multiply(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec4i_multiply_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec4i_divide(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec4i_divide_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec4i_snap(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec4i_snap_i(mint_t *result, mint_t *v0, mint_t i); +mint_t *vec4i_negative(mint_t *result, mint_t *v0); +mint_t *vec4i_abs(mint_t *result, mint_t *v0); +mint_t *vec4i_max(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec4i_min(mint_t *result, mint_t *v0, mint_t *v1); +mint_t *vec4i_clamp(mint_t *result, mint_t *v0, mint_t *v1, + mint_t *v2); #endif #if defined(MATHC_USE_FLOATING_POINT) - bool vec2_is_zero(mfloat_t * v0); - bool vec2_is_equal(mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec2(mfloat_t * result, mfloat_t x, mfloat_t y); - mfloat_t *vec2_assign(mfloat_t * result, mfloat_t * v0); +bool vec2_is_zero(mfloat_t *v0); +bool vec2_is_equal(mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec2(mfloat_t *result, mfloat_t x, mfloat_t y); +mfloat_t *vec2_assign(mfloat_t *result, mfloat_t *v0); #if defined(MATHC_USE_INT) - mfloat_t *vec2_assign_vec2i(mfloat_t * result, mint_t * v0); +mfloat_t *vec2_assign_vec2i(mfloat_t *result, mint_t *v0); #endif - mfloat_t *vec2_zero(mfloat_t * result); - mfloat_t *vec2_one(mfloat_t * result); - mfloat_t *vec2_sign(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec2_add(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec2_add_f(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec2_subtract(mfloat_t * result, mfloat_t * v0, - mfloat_t * v1); - mfloat_t *vec2_subtract_f(mfloat_t * result, mfloat_t * v0, - mfloat_t f); - mfloat_t *vec2_multiply(mfloat_t * result, mfloat_t * v0, - mfloat_t * v1); - mfloat_t *vec2_multiply_f(mfloat_t * result, mfloat_t * v0, - mfloat_t f); - mfloat_t *vec2_multiply_mat2(mfloat_t * result, mfloat_t * v0, - mfloat_t * m0); - mfloat_t *vec2_divide(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec2_divide_f(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec2_snap(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec2_snap_f(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec2_negative(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec2_abs(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec2_floor(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec2_ceil(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec2_round(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec2_max(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec2_min(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec2_clamp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2); - mfloat_t *vec2_normalize(mfloat_t * result, mfloat_t * v0); - mfloat_t vec2_dot(mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec2_project(mfloat_t * result, mfloat_t * v0, - mfloat_t * v1); - mfloat_t *vec2_slide(mfloat_t * result, mfloat_t * v0, - mfloat_t * normal); - mfloat_t *vec2_reflect(mfloat_t * result, mfloat_t * v0, - mfloat_t * normal); - mfloat_t *vec2_tangent(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec2_rotate(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec2_lerp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t f); - mfloat_t *vec2_bezier3(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2, mfloat_t f); - mfloat_t *vec2_bezier4(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2, mfloat_t * v3, mfloat_t f); - mfloat_t vec2_angle(mfloat_t * v0); - mfloat_t vec2_length(mfloat_t * v0); - mfloat_t vec2_length_squared(mfloat_t * v0); - mfloat_t vec2_distance(mfloat_t * v0, mfloat_t * v1); - mfloat_t vec2_distance_squared(mfloat_t * v0, mfloat_t * v1); - bool vec2_linear_independent(mfloat_t * v0, mfloat_t * v1); - mfloat_t **vec2_orthonormalization(mfloat_t result[2][2], - mfloat_t basis[2][2]); - bool vec3_is_zero(mfloat_t * v0); - bool vec3_is_equal(mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec3(mfloat_t * result, mfloat_t x, mfloat_t y, mfloat_t z); - mfloat_t *vec3_assign(mfloat_t * result, mfloat_t * v0); +mfloat_t *vec2_zero(mfloat_t *result); +mfloat_t *vec2_one(mfloat_t *result); +mfloat_t *vec2_sign(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec2_add(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec2_add_f(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec2_subtract(mfloat_t *result, mfloat_t *v0, + mfloat_t *v1); +mfloat_t *vec2_subtract_f(mfloat_t *result, mfloat_t *v0, + mfloat_t f); +mfloat_t *vec2_multiply(mfloat_t *result, mfloat_t *v0, + mfloat_t *v1); +mfloat_t *vec2_multiply_f(mfloat_t *result, mfloat_t *v0, + mfloat_t f); +mfloat_t *vec2_multiply_mat2(mfloat_t *result, mfloat_t *v0, + mfloat_t *m0); +mfloat_t *vec2_divide(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec2_divide_f(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec2_snap(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec2_snap_f(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec2_negative(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec2_abs(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec2_floor(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec2_ceil(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec2_round(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec2_max(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec2_min(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec2_clamp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2); +mfloat_t *vec2_normalize(mfloat_t *result, mfloat_t *v0); +mfloat_t vec2_dot(mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec2_project(mfloat_t *result, mfloat_t *v0, + mfloat_t *v1); +mfloat_t *vec2_slide(mfloat_t *result, mfloat_t *v0, + mfloat_t *normal); +mfloat_t *vec2_reflect(mfloat_t *result, mfloat_t *v0, + mfloat_t *normal); +mfloat_t *vec2_tangent(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec2_rotate(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec2_lerp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t f); +mfloat_t *vec2_bezier3(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2, mfloat_t f); +mfloat_t *vec2_bezier4(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2, mfloat_t *v3, mfloat_t f); +mfloat_t vec2_angle(mfloat_t *v0); +mfloat_t vec2_length(mfloat_t *v0); +mfloat_t vec2_length_squared(mfloat_t *v0); +mfloat_t vec2_distance(mfloat_t *v0, mfloat_t *v1); +mfloat_t vec2_distance_squared(mfloat_t *v0, mfloat_t *v1); +bool vec2_linear_independent(mfloat_t *v0, mfloat_t *v1); +mfloat_t **vec2_orthonormalization(mfloat_t result[2][2], + mfloat_t basis[2][2]); +bool vec3_is_zero(mfloat_t *v0); +bool vec3_is_equal(mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec3(mfloat_t *result, mfloat_t x, mfloat_t y, mfloat_t z); +mfloat_t *vec3_assign(mfloat_t *result, mfloat_t *v0); #if defined(MATHC_USE_INT) - mfloat_t *vec3_assign_vec3i(mfloat_t * result, mint_t * v0); +mfloat_t *vec3_assign_vec3i(mfloat_t *result, mint_t *v0); #endif - mfloat_t *vec3_zero(mfloat_t * result); - mfloat_t *vec3_one(mfloat_t * result); - mfloat_t *vec3_sign(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec3_add(mfloat_t * result, const mfloat_t * v0, - const mfloat_t * v1); - mfloat_t *vec3_add_f(mfloat_t * result, const mfloat_t * v0, - const mfloat_t f); - mfloat_t *vec3_subtract(mfloat_t * result, const mfloat_t * v0, - const mfloat_t * v1); - mfloat_t *vec3_subtract_f(mfloat_t * result, const mfloat_t * v0, - const mfloat_t f); - mfloat_t *vec3_multiply(mfloat_t * result, const mfloat_t * v0, - const mfloat_t * v1); - mfloat_t *vec3_multiply_f(mfloat_t * result, const mfloat_t * v0, - const mfloat_t f); - mfloat_t *vec3_multiply_mat3(mfloat_t * result, mfloat_t * v0, - mfloat_t * m0); - mfloat_t *vec3_divide(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec3_divide_f(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec3_snap(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec3_snap_f(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec3_negative(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec3_abs(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec3_floor(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec3_ceil(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec3_round(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec3_max(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec3_min(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec3_clamp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2); - mfloat_t *vec3_cross(mfloat_t * result, const mfloat_t * v0, - const mfloat_t * v1); - mfloat_t *vec3_normalize(mfloat_t * result, mfloat_t * v0); - mfloat_t vec3_dot(const mfloat_t * v0, const mfloat_t * v1); - mfloat_t *vec3_project(mfloat_t * result, mfloat_t * v0, - mfloat_t * v1); - mfloat_t *vec3_slide(mfloat_t * result, mfloat_t * v0, - mfloat_t * normal); - mfloat_t *vec3_reflect(mfloat_t * result, mfloat_t * v0, - mfloat_t * normal); - mfloat_t *vec3_rotate(mfloat_t * result, mfloat_t * v0, mfloat_t * ra, - mfloat_t f); - mfloat_t *vec3_lerp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t f); - mfloat_t *vec3_bezier3(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2, mfloat_t f); - mfloat_t *vec3_bezier4(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2, mfloat_t * v3, mfloat_t f); - mfloat_t vec3_length(mfloat_t * v0); - mfloat_t vec3_length_squared(mfloat_t * v0); - mfloat_t vec3_distance(mfloat_t * v0, mfloat_t * v1); - mfloat_t vec3_distance_squared(mfloat_t * v0, mfloat_t * v1); - bool vec3_linear_independent(mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2); - mfloat_t **vec3_orthonormalization(mfloat_t result[3][3], - mfloat_t basis[3][3]); - - - - mfloat_t *vec3_rotate_quat(mfloat_t * result, const mfloat_t * v, - const mfloat_t * q); - - struct vec3 psvec3_rotate_quat(const struct vec3 *v, struct quat *q); - - - bool vec4_is_zero(mfloat_t * v0); - bool vec4_is_equal(mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec4(mfloat_t * result, mfloat_t x, mfloat_t y, mfloat_t z, - mfloat_t w); - mfloat_t *vec4_assign(mfloat_t * result, mfloat_t * v0); - +mfloat_t *vec3_zero(mfloat_t *result); +mfloat_t *vec3_one(mfloat_t *result); +mfloat_t *vec3_sign(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec3_add(mfloat_t *result, const mfloat_t *v0, + const mfloat_t *v1); +mfloat_t *vec3_add_f(mfloat_t *result, const mfloat_t *v0, + const mfloat_t f); +mfloat_t *vec3_subtract(mfloat_t *result, const mfloat_t *v0, + const mfloat_t *v1); +mfloat_t *vec3_subtract_f(mfloat_t *result, const mfloat_t *v0, + const mfloat_t f); +mfloat_t *vec3_multiply(mfloat_t *result, const mfloat_t *v0, + const mfloat_t *v1); +mfloat_t *vec3_multiply_f(mfloat_t *result, const mfloat_t *v0, + const mfloat_t f); +mfloat_t *vec3_multiply_mat3(mfloat_t *result, mfloat_t *v0, + mfloat_t *m0); +mfloat_t *vec3_divide(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec3_divide_f(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec3_snap(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec3_snap_f(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec3_negative(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec3_abs(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec3_floor(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec3_ceil(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec3_round(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec3_max(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec3_min(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec3_clamp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2); +mfloat_t *vec3_cross(mfloat_t *result, const mfloat_t *v0, + const mfloat_t *v1); +mfloat_t *vec3_normalize(mfloat_t *result, mfloat_t *v0); +mfloat_t vec3_dot(const mfloat_t *v0, const mfloat_t *v1); +mfloat_t *vec3_project(mfloat_t *result, mfloat_t *v0, + mfloat_t *v1); +mfloat_t *vec3_slide(mfloat_t *result, mfloat_t *v0, + mfloat_t *normal); +mfloat_t *vec3_reflect(mfloat_t *result, mfloat_t *v0, + mfloat_t *normal); +mfloat_t *vec3_rotate(mfloat_t *result, mfloat_t *v0, mfloat_t *ra, + mfloat_t f); +mfloat_t *vec3_lerp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t f); +mfloat_t *vec3_bezier3(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2, mfloat_t f); +mfloat_t *vec3_bezier4(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2, mfloat_t *v3, mfloat_t f); +mfloat_t vec3_length(mfloat_t *v0); +mfloat_t vec3_length_squared(mfloat_t *v0); +mfloat_t vec3_distance(mfloat_t *v0, mfloat_t *v1); +mfloat_t vec3_distance_squared(mfloat_t *v0, mfloat_t *v1); +bool vec3_linear_independent(mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2); +mfloat_t **vec3_orthonormalization(mfloat_t result[3][3], + mfloat_t basis[3][3]); +mfloat_t *vec3_rotate_quat(mfloat_t *result, const mfloat_t *v, + const mfloat_t *q); +struct vec3 psvec3_rotate_quat(const struct vec3 *v, struct quat *q); +bool vec4_is_zero(mfloat_t *v0); +bool vec4_is_equal(mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec4(mfloat_t *result, mfloat_t x, mfloat_t y, mfloat_t z, + mfloat_t w); +mfloat_t *vec4_assign(mfloat_t *result, mfloat_t *v0); #if defined(MATHC_USE_INT) - mfloat_t *vec4_assign_vec4i(mfloat_t * result, mint_t * v0); +mfloat_t *vec4_assign_vec4i(mfloat_t *result, mint_t *v0); #endif - mfloat_t *vec4_zero(mfloat_t * result); - mfloat_t *vec4_one(mfloat_t * result); - mfloat_t *vec4_sign(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec4_add(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec4_add_f(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec4_subtract(mfloat_t * result, mfloat_t * v0, - mfloat_t * v1); - mfloat_t *vec4_subtract_f(mfloat_t * result, mfloat_t * v0, - mfloat_t f); - mfloat_t *vec4_multiply(mfloat_t * result, mfloat_t * v0, - mfloat_t * v1); - mfloat_t *vec4_multiply_f(mfloat_t * result, mfloat_t * v0, - mfloat_t f); - mfloat_t *vec4_multiply_mat4(mfloat_t * result, mfloat_t * v0, - mfloat_t * m0); - mfloat_t *vec4_divide(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec4_divide_f(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec4_snap(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec4_snap_f(mfloat_t * result, mfloat_t * v0, mfloat_t f); - mfloat_t *vec4_negative(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec4_abs(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec4_floor(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec4_ceil(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec4_round(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec4_max(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec4_min(mfloat_t * result, mfloat_t * v0, mfloat_t * v1); - mfloat_t *vec4_clamp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t * v2); - mfloat_t *vec4_normalize(mfloat_t * result, mfloat_t * v0); - mfloat_t *vec4_lerp(mfloat_t * result, mfloat_t * v0, mfloat_t * v1, - mfloat_t f); +mfloat_t *vec4_zero(mfloat_t *result); +mfloat_t *vec4_one(mfloat_t *result); +mfloat_t *vec4_sign(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec4_add(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec4_add_f(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec4_subtract(mfloat_t *result, mfloat_t *v0, + mfloat_t *v1); +mfloat_t *vec4_subtract_f(mfloat_t *result, mfloat_t *v0, + mfloat_t f); +mfloat_t *vec4_multiply(mfloat_t *result, mfloat_t *v0, + mfloat_t *v1); +mfloat_t *vec4_multiply_f(mfloat_t *result, mfloat_t *v0, + mfloat_t f); +mfloat_t *vec4_multiply_mat4(mfloat_t *result, mfloat_t *v0, + mfloat_t *m0); +mfloat_t *vec4_divide(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec4_divide_f(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec4_snap(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec4_snap_f(mfloat_t *result, mfloat_t *v0, mfloat_t f); +mfloat_t *vec4_negative(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec4_abs(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec4_floor(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec4_ceil(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec4_round(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec4_max(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec4_min(mfloat_t *result, mfloat_t *v0, mfloat_t *v1); +mfloat_t *vec4_clamp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t *v2); +mfloat_t *vec4_normalize(mfloat_t *result, mfloat_t *v0); +mfloat_t *vec4_lerp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, + mfloat_t f); +bool quat_is_zero(mfloat_t *q0); +bool quat_is_equal(mfloat_t *q0, mfloat_t *q1); +mfloat_t *quat(mfloat_t *result, mfloat_t x, mfloat_t y, mfloat_t z, + mfloat_t w); - bool quat_is_zero(mfloat_t * q0); - bool quat_is_equal(mfloat_t * q0, mfloat_t * q1); - mfloat_t *quat(mfloat_t * result, mfloat_t x, mfloat_t y, mfloat_t z, - mfloat_t w); +mfloat_t *quat_assign(mfloat_t *result, mfloat_t *q0); +mfloat_t *quat_zero(mfloat_t *result); +mfloat_t *quat_null(mfloat_t *result); +mfloat_t *quat_multiply(mfloat_t *result, const mfloat_t *q0, + const mfloat_t *q1); +mfloat_t *quat_mult_dir3(mfloat_t *result, const mfloat_t *q, + const mfloat_t *v); +mfloat_t *quat_mult_3d(mfloat_t *result, const mfloat_t *q, + const mfloat_t *p); +mfloat_t *quat_multiply_f(mfloat_t *result, mfloat_t *q0, + mfloat_t f); +mfloat_t *quat_divide(mfloat_t *result, mfloat_t *q0, mfloat_t *q1); +mfloat_t *quat_divide_f(mfloat_t *result, mfloat_t *q0, mfloat_t f); +mfloat_t *quat_negative(mfloat_t *result, mfloat_t *q0); +mfloat_t *quat_conjugate(mfloat_t *result, const mfloat_t *q0); +mfloat_t *quat_inverse(mfloat_t *result, mfloat_t *q0); +mfloat_t *quat_normalize(mfloat_t *result, mfloat_t *q0); +mfloat_t quat_dot(mfloat_t *q0, mfloat_t *q1); +mfloat_t *quat_power(mfloat_t *result, mfloat_t *q0, + mfloat_t exponent); +mfloat_t *quat_from_axis_angle(mfloat_t *result, const mfloat_t *v0, + const mfloat_t angle); +mfloat_t *quat_from_vec3(mfloat_t *result, mfloat_t *v0, + mfloat_t *v1); +mfloat_t *quat_from_mat4(mfloat_t *result, mfloat_t *m0); +mfloat_t *quat_lerp(mfloat_t *result, mfloat_t *q0, mfloat_t *q1, + mfloat_t f); +mfloat_t *quat_slerp(mfloat_t *result, mfloat_t *q0, mfloat_t *q1, + mfloat_t f); +mfloat_t quat_length(mfloat_t *q0); +mfloat_t quat_length_squared(mfloat_t *q0); +mfloat_t quat_angle(mfloat_t *q0, mfloat_t *q1); +mfloat_t *quat_from_euler(mfloat_t *q, const mfloat_t *euler); +mfloat_t *mat2(mfloat_t *result, mfloat_t m11, mfloat_t m12, + mfloat_t m21, mfloat_t m22); +mfloat_t *mat2_zero(mfloat_t *result); +mfloat_t *mat2_identity(mfloat_t *result); +mfloat_t mat2_determinant(mfloat_t *m0); +mfloat_t *mat2_assign(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat2_negative(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat2_transpose(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat2_cofactor(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat2_adjugate(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat2_multiply(mfloat_t *result, mfloat_t *m0, + mfloat_t *m1); +mfloat_t *mat2_multiply_f(mfloat_t *result, mfloat_t *m0, + mfloat_t f); +mfloat_t *mat2_inverse(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat2_scaling(mfloat_t *result, mfloat_t *v0); +mfloat_t *mat2_scale(mfloat_t *result, mfloat_t *m0, mfloat_t *v0); +mfloat_t *mat2_rotation_z(mfloat_t *result, mfloat_t f); +mfloat_t *mat2_lerp(mfloat_t *result, mfloat_t *m0, mfloat_t *m1, + mfloat_t f); +mfloat_t *mat3(mfloat_t *result, mfloat_t m11, mfloat_t m12, + mfloat_t m13, mfloat_t m21, mfloat_t m22, mfloat_t m23, + mfloat_t m31, mfloat_t m32, mfloat_t m33); +mfloat_t *mat3_zero(mfloat_t *result); +mfloat_t *mat3_identity(mfloat_t *result); +mfloat_t mat3_determinant(mfloat_t *m0); +mfloat_t *mat3_assign(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat3_negative(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat3_transpose(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat3_cofactor(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat3_multiply(mfloat_t *result, mfloat_t *m0, + mfloat_t *m1); +mfloat_t *mat3_multiply_f(mfloat_t *result, mfloat_t *m0, + mfloat_t f); +mfloat_t *mat3_inverse(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat3_scaling(mfloat_t *result, mfloat_t *v0); +mfloat_t *mat3_scale(mfloat_t *result, mfloat_t *m0, mfloat_t *v0); +mfloat_t *mat3_rotation_x(mfloat_t *result, mfloat_t f); +mfloat_t *mat3_rotation_y(mfloat_t *result, mfloat_t f); +mfloat_t *mat3_rotation_z(mfloat_t *result, mfloat_t f); +mfloat_t *mat3_rotation_axis(mfloat_t *result, mfloat_t *v0, + mfloat_t f); +mfloat_t *mat3_rotation_quat(mfloat_t *result, mfloat_t *q0); +mfloat_t *mat3_lerp(mfloat_t *result, mfloat_t *m0, mfloat_t *m1, + mfloat_t f); +mfloat_t *mat4(mfloat_t *result, mfloat_t m11, mfloat_t m12, + mfloat_t m13, mfloat_t m14, mfloat_t m21, mfloat_t m22, + mfloat_t m23, mfloat_t m24, mfloat_t m31, mfloat_t m32, + mfloat_t m33, mfloat_t m34, mfloat_t m41, mfloat_t m42, + mfloat_t m43, mfloat_t m44); +mfloat_t *mat4_zero(mfloat_t *result); +mfloat_t *mat4_identity(mfloat_t *result); +mfloat_t mat4_determinant(mfloat_t *m0); +mfloat_t *mat4_assign(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat4_negative(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat4_transpose(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat4_cofactor(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat4_rotation_x(mfloat_t *result, mfloat_t f); +mfloat_t *mat4_rotation_y(mfloat_t *result, mfloat_t f); +mfloat_t *mat4_rotation_z(mfloat_t *result, mfloat_t f); +mfloat_t *mat4_rotation_axis(mfloat_t *result, mfloat_t *v0, + mfloat_t f); +mfloat_t *mat4_rotation_quat(mfloat_t *result, mfloat_t *q0); +mfloat_t *mat4_translation(mfloat_t *result, mfloat_t *m0, + mfloat_t *v0); +mfloat_t *mat4_translate(mfloat_t *result, mfloat_t *m0, + mfloat_t *v0); +mfloat_t *mat4_translate_vec3(mfloat_t *mat4, mfloat_t *vec3); +mfloat_t *mat4_translate_vec2(mfloat_t *mat4, mfloat_t *vec2); - mfloat_t *quat_assign(mfloat_t * result, mfloat_t * q0); - mfloat_t *quat_zero(mfloat_t * result); - mfloat_t *quat_null(mfloat_t * result); - mfloat_t *quat_multiply(mfloat_t * result, const mfloat_t * q0, - const mfloat_t * q1); - mfloat_t *quat_mult_dir3(mfloat_t * result, const mfloat_t * q, - const mfloat_t * v); - mfloat_t *quat_mult_3d(mfloat_t * result, const mfloat_t * q, - const mfloat_t * p); - mfloat_t *quat_multiply_f(mfloat_t * result, mfloat_t * q0, - mfloat_t f); - mfloat_t *quat_divide(mfloat_t * result, mfloat_t * q0, mfloat_t * q1); - mfloat_t *quat_divide_f(mfloat_t * result, mfloat_t * q0, mfloat_t f); - mfloat_t *quat_negative(mfloat_t * result, mfloat_t * q0); - mfloat_t *quat_conjugate(mfloat_t * result, const mfloat_t * q0); - mfloat_t *quat_inverse(mfloat_t * result, mfloat_t * q0); - mfloat_t *quat_normalize(mfloat_t * result, mfloat_t * q0); - mfloat_t quat_dot(mfloat_t * q0, mfloat_t * q1); - mfloat_t *quat_power(mfloat_t * result, mfloat_t * q0, - mfloat_t exponent); - mfloat_t *quat_from_axis_angle(mfloat_t * result, const mfloat_t * v0, - const mfloat_t angle); - mfloat_t *quat_from_vec3(mfloat_t * result, mfloat_t * v0, - mfloat_t * v1); - mfloat_t *quat_from_mat4(mfloat_t * result, mfloat_t * m0); - mfloat_t *quat_lerp(mfloat_t * result, mfloat_t * q0, mfloat_t * q1, - mfloat_t f); - mfloat_t *quat_slerp(mfloat_t * result, mfloat_t * q0, mfloat_t * q1, - mfloat_t f); - mfloat_t quat_length(mfloat_t * q0); - mfloat_t quat_length_squared(mfloat_t * q0); - mfloat_t quat_angle(mfloat_t * q0, mfloat_t * q1); +mfloat_t *mat4_scaling(mfloat_t *result, mfloat_t *m0, + mfloat_t *v0); +mfloat_t *mat4_scale(mfloat_t *result, mfloat_t *m0, mfloat_t *v0); - mfloat_t *quat_from_euler(mfloat_t * q, const mfloat_t * euler); +mfloat_t *mat4_scale_vec2(mfloat_t *mat4, mfloat_t *vec2); +mfloat_t *mat4_scale_vec3(mfloat_t *mat4, mfloat_t *vec3); +mfloat_t *mat4_scale_vec2f(mfloat_t *mat4, mfloat_t f); +mfloat_t *mat4_scale_vec3f(mfloat_t *mat4, mfloat_t f); - mfloat_t *mat2(mfloat_t * result, mfloat_t m11, mfloat_t m12, - mfloat_t m21, mfloat_t m22); - mfloat_t *mat2_zero(mfloat_t * result); - mfloat_t *mat2_identity(mfloat_t * result); - mfloat_t mat2_determinant(mfloat_t * m0); - mfloat_t *mat2_assign(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat2_negative(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat2_transpose(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat2_cofactor(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat2_adjugate(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat2_multiply(mfloat_t * result, mfloat_t * m0, - mfloat_t * m1); - mfloat_t *mat2_multiply_f(mfloat_t * result, mfloat_t * m0, - mfloat_t f); - mfloat_t *mat2_inverse(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat2_scaling(mfloat_t * result, mfloat_t * v0); - mfloat_t *mat2_scale(mfloat_t * result, mfloat_t * m0, mfloat_t * v0); - mfloat_t *mat2_rotation_z(mfloat_t * result, mfloat_t f); - mfloat_t *mat2_lerp(mfloat_t * result, mfloat_t * m0, mfloat_t * m1, - mfloat_t f); - mfloat_t *mat3(mfloat_t * result, mfloat_t m11, mfloat_t m12, - mfloat_t m13, mfloat_t m21, mfloat_t m22, mfloat_t m23, - mfloat_t m31, mfloat_t m32, mfloat_t m33); - mfloat_t *mat3_zero(mfloat_t * result); - mfloat_t *mat3_identity(mfloat_t * result); - mfloat_t mat3_determinant(mfloat_t * m0); - mfloat_t *mat3_assign(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat3_negative(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat3_transpose(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat3_cofactor(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat3_multiply(mfloat_t * result, mfloat_t * m0, - mfloat_t * m1); - mfloat_t *mat3_multiply_f(mfloat_t * result, mfloat_t * m0, - mfloat_t f); - mfloat_t *mat3_inverse(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat3_scaling(mfloat_t * result, mfloat_t * v0); - mfloat_t *mat3_scale(mfloat_t * result, mfloat_t * m0, mfloat_t * v0); - mfloat_t *mat3_rotation_x(mfloat_t * result, mfloat_t f); - mfloat_t *mat3_rotation_y(mfloat_t * result, mfloat_t f); - mfloat_t *mat3_rotation_z(mfloat_t * result, mfloat_t f); - mfloat_t *mat3_rotation_axis(mfloat_t * result, mfloat_t * v0, - mfloat_t f); - mfloat_t *mat3_rotation_quat(mfloat_t * result, mfloat_t * q0); - mfloat_t *mat3_lerp(mfloat_t * result, mfloat_t * m0, mfloat_t * m1, - mfloat_t f); - mfloat_t *mat4(mfloat_t * result, mfloat_t m11, mfloat_t m12, - mfloat_t m13, mfloat_t m14, mfloat_t m21, mfloat_t m22, - mfloat_t m23, mfloat_t m24, mfloat_t m31, mfloat_t m32, - mfloat_t m33, mfloat_t m34, mfloat_t m41, mfloat_t m42, - mfloat_t m43, mfloat_t m44); - mfloat_t *mat4_zero(mfloat_t * result); - mfloat_t *mat4_identity(mfloat_t * result); - mfloat_t mat4_determinant(mfloat_t * m0); - mfloat_t *mat4_assign(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat4_negative(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat4_transpose(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat4_cofactor(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat4_rotation_x(mfloat_t * result, mfloat_t f); - mfloat_t *mat4_rotation_y(mfloat_t * result, mfloat_t f); - mfloat_t *mat4_rotation_z(mfloat_t * result, mfloat_t f); - mfloat_t *mat4_rotation_axis(mfloat_t * result, mfloat_t * v0, - mfloat_t f); - mfloat_t *mat4_rotation_quat(mfloat_t * result, mfloat_t * q0); - mfloat_t *mat4_translation(mfloat_t * result, mfloat_t * m0, - mfloat_t * v0); - - - mfloat_t *mat4_translate(mfloat_t * result, mfloat_t * m0, - mfloat_t * v0); - mfloat_t *mat4_translate_vec3(mfloat_t * mat4, mfloat_t * vec3); - mfloat_t *mat4_translate_vec2(mfloat_t * mat4, mfloat_t * vec2); - - mfloat_t *mat4_scaling(mfloat_t * result, mfloat_t * m0, - mfloat_t * v0); - mfloat_t *mat4_scale(mfloat_t * result, mfloat_t * m0, mfloat_t * v0); - - mfloat_t *mat4_scale_vec2(mfloat_t * mat4, mfloat_t * vec2); - mfloat_t *mat4_scale_vec3(mfloat_t * mat4, mfloat_t * vec3); - - mfloat_t *mat4_scale_vec2f(mfloat_t * mat4, mfloat_t f); - mfloat_t *mat4_scale_vec3f(mfloat_t * mat4, mfloat_t f); - - - mfloat_t *mat4_multiply(mfloat_t * result, mfloat_t * m0, - mfloat_t * m1); - mfloat_t *mat4_multiply_f(mfloat_t * result, mfloat_t * m0, - mfloat_t f); - mfloat_t *mat4_inverse(mfloat_t * result, mfloat_t * m0); - mfloat_t *mat4_lerp(mfloat_t * result, mfloat_t * m0, mfloat_t * m1, - mfloat_t f); - mfloat_t *mat4_look_at(mfloat_t * result, const mfloat_t * position, - const mfloat_t * target, const mfloat_t * up); - mfloat_t *mat4_ortho(mfloat_t * result, mfloat_t l, mfloat_t r, - mfloat_t b, mfloat_t t, mfloat_t n, mfloat_t f); - mfloat_t *mat4_perspective(mfloat_t * result, mfloat_t fov_y, - mfloat_t aspect, mfloat_t n, mfloat_t f); - mfloat_t *mat4_perspective_fov(mfloat_t * result, mfloat_t fov, - mfloat_t w, mfloat_t h, mfloat_t n, - mfloat_t f); - mfloat_t *mat4_perspective_infinite(mfloat_t * result, mfloat_t fov_y, - mfloat_t aspect, mfloat_t n); +mfloat_t *mat4_multiply(mfloat_t *result, mfloat_t *m0, + mfloat_t *m1); +mfloat_t *mat4_multiply_f(mfloat_t *result, mfloat_t *m0, + mfloat_t f); +mfloat_t *mat4_inverse(mfloat_t *result, mfloat_t *m0); +mfloat_t *mat4_lerp(mfloat_t *result, mfloat_t *m0, mfloat_t *m1, + mfloat_t f); +mfloat_t *mat4_look_at(mfloat_t *result, const mfloat_t *position, + const mfloat_t *target, const mfloat_t *up); +mfloat_t *mat4_ortho(mfloat_t *result, mfloat_t l, mfloat_t r, + mfloat_t b, mfloat_t t, mfloat_t n, mfloat_t f); +mfloat_t *mat4_perspective(mfloat_t *result, mfloat_t fov_y, + mfloat_t aspect, mfloat_t n, mfloat_t f); +mfloat_t *mat4_perspective_fov(mfloat_t *result, mfloat_t fov, + mfloat_t w, mfloat_t h, mfloat_t n, + mfloat_t f); +mfloat_t *mat4_perspective_infinite(mfloat_t *result, mfloat_t fov_y, + mfloat_t aspect, mfloat_t n); #endif #if defined(MATHC_USE_STRUCT_FUNCTIONS) #if defined(MATHC_USE_INT) - bool svec2i_is_zero(struct vec2i v0); - bool svec2i_is_equal(struct vec2i v0, struct vec2i v1); - struct vec2i svec2i(mint_t x, mint_t y); - struct vec2i svec2i_assign(struct vec2i v0); +bool svec2i_is_zero(struct vec2i v0); +bool svec2i_is_equal(struct vec2i v0, struct vec2i v1); +struct vec2i svec2i(mint_t x, mint_t y); +struct vec2i svec2i_assign(struct vec2i v0); #if defined(MATHC_USE_FLOATING_POINT) - struct vec2i svec2i_assign_vec2(struct vec2 v0); +struct vec2i svec2i_assign_vec2(struct vec2 v0); #endif - struct vec2i svec2i_zero(void); - struct vec2i svec2i_one(void); - struct vec2i svec2i_sign(struct vec2i v0); - struct vec2i svec2i_add(struct vec2i v0, struct vec2i v1); - struct vec2i svec2i_add_i(struct vec2i v0, mint_t i); - struct vec2i svec2i_subtract(struct vec2i v0, struct vec2i v1); - struct vec2i svec2i_subtract_i(struct vec2i v0, mint_t i); - struct vec2i svec2i_multiply(struct vec2i v0, struct vec2i v1); - struct vec2i svec2i_multiply_i(struct vec2i v0, mint_t i); - struct vec2i svec2i_divide(struct vec2i v0, struct vec2i v1); - struct vec2i svec2i_divide_i(struct vec2i v0, mint_t i); - struct vec2i svec2i_snap(struct vec2i v0, struct vec2i v1); - struct vec2i svec2i_snap_i(struct vec2i v0, mint_t i); - struct vec2i svec2i_negative(struct vec2i v0); - struct vec2i svec2i_abs(struct vec2i v0); - struct vec2i svec2i_max(struct vec2i v0, struct vec2i v1); - struct vec2i svec2i_min(struct vec2i v0, struct vec2i v1); - struct vec2i svec2i_clamp(struct vec2i v0, struct vec2i v1, - struct vec2i v2); - struct vec2i svec2i_tangent(struct vec2i v0); - bool svec3i_is_zero(struct vec3i v0); - bool svec3i_is_equal(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i(mint_t x, mint_t y, mint_t z); - struct vec3i svec3i_assign(struct vec3i v0); +struct vec2i svec2i_zero(void); +struct vec2i svec2i_one(void); +struct vec2i svec2i_sign(struct vec2i v0); +struct vec2i svec2i_add(struct vec2i v0, struct vec2i v1); +struct vec2i svec2i_add_i(struct vec2i v0, mint_t i); +struct vec2i svec2i_subtract(struct vec2i v0, struct vec2i v1); +struct vec2i svec2i_subtract_i(struct vec2i v0, mint_t i); +struct vec2i svec2i_multiply(struct vec2i v0, struct vec2i v1); +struct vec2i svec2i_multiply_i(struct vec2i v0, mint_t i); +struct vec2i svec2i_divide(struct vec2i v0, struct vec2i v1); +struct vec2i svec2i_divide_i(struct vec2i v0, mint_t i); +struct vec2i svec2i_snap(struct vec2i v0, struct vec2i v1); +struct vec2i svec2i_snap_i(struct vec2i v0, mint_t i); +struct vec2i svec2i_negative(struct vec2i v0); +struct vec2i svec2i_abs(struct vec2i v0); +struct vec2i svec2i_max(struct vec2i v0, struct vec2i v1); +struct vec2i svec2i_min(struct vec2i v0, struct vec2i v1); +struct vec2i svec2i_clamp(struct vec2i v0, struct vec2i v1, + struct vec2i v2); +struct vec2i svec2i_tangent(struct vec2i v0); +bool svec3i_is_zero(struct vec3i v0); +bool svec3i_is_equal(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i(mint_t x, mint_t y, mint_t z); +struct vec3i svec3i_assign(struct vec3i v0); #if defined(MATHC_USE_FLOATING_POINT) - struct vec3i svec3i_assign_vec3(struct vec3 v0); +struct vec3i svec3i_assign_vec3(struct vec3 v0); #endif - struct vec3i svec3i_zero(void); - struct vec3i svec3i_one(void); - struct vec3i svec3i_sign(struct vec3i v0); - struct vec3i svec3i_add(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i_add_i(struct vec3i v0, mint_t i); - struct vec3i svec3i_subtract(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i_subtract_i(struct vec3i v0, mint_t i); - struct vec3i svec3i_multiply(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i_multiply_i(struct vec3i v0, mint_t i); - struct vec3i svec3i_divide(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i_divide_i(struct vec3i v0, mint_t i); - struct vec3i svec3i_snap(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i_snap_i(struct vec3i v0, mint_t i); - struct vec3i svec3i_cross(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i_negative(struct vec3i v0); - struct vec3i svec3i_abs(struct vec3i v0); - struct vec3i svec3i_max(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i_min(struct vec3i v0, struct vec3i v1); - struct vec3i svec3i_clamp(struct vec3i v0, struct vec3i v1, - struct vec3i v2); - bool svec4i_is_zero(struct vec4i v0); - bool svec4i_is_equal(struct vec4i v0, struct vec4i v1); - struct vec4i svec4i(mint_t x, mint_t y, mint_t z, mint_t w); - struct vec4i svec4i_assign(struct vec4i v0); +struct vec3i svec3i_zero(void); +struct vec3i svec3i_one(void); +struct vec3i svec3i_sign(struct vec3i v0); +struct vec3i svec3i_add(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i_add_i(struct vec3i v0, mint_t i); +struct vec3i svec3i_subtract(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i_subtract_i(struct vec3i v0, mint_t i); +struct vec3i svec3i_multiply(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i_multiply_i(struct vec3i v0, mint_t i); +struct vec3i svec3i_divide(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i_divide_i(struct vec3i v0, mint_t i); +struct vec3i svec3i_snap(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i_snap_i(struct vec3i v0, mint_t i); +struct vec3i svec3i_cross(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i_negative(struct vec3i v0); +struct vec3i svec3i_abs(struct vec3i v0); +struct vec3i svec3i_max(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i_min(struct vec3i v0, struct vec3i v1); +struct vec3i svec3i_clamp(struct vec3i v0, struct vec3i v1, + struct vec3i v2); +bool svec4i_is_zero(struct vec4i v0); +bool svec4i_is_equal(struct vec4i v0, struct vec4i v1); +struct vec4i svec4i(mint_t x, mint_t y, mint_t z, mint_t w); +struct vec4i svec4i_assign(struct vec4i v0); #if defined(MATHC_USE_FLOATING_POINT) - struct vec4i svec4i_assign_vec4(struct vec4 v0); +struct vec4i svec4i_assign_vec4(struct vec4 v0); #endif - struct vec4i svec4i_zero(void); - struct vec4i svec4i_one(void); - struct vec4i svec4i_sign(struct vec4i v0); - struct vec4i svec4i_add(struct vec4i v0, struct vec4i v1); - struct vec4i svec4i_add_i(struct vec4i v0, mint_t i); - struct vec4i svec4i_subtract(struct vec4i v0, struct vec4i v1); - struct vec4i svec4i_subtract_i(struct vec4i v0, mint_t i); - struct vec4i svec4i_multiply(struct vec4i v0, struct vec4i v1); - struct vec4i svec4i_multiply_i(struct vec4i v0, mint_t i); - struct vec4i svec4i_divide(struct vec4i v0, struct vec4i v1); - struct vec4i svec4i_divide_i(struct vec4i v0, mint_t i); - struct vec4i svec4i_snap(struct vec4i v0, struct vec4i v1); - struct vec4i svec4i_snap_i(struct vec4i v0, mint_t i); - struct vec4i svec4i_negative(struct vec4i v0); - struct vec4i svec4i_abs(struct vec4i v0); - struct vec4i svec4i_max(struct vec4i v0, struct vec4i v1); - struct vec4i svec4i_min(struct vec4i v0, struct vec4i v1); - struct vec4i svec4i_clamp(struct vec4i v0, struct vec4i v1, - struct vec4i v2); +struct vec4i svec4i_zero(void); +struct vec4i svec4i_one(void); +struct vec4i svec4i_sign(struct vec4i v0); +struct vec4i svec4i_add(struct vec4i v0, struct vec4i v1); +struct vec4i svec4i_add_i(struct vec4i v0, mint_t i); +struct vec4i svec4i_subtract(struct vec4i v0, struct vec4i v1); +struct vec4i svec4i_subtract_i(struct vec4i v0, mint_t i); +struct vec4i svec4i_multiply(struct vec4i v0, struct vec4i v1); +struct vec4i svec4i_multiply_i(struct vec4i v0, mint_t i); +struct vec4i svec4i_divide(struct vec4i v0, struct vec4i v1); +struct vec4i svec4i_divide_i(struct vec4i v0, mint_t i); +struct vec4i svec4i_snap(struct vec4i v0, struct vec4i v1); +struct vec4i svec4i_snap_i(struct vec4i v0, mint_t i); +struct vec4i svec4i_negative(struct vec4i v0); +struct vec4i svec4i_abs(struct vec4i v0); +struct vec4i svec4i_max(struct vec4i v0, struct vec4i v1); +struct vec4i svec4i_min(struct vec4i v0, struct vec4i v1); +struct vec4i svec4i_clamp(struct vec4i v0, struct vec4i v1, + struct vec4i v2); #endif #if defined(MATHC_USE_FLOATING_POINT) - bool svec2_is_zero(struct vec2 v0); - bool svec2_is_equal(struct vec2 v0, struct vec2 v1); - struct vec2 svec2(mfloat_t x, mfloat_t y); - struct vec2 svec2_assign(struct vec2 v0); +bool svec2_is_zero(struct vec2 v0); +bool svec2_is_equal(struct vec2 v0, struct vec2 v1); +struct vec2 svec2(mfloat_t x, mfloat_t y); +struct vec2 svec2_assign(struct vec2 v0); #if defined(MATHC_USE_INT) - struct vec2 svec2_assign_vec2i(struct vec2i v0); +struct vec2 svec2_assign_vec2i(struct vec2i v0); #endif - struct vec2 svec2_zero(void); - struct vec2 svec2_one(void); - struct vec2 svec2_sign(struct vec2 v0); - struct vec2 svec2_add(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_add_f(struct vec2 v0, mfloat_t f); - struct vec2 svec2_subtract(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_subtract_f(struct vec2 v0, mfloat_t f); - struct vec2 svec2_multiply(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_multiply_f(struct vec2 v0, mfloat_t f); - struct vec2 svec2_multiply_mat2(struct vec2 v0, struct mat2 m0); - struct vec2 svec2_divide(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_divide_f(struct vec2 v0, mfloat_t f); - struct vec2 svec2_snap(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_snap_f(struct vec2 v0, mfloat_t f); - struct vec2 svec2_negative(struct vec2 v0); - struct vec2 svec2_abs(struct vec2 v0); - struct vec2 svec2_floor(struct vec2 v0); - struct vec2 svec2_ceil(struct vec2 v0); - struct vec2 svec2_round(struct vec2 v0); - struct vec2 svec2_max(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_min(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_clamp(struct vec2 v0, struct vec2 v1, - struct vec2 v2); - struct vec2 svec2_normalize(struct vec2 v0); - mfloat_t svec2_dot(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_project(struct vec2 v0, struct vec2 v1); - struct vec2 svec2_slide(struct vec2 v0, struct vec2 normal); - struct vec2 svec2_reflect(struct vec2 v0, struct vec2 normal); - struct vec2 svec2_tangent(struct vec2 v0); - struct vec2 svec2_rotate(struct vec2 v0, mfloat_t f); - struct vec2 svec2_lerp(struct vec2 v0, struct vec2 v1, mfloat_t f); - struct vec2 svec2_bezier3(struct vec2 v0, struct vec2 v1, - struct vec2 v2, mfloat_t f); - struct vec2 svec2_bezier4(struct vec2 v0, struct vec2 v1, - struct vec2 v2, struct vec2 v3, mfloat_t f); - mfloat_t svec2_angle(struct vec2 v0); - mfloat_t svec2_length(struct vec2 v0); - mfloat_t svec2_length_squared(struct vec2 v0); - mfloat_t svec2_distance(struct vec2 v0, struct vec2 v1); - mfloat_t svec2_distance_squared(struct vec2 v0, struct vec2 v1); - bool svec3_is_zero(struct vec3 v0); - bool svec3_is_equal(struct vec3 v0, struct vec3 v1); - struct vec3 svec3(mfloat_t x, mfloat_t y, mfloat_t z); - struct vec3 svec3_assign(struct vec3 v0); +struct vec2 svec2_zero(void); +struct vec2 svec2_one(void); +struct vec2 svec2_sign(struct vec2 v0); +struct vec2 svec2_add(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_add_f(struct vec2 v0, mfloat_t f); +struct vec2 svec2_subtract(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_subtract_f(struct vec2 v0, mfloat_t f); +struct vec2 svec2_multiply(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_multiply_f(struct vec2 v0, mfloat_t f); +struct vec2 svec2_multiply_mat2(struct vec2 v0, struct mat2 m0); +struct vec2 svec2_divide(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_divide_f(struct vec2 v0, mfloat_t f); +struct vec2 svec2_snap(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_snap_f(struct vec2 v0, mfloat_t f); +struct vec2 svec2_negative(struct vec2 v0); +struct vec2 svec2_abs(struct vec2 v0); +struct vec2 svec2_floor(struct vec2 v0); +struct vec2 svec2_ceil(struct vec2 v0); +struct vec2 svec2_round(struct vec2 v0); +struct vec2 svec2_max(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_min(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_clamp(struct vec2 v0, struct vec2 v1, + struct vec2 v2); +struct vec2 svec2_normalize(struct vec2 v0); +mfloat_t svec2_dot(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_project(struct vec2 v0, struct vec2 v1); +struct vec2 svec2_slide(struct vec2 v0, struct vec2 normal); +struct vec2 svec2_reflect(struct vec2 v0, struct vec2 normal); +struct vec2 svec2_tangent(struct vec2 v0); +struct vec2 svec2_rotate(struct vec2 v0, mfloat_t f); +struct vec2 svec2_lerp(struct vec2 v0, struct vec2 v1, mfloat_t f); +struct vec2 svec2_bezier3(struct vec2 v0, struct vec2 v1, + struct vec2 v2, mfloat_t f); +struct vec2 svec2_bezier4(struct vec2 v0, struct vec2 v1, + struct vec2 v2, struct vec2 v3, mfloat_t f); +mfloat_t svec2_angle(struct vec2 v0); +mfloat_t svec2_length(struct vec2 v0); +mfloat_t svec2_length_squared(struct vec2 v0); +mfloat_t svec2_distance(struct vec2 v0, struct vec2 v1); +mfloat_t svec2_distance_squared(struct vec2 v0, struct vec2 v1); +bool svec3_is_zero(struct vec3 v0); +bool svec3_is_equal(struct vec3 v0, struct vec3 v1); +struct vec3 svec3(mfloat_t x, mfloat_t y, mfloat_t z); +struct vec3 svec3_assign(struct vec3 v0); #if defined(MATHC_USE_INT) - struct vec3 svec3_assign_vec3i(struct vec3i v0); +struct vec3 svec3_assign_vec3i(struct vec3i v0); #endif - struct vec3 svec3_zero(void); - struct vec3 svec3_one(void); - struct vec3 svec3_sign(struct vec3 v0); - struct vec3 svec3_add(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_add_f(struct vec3 v0, mfloat_t f); - struct vec3 svec3_subtract(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_subtract_f(struct vec3 v0, mfloat_t f); - struct vec3 svec3_multiply(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_multiply_f(struct vec3 v0, mfloat_t f); - struct vec3 svec3_multiply_mat3(struct vec3 v0, struct mat3 m0); - struct vec3 svec3_divide(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_divide_f(struct vec3 v0, mfloat_t f); - struct vec3 svec3_snap(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_snap_f(struct vec3 v0, mfloat_t f); - struct vec3 svec3_negative(struct vec3 v0); - struct vec3 svec3_abs(struct vec3 v0); - struct vec3 svec3_floor(struct vec3 v0); - struct vec3 svec3_ceil(struct vec3 v0); - struct vec3 svec3_round(struct vec3 v0); - struct vec3 svec3_max(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_min(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_clamp(struct vec3 v0, struct vec3 v1, - struct vec3 v2); - struct vec3 svec3_cross(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_normalize(struct vec3 v0); - mfloat_t svec3_dot(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_project(struct vec3 v0, struct vec3 v1); - struct vec3 svec3_slide(struct vec3 v0, struct vec3 normal); - struct vec3 svec3_reflect(struct vec3 v0, struct vec3 normal); - struct vec3 svec3_rotate(struct vec3 v0, struct vec3 ra, mfloat_t f); - struct vec3 svec3_lerp(struct vec3 v0, struct vec3 v1, mfloat_t f); - struct vec3 svec3_bezier3(struct vec3 v0, struct vec3 v1, - struct vec3 v2, mfloat_t f); - struct vec3 svec3_bezier4(struct vec3 v0, struct vec3 v1, - struct vec3 v2, struct vec3 v3, mfloat_t f); - mfloat_t svec3_length(struct vec3 v0); - mfloat_t svec3_length_squared(struct vec3 v0); - mfloat_t svec3_distance(struct vec3 v0, struct vec3 v1); - mfloat_t svec3_distance_squared(struct vec3 v0, struct vec3 v1); - bool svec4_is_zero(struct vec4 v0); - bool svec4_is_equal(struct vec4 v0, struct vec4 v1); - struct vec4 svec4(mfloat_t x, mfloat_t y, mfloat_t z, mfloat_t w); - struct vec4 svec4_assign(struct vec4 v0); +struct vec3 svec3_zero(void); +struct vec3 svec3_one(void); +struct vec3 svec3_sign(struct vec3 v0); +struct vec3 svec3_add(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_add_f(struct vec3 v0, mfloat_t f); +struct vec3 svec3_subtract(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_subtract_f(struct vec3 v0, mfloat_t f); +struct vec3 svec3_multiply(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_multiply_f(struct vec3 v0, mfloat_t f); +struct vec3 svec3_multiply_mat3(struct vec3 v0, struct mat3 m0); +struct vec3 svec3_divide(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_divide_f(struct vec3 v0, mfloat_t f); +struct vec3 svec3_snap(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_snap_f(struct vec3 v0, mfloat_t f); +struct vec3 svec3_negative(struct vec3 v0); +struct vec3 svec3_abs(struct vec3 v0); +struct vec3 svec3_floor(struct vec3 v0); +struct vec3 svec3_ceil(struct vec3 v0); +struct vec3 svec3_round(struct vec3 v0); +struct vec3 svec3_max(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_min(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_clamp(struct vec3 v0, struct vec3 v1, + struct vec3 v2); +struct vec3 svec3_cross(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_normalize(struct vec3 v0); +mfloat_t svec3_dot(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_project(struct vec3 v0, struct vec3 v1); +struct vec3 svec3_slide(struct vec3 v0, struct vec3 normal); +struct vec3 svec3_reflect(struct vec3 v0, struct vec3 normal); +struct vec3 svec3_rotate(struct vec3 v0, struct vec3 ra, mfloat_t f); +struct vec3 svec3_lerp(struct vec3 v0, struct vec3 v1, mfloat_t f); +struct vec3 svec3_bezier3(struct vec3 v0, struct vec3 v1, + struct vec3 v2, mfloat_t f); +struct vec3 svec3_bezier4(struct vec3 v0, struct vec3 v1, + struct vec3 v2, struct vec3 v3, mfloat_t f); +mfloat_t svec3_length(struct vec3 v0); +mfloat_t svec3_length_squared(struct vec3 v0); +mfloat_t svec3_distance(struct vec3 v0, struct vec3 v1); +mfloat_t svec3_distance_squared(struct vec3 v0, struct vec3 v1); +bool svec4_is_zero(struct vec4 v0); +bool svec4_is_equal(struct vec4 v0, struct vec4 v1); +struct vec4 svec4(mfloat_t x, mfloat_t y, mfloat_t z, mfloat_t w); +struct vec4 svec4_assign(struct vec4 v0); #if defined(MATHC_USE_INT) - struct vec4 svec4_assign_vec4i(struct vec4i v0); +struct vec4 svec4_assign_vec4i(struct vec4i v0); #endif - struct vec4 svec4_zero(void); - struct vec4 svec4_one(void); - struct vec4 svec4_sign(struct vec4 v0); - struct vec4 svec4_add(struct vec4 v0, struct vec4 v1); - struct vec4 svec4_add_f(struct vec4 v0, mfloat_t f); - struct vec4 svec4_subtract(struct vec4 v0, struct vec4 v1); - struct vec4 svec4_subtract_f(struct vec4 v0, mfloat_t f); - struct vec4 svec4_multiply(struct vec4 v0, struct vec4 v1); - struct vec4 svec4_multiply_f(struct vec4 v0, mfloat_t f); - struct vec4 svec4_multiply_mat4(struct vec4 v0, struct mat4 m0); - struct vec4 svec4_divide(struct vec4 v0, struct vec4 v1); - struct vec4 svec4_divide_f(struct vec4 v0, mfloat_t f); - struct vec4 svec4_snap(struct vec4 v0, struct vec4 v1); - struct vec4 svec4_snap_f(struct vec4 v0, mfloat_t f); - struct vec4 svec4_negative(struct vec4 v0); - struct vec4 svec4_abs(struct vec4 v0); - struct vec4 svec4_floor(struct vec4 v0); - struct vec4 svec4_ceil(struct vec4 v0); - struct vec4 svec4_round(struct vec4 v0); - struct vec4 svec4_max(struct vec4 v0, struct vec4 v1); - struct vec4 svec4_min(struct vec4 v0, struct vec4 v1); - struct vec4 svec4_clamp(struct vec4 v0, struct vec4 v1, - struct vec4 v2); - struct vec4 svec4_normalize(struct vec4 v0); - struct vec4 svec4_lerp(struct vec4 v0, struct vec4 v1, mfloat_t f); - bool squat_is_zero(struct quat q0); - bool squat_is_equal(struct quat q0, struct quat q1); +struct vec4 svec4_zero(void); +struct vec4 svec4_one(void); +struct vec4 svec4_sign(struct vec4 v0); +struct vec4 svec4_add(struct vec4 v0, struct vec4 v1); +struct vec4 svec4_add_f(struct vec4 v0, mfloat_t f); +struct vec4 svec4_subtract(struct vec4 v0, struct vec4 v1); +struct vec4 svec4_subtract_f(struct vec4 v0, mfloat_t f); +struct vec4 svec4_multiply(struct vec4 v0, struct vec4 v1); +struct vec4 svec4_multiply_f(struct vec4 v0, mfloat_t f); +struct vec4 svec4_multiply_mat4(struct vec4 v0, struct mat4 m0); +struct vec4 svec4_divide(struct vec4 v0, struct vec4 v1); +struct vec4 svec4_divide_f(struct vec4 v0, mfloat_t f); +struct vec4 svec4_snap(struct vec4 v0, struct vec4 v1); +struct vec4 svec4_snap_f(struct vec4 v0, mfloat_t f); +struct vec4 svec4_negative(struct vec4 v0); +struct vec4 svec4_abs(struct vec4 v0); +struct vec4 svec4_floor(struct vec4 v0); +struct vec4 svec4_ceil(struct vec4 v0); +struct vec4 svec4_round(struct vec4 v0); +struct vec4 svec4_max(struct vec4 v0, struct vec4 v1); +struct vec4 svec4_min(struct vec4 v0, struct vec4 v1); +struct vec4 svec4_clamp(struct vec4 v0, struct vec4 v1, + struct vec4 v2); +struct vec4 svec4_normalize(struct vec4 v0); +struct vec4 svec4_lerp(struct vec4 v0, struct vec4 v1, mfloat_t f); +bool squat_is_zero(struct quat q0); +bool squat_is_equal(struct quat q0, struct quat q1); +struct quat squat(mfloat_t x, mfloat_t y, mfloat_t z, mfloat_t w); +struct quat squat_assign(struct quat q0); +struct quat squat_zero(void); +struct quat squat_null(void); +struct quat squat_multiply(struct quat q0, struct quat q1); +struct quat squat_multiply_f(struct quat q0, mfloat_t f); +struct quat squat_divide(struct quat q0, struct quat q1); +struct quat squat_divide_f(struct quat q0, mfloat_t f); +struct quat squat_negative(struct quat q0); +struct quat squat_conjugate(struct quat q0); +struct quat squat_inverse(struct quat q0); +struct quat squat_normalize(struct quat q0); +mfloat_t squat_dot(struct quat q0, struct quat q1); +struct quat squat_power(struct quat q0, mfloat_t exponent); +struct quat squat_from_axis_angle(struct vec3 v0, mfloat_t angle); +struct quat squat_from_vec3(struct vec3 v0, struct vec3 v1); +struct quat squat_from_mat4(struct mat4 m0); +struct quat squat_lerp(struct quat q0, struct quat q1, mfloat_t f); +struct quat squat_slerp(struct quat q0, struct quat q1, mfloat_t f); - struct quat squat(mfloat_t x, mfloat_t y, mfloat_t z, mfloat_t w); - struct quat squat_assign(struct quat q0); - struct quat squat_zero(void); - struct quat squat_null(void); - struct quat squat_multiply(struct quat q0, struct quat q1); - struct quat squat_multiply_f(struct quat q0, mfloat_t f); - struct quat squat_divide(struct quat q0, struct quat q1); - struct quat squat_divide_f(struct quat q0, mfloat_t f); - struct quat squat_negative(struct quat q0); - struct quat squat_conjugate(struct quat q0); - struct quat squat_inverse(struct quat q0); - struct quat squat_normalize(struct quat q0); - mfloat_t squat_dot(struct quat q0, struct quat q1); - struct quat squat_power(struct quat q0, mfloat_t exponent); - struct quat squat_from_axis_angle(struct vec3 v0, mfloat_t angle); - struct quat squat_from_vec3(struct vec3 v0, struct vec3 v1); - struct quat squat_from_mat4(struct mat4 m0); - struct quat squat_lerp(struct quat q0, struct quat q1, mfloat_t f); - struct quat squat_slerp(struct quat q0, struct quat q1, mfloat_t f); +struct quat squat_from_euler(mfloat_t x, mfloat_t y, mfloat_t z); - struct quat squat_from_euler(mfloat_t x, mfloat_t y, mfloat_t z); - - - mfloat_t squat_length(struct quat q0); - mfloat_t squat_length_squared(struct quat q0); - mfloat_t squat_angle(struct quat q0, struct quat q1); - struct mat2 smat2(mfloat_t m11, mfloat_t m12, mfloat_t m21, - mfloat_t m22); - struct mat2 smat2_zero(void); - struct mat2 smat2_identity(void); - mfloat_t smat2_determinant(struct mat2 m0); - struct mat2 smat2_assign(struct mat2 m0); - struct mat2 smat2_negative(struct mat2 m0); - struct mat2 smat2_transpose(struct mat2 m0); - struct mat2 smat2_cofactor(struct mat2 m0); - struct mat2 smat2_adjugate(struct mat2 m0); - struct mat2 smat2_multiply(struct mat2 m0, struct mat2 m1); - struct mat2 smat2_multiply_f(struct mat2 m0, mfloat_t f); - struct mat2 smat2_inverse(struct mat2 m0); - struct mat2 smat2_scaling(struct vec2 v0); - struct mat2 smat2_scale(struct mat2 m0, struct vec2 v0); - struct mat2 smat2_rotation_z(mfloat_t f); - struct mat2 smat2_lerp(struct mat2 m0, struct mat2 m1, mfloat_t f); - struct mat3 smat3(mfloat_t m11, mfloat_t m12, mfloat_t m13, - mfloat_t m21, mfloat_t m22, mfloat_t m23, - mfloat_t m31, mfloat_t m32, mfloat_t m33); - struct mat3 smat3_zero(void); - struct mat3 smat3_identity(void); - mfloat_t smat3_determinant(struct mat3 m0); - struct mat3 smat3_assign(struct mat3 m0); - struct mat3 smat3_negative(struct mat3 m0); - struct mat3 smat3_transpose(struct mat3 m0); - struct mat3 smat3_cofactor(struct mat3 m0); - struct mat3 smat3_multiply(struct mat3 m0, struct mat3 m1); - struct mat3 smat3_multiply_f(struct mat3 m0, mfloat_t f); - struct mat3 smat3_inverse(struct mat3 m0); - struct mat3 smat3_scaling(struct vec3 v0); - struct mat3 smat3_scale(struct mat3 m0, struct vec3 v0); - struct mat3 smat3_rotation_x(mfloat_t f); - struct mat3 smat3_rotation_y(mfloat_t f); - struct mat3 smat3_rotation_z(mfloat_t f); - struct mat3 smat3_rotation_axis(struct vec3 v0, mfloat_t f); - struct mat3 smat3_rotation_quat(struct quat q0); - struct mat3 smat3_lerp(struct mat3 m0, struct mat3 m1, mfloat_t f); - struct mat4 smat4(mfloat_t m11, mfloat_t m12, mfloat_t m13, - mfloat_t m14, mfloat_t m21, mfloat_t m22, - mfloat_t m23, mfloat_t m24, mfloat_t m31, - mfloat_t m32, mfloat_t m33, mfloat_t m34, - mfloat_t m41, mfloat_t m42, mfloat_t m43, - mfloat_t m44); - struct mat4 smat4_zero(void); - struct mat4 smat4_identity(void); - mfloat_t smat4_determinant(struct mat4 m0); - struct mat4 smat4_assign(struct mat4 m0); - struct mat4 smat4_negative(struct mat4 m0); - struct mat4 smat4_transpose(struct mat4 m0); - struct mat4 smat4_cofactor(struct mat4 m0); - struct mat4 smat4_rotation_x(mfloat_t f); - struct mat4 smat4_rotation_y(mfloat_t f); - struct mat4 smat4_rotation_z(mfloat_t f); - struct mat4 smat4_rotation_axis(struct vec3 v0, mfloat_t f); - struct mat4 smat4_rotation_quat(struct quat q0); - struct mat4 smat4_translation(struct mat4 m0, struct vec3 v0); - struct mat4 smat4_translate(struct mat4 m0, struct vec3 v0); - struct mat4 smat4_scaling(struct mat4 m0, struct vec3 v0); - struct mat4 smat4_scale(struct mat4 m0, struct vec3 v0); - struct mat4 smat4_multiply(struct mat4 m0, struct mat4 m1); - struct mat4 smat4_multiply_f(struct mat4 m0, mfloat_t f); - struct mat4 smat4_inverse(struct mat4 m0); - struct mat4 smat4_lerp(struct mat4 m0, struct mat4 m1, mfloat_t f); - struct mat4 smat4_look_at(struct vec3 position, struct vec3 target, - struct vec3 up); - struct mat4 smat4_ortho(mfloat_t l, mfloat_t r, mfloat_t b, mfloat_t t, - mfloat_t n, mfloat_t f); - struct mat4 smat4_perspective(mfloat_t fov_y, mfloat_t aspect, - mfloat_t n, mfloat_t f); - struct mat4 smat4_perspective_fov(mfloat_t fov, mfloat_t w, mfloat_t h, - mfloat_t n, mfloat_t f); - struct mat4 smat4_perspective_infinite(mfloat_t fov_y, mfloat_t aspect, - mfloat_t n); +mfloat_t squat_length(struct quat q0); +mfloat_t squat_length_squared(struct quat q0); +mfloat_t squat_angle(struct quat q0, struct quat q1); +struct mat2 smat2(mfloat_t m11, mfloat_t m12, mfloat_t m21, + mfloat_t m22); +struct mat2 smat2_zero(void); +struct mat2 smat2_identity(void); +mfloat_t smat2_determinant(struct mat2 m0); +struct mat2 smat2_assign(struct mat2 m0); +struct mat2 smat2_negative(struct mat2 m0); +struct mat2 smat2_transpose(struct mat2 m0); +struct mat2 smat2_cofactor(struct mat2 m0); +struct mat2 smat2_adjugate(struct mat2 m0); +struct mat2 smat2_multiply(struct mat2 m0, struct mat2 m1); +struct mat2 smat2_multiply_f(struct mat2 m0, mfloat_t f); +struct mat2 smat2_inverse(struct mat2 m0); +struct mat2 smat2_scaling(struct vec2 v0); +struct mat2 smat2_scale(struct mat2 m0, struct vec2 v0); +struct mat2 smat2_rotation_z(mfloat_t f); +struct mat2 smat2_lerp(struct mat2 m0, struct mat2 m1, mfloat_t f); +struct mat3 smat3(mfloat_t m11, mfloat_t m12, mfloat_t m13, + mfloat_t m21, mfloat_t m22, mfloat_t m23, + mfloat_t m31, mfloat_t m32, mfloat_t m33); +struct mat3 smat3_zero(void); +struct mat3 smat3_identity(void); +mfloat_t smat3_determinant(struct mat3 m0); +struct mat3 smat3_assign(struct mat3 m0); +struct mat3 smat3_negative(struct mat3 m0); +struct mat3 smat3_transpose(struct mat3 m0); +struct mat3 smat3_cofactor(struct mat3 m0); +struct mat3 smat3_multiply(struct mat3 m0, struct mat3 m1); +struct mat3 smat3_multiply_f(struct mat3 m0, mfloat_t f); +struct mat3 smat3_inverse(struct mat3 m0); +struct mat3 smat3_scaling(struct vec3 v0); +struct mat3 smat3_scale(struct mat3 m0, struct vec3 v0); +struct mat3 smat3_rotation_x(mfloat_t f); +struct mat3 smat3_rotation_y(mfloat_t f); +struct mat3 smat3_rotation_z(mfloat_t f); +struct mat3 smat3_rotation_axis(struct vec3 v0, mfloat_t f); +struct mat3 smat3_rotation_quat(struct quat q0); +struct mat3 smat3_lerp(struct mat3 m0, struct mat3 m1, mfloat_t f); +struct mat4 smat4(mfloat_t m11, mfloat_t m12, mfloat_t m13, + mfloat_t m14, mfloat_t m21, mfloat_t m22, + mfloat_t m23, mfloat_t m24, mfloat_t m31, + mfloat_t m32, mfloat_t m33, mfloat_t m34, + mfloat_t m41, mfloat_t m42, mfloat_t m43, + mfloat_t m44); +struct mat4 smat4_zero(void); +struct mat4 smat4_identity(void); +mfloat_t smat4_determinant(struct mat4 m0); +struct mat4 smat4_assign(struct mat4 m0); +struct mat4 smat4_negative(struct mat4 m0); +struct mat4 smat4_transpose(struct mat4 m0); +struct mat4 smat4_cofactor(struct mat4 m0); +struct mat4 smat4_rotation_x(mfloat_t f); +struct mat4 smat4_rotation_y(mfloat_t f); +struct mat4 smat4_rotation_z(mfloat_t f); +struct mat4 smat4_rotation_axis(struct vec3 v0, mfloat_t f); +struct mat4 smat4_rotation_quat(struct quat q0); +struct mat4 smat4_translation(struct mat4 m0, struct vec3 v0); +struct mat4 smat4_translate(struct mat4 m0, struct vec3 v0); +struct mat4 smat4_scaling(struct mat4 m0, struct vec3 v0); +struct mat4 smat4_scale(struct mat4 m0, struct vec3 v0); +struct mat4 smat4_multiply(struct mat4 m0, struct mat4 m1); +struct mat4 smat4_multiply_f(struct mat4 m0, mfloat_t f); +struct mat4 smat4_inverse(struct mat4 m0); +struct mat4 smat4_lerp(struct mat4 m0, struct mat4 m1, mfloat_t f); +struct mat4 smat4_look_at(struct vec3 position, struct vec3 target, + struct vec3 up); +struct mat4 smat4_ortho(mfloat_t l, mfloat_t r, mfloat_t b, mfloat_t t, + mfloat_t n, mfloat_t f); +struct mat4 smat4_perspective(mfloat_t fov_y, mfloat_t aspect, + mfloat_t n, mfloat_t f); +struct mat4 smat4_perspective_fov(mfloat_t fov, mfloat_t w, mfloat_t h, + mfloat_t n, mfloat_t f); +struct mat4 smat4_perspective_infinite(mfloat_t fov_y, mfloat_t aspect, + mfloat_t n); #endif #endif #if defined(MATHC_USE_POINTER_STRUCT_FUNCTIONS) #if defined(MATHC_USE_INT) - bool psvec2i_is_zero(struct vec2i *v0); - bool psvec2i_is_equal(struct vec2i *v0, struct vec2i *v1); - struct vec2i *psvec2i(struct vec2i *result, mint_t x, mint_t y); - struct vec2i *psvec2i_assign(struct vec2i *result, struct vec2i *v0); +bool psvec2i_is_zero(struct vec2i *v0); +bool psvec2i_is_equal(struct vec2i *v0, struct vec2i *v1); +struct vec2i *psvec2i(struct vec2i *result, mint_t x, mint_t y); +struct vec2i *psvec2i_assign(struct vec2i *result, struct vec2i *v0); #if defined(MATHC_USE_FLOATING_POINT) - struct vec2i *psvec2i_assign_vec2(struct vec2i *result, - struct vec2 *v0); +struct vec2i *psvec2i_assign_vec2(struct vec2i *result, + struct vec2 *v0); #endif - struct vec2i *psvec2i_zero(struct vec2i *result); - struct vec2i *psvec2i_one(struct vec2i *result); - struct vec2i *psvec2i_sign(struct vec2i *result, struct vec2i *v0); - struct vec2i *psvec2i_add(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1); - struct vec2i *psvec2i_add_i(struct vec2i *result, struct vec2i *v0, - mint_t i); - struct vec2i *psvec2i_subtract(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1); - struct vec2i *psvec2i_subtract_i(struct vec2i *result, - struct vec2i *v0, mint_t i); - struct vec2i *psvec2i_multiply(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1); - struct vec2i *psvec2i_multiply_i(struct vec2i *result, - struct vec2i *v0, mint_t i); - struct vec2i *psvec2i_divide(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1); - struct vec2i *psvec2i_divide_i(struct vec2i *result, struct vec2i *v0, - mint_t i); - struct vec2i *psvec2i_snap(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1); - struct vec2i *psvec2i_snap_i(struct vec2i *result, struct vec2i *v0, - mint_t i); - struct vec2i *psvec2i_negative(struct vec2i *result, struct vec2i *v0); - struct vec2i *psvec2i_abs(struct vec2i *result, struct vec2i *v0); - struct vec2i *psvec2i_max(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1); - struct vec2i *psvec2i_min(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1); - struct vec2i *psvec2i_clamp(struct vec2i *result, struct vec2i *v0, - struct vec2i *v1, struct vec2i *v2); - struct vec2i *psvec2i_tangent(struct vec2i *result, struct vec2i *v0); - bool psvec3i_is_zero(struct vec3i *v0); - bool psvec3i_is_equal(struct vec3i *v0, struct vec3i *v1); - struct vec3i *psvec3i(struct vec3i *result, mint_t x, mint_t y, - mint_t z); - struct vec3i *psvec3i_assign(struct vec3i *result, struct vec3i *v0); +struct vec2i *psvec2i_zero(struct vec2i *result); +struct vec2i *psvec2i_one(struct vec2i *result); +struct vec2i *psvec2i_sign(struct vec2i *result, struct vec2i *v0); +struct vec2i *psvec2i_add(struct vec2i *result, struct vec2i *v0, + struct vec2i *v1); +struct vec2i *psvec2i_add_i(struct vec2i *result, struct vec2i *v0, + mint_t i); +struct vec2i *psvec2i_subtract(struct vec2i *result, struct vec2i *v0, + struct vec2i *v1); +struct vec2i *psvec2i_subtract_i(struct vec2i *result, + struct vec2i *v0, mint_t i); +struct vec2i *psvec2i_multiply(struct vec2i *result, struct vec2i *v0, + struct vec2i *v1); +struct vec2i *psvec2i_multiply_i(struct vec2i *result, + struct vec2i *v0, mint_t i); +struct vec2i *psvec2i_divide(struct vec2i *result, struct vec2i *v0, + struct vec2i *v1); +struct vec2i *psvec2i_divide_i(struct vec2i *result, struct vec2i *v0, + mint_t i); +struct vec2i *psvec2i_snap(struct vec2i *result, struct vec2i *v0, + struct vec2i *v1); +struct vec2i *psvec2i_snap_i(struct vec2i *result, struct vec2i *v0, + mint_t i); +struct vec2i *psvec2i_negative(struct vec2i *result, struct vec2i *v0); +struct vec2i *psvec2i_abs(struct vec2i *result, struct vec2i *v0); +struct vec2i *psvec2i_max(struct vec2i *result, struct vec2i *v0, + struct vec2i *v1); +struct vec2i *psvec2i_min(struct vec2i *result, struct vec2i *v0, + struct vec2i *v1); +struct vec2i *psvec2i_clamp(struct vec2i *result, struct vec2i *v0, + struct vec2i *v1, struct vec2i *v2); +struct vec2i *psvec2i_tangent(struct vec2i *result, struct vec2i *v0); +bool psvec3i_is_zero(struct vec3i *v0); +bool psvec3i_is_equal(struct vec3i *v0, struct vec3i *v1); +struct vec3i *psvec3i(struct vec3i *result, mint_t x, mint_t y, + mint_t z); +struct vec3i *psvec3i_assign(struct vec3i *result, struct vec3i *v0); #if defined(MATHC_USE_FLOATING_POINT) - struct vec3i *psvec3i_assign_vec3(struct vec3i *result, - struct vec3 *v0); +struct vec3i *psvec3i_assign_vec3(struct vec3i *result, + struct vec3 *v0); #endif - struct vec3i *psvec3i_zero(struct vec3i *result); - struct vec3i *psvec3i_one(struct vec3i *result); - struct vec3i *psvec3i_sign(struct vec3i *result, struct vec3i *v0); - struct vec3i *psvec3i_add(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1); - struct vec3i *psvec3i_add_i(struct vec3i *result, struct vec3i *v0, - mint_t i); - struct vec3i *psvec3i_subtract(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1); - struct vec3i *psvec3i_subtract_i(struct vec3i *result, - struct vec3i *v0, mint_t i); - struct vec3i *psvec3i_multiply(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1); - struct vec3i *psvec3i_multiply_i(struct vec3i *result, - struct vec3i *v0, mint_t i); - struct vec3i *psvec3i_divide(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1); - struct vec3i *psvec3i_divide_i(struct vec3i *result, struct vec3i *v0, - mint_t i); - struct vec3i *psvec3i_snap(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1); - struct vec3i *psvec3i_snap_i(struct vec3i *result, struct vec3i *v0, - mint_t i); - struct vec3i *psvec3i_cross(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1); - struct vec3i *psvec3i_negative(struct vec3i *result, struct vec3i *v0); - struct vec3i *psvec3i_abs(struct vec3i *result, struct vec3i *v0); - struct vec3i *psvec3i_max(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1); - struct vec3i *psvec3i_min(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1); - struct vec3i *psvec3i_clamp(struct vec3i *result, struct vec3i *v0, - struct vec3i *v1, struct vec3i *v2); - bool psvec4i_is_zero(struct vec4i *v0); - bool psvec4i_is_equal(struct vec4i *v0, struct vec4i *v1); - struct vec4i *psvec4i(struct vec4i *result, mint_t x, mint_t y, - mint_t z, mint_t w); - struct vec4i *psvec4i_assign(struct vec4i *result, struct vec4i *v0); +struct vec3i *psvec3i_zero(struct vec3i *result); +struct vec3i *psvec3i_one(struct vec3i *result); +struct vec3i *psvec3i_sign(struct vec3i *result, struct vec3i *v0); +struct vec3i *psvec3i_add(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1); +struct vec3i *psvec3i_add_i(struct vec3i *result, struct vec3i *v0, + mint_t i); +struct vec3i *psvec3i_subtract(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1); +struct vec3i *psvec3i_subtract_i(struct vec3i *result, + struct vec3i *v0, mint_t i); +struct vec3i *psvec3i_multiply(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1); +struct vec3i *psvec3i_multiply_i(struct vec3i *result, + struct vec3i *v0, mint_t i); +struct vec3i *psvec3i_divide(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1); +struct vec3i *psvec3i_divide_i(struct vec3i *result, struct vec3i *v0, + mint_t i); +struct vec3i *psvec3i_snap(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1); +struct vec3i *psvec3i_snap_i(struct vec3i *result, struct vec3i *v0, + mint_t i); +struct vec3i *psvec3i_cross(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1); +struct vec3i *psvec3i_negative(struct vec3i *result, struct vec3i *v0); +struct vec3i *psvec3i_abs(struct vec3i *result, struct vec3i *v0); +struct vec3i *psvec3i_max(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1); +struct vec3i *psvec3i_min(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1); +struct vec3i *psvec3i_clamp(struct vec3i *result, struct vec3i *v0, + struct vec3i *v1, struct vec3i *v2); +bool psvec4i_is_zero(struct vec4i *v0); +bool psvec4i_is_equal(struct vec4i *v0, struct vec4i *v1); +struct vec4i *psvec4i(struct vec4i *result, mint_t x, mint_t y, + mint_t z, mint_t w); +struct vec4i *psvec4i_assign(struct vec4i *result, struct vec4i *v0); #if defined(MATHC_USE_FLOATING_POINT) - struct vec4i *psvec4i_assign_vec4(struct vec4i *result, - struct vec4 *v0); +struct vec4i *psvec4i_assign_vec4(struct vec4i *result, + struct vec4 *v0); #endif - struct vec4i *psvec4i_zero(struct vec4i *result); - struct vec4i *psvec4i_one(struct vec4i *result); - struct vec4i *psvec4i_sign(struct vec4i *result, struct vec4i *v0); - struct vec4i *psvec4i_add(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1); - struct vec4i *psvec4i_add_i(struct vec4i *result, struct vec4i *v0, - mint_t i); - struct vec4i *psvec4i_subtract(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1); - struct vec4i *psvec4i_subtract_i(struct vec4i *result, - struct vec4i *v0, mint_t i); - struct vec4i *psvec4i_multiply(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1); - struct vec4i *psvec4i_multiply_i(struct vec4i *result, - struct vec4i *v0, mint_t i); - struct vec4i *psvec4i_divide(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1); - struct vec4i *psvec4i_divide_i(struct vec4i *result, struct vec4i *v0, - mint_t i); - struct vec4i *psvec4i_snap(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1); - struct vec4i *psvec4i_snap_i(struct vec4i *result, struct vec4i *v0, - mint_t i); - struct vec4i *psvec4i_negative(struct vec4i *result, struct vec4i *v0); - struct vec4i *psvec4i_abs(struct vec4i *result, struct vec4i *v0); - struct vec4i *psvec4i_max(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1); - struct vec4i *psvec4i_min(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1); - struct vec4i *psvec4i_clamp(struct vec4i *result, struct vec4i *v0, - struct vec4i *v1, struct vec4i *v2); +struct vec4i *psvec4i_zero(struct vec4i *result); +struct vec4i *psvec4i_one(struct vec4i *result); +struct vec4i *psvec4i_sign(struct vec4i *result, struct vec4i *v0); +struct vec4i *psvec4i_add(struct vec4i *result, struct vec4i *v0, + struct vec4i *v1); +struct vec4i *psvec4i_add_i(struct vec4i *result, struct vec4i *v0, + mint_t i); +struct vec4i *psvec4i_subtract(struct vec4i *result, struct vec4i *v0, + struct vec4i *v1); +struct vec4i *psvec4i_subtract_i(struct vec4i *result, + struct vec4i *v0, mint_t i); +struct vec4i *psvec4i_multiply(struct vec4i *result, struct vec4i *v0, + struct vec4i *v1); +struct vec4i *psvec4i_multiply_i(struct vec4i *result, + struct vec4i *v0, mint_t i); +struct vec4i *psvec4i_divide(struct vec4i *result, struct vec4i *v0, + struct vec4i *v1); +struct vec4i *psvec4i_divide_i(struct vec4i *result, struct vec4i *v0, + mint_t i); +struct vec4i *psvec4i_snap(struct vec4i *result, struct vec4i *v0, + struct vec4i *v1); +struct vec4i *psvec4i_snap_i(struct vec4i *result, struct vec4i *v0, + mint_t i); +struct vec4i *psvec4i_negative(struct vec4i *result, struct vec4i *v0); +struct vec4i *psvec4i_abs(struct vec4i *result, struct vec4i *v0); +struct vec4i *psvec4i_max(struct vec4i *result, struct vec4i *v0, + struct vec4i *v1); +struct vec4i *psvec4i_min(struct vec4i *result, struct vec4i *v0, + struct vec4i *v1); +struct vec4i *psvec4i_clamp(struct vec4i *result, struct vec4i *v0, + struct vec4i *v1, struct vec4i *v2); #endif #if defined(MATHC_USE_FLOATING_POINT) - bool psvec2_is_zero(struct vec2 *v0); - bool psvec2_is_equal(struct vec2 *v0, struct vec2 *v1); - struct vec2 *psvec2(struct vec2 *result, mfloat_t x, mfloat_t y); - struct vec2 *psvec2_assign(struct vec2 *result, struct vec2 *v0); +bool psvec2_is_zero(struct vec2 *v0); +bool psvec2_is_equal(struct vec2 *v0, struct vec2 *v1); +struct vec2 *psvec2(struct vec2 *result, mfloat_t x, mfloat_t y); +struct vec2 *psvec2_assign(struct vec2 *result, struct vec2 *v0); #if defined(MATHC_USE_INT) - struct vec2 *psvec2_assign_vec2i(struct vec2 *result, - struct vec2i *v0); +struct vec2 *psvec2_assign_vec2i(struct vec2 *result, + struct vec2i *v0); #endif - struct vec2 *psvec2_zero(struct vec2 *result); - struct vec2 *psvec2_one(struct vec2 *result); - struct vec2 *psvec2_sign(struct vec2 *result, struct vec2 *v0); - struct vec2 *psvec2_add(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1); - struct vec2 *psvec2_add_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f); - struct vec2 *psvec2_subtract(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1); - struct vec2 *psvec2_subtract_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f); - struct vec2 *psvec2_multiply(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1); - struct vec2 *psvec2_multiply_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f); - struct vec2 *psvec2_multiply_mat2(struct vec2 *result, struct vec2 *v0, - struct mat2 *m0); - struct vec2 *psvec2_divide(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1); - struct vec2 *psvec2_divide_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f); - struct vec2 *psvec2_snap(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1); - struct vec2 *psvec2_snap_f(struct vec2 *result, struct vec2 *v0, - mfloat_t f); - struct vec2 *psvec2_negative(struct vec2 *result, struct vec2 *v0); - struct vec2 *psvec2_abs(struct vec2 *result, struct vec2 *v0); - struct vec2 *psvec2_floor(struct vec2 *result, struct vec2 *v0); - struct vec2 *psvec2_ceil(struct vec2 *result, struct vec2 *v0); - struct vec2 *psvec2_round(struct vec2 *result, struct vec2 *v0); - struct vec2 *psvec2_max(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1); - struct vec2 *psvec2_min(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1); - struct vec2 *psvec2_clamp(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1, struct vec2 *v2); - struct vec2 *psvec2_normalize(struct vec2 *result, struct vec2 *v0); - mfloat_t psvec2_dot(struct vec2 *v0, struct vec2 *v1); - struct vec2 *psvec2_project(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1); - struct vec2 *psvec2_slide(struct vec2 *result, struct vec2 *v0, - struct vec2 *normal); - struct vec2 *psvec2_reflect(struct vec2 *result, struct vec2 *v0, - struct vec2 *normal); - struct vec2 *psvec2_tangent(struct vec2 *result, struct vec2 *v0); - struct vec2 *psvec2_rotate(struct vec2 *result, struct vec2 *v0, - mfloat_t f); - struct vec2 *psvec2_lerp(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1, mfloat_t f); - struct vec2 *psvec2_bezier3(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1, struct vec2 *v2, - mfloat_t f); - struct vec2 *psvec2_bezier4(struct vec2 *result, struct vec2 *v0, - struct vec2 *v1, struct vec2 *v2, - struct vec2 *v3, mfloat_t f); - mfloat_t psvec2_angle(struct vec2 *v0); - mfloat_t psvec2_length(struct vec2 *v0); - mfloat_t psvec2_length_squared(struct vec2 *v0); - mfloat_t psvec2_distance(struct vec2 *v0, struct vec2 *v1); - mfloat_t psvec2_distance_squared(struct vec2 *v0, struct vec2 *v1); - bool psvec3_is_zero(struct vec3 *v0); - bool psvec3_is_equal(struct vec3 *v0, struct vec3 *v1); - struct vec3 *psvec3(struct vec3 *result, mfloat_t x, mfloat_t y, - mfloat_t z); - struct vec3 *psvec3_assign(struct vec3 *result, struct vec3 *v0); +struct vec2 *psvec2_zero(struct vec2 *result); +struct vec2 *psvec2_one(struct vec2 *result); +struct vec2 *psvec2_sign(struct vec2 *result, struct vec2 *v0); +struct vec2 *psvec2_add(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1); +struct vec2 *psvec2_add_f(struct vec2 *result, struct vec2 *v0, + mfloat_t f); +struct vec2 *psvec2_subtract(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1); +struct vec2 *psvec2_subtract_f(struct vec2 *result, struct vec2 *v0, + mfloat_t f); +struct vec2 *psvec2_multiply(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1); +struct vec2 *psvec2_multiply_f(struct vec2 *result, struct vec2 *v0, + mfloat_t f); +struct vec2 *psvec2_multiply_mat2(struct vec2 *result, struct vec2 *v0, + struct mat2 *m0); +struct vec2 *psvec2_divide(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1); +struct vec2 *psvec2_divide_f(struct vec2 *result, struct vec2 *v0, + mfloat_t f); +struct vec2 *psvec2_snap(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1); +struct vec2 *psvec2_snap_f(struct vec2 *result, struct vec2 *v0, + mfloat_t f); +struct vec2 *psvec2_negative(struct vec2 *result, struct vec2 *v0); +struct vec2 *psvec2_abs(struct vec2 *result, struct vec2 *v0); +struct vec2 *psvec2_floor(struct vec2 *result, struct vec2 *v0); +struct vec2 *psvec2_ceil(struct vec2 *result, struct vec2 *v0); +struct vec2 *psvec2_round(struct vec2 *result, struct vec2 *v0); +struct vec2 *psvec2_max(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1); +struct vec2 *psvec2_min(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1); +struct vec2 *psvec2_clamp(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1, struct vec2 *v2); +struct vec2 *psvec2_normalize(struct vec2 *result, struct vec2 *v0); +mfloat_t psvec2_dot(struct vec2 *v0, struct vec2 *v1); +struct vec2 *psvec2_project(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1); +struct vec2 *psvec2_slide(struct vec2 *result, struct vec2 *v0, + struct vec2 *normal); +struct vec2 *psvec2_reflect(struct vec2 *result, struct vec2 *v0, + struct vec2 *normal); +struct vec2 *psvec2_tangent(struct vec2 *result, struct vec2 *v0); +struct vec2 *psvec2_rotate(struct vec2 *result, struct vec2 *v0, + mfloat_t f); +struct vec2 *psvec2_lerp(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1, mfloat_t f); +struct vec2 *psvec2_bezier3(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1, struct vec2 *v2, + mfloat_t f); +struct vec2 *psvec2_bezier4(struct vec2 *result, struct vec2 *v0, + struct vec2 *v1, struct vec2 *v2, + struct vec2 *v3, mfloat_t f); +mfloat_t psvec2_angle(struct vec2 *v0); +mfloat_t psvec2_length(struct vec2 *v0); +mfloat_t psvec2_length_squared(struct vec2 *v0); +mfloat_t psvec2_distance(struct vec2 *v0, struct vec2 *v1); +mfloat_t psvec2_distance_squared(struct vec2 *v0, struct vec2 *v1); +bool psvec3_is_zero(struct vec3 *v0); +bool psvec3_is_equal(struct vec3 *v0, struct vec3 *v1); +struct vec3 *psvec3(struct vec3 *result, mfloat_t x, mfloat_t y, + mfloat_t z); +struct vec3 *psvec3_assign(struct vec3 *result, struct vec3 *v0); #if defined(MATHC_USE_INT) - struct vec3 *psvec3_assign_vec3i(struct vec3 *result, - struct vec3i *v0); +struct vec3 *psvec3_assign_vec3i(struct vec3 *result, + struct vec3i *v0); #endif - struct vec3 *psvec3_zero(struct vec3 *result); - struct vec3 *psvec3_one(struct vec3 *result); - struct vec3 *psvec3_sign(struct vec3 *result, struct vec3 *v0); - struct vec3 *psvec3_add(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_add_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f); - struct vec3 *psvec3_subtract(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_subtract_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f); - struct vec3 *psvec3_multiply(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_multiply_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f); - struct vec3 *psvec3_multiply_mat3(struct vec3 *result, struct vec3 *v0, - struct mat3 *m0); - struct vec3 *psvec3_divide(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_divide_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f); - struct vec3 *psvec3_snap(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_snap_f(struct vec3 *result, struct vec3 *v0, - mfloat_t f); - struct vec3 *psvec3_negative(struct vec3 *result, struct vec3 *v0); - struct vec3 *psvec3_abs(struct vec3 *result, struct vec3 *v0); - struct vec3 *psvec3_floor(struct vec3 *result, struct vec3 *v0); - struct vec3 *psvec3_ceil(struct vec3 *result, struct vec3 *v0); - struct vec3 *psvec3_round(struct vec3 *result, struct vec3 *v0); - struct vec3 *psvec3_max(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_min(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_clamp(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1, struct vec3 *v2); - struct vec3 *psvec3_cross(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_normalize(struct vec3 *result, struct vec3 *v0); - mfloat_t psvec3_dot(struct vec3 *v0, struct vec3 *v1); - struct vec3 *psvec3_project(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1); - struct vec3 *psvec3_slide(struct vec3 *result, struct vec3 *v0, - struct vec3 *normal); - struct vec3 *psvec3_reflect(struct vec3 *result, struct vec3 *v0, - struct vec3 *normal); - struct vec3 *psvec3_rotate(struct vec3 *result, struct vec3 *v0, - struct vec3 *ra, mfloat_t f); - struct vec3 *psvec3_lerp(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1, mfloat_t f); - struct vec3 *psvec3_bezier3(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1, struct vec3 *v2, - mfloat_t f); - struct vec3 *psvec3_bezier4(struct vec3 *result, struct vec3 *v0, - struct vec3 *v1, struct vec3 *v2, - struct vec3 *v3, mfloat_t f); - mfloat_t psvec3_length(struct vec3 *v0); - mfloat_t psvec3_length_squared(struct vec3 *v0); - mfloat_t psvec3_distance(struct vec3 *v0, struct vec3 *v1); - mfloat_t psvec3_distance_squared(struct vec3 *v0, struct vec3 *v1); - bool psvec4_is_zero(struct vec4 *v0); - bool psvec4_is_equal(struct vec4 *v0, struct vec4 *v1); - struct vec4 *psvec4(struct vec4 *result, mfloat_t x, mfloat_t y, - mfloat_t z, mfloat_t w); - struct vec4 *psvec4_assign(struct vec4 *result, struct vec4 *v0); +struct vec3 *psvec3_zero(struct vec3 *result); +struct vec3 *psvec3_one(struct vec3 *result); +struct vec3 *psvec3_sign(struct vec3 *result, struct vec3 *v0); +struct vec3 *psvec3_add(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_add_f(struct vec3 *result, struct vec3 *v0, + mfloat_t f); +struct vec3 *psvec3_subtract(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_subtract_f(struct vec3 *result, struct vec3 *v0, + mfloat_t f); +struct vec3 *psvec3_multiply(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_multiply_f(struct vec3 *result, struct vec3 *v0, + mfloat_t f); +struct vec3 *psvec3_multiply_mat3(struct vec3 *result, struct vec3 *v0, + struct mat3 *m0); +struct vec3 *psvec3_divide(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_divide_f(struct vec3 *result, struct vec3 *v0, + mfloat_t f); +struct vec3 *psvec3_snap(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_snap_f(struct vec3 *result, struct vec3 *v0, + mfloat_t f); +struct vec3 *psvec3_negative(struct vec3 *result, struct vec3 *v0); +struct vec3 *psvec3_abs(struct vec3 *result, struct vec3 *v0); +struct vec3 *psvec3_floor(struct vec3 *result, struct vec3 *v0); +struct vec3 *psvec3_ceil(struct vec3 *result, struct vec3 *v0); +struct vec3 *psvec3_round(struct vec3 *result, struct vec3 *v0); +struct vec3 *psvec3_max(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_min(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_clamp(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1, struct vec3 *v2); +struct vec3 *psvec3_cross(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_normalize(struct vec3 *result, struct vec3 *v0); +mfloat_t psvec3_dot(struct vec3 *v0, struct vec3 *v1); +struct vec3 *psvec3_project(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1); +struct vec3 *psvec3_slide(struct vec3 *result, struct vec3 *v0, + struct vec3 *normal); +struct vec3 *psvec3_reflect(struct vec3 *result, struct vec3 *v0, + struct vec3 *normal); +struct vec3 *psvec3_rotate(struct vec3 *result, struct vec3 *v0, + struct vec3 *ra, mfloat_t f); +struct vec3 *psvec3_lerp(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1, mfloat_t f); +struct vec3 *psvec3_bezier3(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1, struct vec3 *v2, + mfloat_t f); +struct vec3 *psvec3_bezier4(struct vec3 *result, struct vec3 *v0, + struct vec3 *v1, struct vec3 *v2, + struct vec3 *v3, mfloat_t f); +mfloat_t psvec3_length(struct vec3 *v0); +mfloat_t psvec3_length_squared(struct vec3 *v0); +mfloat_t psvec3_distance(struct vec3 *v0, struct vec3 *v1); +mfloat_t psvec3_distance_squared(struct vec3 *v0, struct vec3 *v1); +bool psvec4_is_zero(struct vec4 *v0); +bool psvec4_is_equal(struct vec4 *v0, struct vec4 *v1); +struct vec4 *psvec4(struct vec4 *result, mfloat_t x, mfloat_t y, + mfloat_t z, mfloat_t w); +struct vec4 *psvec4_assign(struct vec4 *result, struct vec4 *v0); #if defined(MATHC_USE_INT) - struct vec4 *psvec4_assign_vec4i(struct vec4 *result, - struct vec4i *v0); +struct vec4 *psvec4_assign_vec4i(struct vec4 *result, + struct vec4i *v0); #endif - struct vec4 *psvec4_zero(struct vec4 *result); - struct vec4 *psvec4_one(struct vec4 *result); - struct vec4 *psvec4_sign(struct vec4 *result, struct vec4 *v0); - struct vec4 *psvec4_add(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1); - struct vec4 *psvec4_add_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f); - struct vec4 *psvec4_subtract(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1); - struct vec4 *psvec4_subtract_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f); - struct vec4 *psvec4_multiply(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1); - struct vec4 *psvec4_multiply_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f); - struct vec4 *psvec4_multiply_mat4(struct vec4 *result, struct vec4 *v0, - struct mat4 *m0); - struct vec4 *psvec4_divide(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1); - struct vec4 *psvec4_divide_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f); - struct vec4 *psvec4_snap(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1); - struct vec4 *psvec4_snap_f(struct vec4 *result, struct vec4 *v0, - mfloat_t f); - struct vec4 *psvec4_negative(struct vec4 *result, struct vec4 *v0); - struct vec4 *psvec4_abs(struct vec4 *result, struct vec4 *v0); - struct vec4 *psvec4_floor(struct vec4 *result, struct vec4 *v0); - struct vec4 *psvec4_ceil(struct vec4 *result, struct vec4 *v0); - struct vec4 *psvec4_round(struct vec4 *result, struct vec4 *v0); - struct vec4 *psvec4_max(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1); - struct vec4 *psvec4_min(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1); - struct vec4 *psvec4_clamp(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1, struct vec4 *v2); - struct vec4 *psvec4_normalize(struct vec4 *result, struct vec4 *v0); - struct vec4 *psvec4_lerp(struct vec4 *result, struct vec4 *v0, - struct vec4 *v1, mfloat_t f); - bool psquat_is_zero(struct quat *q0); - bool psquat_is_equal(struct quat *q0, struct quat *q1); - struct quat *psquat(struct quat *result, mfloat_t x, mfloat_t y, - mfloat_t z, mfloat_t w); - struct quat *psquat_assign(struct quat *result, struct quat *q0); - struct quat *psquat_zero(struct quat *result); - struct quat *psquat_null(struct quat *result); - struct quat *psquat_multiply(struct quat *result, struct quat *q0, - struct quat *q1); - struct quat *psquat_multiply_f(struct quat *result, struct quat *q0, - mfloat_t f); - struct quat *psquat_divide(struct quat *result, struct quat *q0, - struct quat *q1); - struct quat *psquat_divide_f(struct quat *result, struct quat *q0, - mfloat_t f); - struct quat *psquat_negative(struct quat *result, struct quat *q0); - struct quat *psquat_conjugate(struct quat *result, struct quat *q0); - struct quat *psquat_inverse(struct quat *result, struct quat *q0); - struct quat *psquat_normalize(struct quat *result, struct quat *q0); - mfloat_t psquat_dot(struct quat *q0, struct quat *q1); - struct quat *psquat_power(struct quat *result, struct quat *q0, - mfloat_t exponent); - struct quat *psquat_from_axis_angle(struct quat *result, - struct vec3 *v0, mfloat_t angle); - struct quat *psquat_from_vec3(struct quat *result, struct vec3 *v0, - struct vec3 *v1); - struct quat *psquat_from_mat4(struct quat *result, struct mat4 *m0); - struct quat *psquat_lerp(struct quat *result, struct quat *q0, - struct quat *q1, mfloat_t f); - struct quat *psquat_slerp(struct quat *result, struct quat *q0, - struct quat *q1, mfloat_t f); - mfloat_t psquat_length(struct quat *q0); - mfloat_t psquat_length_squared(struct quat *q0); - mfloat_t psquat_angle(struct quat *q0, struct quat *q1); - struct mat2 *psmat2(struct mat2 *result, mfloat_t m11, mfloat_t m12, - mfloat_t m21, mfloat_t m22); - struct mat2 *psmat2_zero(struct mat2 *result); - struct mat2 *psmat2_identity(struct mat2 *result); - mfloat_t psmat2_determinant(struct mat2 *m0); - struct mat2 *psmat2_assign(struct mat2 *result, struct mat2 *m0); - struct mat2 *psmat2_negative(struct mat2 *result, struct mat2 *m0); - struct mat2 *psmat2_transpose(struct mat2 *result, struct mat2 *m0); - struct mat2 *psmat2_cofactor(struct mat2 *result, struct mat2 *m0); - struct mat2 *psmat2_adjugate(struct mat2 *result, struct mat2 *m0); - struct mat2 *psmat2_multiply(struct mat2 *result, struct mat2 *m0, - struct mat2 *m1); - struct mat2 *psmat2_multiply_f(struct mat2 *result, struct mat2 *m0, - mfloat_t f); - struct mat2 *psmat2_inverse(struct mat2 *result, struct mat2 *m0); - struct mat2 *psmat2_scaling(struct mat2 *result, struct vec2 *v0); - struct mat2 *psmat2_scale(struct mat2 *result, struct mat2 *m0, - struct vec2 *v0); - struct mat2 *psmat2_rotation_z(struct mat2 *result, mfloat_t f); - struct mat2 *psmat2_lerp(struct mat2 *result, struct mat2 *m0, - struct mat2 *m1, mfloat_t f); - struct mat3 *psmat3(struct mat3 *result, mfloat_t m11, mfloat_t m12, - mfloat_t m13, mfloat_t m21, mfloat_t m22, - mfloat_t m23, mfloat_t m31, mfloat_t m32, - mfloat_t m33); - struct mat3 *psmat3_zero(struct mat3 *result); - struct mat3 *psmat3_identity(struct mat3 *result); - mfloat_t psmat3_determinant(struct mat3 *m0); - struct mat3 *psmat3_assign(struct mat3 *result, struct mat3 *m0); - struct mat3 *psmat3_negative(struct mat3 *result, struct mat3 *m0); - struct mat3 *psmat3_transpose(struct mat3 *result, struct mat3 *m0); - struct mat3 *psmat3_cofactor(struct mat3 *result, struct mat3 *m0); - struct mat3 *psmat3_multiply(struct mat3 *result, struct mat3 *m0, - struct mat3 *m1); - struct mat3 *psmat3_multiply_f(struct mat3 *result, struct mat3 *m0, - mfloat_t f); - struct mat3 *psmat3_inverse(struct mat3 *result, struct mat3 *m0); - struct mat3 *psmat3_scaling(struct mat3 *result, struct vec3 *v0); - struct mat3 *psmat3_scale(struct mat3 *result, struct mat3 *m0, - struct vec3 *v0); - struct mat3 *psmat3_rotation_x(struct mat3 *result, mfloat_t f); - struct mat3 *psmat3_rotation_y(struct mat3 *result, mfloat_t f); - struct mat3 *psmat3_rotation_z(struct mat3 *result, mfloat_t f); - struct mat3 *psmat3_rotation_axis(struct mat3 *result, struct vec3 *v0, - mfloat_t f); - struct mat3 *psmat3_rotation_quat(struct mat3 *result, - struct quat *q0); - struct mat3 *psmat3_lerp(struct mat3 *result, struct mat3 *m0, - struct mat3 *m1, mfloat_t f); - struct mat4 *psmat4(struct mat4 *result, mfloat_t m11, mfloat_t m12, - mfloat_t m13, mfloat_t m14, mfloat_t m21, - mfloat_t m22, mfloat_t m23, mfloat_t m24, - mfloat_t m31, mfloat_t m32, mfloat_t m33, - mfloat_t m34, mfloat_t m41, mfloat_t m42, - mfloat_t m43, mfloat_t m44); - struct mat4 *psmat4_zero(struct mat4 *result); - struct mat4 *psmat4_identity(struct mat4 *result); - mfloat_t psmat4_determinant(struct mat4 *m0); - struct mat4 *psmat4_assign(struct mat4 *result, struct mat4 *m0); - struct mat4 *psmat4_negative(struct mat4 *result, struct mat4 *m0); - struct mat4 *psmat4_transpose(struct mat4 *result, struct mat4 *m0); - struct mat4 *psmat4_cofactor(struct mat4 *result, struct mat4 *m0); - struct mat4 *psmat4_rotation_x(struct mat4 *result, mfloat_t f); - struct mat4 *psmat4_rotation_y(struct mat4 *result, mfloat_t f); - struct mat4 *psmat4_rotation_z(struct mat4 *result, mfloat_t f); - struct mat4 *psmat4_rotation_axis(struct mat4 *result, struct vec3 *v0, - mfloat_t f); - struct mat4 *psmat4_rotation_quat(struct mat4 *result, - struct quat *q0); - struct mat4 *psmat4_translation(struct mat4 *result, struct mat4 *m0, - struct vec3 *v0); - struct mat4 *psmat4_translate(struct mat4 *result, struct mat4 *m0, - struct vec3 *v0); - struct mat4 *psmat4_scaling(struct mat4 *result, struct mat4 *m0, - struct vec3 *v0); - struct mat4 *psmat4_scale(struct mat4 *result, struct mat4 *m0, - struct vec3 *v0); - struct mat4 *psmat4_multiply(struct mat4 *result, struct mat4 *m0, - struct mat4 *m1); - struct mat4 *psmat4_multiply_f(struct mat4 *result, struct mat4 *m0, - mfloat_t f); - struct mat4 *psmat4_inverse(struct mat4 *result, struct mat4 *m0); - struct mat4 *psmat4_lerp(struct mat4 *result, struct mat4 *m0, - struct mat4 *m1, mfloat_t f); - struct mat4 *psmat4_look_at(struct mat4 *result, struct vec3 *position, - struct vec3 *target, struct vec3 *up); - struct mat4 *psmat4_ortho(struct mat4 *result, mfloat_t l, mfloat_t r, - mfloat_t b, mfloat_t t, mfloat_t n, - mfloat_t f); - struct mat4 *psmat4_perspective(struct mat4 *result, mfloat_t fov_y, - mfloat_t aspect, mfloat_t n, - mfloat_t f); - struct mat4 *psmat4_perspective_fov(struct mat4 *result, mfloat_t fov, - mfloat_t w, mfloat_t h, mfloat_t n, - mfloat_t f); - struct mat4 *psmat4_perspective_infinite(struct mat4 *result, - mfloat_t fov_y, - mfloat_t aspect, mfloat_t n); +struct vec4 *psvec4_zero(struct vec4 *result); +struct vec4 *psvec4_one(struct vec4 *result); +struct vec4 *psvec4_sign(struct vec4 *result, struct vec4 *v0); +struct vec4 *psvec4_add(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1); +struct vec4 *psvec4_add_f(struct vec4 *result, struct vec4 *v0, + mfloat_t f); +struct vec4 *psvec4_subtract(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1); +struct vec4 *psvec4_subtract_f(struct vec4 *result, struct vec4 *v0, + mfloat_t f); +struct vec4 *psvec4_multiply(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1); +struct vec4 *psvec4_multiply_f(struct vec4 *result, struct vec4 *v0, + mfloat_t f); +struct vec4 *psvec4_multiply_mat4(struct vec4 *result, struct vec4 *v0, + struct mat4 *m0); +struct vec4 *psvec4_divide(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1); +struct vec4 *psvec4_divide_f(struct vec4 *result, struct vec4 *v0, + mfloat_t f); +struct vec4 *psvec4_snap(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1); +struct vec4 *psvec4_snap_f(struct vec4 *result, struct vec4 *v0, + mfloat_t f); +struct vec4 *psvec4_negative(struct vec4 *result, struct vec4 *v0); +struct vec4 *psvec4_abs(struct vec4 *result, struct vec4 *v0); +struct vec4 *psvec4_floor(struct vec4 *result, struct vec4 *v0); +struct vec4 *psvec4_ceil(struct vec4 *result, struct vec4 *v0); +struct vec4 *psvec4_round(struct vec4 *result, struct vec4 *v0); +struct vec4 *psvec4_max(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1); +struct vec4 *psvec4_min(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1); +struct vec4 *psvec4_clamp(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1, struct vec4 *v2); +struct vec4 *psvec4_normalize(struct vec4 *result, struct vec4 *v0); +struct vec4 *psvec4_lerp(struct vec4 *result, struct vec4 *v0, + struct vec4 *v1, mfloat_t f); +bool psquat_is_zero(struct quat *q0); +bool psquat_is_equal(struct quat *q0, struct quat *q1); +struct quat *psquat(struct quat *result, mfloat_t x, mfloat_t y, + mfloat_t z, mfloat_t w); +struct quat *psquat_assign(struct quat *result, struct quat *q0); +struct quat *psquat_zero(struct quat *result); +struct quat *psquat_null(struct quat *result); +struct quat *psquat_multiply(struct quat *result, struct quat *q0, + struct quat *q1); +struct quat *psquat_multiply_f(struct quat *result, struct quat *q0, + mfloat_t f); +struct quat *psquat_divide(struct quat *result, struct quat *q0, + struct quat *q1); +struct quat *psquat_divide_f(struct quat *result, struct quat *q0, + mfloat_t f); +struct quat *psquat_negative(struct quat *result, struct quat *q0); +struct quat *psquat_conjugate(struct quat *result, struct quat *q0); +struct quat *psquat_inverse(struct quat *result, struct quat *q0); +struct quat *psquat_normalize(struct quat *result, struct quat *q0); +mfloat_t psquat_dot(struct quat *q0, struct quat *q1); +struct quat *psquat_power(struct quat *result, struct quat *q0, + mfloat_t exponent); +struct quat *psquat_from_axis_angle(struct quat *result, + struct vec3 *v0, mfloat_t angle); +struct quat *psquat_from_vec3(struct quat *result, struct vec3 *v0, + struct vec3 *v1); +struct quat *psquat_from_mat4(struct quat *result, struct mat4 *m0); +struct quat *psquat_lerp(struct quat *result, struct quat *q0, + struct quat *q1, mfloat_t f); +struct quat *psquat_slerp(struct quat *result, struct quat *q0, + struct quat *q1, mfloat_t f); +mfloat_t psquat_length(struct quat *q0); +mfloat_t psquat_length_squared(struct quat *q0); +mfloat_t psquat_angle(struct quat *q0, struct quat *q1); +struct mat2 *psmat2(struct mat2 *result, mfloat_t m11, mfloat_t m12, + mfloat_t m21, mfloat_t m22); +struct mat2 *psmat2_zero(struct mat2 *result); +struct mat2 *psmat2_identity(struct mat2 *result); +mfloat_t psmat2_determinant(struct mat2 *m0); +struct mat2 *psmat2_assign(struct mat2 *result, struct mat2 *m0); +struct mat2 *psmat2_negative(struct mat2 *result, struct mat2 *m0); +struct mat2 *psmat2_transpose(struct mat2 *result, struct mat2 *m0); +struct mat2 *psmat2_cofactor(struct mat2 *result, struct mat2 *m0); +struct mat2 *psmat2_adjugate(struct mat2 *result, struct mat2 *m0); +struct mat2 *psmat2_multiply(struct mat2 *result, struct mat2 *m0, + struct mat2 *m1); +struct mat2 *psmat2_multiply_f(struct mat2 *result, struct mat2 *m0, + mfloat_t f); +struct mat2 *psmat2_inverse(struct mat2 *result, struct mat2 *m0); +struct mat2 *psmat2_scaling(struct mat2 *result, struct vec2 *v0); +struct mat2 *psmat2_scale(struct mat2 *result, struct mat2 *m0, + struct vec2 *v0); +struct mat2 *psmat2_rotation_z(struct mat2 *result, mfloat_t f); +struct mat2 *psmat2_lerp(struct mat2 *result, struct mat2 *m0, + struct mat2 *m1, mfloat_t f); +struct mat3 *psmat3(struct mat3 *result, mfloat_t m11, mfloat_t m12, + mfloat_t m13, mfloat_t m21, mfloat_t m22, + mfloat_t m23, mfloat_t m31, mfloat_t m32, + mfloat_t m33); +struct mat3 *psmat3_zero(struct mat3 *result); +struct mat3 *psmat3_identity(struct mat3 *result); +mfloat_t psmat3_determinant(struct mat3 *m0); +struct mat3 *psmat3_assign(struct mat3 *result, struct mat3 *m0); +struct mat3 *psmat3_negative(struct mat3 *result, struct mat3 *m0); +struct mat3 *psmat3_transpose(struct mat3 *result, struct mat3 *m0); +struct mat3 *psmat3_cofactor(struct mat3 *result, struct mat3 *m0); +struct mat3 *psmat3_multiply(struct mat3 *result, struct mat3 *m0, + struct mat3 *m1); +struct mat3 *psmat3_multiply_f(struct mat3 *result, struct mat3 *m0, + mfloat_t f); +struct mat3 *psmat3_inverse(struct mat3 *result, struct mat3 *m0); +struct mat3 *psmat3_scaling(struct mat3 *result, struct vec3 *v0); +struct mat3 *psmat3_scale(struct mat3 *result, struct mat3 *m0, + struct vec3 *v0); +struct mat3 *psmat3_rotation_x(struct mat3 *result, mfloat_t f); +struct mat3 *psmat3_rotation_y(struct mat3 *result, mfloat_t f); +struct mat3 *psmat3_rotation_z(struct mat3 *result, mfloat_t f); +struct mat3 *psmat3_rotation_axis(struct mat3 *result, struct vec3 *v0, + mfloat_t f); +struct mat3 *psmat3_rotation_quat(struct mat3 *result, + struct quat *q0); +struct mat3 *psmat3_lerp(struct mat3 *result, struct mat3 *m0, + struct mat3 *m1, mfloat_t f); +struct mat4 *psmat4(struct mat4 *result, mfloat_t m11, mfloat_t m12, + mfloat_t m13, mfloat_t m14, mfloat_t m21, + mfloat_t m22, mfloat_t m23, mfloat_t m24, + mfloat_t m31, mfloat_t m32, mfloat_t m33, + mfloat_t m34, mfloat_t m41, mfloat_t m42, + mfloat_t m43, mfloat_t m44); +struct mat4 *psmat4_zero(struct mat4 *result); +struct mat4 *psmat4_identity(struct mat4 *result); +mfloat_t psmat4_determinant(struct mat4 *m0); +struct mat4 *psmat4_assign(struct mat4 *result, struct mat4 *m0); +struct mat4 *psmat4_negative(struct mat4 *result, struct mat4 *m0); +struct mat4 *psmat4_transpose(struct mat4 *result, struct mat4 *m0); +struct mat4 *psmat4_cofactor(struct mat4 *result, struct mat4 *m0); +struct mat4 *psmat4_rotation_x(struct mat4 *result, mfloat_t f); +struct mat4 *psmat4_rotation_y(struct mat4 *result, mfloat_t f); +struct mat4 *psmat4_rotation_z(struct mat4 *result, mfloat_t f); +struct mat4 *psmat4_rotation_axis(struct mat4 *result, struct vec3 *v0, + mfloat_t f); +struct mat4 *psmat4_rotation_quat(struct mat4 *result, + struct quat *q0); +struct mat4 *psmat4_translation(struct mat4 *result, struct mat4 *m0, + struct vec3 *v0); +struct mat4 *psmat4_translate(struct mat4 *result, struct mat4 *m0, + struct vec3 *v0); +struct mat4 *psmat4_scaling(struct mat4 *result, struct mat4 *m0, + struct vec3 *v0); +struct mat4 *psmat4_scale(struct mat4 *result, struct mat4 *m0, + struct vec3 *v0); +struct mat4 *psmat4_multiply(struct mat4 *result, struct mat4 *m0, + struct mat4 *m1); +struct mat4 *psmat4_multiply_f(struct mat4 *result, struct mat4 *m0, + mfloat_t f); +struct mat4 *psmat4_inverse(struct mat4 *result, struct mat4 *m0); +struct mat4 *psmat4_lerp(struct mat4 *result, struct mat4 *m0, + struct mat4 *m1, mfloat_t f); +struct mat4 *psmat4_look_at(struct mat4 *result, struct vec3 *position, + struct vec3 *target, struct vec3 *up); +struct mat4 *psmat4_ortho(struct mat4 *result, mfloat_t l, mfloat_t r, + mfloat_t b, mfloat_t t, mfloat_t n, + mfloat_t f); +struct mat4 *psmat4_perspective(struct mat4 *result, mfloat_t fov_y, + mfloat_t aspect, mfloat_t n, + mfloat_t f); +struct mat4 *psmat4_perspective_fov(struct mat4 *result, mfloat_t fov, + mfloat_t w, mfloat_t h, mfloat_t n, + mfloat_t f); +struct mat4 *psmat4_perspective_infinite(struct mat4 *result, + mfloat_t fov_y, + mfloat_t aspect, mfloat_t n); #endif #endif #if defined(MATHC_USE_FLOATING_POINT) && defined(MATHC_USE_EASING_FUNCTIONS) - mfloat_t quadratic_ease_out(mfloat_t f); - mfloat_t quadratic_ease_in(mfloat_t f); - mfloat_t quadratic_ease_in_out(mfloat_t f); - mfloat_t cubic_ease_out(mfloat_t f); - mfloat_t cubic_ease_in(mfloat_t f); - mfloat_t cubic_ease_in_out(mfloat_t f); - mfloat_t quartic_ease_out(mfloat_t f); - mfloat_t quartic_ease_in(mfloat_t f); - mfloat_t quartic_ease_in_out(mfloat_t f); - mfloat_t quintic_ease_out(mfloat_t f); - mfloat_t quintic_ease_in(mfloat_t f); - mfloat_t quintic_ease_in_out(mfloat_t f); - mfloat_t sine_ease_out(mfloat_t f); - mfloat_t sine_ease_in(mfloat_t f); - mfloat_t sine_ease_in_out(mfloat_t f); - mfloat_t circular_ease_out(mfloat_t f); - mfloat_t circular_ease_in(mfloat_t f); - mfloat_t circular_ease_in_out(mfloat_t f); - mfloat_t exponential_ease_out(mfloat_t f); - mfloat_t exponential_ease_in(mfloat_t f); - mfloat_t exponential_ease_in_out(mfloat_t f); - mfloat_t elastic_ease_out(mfloat_t f); - mfloat_t elastic_ease_in(mfloat_t f); - mfloat_t elastic_ease_in_out(mfloat_t f); - mfloat_t back_ease_out(mfloat_t f); - mfloat_t back_ease_in(mfloat_t f); - mfloat_t back_ease_in_out(mfloat_t f); - mfloat_t bounce_ease_out(mfloat_t f); - mfloat_t bounce_ease_in(mfloat_t f); - mfloat_t bounce_ease_in_out(mfloat_t f); +mfloat_t quadratic_ease_out(mfloat_t f); +mfloat_t quadratic_ease_in(mfloat_t f); +mfloat_t quadratic_ease_in_out(mfloat_t f); +mfloat_t cubic_ease_out(mfloat_t f); +mfloat_t cubic_ease_in(mfloat_t f); +mfloat_t cubic_ease_in_out(mfloat_t f); +mfloat_t quartic_ease_out(mfloat_t f); +mfloat_t quartic_ease_in(mfloat_t f); +mfloat_t quartic_ease_in_out(mfloat_t f); +mfloat_t quintic_ease_out(mfloat_t f); +mfloat_t quintic_ease_in(mfloat_t f); +mfloat_t quintic_ease_in_out(mfloat_t f); +mfloat_t sine_ease_out(mfloat_t f); +mfloat_t sine_ease_in(mfloat_t f); +mfloat_t sine_ease_in_out(mfloat_t f); +mfloat_t circular_ease_out(mfloat_t f); +mfloat_t circular_ease_in(mfloat_t f); +mfloat_t circular_ease_in_out(mfloat_t f); +mfloat_t exponential_ease_out(mfloat_t f); +mfloat_t exponential_ease_in(mfloat_t f); +mfloat_t exponential_ease_in_out(mfloat_t f); +mfloat_t elastic_ease_out(mfloat_t f); +mfloat_t elastic_ease_in(mfloat_t f); +mfloat_t elastic_ease_in_out(mfloat_t f); +mfloat_t back_ease_out(mfloat_t f); +mfloat_t back_ease_in(mfloat_t f); +mfloat_t back_ease_in_out(mfloat_t f); +mfloat_t bounce_ease_out(mfloat_t f); +mfloat_t bounce_ease_in(mfloat_t f); +mfloat_t bounce_ease_in_out(mfloat_t f); #endif #endif diff --git a/source/engine/nuke.c b/source/engine/nuke.c index 92c5745..70efd69 100644 --- a/source/engine/nuke.c +++ b/source/engine/nuke.c @@ -1,155 +1,147 @@ -#define NK_INCLUDE_FIXED_TYPES #define NK_INCLUDE_STANDARD_IO -#define NK_INCLUDE_STANDARD_VARARGS -#define NK_INCLUDE_DEFAULT_ALLOCATOR -#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT -#define NK_INCLUDE_FONT_BAKING -#define NK_INCLUDE_DEFAULT_FONT -#define NK_INCLUDE_STANDARD_BOOL + #define NK_IMPLEMENTATION -#define NK_GLFW_GL3_IMPLEMENTATION #define NK_KEYSTATE_BASED_INPUT +#define STBTT_STATIC + #include "nuke.h" -#include "nuklear_glfw_gl3.h" + +#define SOKOL_GLCORE33 +#include "sokol/sokol_gfx.h" + +#define SOKOL_NUKLEAR_NO_SOKOL_APP +#define SOKOL_NUKLEAR_IMPL + +#include "sokol/sokol_nuklear.h" #include -#include "window.h" -#include "texture.h" #include "log.h" +#include "texture.h" +#include "window.h" #define MAX_VERTEX_BUFFER 512 * 1024 #define MAX_ELEMENT_BUFFER 128 * 1024 struct nk_context *ctx; -static struct nk_glfw nkglfw = {0}; - +//static struct nk_glfw nkglfw = {0}; void nuke_init(struct window *win) { - window_makecurrent(win); - - ctx = nk_glfw3_init(&nkglfw, win->window, NK_GLFW3_INSTALL_CALLBACKS); - - struct nk_font_atlas *atlas; - nk_glfw3_font_stash_begin(&nkglfw, &atlas); - struct nk_font *noto = nk_font_atlas_add_from_file(atlas, "fonts/teenytinypixels.tff", 14, 0); - nk_glfw3_font_stash_end(&nkglfw); + window_makecurrent(win); + + snk_setup(&(snk_desc_t){ + .no_default_font = false + }); } -void nuke_start() -{ - nk_glfw3_new_frame(&nkglfw); +void nuke_start() { + ctx = snk_new_frame(); } -void nuke_end() -{ - nk_glfw3_render(&nkglfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER); +void nuke_end() { + snk_render(1200,720); } - int nuke_begin(const char *lbl, struct nk_rect rect, int flags) { - return nk_begin(ctx, lbl, rect, flags); + return nk_begin(ctx, lbl, rect, flags); } -int nuke_begin_win(const char *lbl) -{ +int nuke_begin_win(const char *lbl) { return nk_begin(ctx, lbl, nk_rect(10, 10, 400, 600), NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_SCALABLE | NK_WINDOW_TITLE); } void nuke_stop() { - nk_end(ctx); + nk_end(ctx); } struct nk_rect nuke_win_get_bounds() { - return nk_window_get_bounds(ctx); + return nk_window_get_bounds(ctx); } -void nuke_row(int height) -{ +void nuke_row(int height) { nk_layout_row_dynamic(ctx, height, 1); } void nuke_property_float3(const char *label, float min, float *val, float max, float step, float dragstep) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_label(ctx, label, NK_TEXT_LEFT); - nk_layout_row_dynamic(ctx, 25, 3); - nuke_property_float("#X", min, &val[0], max, step, dragstep); - nuke_property_float("#Y", min, &val[1], max, step, dragstep); - nuke_property_float("#Z", min, &val[2], max, step, dragstep); + nk_layout_row_dynamic(ctx, 25, 1); + nk_label(ctx, label, NK_TEXT_LEFT); + nk_layout_row_dynamic(ctx, 25, 3); + nuke_property_float("#X", min, &val[0], max, step, dragstep); + nuke_property_float("#Y", min, &val[1], max, step, dragstep); + nuke_property_float("#Z", min, &val[2], max, step, dragstep); } void nuke_property_float2(const char *label, float min, float *val, float max, float step, float dragstep) { - nk_layout_row_dynamic(ctx, 25, 1); - nk_label(ctx, label, NK_TEXT_LEFT); - nk_layout_row_dynamic(ctx, 25, 2); - nuke_property_float("#X", min, &val[0], max, step, dragstep); - nuke_property_float("#Y", min, &val[1], max, step, dragstep); + nk_layout_row_dynamic(ctx, 25, 1); + nk_label(ctx, label, NK_TEXT_LEFT); + nk_layout_row_dynamic(ctx, 25, 2); + nuke_property_float("#X", min, &val[0], max, step, dragstep); + nuke_property_float("#Y", min, &val[1], max, step, dragstep); } void nuke_property_float(const char *lbl, float min, float *val, float max, float step, float dragstep) { - nk_property_float(ctx, lbl, min, val, max, step, dragstep); + nk_property_float(ctx, lbl, min, val, max, step, dragstep); } int nuke_btn(const char *lbl) { - return nk_button_label(ctx, lbl); + return nk_button_label(ctx, lbl); } void nuke_img(char *path) { -/* - struct Texture *t = texture_pullfromfile(path); - nk_layout_row_static(ctx, t->height, t->width, 1); - nk_image(ctx, nk_image_id(t->id)); -*/ + /* + struct Texture *t = texture_pullfromfile(path); + nk_layout_row_static(ctx, t->height, t->width, 1); + nk_image(ctx, nk_image_id(t->id)); + */ } void nuke_property_int(const char *lbl, int min, int *val, int max, int step) { - nk_property_int(ctx, lbl, min, val, max, step, step); + nk_property_int(ctx, lbl, min, val, max, step, step); } void nuke_radio_btn(const char *lbl, int *val, int cmp) { - if (nk_option_label(ctx, lbl, *val==cmp)) *val = cmp; + if (nk_option_label(ctx, lbl, *val == cmp)) *val = cmp; } void nuke_checkbox(const char *lbl, int *val) { - nk_checkbox_label(ctx, lbl, val); + nk_checkbox_label(ctx, lbl, val); } -void nuke_scrolltext(char *str) -{ - nk_edit_string_zero_terminated(ctx, NK_EDIT_MULTILINE|NK_EDIT_GOTO_END_ON_ACTIVATE, str, 1024*1024*5, NULL); +void nuke_scrolltext(char *str) { + nk_edit_string_zero_terminated(ctx, NK_EDIT_MULTILINE | NK_EDIT_GOTO_END_ON_ACTIVATE, str, 1024 * 1024 * 5, NULL); } void nuke_nel(int cols) { - nk_layout_row_dynamic(ctx, 25, cols); + nk_layout_row_dynamic(ctx, 25, cols); } void nuke_nel_h(int cols, int h) { - nk_layout_row_dynamic(ctx, h, cols); + nk_layout_row_dynamic(ctx, h, cols); } void nuke_label(const char *s) { - nk_label(ctx, s, NK_TEXT_LEFT); + nk_label(ctx, s, NK_TEXT_LEFT); } void nuke_edit_str(char *str) { - nk_edit_string_zero_terminated(ctx, NK_EDIT_BOX|NK_EDIT_NO_HORIZONTAL_SCROLL, str, 130, nk_filter_ascii); + nk_edit_string_zero_terminated(ctx, NK_EDIT_BOX | NK_EDIT_NO_HORIZONTAL_SCROLL, str, 130, nk_filter_ascii); } int nuke_push_tree_id(const char *name, int id) { - return nk_tree_push_id(ctx, NK_TREE_NODE, name, NK_MINIMIZED, id); + return nk_tree_push_id(ctx, NK_TREE_NODE, name, NK_MINIMIZED, id); } void nuke_tree_pop() { - nk_tree_pop(ctx); + nk_tree_pop(ctx); } void nuke_labelf(const char *fmt, ...) { - char buf[512]; + char buf[512]; - va_list args; - va_start(args, fmt); - vsnprintf(buf, 512, fmt, args); - nuke_label(buf); - va_end(args); + va_list args; + va_start(args, fmt); + vsnprintf(buf, 512, fmt, args); + nuke_label(buf); + va_end(args); } diff --git a/source/engine/nuke.h b/source/engine/nuke.h index 1caa96f..044f231 100644 --- a/source/engine/nuke.h +++ b/source/engine/nuke.h @@ -1,6 +1,14 @@ #ifndef NUKE_H #define NUKE_H +#define NK_INCLUDE_FIXED_TYPES +#define NK_INCLUDE_STANDARD_VARARGS +#define NK_INCLUDE_FONT_BAKING +#define NK_INCLUDE_DEFAULT_FONT +#define NK_INCLUDE_STANDARD_BOOL +#define NK_INCLUDE_DEFAULT_ALLOCATOR +#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT + #include "nuklear.h" struct window; diff --git a/source/engine/openglrender.c b/source/engine/openglrender.c index 8351fb1..3fcab53 100644 --- a/source/engine/openglrender.c +++ b/source/engine/openglrender.c @@ -1,16 +1,20 @@ #include "openglrender.h" -#include "sprite.h" -#include "shader.h" -#include "font.h" -#include "config.h" -#include "gameobject.h" #include "camera.h" -#include "window.h" -#include "debugdraw.h" -#include "log.h" +#include "config.h" #include "datastream.h" +#include "debugdraw.h" +#include "font.h" +#include "gameobject.h" +#include "log.h" #include "nuke.h" +#include "shader.h" +#include "sprite.h" +#include "window.h" +#include "model.h" +#include "stb_ds.h" + +#include "HandmadeMath.h" int renderMode = LIT; @@ -19,13 +23,13 @@ struct shader *wireframeShader = NULL; struct shader *animSpriteShader = NULL; static struct shader *textShader; -mfloat_t editorClearColor[4] = { 0.2f, 0.4f, 0.3f, 1.f }; +mfloat_t editorClearColor[4] = {0.2f, 0.4f, 0.3f, 1.f}; float shadowLookahead = 8.5f; -mfloat_t gridSmallColor[3] = { 0.35f, 1.f, 0.9f }; +mfloat_t gridSmallColor[3] = {0.35f, 1.f, 0.9f}; -mfloat_t gridBigColor[3] = { 0.92f, 0.92f, 0.68f }; +mfloat_t gridBigColor[3] = {0.92f, 0.92f, 0.68f}; float gridScale = 500.f; float smallGridUnit = 1.f; @@ -50,130 +54,263 @@ bool renderReflection = true; ///// for editing struct gameobject *selectedobject = NULL; -char objectName[200] = { '\0' }; // object name buffer +char objectName[200] = {'\0'}; // object name buffer struct sprite *tsprite = NULL; const char *donquixote; +static struct model *duck; + +sg_image ddimg; + void debug_draw_phys(int draw) { - debugDrawPhysics = draw; + debugDrawPhysics = draw; } -void opengl_rendermode(enum RenderMode r) -{ +void opengl_rendermode(enum RenderMode r) { renderMode = r; } sg_pipeline mainpip; sg_pass_action pass_action = {0}; -void openglInit() -{ - if (!mainwin) { - YughError("No window to init OpenGL on.", 1); - exit(1); +static struct { + sg_pass_action pass_action; + sg_pass pass; + sg_pipeline pipe; + sg_shader shader; +} sg_shadow; + +static struct { + sg_shader shader; + sg_pipeline pipe; + sg_bindings bind; + sg_pass pass; + sg_image img; + sg_image depth_img; +} crt_post; + + +void openglInit() { + if (!mainwin) { + YughError("No window to init OpenGL on.", 1); + exit(1); + } + + font_init(NULL); + debugdraw_init(); + sprite_initialize(); + nuke_init(mainwin); + + model_init(); +// duck = MakeModel("sponza.glb"); + + pass_action = (sg_pass_action){ + .colors[0] = {.action = SG_ACTION_CLEAR, .value = {editorClearColor[1], editorClearColor[2], editorClearColor[3], 1.f}}, + }; + + crt_post.shader = sg_make_shader(&(sg_shader_desc){ + .vs.source = slurp_text("shaders/postvert.glsl"), + .fs.source = slurp_text("shaders/crtfrag.glsl"), + + .fs.images[0] = { + .name = "diffuse_texture", + .image_type = SG_IMAGETYPE_2D, + .sampler_type = SG_SAMPLERTYPE_FLOAT } + }); -// donquixote = slurp_text("quixote.txt"); + crt_post.pipe = sg_make_pipeline(&(sg_pipeline_desc){ + .shader = crt_post.shader, + .layout = { + .attrs = { + [0].format = SG_VERTEXFORMAT_FLOAT2, + [1].format = SG_VERTEXFORMAT_FLOAT2 + } + } + }); - ////// MAKE SHADERS - spriteShader = MakeShader("spritevert.glsl", "spritefrag.glsl"); - wireframeShader = MakeShader("spritevert.glsl", "spritewireframefrag.glsl"); - animSpriteShader = MakeShader("animspritevert.glsl", "animspritefrag.glsl"); - textShader = MakeShader("textvert.glsl", "textfrag.glsl"); + crt_post.img = sg_make_image(&(sg_image_desc){ + .render_target = true, + .width = 1200, + .height = 720, + }); - font_init(textShader); - sprite_initialize(); - debugdraw_init(); + crt_post.depth_img = sg_make_image(&(sg_image_desc){ + .render_target = true, + .width = 1200, + .height = 720, + .pixel_format = SG_PIXELFORMAT_DEPTH_STENCIL + }); - glClearColor(editorClearColor[0], editorClearColor[1], editorClearColor[2], editorClearColor[3]); + crt_post.pass = sg_make_pass(&(sg_pass_desc){ + .color_attachments[0].image = crt_post.img, + .depth_stencil_attachment.image = crt_post.depth_img, + }); + + float crt_quad[] = { + -1, 1, 0, 1, + -1, -1, 0, 0, + 1, -1, 1, 0, + -1, 1, 0, 1, + 1, -1, 1, 0, + 1, 1, 1, 1 + }; + + crt_post.bind.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ + .size = sizeof(crt_quad), + .data = crt_quad + }); + + crt_post.bind.fs_images[0] = crt_post.img; /* - glCullFace(GL_BACK); + sg_image_desc shadow_desc = { + .render_target = true, + .width = 1024, + .height = 1024, + .pixel_format = SG_PIXELFORMAT_R32F, + }; + sg_image depth_img = sg_make_image(&shadow_desc); + shadow_desc.pixel_format = SG_PIXELFORMAT_DEPTH; + ddimg = sg_make_image(&shadow_desc); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + duck = MakeModel("sponza.glb"); + + sg_shadow.pass = sg_make_pass(&(sg_pass_desc){ + .color_attachments[0].image = depth_img, + .depth_stencil_attachment.image = ddimg, + }); + + sg_shadow.pass_action = (sg_pass_action) { + .colors[0] = { .action=SG_ACTION_CLEAR, .value = {1,1,1,1} } }; - glGenBuffers(1, &projUBO); - glBindBuffer(GL_UNIFORM_BUFFER, projUBO); - glBufferData(GL_UNIFORM_BUFFER, 64, NULL, GL_DYNAMIC_DRAW); - glBindBufferRange(GL_UNIFORM_BUFFER, 0, projUBO, 0, sizeof(float) * 16); - glBindBuffer(GL_UNIFORM_BUFFER, 0); + sg_shadow.shader = sg_make_shader(&(sg_shader_desc){ + .vs.source = slurp_text("shaders/shadowvert.glsl"), + .fs.source = slurp_text("shaders/shadowfrag.glsl"), + .vs.uniform_blocks[0] = { + .size = sizeof(float) * 16 * 2, + .uniforms = { + [0] = {.name = "lightSpaceMatrix", .type = SG_UNIFORMTYPE_MAT4}, + [1] = {.name = "model", .type = SG_UNIFORMTYPE_MAT4}, + } + } + }); - shader_setUBO(spriteShader, "Projection", 0); - shader_setUBO(textShader, "Projection", 0); - shader_setUBO(animSpriteShader, "Projection", 0); + sg_shadow.pipe = sg_make_pipeline(&(sg_pipeline_desc){ + .shader = sg_shadow.shader, + .layout = { + .attrs = { + [0].format = SG_VERTEXFORMAT_FLOAT3, + } + }, + .depth = { + .compare = SG_COMPAREFUNC_LESS_EQUAL, + .write_enabled = true, + .pixel_format = SG_PIXELFORMAT_DEPTH + }, + .colors[0].pixel_format = SG_PIXELFORMAT_R32F, + .index_type = SG_INDEXTYPE_UINT16, + .cull_mode = SG_CULLMODE_BACK, + }); + */ } - static cpBody *camera = NULL; void set_cam_body(cpBody *body) { - camera = body; + camera = body; } cpVect cam_pos() { - return camera ? cpBodyGetPosition(camera) : cpvzero; + return camera ? cpBodyGetPosition(camera) : cpvzero; } + static float zoom = 1.f; float cam_zoom() { return zoom; } - void add_zoom(float val) { zoom = val; } mfloat_t projection[16] = {0.f}; -void openglRender(struct window *window) -{ - sg_begin_default_pass(&pass_action, window->width, window->height); +HMM_Vec3 dirl_pos = {4, 100, 20}; - //////////// 2D projection - cpVect pos = cam_pos(); +void openglRender(struct window *window) { +/* + HMM_Mat4 model = HMM_M4D(1.f); + float scale = 0.08; + model = HMM_MulM4(model, HMM_Scale((HMM_Vec3){scale,scale,scale})); - mat4_ortho(projection, pos.x - zoom*window->width/2, - pos.x + zoom*window->width/2, - pos.y - zoom*window->height/2, - pos.y + zoom*window->height/2, -1.f, 1.f); - mfloat_t ui_projection[16] = { 0.f }; - mat4_ortho(ui_projection, 0, - window->width, - 0, - window->height, -1.f, 1.f); + // Shadow pass + sg_begin_pass(sg_shadow.pass, &sg_shadow.pass_action); + sg_apply_pipeline(sg_shadow.pipe); - sprite_draw_all(); - gui_draw_img("pill1.png", 200, 200); - float a[2] = {100,100}; - float w[3] = {1.f,1.f,1.f}; - renderText("TEST RENDER", a, 1.f, w, 0,-1); - - float b[2] = {50,50}; - renderText("TEST @@@@ RENDER", b, 1.f, w, 0,-1); + HMM_Mat4 light_proj = HMM_Orthographic_RH_ZO(-100.f, 100.f, -100.f, 100.f, 1.f, 100.f); + HMM_Mat4 light_view = HMM_LookAt_RH(dirl_pos, (HMM_Vec3){0,0,0}, (HMM_Vec3){0,1,0}); - /* UI Elements & Debug elements */ -// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -// glDisable(GL_DEPTH_TEST); - //// DEBUG -// if (debugDrawPhysics) -// gameobject_draw_debugs(); + HMM_Mat4 lsm = HMM_MulM4(light_proj, light_view); -// call_debugs(); + HMM_Mat4 subo[2]; + subo[0] = lsm; + subo[1] = model; - ////// TEXT && GUI -// glBindBuffer(GL_UNIFORM_BUFFER, projUBO); -// glBufferSubData(GL_UNIFORM_BUFFER, 0, 64, ui_projection); - text_flush(); + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(subo)); + + for (int i = 0; i < arrlen(duck->meshes); i++) { + sg_bindings sbind = {0}; + sbind.vertex_buffers[0] = duck->meshes[i].bind.vertex_buffers[0]; + sbind.index_buffer = duck->meshes[i].bind.index_buffer; + sg_apply_bindings(&sbind); + sg_draw(0,duck->meshes[i].face_count,1); + } + sg_end_pass(); -// call_gui(); + draw_model(duck,model, lsm); +*/ -// nuke_start(); -// call_nk_gui(); -// nuke_end(); +// sg_begin_default_pass(&pass_action, window->width, window->height); + sg_begin_pass(crt_post.pass, &pass_action); + //////////// 2D projection + cpVect pos = cam_pos(); + + mat4_ortho(projection, pos.x - zoom * window->width / 2, + pos.x + zoom * window->width / 2, + pos.y - zoom * window->height / 2, + pos.y + zoom * window->height / 2, -1.f, 1.f); + + mfloat_t ui_projection[16] = {0.f}; + mat4_ortho(ui_projection, 0, window->width, 0, window->height, -1.f, 1.f); + + sprite_draw_all(); + sprite_flush(); + + //// DEBUG + if (debugDrawPhysics) + gameobject_draw_debugs(); + + call_debugs(); + debug_flush(); + + ////// TEXT && GUI + call_gui(); + + text_flush(); + + nuke_start(); + call_nk_gui(); + nuke_end(); sg_end_pass(); - sg_commit(); + + sg_begin_default_pass(&pass_action, window->width, window->height); + sg_apply_pipeline(crt_post.pipe); + sg_apply_bindings(&crt_post.bind); + sg_draw(0,6,1); + sg_end_pass(); + - sprite_flush(); + sg_commit(); } diff --git a/source/engine/openglrender.h b/source/engine/openglrender.h index ff74faf..fdabb24 100644 --- a/source/engine/openglrender.h +++ b/source/engine/openglrender.h @@ -1,16 +1,23 @@ #ifndef OPENGL_RENDER_H #define OPENGL_RENDER_H +#include "sokol/sokol_gfx.h" +#include "HandmadeMath.h" + struct mCamera; struct window; extern struct shader *spriteShader; extern struct shader *animSpriteShader; +extern sg_image ddimg; + extern struct sprite *tsprite; extern int renderMode; +extern HMM_Vec3 dirl_pos; + extern float projection[16]; extern float gridScale; diff --git a/source/engine/parson.c b/source/engine/parson.c index 6f7e94f..a2ef266 100644 --- a/source/engine/parson.c +++ b/source/engine/parson.c @@ -34,18 +34,16 @@ #define PARSON_IMPL_VERSION_MINOR 4 #define PARSON_IMPL_VERSION_PATCH 0 -#if (PARSON_VERSION_MAJOR != PARSON_IMPL_VERSION_MAJOR)\ -|| (PARSON_VERSION_MINOR != PARSON_IMPL_VERSION_MINOR)\ -|| (PARSON_VERSION_PATCH != PARSON_IMPL_VERSION_PATCH) +#if (PARSON_VERSION_MAJOR != PARSON_IMPL_VERSION_MAJOR) || (PARSON_VERSION_MINOR != PARSON_IMPL_VERSION_MINOR) || (PARSON_VERSION_PATCH != PARSON_IMPL_VERSION_PATCH) #error "parson version mismatch between parson.c and parson.h" #endif +#include +#include +#include #include #include #include -#include -#include -#include /* Apparently sscanf is not implemented in some "standard" libraries, so don't use it, if you * don't have to. */ @@ -61,7 +59,7 @@ #define strcpy USE_MEMCPY_INSTEAD_OF_STRCPY #define STARTING_CAPACITY 16 -#define MAX_NESTING 2048 +#define MAX_NESTING 2048 #ifndef PARSON_DEFAULT_FLOAT_FORMAT #define PARSON_DEFAULT_FLOAT_FORMAT "%1.17g" /* do not increase precision without incresing NUM_BUF_SIZE */ @@ -71,10 +69,13 @@ #define PARSON_NUM_BUF_SIZE 64 /* double printed with "%1.17g" shouldn't be longer than 25 bytes so let's be paranoid and use 64 */ #endif -#define SIZEOF_TOKEN(a) (sizeof(a) - 1) -#define SKIP_CHAR(str) ((*str)++) -#define SKIP_WHITESPACES(str) while (isspace((unsigned char)(**str))) { SKIP_CHAR(str); } -#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define SIZEOF_TOKEN(a) (sizeof(a) - 1) +#define SKIP_CHAR(str) ((*str)++) +#define SKIP_WHITESPACES(str) \ + while (isspace((unsigned char)(**str))) { \ + SKIP_CHAR(str); \ + } +#define MAX(a, b) ((a) > (b) ? (a) : (b)) #undef malloc #undef free @@ -82,7 +83,7 @@ #if defined(isnan) && defined(isinf) #define IS_NUMBER_INVALID(x) (isnan((x)) || isinf((x))) #else -#define IS_NUMBER_INVALID(x) (((x) * 0.0) != 0.0) +#define IS_NUMBER_INVALID(x) (((x)*0.0) != 0.0) #endif #define OBJECT_INVALID_IX ((size_t)-1) @@ -94,7 +95,7 @@ static int parson_escape_slashes = 1; static char *parson_float_format = NULL; -#define IS_CONT(b) (((unsigned char)(b) & 0xC0) == 0x80) /* is utf-8 continuation byte */ +#define IS_CONT(b) (((unsigned char)(b)&0xC0) == 0x80) /* is utf-8 continuation byte */ typedef int parson_bool_t; @@ -102,92 +103,92 @@ typedef int parson_bool_t; #define PARSON_FALSE 0 typedef struct json_string { - char *chars; - size_t length; + char *chars; + size_t length; } JSON_String; /* Type definitions */ typedef union json_value_value { - JSON_String string; - double number; - JSON_Object *object; - JSON_Array *array; - int boolean; - int null; + JSON_String string; + double number; + JSON_Object *object; + JSON_Array *array; + int boolean; + int null; } JSON_Value_Value; struct json_value_t { - JSON_Value *parent; - JSON_Value_Type type; - JSON_Value_Value value; + JSON_Value *parent; + JSON_Value_Type type; + JSON_Value_Value value; }; struct json_object_t { - JSON_Value *wrapping_value; - size_t *cells; - unsigned long *hashes; - char **names; - JSON_Value **values; - size_t *cell_ixs; - size_t count; - size_t item_capacity; - size_t cell_capacity; + JSON_Value *wrapping_value; + size_t *cells; + unsigned long *hashes; + char **names; + JSON_Value **values; + size_t *cell_ixs; + size_t count; + size_t item_capacity; + size_t cell_capacity; }; struct json_array_t { - JSON_Value *wrapping_value; - JSON_Value **items; - size_t count; - size_t capacity; + JSON_Value *wrapping_value; + JSON_Value **items; + size_t count; + size_t capacity; }; /* Various */ -static char * read_file(const char *filename); -static void remove_comments(char *string, const char *start_token, const char *end_token); -static char * parson_strndup(const char *string, size_t n); -static char * parson_strdup(const char *string); -static int hex_char_to_int(char c); +static char *read_file(const char *filename); +static void remove_comments(char *string, const char *start_token, const char *end_token); +static char *parson_strndup(const char *string, size_t n); +static char *parson_strdup(const char *string); +static int hex_char_to_int(char c); static JSON_Status parse_utf16_hex(const char *string, unsigned int *result); -static int num_bytes_in_utf8_sequence(unsigned char c); -static JSON_Status verify_utf8_sequence(const unsigned char *string, int *len); +static int num_bytes_in_utf8_sequence(unsigned char c); +static JSON_Status verify_utf8_sequence(const unsigned char *string, int *len); static parson_bool_t is_valid_utf8(const char *string, size_t string_len); static parson_bool_t is_decimal(const char *string, size_t length); static unsigned long hash_string(const char *string, size_t n); /* JSON Object */ -static JSON_Object * json_object_make(JSON_Value *wrapping_value); -static JSON_Status json_object_init(JSON_Object *object, size_t capacity); -static void json_object_deinit(JSON_Object *object, parson_bool_t free_keys, parson_bool_t free_values); -static JSON_Status json_object_grow_and_rehash(JSON_Object *object); -static size_t json_object_get_cell_ix(const JSON_Object *object, const char *key, size_t key_len, unsigned long hash, parson_bool_t *out_found); -static JSON_Status json_object_add(JSON_Object *object, char *name, JSON_Value *value); -static JSON_Value * json_object_getn_value(const JSON_Object *object, const char *name, size_t name_len); -static JSON_Status json_object_remove_internal(JSON_Object *object, const char *name, parson_bool_t free_value); -static JSON_Status json_object_dotremove_internal(JSON_Object *object, const char *name, parson_bool_t free_value); -static void json_object_free(JSON_Object *object); +static JSON_Object *json_object_make(JSON_Value *wrapping_value); +static JSON_Status json_object_init(JSON_Object *object, size_t capacity); +static void json_object_deinit(JSON_Object *object, parson_bool_t free_keys, parson_bool_t free_values); +static JSON_Status json_object_grow_and_rehash(JSON_Object *object); +static size_t json_object_get_cell_ix(const JSON_Object *object, const char *key, size_t key_len, unsigned long hash, parson_bool_t *out_found); +static JSON_Status json_object_add(JSON_Object *object, char *name, JSON_Value *value); +static JSON_Value *json_object_getn_value(const JSON_Object *object, const char *name, size_t name_len); +static JSON_Status json_object_remove_internal(JSON_Object *object, const char *name, parson_bool_t free_value); +static JSON_Status json_object_dotremove_internal(JSON_Object *object, const char *name, parson_bool_t free_value); +static void json_object_free(JSON_Object *object); /* JSON Array */ -static JSON_Array * json_array_make(JSON_Value *wrapping_value); -static JSON_Status json_array_add(JSON_Array *array, JSON_Value *value); -static JSON_Status json_array_resize(JSON_Array *array, size_t new_capacity); -static void json_array_free(JSON_Array *array); +static JSON_Array *json_array_make(JSON_Value *wrapping_value); +static JSON_Status json_array_add(JSON_Array *array, JSON_Value *value); +static JSON_Status json_array_resize(JSON_Array *array, size_t new_capacity); +static void json_array_free(JSON_Array *array); /* JSON Value */ -static JSON_Value * json_value_init_string_no_copy(char *string, size_t length); -static const JSON_String * json_value_get_string_desc(const JSON_Value *value); +static JSON_Value *json_value_init_string_no_copy(char *string, size_t length); +static const JSON_String *json_value_get_string_desc(const JSON_Value *value); /* Parser */ -static JSON_Status skip_quotes(const char **string); -static JSON_Status parse_utf16(const char **unprocessed, char **processed); -static char * process_string(const char *input, size_t input_len, size_t *output_len); -static char * get_quoted_string(const char **string, size_t *output_string_len); -static JSON_Value * parse_object_value(const char **string, size_t nesting); -static JSON_Value * parse_array_value(const char **string, size_t nesting); -static JSON_Value * parse_string_value(const char **string); -static JSON_Value * parse_boolean_value(const char **string); -static JSON_Value * parse_number_value(const char **string); -static JSON_Value * parse_null_value(const char **string); -static JSON_Value * parse_value(const char **string, size_t nesting); +static JSON_Status skip_quotes(const char **string); +static JSON_Status parse_utf16(const char **unprocessed, char **processed); +static char *process_string(const char *input, size_t input_len, size_t *output_len); +static char *get_quoted_string(const char **string, size_t *output_string_len); +static JSON_Value *parse_object_value(const char **string, size_t nesting); +static JSON_Value *parse_array_value(const char **string, size_t nesting); +static JSON_Value *parse_string_value(const char **string); +static JSON_Value *parse_boolean_value(const char **string); +static JSON_Value *parse_number_value(const char **string); +static JSON_Value *parse_null_value(const char **string); +static JSON_Value *parse_value(const char **string, size_t nesting); /* Serialization */ static int json_serialize_to_buffer_r(const JSON_Value *value, char *buf, int level, parson_bool_t is_pretty, char *num_buf); @@ -196,2257 +197,2361 @@ static int append_indent(char *buf, int level); static int append_string(char *buf, const char *string); /* Various */ -static char * read_file(const char * filename) { - FILE *fp = fopen(filename, "r"); - size_t size_to_read = 0; - size_t size_read = 0; - long pos; - char *file_contents; - if (!fp) { - return NULL; - } - fseek(fp, 0L, SEEK_END); - pos = ftell(fp); - if (pos < 0) { - fclose(fp); - return NULL; - } - size_to_read = pos; - rewind(fp); - file_contents = (char*)parson_malloc(sizeof(char) * (size_to_read + 1)); - if (!file_contents) { - fclose(fp); - return NULL; - } - size_read = fread(file_contents, 1, size_to_read, fp); - if (size_read == 0 || ferror(fp)) { - fclose(fp); - parson_free(file_contents); - return NULL; - } +static char *read_file(const char *filename) { + FILE *fp = fopen(filename, "r"); + size_t size_to_read = 0; + size_t size_read = 0; + long pos; + char *file_contents; + if (!fp) { + return NULL; + } + fseek(fp, 0L, SEEK_END); + pos = ftell(fp); + if (pos < 0) { fclose(fp); - file_contents[size_read] = '\0'; - return file_contents; + return NULL; + } + size_to_read = pos; + rewind(fp); + file_contents = (char *)parson_malloc(sizeof(char) * (size_to_read + 1)); + if (!file_contents) { + fclose(fp); + return NULL; + } + size_read = fread(file_contents, 1, size_to_read, fp); + if (size_read == 0 || ferror(fp)) { + fclose(fp); + parson_free(file_contents); + return NULL; + } + fclose(fp); + file_contents[size_read] = '\0'; + return file_contents; } static void remove_comments(char *string, const char *start_token, const char *end_token) { - parson_bool_t in_string = PARSON_FALSE, escaped = PARSON_FALSE; - size_t i; - char *ptr = NULL, current_char; - size_t start_token_len = strlen(start_token); - size_t end_token_len = strlen(end_token); - if (start_token_len == 0 || end_token_len == 0) { + parson_bool_t in_string = PARSON_FALSE, escaped = PARSON_FALSE; + size_t i; + char *ptr = NULL, current_char; + size_t start_token_len = strlen(start_token); + size_t end_token_len = strlen(end_token); + if (start_token_len == 0 || end_token_len == 0) { + return; + } + while ((current_char = *string) != '\0') { + if (current_char == '\\' && !escaped) { + escaped = PARSON_TRUE; + string++; + continue; + } else if (current_char == '\"' && !escaped) { + in_string = !in_string; + } else if (!in_string && strncmp(string, start_token, start_token_len) == 0) { + for (i = 0; i < start_token_len; i++) { + string[i] = ' '; + } + string = string + start_token_len; + ptr = strstr(string, end_token); + if (!ptr) { return; + } + for (i = 0; i < (ptr - string) + end_token_len; i++) { + string[i] = ' '; + } + string = ptr + end_token_len - 1; } - while ((current_char = *string) != '\0') { - if (current_char == '\\' && !escaped) { - escaped = PARSON_TRUE; - string++; - continue; - } else if (current_char == '\"' && !escaped) { - in_string = !in_string; - } else if (!in_string && strncmp(string, start_token, start_token_len) == 0) { - for(i = 0; i < start_token_len; i++) { - string[i] = ' '; - } - string = string + start_token_len; - ptr = strstr(string, end_token); - if (!ptr) { - return; - } - for (i = 0; i < (ptr - string) + end_token_len; i++) { - string[i] = ' '; - } - string = ptr + end_token_len - 1; - } - escaped = PARSON_FALSE; - string++; - } + escaped = PARSON_FALSE; + string++; + } } -static char * parson_strndup(const char *string, size_t n) { - /* We expect the caller has validated that 'n' fits within the input buffer. */ - char *output_string = (char*)parson_malloc(n + 1); - if (!output_string) { - return NULL; - } - output_string[n] = '\0'; - memcpy(output_string, string, n); - return output_string; +static char *parson_strndup(const char *string, size_t n) { + /* We expect the caller has validated that 'n' fits within the input buffer. */ + char *output_string = (char *)parson_malloc(n + 1); + if (!output_string) { + return NULL; + } + output_string[n] = '\0'; + memcpy(output_string, string, n); + return output_string; } -static char * parson_strdup(const char *string) { - return parson_strndup(string, strlen(string)); +static char *parson_strdup(const char *string) { + return parson_strndup(string, strlen(string)); } static int hex_char_to_int(char c) { - if (c >= '0' && c <= '9') { - return c - '0'; - } else if (c >= 'a' && c <= 'f') { - return c - 'a' + 10; - } else if (c >= 'A' && c <= 'F') { - return c - 'A' + 10; - } - return -1; + if (c >= '0' && c <= '9') { + return c - '0'; + } else if (c >= 'a' && c <= 'f') { + return c - 'a' + 10; + } else if (c >= 'A' && c <= 'F') { + return c - 'A' + 10; + } + return -1; } static JSON_Status parse_utf16_hex(const char *s, unsigned int *result) { - int x1, x2, x3, x4; - if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0' || s[3] == '\0') { - return JSONFailure; - } - x1 = hex_char_to_int(s[0]); - x2 = hex_char_to_int(s[1]); - x3 = hex_char_to_int(s[2]); - x4 = hex_char_to_int(s[3]); - if (x1 == -1 || x2 == -1 || x3 == -1 || x4 == -1) { - return JSONFailure; - } - *result = (unsigned int)((x1 << 12) | (x2 << 8) | (x3 << 4) | x4); - return JSONSuccess; + int x1, x2, x3, x4; + if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0' || s[3] == '\0') { + return JSONFailure; + } + x1 = hex_char_to_int(s[0]); + x2 = hex_char_to_int(s[1]); + x3 = hex_char_to_int(s[2]); + x4 = hex_char_to_int(s[3]); + if (x1 == -1 || x2 == -1 || x3 == -1 || x4 == -1) { + return JSONFailure; + } + *result = (unsigned int)((x1 << 12) | (x2 << 8) | (x3 << 4) | x4); + return JSONSuccess; } static int num_bytes_in_utf8_sequence(unsigned char c) { - if (c == 0xC0 || c == 0xC1 || c > 0xF4 || IS_CONT(c)) { - return 0; - } else if ((c & 0x80) == 0) { /* 0xxxxxxx */ - return 1; - } else if ((c & 0xE0) == 0xC0) { /* 110xxxxx */ - return 2; - } else if ((c & 0xF0) == 0xE0) { /* 1110xxxx */ - return 3; - } else if ((c & 0xF8) == 0xF0) { /* 11110xxx */ - return 4; - } - return 0; /* won't happen */ + if (c == 0xC0 || c == 0xC1 || c > 0xF4 || IS_CONT(c)) { + return 0; + } else if ((c & 0x80) == 0) { /* 0xxxxxxx */ + return 1; + } else if ((c & 0xE0) == 0xC0) { /* 110xxxxx */ + return 2; + } else if ((c & 0xF0) == 0xE0) { /* 1110xxxx */ + return 3; + } else if ((c & 0xF8) == 0xF0) { /* 11110xxx */ + return 4; + } + return 0; /* won't happen */ } static JSON_Status verify_utf8_sequence(const unsigned char *string, int *len) { - unsigned int cp = 0; - *len = num_bytes_in_utf8_sequence(string[0]); + unsigned int cp = 0; + *len = num_bytes_in_utf8_sequence(string[0]); - if (*len == 1) { - cp = string[0]; - } else if (*len == 2 && IS_CONT(string[1])) { - cp = string[0] & 0x1F; - cp = (cp << 6) | (string[1] & 0x3F); - } else if (*len == 3 && IS_CONT(string[1]) && IS_CONT(string[2])) { - cp = ((unsigned char)string[0]) & 0xF; - cp = (cp << 6) | (string[1] & 0x3F); - cp = (cp << 6) | (string[2] & 0x3F); - } else if (*len == 4 && IS_CONT(string[1]) && IS_CONT(string[2]) && IS_CONT(string[3])) { - cp = string[0] & 0x7; - cp = (cp << 6) | (string[1] & 0x3F); - cp = (cp << 6) | (string[2] & 0x3F); - cp = (cp << 6) | (string[3] & 0x3F); - } else { - return JSONFailure; - } + if (*len == 1) { + cp = string[0]; + } else if (*len == 2 && IS_CONT(string[1])) { + cp = string[0] & 0x1F; + cp = (cp << 6) | (string[1] & 0x3F); + } else if (*len == 3 && IS_CONT(string[1]) && IS_CONT(string[2])) { + cp = ((unsigned char)string[0]) & 0xF; + cp = (cp << 6) | (string[1] & 0x3F); + cp = (cp << 6) | (string[2] & 0x3F); + } else if (*len == 4 && IS_CONT(string[1]) && IS_CONT(string[2]) && IS_CONT(string[3])) { + cp = string[0] & 0x7; + cp = (cp << 6) | (string[1] & 0x3F); + cp = (cp << 6) | (string[2] & 0x3F); + cp = (cp << 6) | (string[3] & 0x3F); + } else { + return JSONFailure; + } - /* overlong encodings */ - if ((cp < 0x80 && *len > 1) || - (cp < 0x800 && *len > 2) || - (cp < 0x10000 && *len > 3)) { - return JSONFailure; - } + /* overlong encodings */ + if ((cp < 0x80 && *len > 1) || + (cp < 0x800 && *len > 2) || + (cp < 0x10000 && *len > 3)) { + return JSONFailure; + } - /* invalid unicode */ - if (cp > 0x10FFFF) { - return JSONFailure; - } + /* invalid unicode */ + if (cp > 0x10FFFF) { + return JSONFailure; + } - /* surrogate halves */ - if (cp >= 0xD800 && cp <= 0xDFFF) { - return JSONFailure; - } + /* surrogate halves */ + if (cp >= 0xD800 && cp <= 0xDFFF) { + return JSONFailure; + } - return JSONSuccess; + return JSONSuccess; } static int is_valid_utf8(const char *string, size_t string_len) { - int len = 0; - const char *string_end = string + string_len; - while (string < string_end) { - if (verify_utf8_sequence((const unsigned char*)string, &len) != JSONSuccess) { - return PARSON_FALSE; - } - string += len; + int len = 0; + const char *string_end = string + string_len; + while (string < string_end) { + if (verify_utf8_sequence((const unsigned char *)string, &len) != JSONSuccess) { + return PARSON_FALSE; } - return PARSON_TRUE; + string += len; + } + return PARSON_TRUE; } static parson_bool_t is_decimal(const char *string, size_t length) { - if (length > 1 && string[0] == '0' && string[1] != '.') { - return PARSON_FALSE; + if (length > 1 && string[0] == '0' && string[1] != '.') { + return PARSON_FALSE; + } + if (length > 2 && !strncmp(string, "-0", 2) && string[2] != '.') { + return PARSON_FALSE; + } + while (length--) { + if (strchr("xX", string[length])) { + return PARSON_FALSE; } - if (length > 2 && !strncmp(string, "-0", 2) && string[2] != '.') { - return PARSON_FALSE; - } - while (length--) { - if (strchr("xX", string[length])) { - return PARSON_FALSE; - } - } - return PARSON_TRUE; + } + return PARSON_TRUE; } static unsigned long hash_string(const char *string, size_t n) { #ifdef PARSON_FORCE_HASH_COLLISIONS - (void)string; - (void)n; - return 0; + (void)string; + (void)n; + return 0; #else - unsigned long hash = 5381; - unsigned char c; - size_t i = 0; - for (i = 0; i < n; i++) { - c = string[i]; - if (c == '\0') { - break; - } - hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + unsigned long hash = 5381; + unsigned char c; + size_t i = 0; + for (i = 0; i < n; i++) { + c = string[i]; + if (c == '\0') { + break; } - return hash; + hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + } + return hash; #endif } /* JSON Object */ -static JSON_Object * json_object_make(JSON_Value *wrapping_value) { - JSON_Status res = JSONFailure; - JSON_Object *new_obj = (JSON_Object*)parson_malloc(sizeof(JSON_Object)); - if (new_obj == NULL) { - return NULL; - } - new_obj->wrapping_value = wrapping_value; - res = json_object_init(new_obj, 0); - if (res != JSONSuccess) { - parson_free(new_obj); - return NULL; - } - return new_obj; +static JSON_Object *json_object_make(JSON_Value *wrapping_value) { + JSON_Status res = JSONFailure; + JSON_Object *new_obj = (JSON_Object *)parson_malloc(sizeof(JSON_Object)); + if (new_obj == NULL) { + return NULL; + } + new_obj->wrapping_value = wrapping_value; + res = json_object_init(new_obj, 0); + if (res != JSONSuccess) { + parson_free(new_obj); + return NULL; + } + return new_obj; } static JSON_Status json_object_init(JSON_Object *object, size_t capacity) { - unsigned int i = 0; + unsigned int i = 0; - object->cells = NULL; - object->names = NULL; - object->values = NULL; - object->cell_ixs = NULL; - object->hashes = NULL; + object->cells = NULL; + object->names = NULL; + object->values = NULL; + object->cell_ixs = NULL; + object->hashes = NULL; - object->count = 0; - object->cell_capacity = capacity; - object->item_capacity = (unsigned int)(capacity * 0.7f); + object->count = 0; + object->cell_capacity = capacity; + object->item_capacity = (unsigned int)(capacity * 0.7f); - if (capacity == 0) { - return JSONSuccess; - } - - object->cells = (size_t*)parson_malloc(object->cell_capacity * sizeof(*object->cells)); - object->names = (char**)parson_malloc(object->item_capacity * sizeof(*object->names)); - object->values = (JSON_Value**)parson_malloc(object->item_capacity * sizeof(*object->values)); - object->cell_ixs = (size_t*)parson_malloc(object->item_capacity * sizeof(*object->cell_ixs)); - object->hashes = (unsigned long*)parson_malloc(object->item_capacity * sizeof(*object->hashes)); - if (object->cells == NULL - || object->names == NULL - || object->values == NULL - || object->cell_ixs == NULL - || object->hashes == NULL) { - goto error; - } - for (i = 0; i < object->cell_capacity; i++) { - object->cells[i] = OBJECT_INVALID_IX; - } + if (capacity == 0) { return JSONSuccess; + } + + object->cells = (size_t *)parson_malloc(object->cell_capacity * sizeof(*object->cells)); + object->names = (char **)parson_malloc(object->item_capacity * sizeof(*object->names)); + object->values = (JSON_Value **)parson_malloc(object->item_capacity * sizeof(*object->values)); + object->cell_ixs = (size_t *)parson_malloc(object->item_capacity * sizeof(*object->cell_ixs)); + object->hashes = (unsigned long *)parson_malloc(object->item_capacity * sizeof(*object->hashes)); + if (object->cells == NULL || object->names == NULL || object->values == NULL || object->cell_ixs == NULL || object->hashes == NULL) { + goto error; + } + for (i = 0; i < object->cell_capacity; i++) { + object->cells[i] = OBJECT_INVALID_IX; + } + return JSONSuccess; error: - parson_free(object->cells); - parson_free(object->names); - parson_free(object->values); - parson_free(object->cell_ixs); - parson_free(object->hashes); - return JSONFailure; + parson_free(object->cells); + parson_free(object->names); + parson_free(object->values); + parson_free(object->cell_ixs); + parson_free(object->hashes); + return JSONFailure; } static void json_object_deinit(JSON_Object *object, parson_bool_t free_keys, parson_bool_t free_values) { - unsigned int i = 0; - for (i = 0; i < object->count; i++) { - if (free_keys) { - parson_free(object->names[i]); - } - if (free_values) { - json_value_free(object->values[i]); - } + unsigned int i = 0; + for (i = 0; i < object->count; i++) { + if (free_keys) { + parson_free(object->names[i]); } + if (free_values) { + json_value_free(object->values[i]); + } + } - object->count = 0; - object->item_capacity = 0; - object->cell_capacity = 0; + object->count = 0; + object->item_capacity = 0; + object->cell_capacity = 0; - parson_free(object->cells); - parson_free(object->names); - parson_free(object->values); - parson_free(object->cell_ixs); - parson_free(object->hashes); + parson_free(object->cells); + parson_free(object->names); + parson_free(object->values); + parson_free(object->cell_ixs); + parson_free(object->hashes); - object->cells = NULL; - object->names = NULL; - object->values = NULL; - object->cell_ixs = NULL; - object->hashes = NULL; + object->cells = NULL; + object->names = NULL; + object->values = NULL; + object->cell_ixs = NULL; + object->hashes = NULL; } static JSON_Status json_object_grow_and_rehash(JSON_Object *object) { - JSON_Value *wrapping_value = NULL; - JSON_Object new_object; - char *key = NULL; - JSON_Value *value = NULL; - unsigned int i = 0; - size_t new_capacity = MAX(object->cell_capacity * 2, STARTING_CAPACITY); - JSON_Status res = json_object_init(&new_object, new_capacity); + JSON_Value *wrapping_value = NULL; + JSON_Object new_object; + char *key = NULL; + JSON_Value *value = NULL; + unsigned int i = 0; + size_t new_capacity = MAX(object->cell_capacity * 2, STARTING_CAPACITY); + JSON_Status res = json_object_init(&new_object, new_capacity); + if (res != JSONSuccess) { + return JSONFailure; + } + + wrapping_value = json_object_get_wrapping_value(object); + new_object.wrapping_value = wrapping_value; + + for (i = 0; i < object->count; i++) { + key = object->names[i]; + value = object->values[i]; + res = json_object_add(&new_object, key, value); if (res != JSONSuccess) { - return JSONFailure; + json_object_deinit(&new_object, PARSON_FALSE, PARSON_FALSE); + return JSONFailure; } - - wrapping_value = json_object_get_wrapping_value(object); - new_object.wrapping_value = wrapping_value; - - for (i = 0; i < object->count; i++) { - key = object->names[i]; - value = object->values[i]; - res = json_object_add(&new_object, key, value); - if (res != JSONSuccess) { - json_object_deinit(&new_object, PARSON_FALSE, PARSON_FALSE); - return JSONFailure; - } - value->parent = wrapping_value; - } - json_object_deinit(object, PARSON_FALSE, PARSON_FALSE); - *object = new_object; - return JSONSuccess; + value->parent = wrapping_value; + } + json_object_deinit(object, PARSON_FALSE, PARSON_FALSE); + *object = new_object; + return JSONSuccess; } static size_t json_object_get_cell_ix(const JSON_Object *object, const char *key, size_t key_len, unsigned long hash, parson_bool_t *out_found) { - size_t cell_ix = hash & (object->cell_capacity - 1); - size_t cell = 0; - size_t ix = 0; - unsigned int i = 0; - unsigned long hash_to_check = 0; - const char *key_to_check = NULL; - size_t key_to_check_len = 0; + size_t cell_ix = hash & (object->cell_capacity - 1); + size_t cell = 0; + size_t ix = 0; + unsigned int i = 0; + unsigned long hash_to_check = 0; + const char *key_to_check = NULL; + size_t key_to_check_len = 0; - *out_found = PARSON_FALSE; + *out_found = PARSON_FALSE; - for (i = 0; i < object->cell_capacity; i++) { - ix = (cell_ix + i) & (object->cell_capacity - 1); - cell = object->cells[ix]; - if (cell == OBJECT_INVALID_IX) { - return ix; - } - hash_to_check = object->hashes[cell]; - if (hash != hash_to_check) { - continue; - } - key_to_check = object->names[cell]; - key_to_check_len = strlen(key_to_check); - if (key_to_check_len == key_len && strncmp(key, key_to_check, key_len) == 0) { - *out_found = PARSON_TRUE; - return ix; - } + for (i = 0; i < object->cell_capacity; i++) { + ix = (cell_ix + i) & (object->cell_capacity - 1); + cell = object->cells[ix]; + if (cell == OBJECT_INVALID_IX) { + return ix; } - return OBJECT_INVALID_IX; + hash_to_check = object->hashes[cell]; + if (hash != hash_to_check) { + continue; + } + key_to_check = object->names[cell]; + key_to_check_len = strlen(key_to_check); + if (key_to_check_len == key_len && strncmp(key, key_to_check, key_len) == 0) { + *out_found = PARSON_TRUE; + return ix; + } + } + return OBJECT_INVALID_IX; } static JSON_Status json_object_add(JSON_Object *object, char *name, JSON_Value *value) { - unsigned long hash = 0; - parson_bool_t found = PARSON_FALSE; - size_t cell_ix = 0; - JSON_Status res = JSONFailure; + unsigned long hash = 0; + parson_bool_t found = PARSON_FALSE; + size_t cell_ix = 0; + JSON_Status res = JSONFailure; - if (!object || !name || !value) { - return JSONFailure; + if (!object || !name || !value) { + return JSONFailure; + } + + hash = hash_string(name, strlen(name)); + found = PARSON_FALSE; + cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found); + if (found) { + return JSONFailure; + } + + if (object->count >= object->item_capacity) { + res = json_object_grow_and_rehash(object); + if (res != JSONSuccess) { + return JSONFailure; } - - hash = hash_string(name, strlen(name)); - found = PARSON_FALSE; cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found); - if (found) { - return JSONFailure; - } + } - if (object->count >= object->item_capacity) { - res = json_object_grow_and_rehash(object); - if (res != JSONSuccess) { - return JSONFailure; - } - cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found); - } + object->names[object->count] = name; + object->cells[cell_ix] = object->count; + object->values[object->count] = value; + object->cell_ixs[object->count] = cell_ix; + object->hashes[object->count] = hash; + object->count++; + value->parent = json_object_get_wrapping_value(object); - object->names[object->count] = name; - object->cells[cell_ix] = object->count; - object->values[object->count] = value; - object->cell_ixs[object->count] = cell_ix; - object->hashes[object->count] = hash; - object->count++; - value->parent = json_object_get_wrapping_value(object); - - return JSONSuccess; + return JSONSuccess; } -static JSON_Value * json_object_getn_value(const JSON_Object *object, const char *name, size_t name_len) { - unsigned long hash = 0; - parson_bool_t found = PARSON_FALSE; - size_t cell_ix = 0; - size_t item_ix = 0; - if (!object || !name) { - return NULL; - } - hash = hash_string(name, name_len); - found = PARSON_FALSE; - cell_ix = json_object_get_cell_ix(object, name, name_len, hash, &found); - if (!found) { - return NULL; - } - item_ix = object->cells[cell_ix]; - return object->values[item_ix]; +static JSON_Value *json_object_getn_value(const JSON_Object *object, const char *name, size_t name_len) { + unsigned long hash = 0; + parson_bool_t found = PARSON_FALSE; + size_t cell_ix = 0; + size_t item_ix = 0; + if (!object || !name) { + return NULL; + } + hash = hash_string(name, name_len); + found = PARSON_FALSE; + cell_ix = json_object_get_cell_ix(object, name, name_len, hash, &found); + if (!found) { + return NULL; + } + item_ix = object->cells[cell_ix]; + return object->values[item_ix]; } static JSON_Status json_object_remove_internal(JSON_Object *object, const char *name, parson_bool_t free_value) { - unsigned long hash = 0; - parson_bool_t found = PARSON_FALSE; - size_t cell = 0; - size_t item_ix = 0; - size_t last_item_ix = 0; - size_t i = 0; - size_t j = 0; - size_t x = 0; - size_t k = 0; - JSON_Value *val = NULL; + unsigned long hash = 0; + parson_bool_t found = PARSON_FALSE; + size_t cell = 0; + size_t item_ix = 0; + size_t last_item_ix = 0; + size_t i = 0; + size_t j = 0; + size_t x = 0; + size_t k = 0; + JSON_Value *val = NULL; - if (object == NULL) { - return JSONFailure; - } + if (object == NULL) { + return JSONFailure; + } - hash = hash_string(name, strlen(name)); - found = PARSON_FALSE; - cell = json_object_get_cell_ix(object, name, strlen(name), hash, &found); - if (!found) { - return JSONFailure; - } + hash = hash_string(name, strlen(name)); + found = PARSON_FALSE; + cell = json_object_get_cell_ix(object, name, strlen(name), hash, &found); + if (!found) { + return JSONFailure; + } - item_ix = object->cells[cell]; - if (free_value) { - val = object->values[item_ix]; - json_value_free(val); - val = NULL; - } + item_ix = object->cells[cell]; + if (free_value) { + val = object->values[item_ix]; + json_value_free(val); + val = NULL; + } - parson_free(object->names[item_ix]); - last_item_ix = object->count - 1; - if (item_ix < last_item_ix) { - object->names[item_ix] = object->names[last_item_ix]; - object->values[item_ix] = object->values[last_item_ix]; - object->cell_ixs[item_ix] = object->cell_ixs[last_item_ix]; - object->hashes[item_ix] = object->hashes[last_item_ix]; - object->cells[object->cell_ixs[item_ix]] = item_ix; - } - object->count--; + parson_free(object->names[item_ix]); + last_item_ix = object->count - 1; + if (item_ix < last_item_ix) { + object->names[item_ix] = object->names[last_item_ix]; + object->values[item_ix] = object->values[last_item_ix]; + object->cell_ixs[item_ix] = object->cell_ixs[last_item_ix]; + object->hashes[item_ix] = object->hashes[last_item_ix]; + object->cells[object->cell_ixs[item_ix]] = item_ix; + } + object->count--; - i = cell; - j = i; - for (x = 0; x < (object->cell_capacity - 1); x++) { - j = (j + 1) & (object->cell_capacity - 1); - if (object->cells[j] == OBJECT_INVALID_IX) { - break; - } - k = object->hashes[object->cells[j]] & (object->cell_capacity - 1); - if ((j > i && (k <= i || k > j)) - || (j < i && (k <= i && k > j))) { - object->cell_ixs[object->cells[j]] = i; - object->cells[i] = object->cells[j]; - i = j; - } + i = cell; + j = i; + for (x = 0; x < (object->cell_capacity - 1); x++) { + j = (j + 1) & (object->cell_capacity - 1); + if (object->cells[j] == OBJECT_INVALID_IX) { + break; } - object->cells[i] = OBJECT_INVALID_IX; - return JSONSuccess; + k = object->hashes[object->cells[j]] & (object->cell_capacity - 1); + if ((j > i && (k <= i || k > j)) || (j < i && (k <= i && k > j))) { + object->cell_ixs[object->cells[j]] = i; + object->cells[i] = object->cells[j]; + i = j; + } + } + object->cells[i] = OBJECT_INVALID_IX; + return JSONSuccess; } static JSON_Status json_object_dotremove_internal(JSON_Object *object, const char *name, parson_bool_t free_value) { - JSON_Value *temp_value = NULL; - JSON_Object *temp_object = NULL; - const char *dot_pos = strchr(name, '.'); - if (!dot_pos) { - return json_object_remove_internal(object, name, free_value); - } - temp_value = json_object_getn_value(object, name, dot_pos - name); - if (json_value_get_type(temp_value) != JSONObject) { - return JSONFailure; - } - temp_object = json_value_get_object(temp_value); - return json_object_dotremove_internal(temp_object, dot_pos + 1, free_value); + JSON_Value *temp_value = NULL; + JSON_Object *temp_object = NULL; + const char *dot_pos = strchr(name, '.'); + if (!dot_pos) { + return json_object_remove_internal(object, name, free_value); + } + temp_value = json_object_getn_value(object, name, dot_pos - name); + if (json_value_get_type(temp_value) != JSONObject) { + return JSONFailure; + } + temp_object = json_value_get_object(temp_value); + return json_object_dotremove_internal(temp_object, dot_pos + 1, free_value); } static void json_object_free(JSON_Object *object) { - json_object_deinit(object, PARSON_TRUE, PARSON_TRUE); - parson_free(object); + json_object_deinit(object, PARSON_TRUE, PARSON_TRUE); + parson_free(object); } /* JSON Array */ -static JSON_Array * json_array_make(JSON_Value *wrapping_value) { - JSON_Array *new_array = (JSON_Array*)parson_malloc(sizeof(JSON_Array)); - if (new_array == NULL) { - return NULL; - } - new_array->wrapping_value = wrapping_value; - new_array->items = (JSON_Value**)NULL; - new_array->capacity = 0; - new_array->count = 0; - return new_array; +static JSON_Array *json_array_make(JSON_Value *wrapping_value) { + JSON_Array *new_array = (JSON_Array *)parson_malloc(sizeof(JSON_Array)); + if (new_array == NULL) { + return NULL; + } + new_array->wrapping_value = wrapping_value; + new_array->items = (JSON_Value **)NULL; + new_array->capacity = 0; + new_array->count = 0; + return new_array; } static JSON_Status json_array_add(JSON_Array *array, JSON_Value *value) { - if (array->count >= array->capacity) { - size_t new_capacity = MAX(array->capacity * 2, STARTING_CAPACITY); - if (json_array_resize(array, new_capacity) != JSONSuccess) { - return JSONFailure; - } + if (array->count >= array->capacity) { + size_t new_capacity = MAX(array->capacity * 2, STARTING_CAPACITY); + if (json_array_resize(array, new_capacity) != JSONSuccess) { + return JSONFailure; } - value->parent = json_array_get_wrapping_value(array); - array->items[array->count] = value; - array->count++; - return JSONSuccess; + } + value->parent = json_array_get_wrapping_value(array); + array->items[array->count] = value; + array->count++; + return JSONSuccess; } static JSON_Status json_array_resize(JSON_Array *array, size_t new_capacity) { - JSON_Value **new_items = NULL; - if (new_capacity == 0) { - return JSONFailure; - } - new_items = (JSON_Value**)parson_malloc(new_capacity * sizeof(JSON_Value*)); - if (new_items == NULL) { - return JSONFailure; - } - if (array->items != NULL && array->count > 0) { - memcpy(new_items, array->items, array->count * sizeof(JSON_Value*)); - } - parson_free(array->items); - array->items = new_items; - array->capacity = new_capacity; - return JSONSuccess; + JSON_Value **new_items = NULL; + if (new_capacity == 0) { + return JSONFailure; + } + new_items = (JSON_Value **)parson_malloc(new_capacity * sizeof(JSON_Value *)); + if (new_items == NULL) { + return JSONFailure; + } + if (array->items != NULL && array->count > 0) { + memcpy(new_items, array->items, array->count * sizeof(JSON_Value *)); + } + parson_free(array->items); + array->items = new_items; + array->capacity = new_capacity; + return JSONSuccess; } static void json_array_free(JSON_Array *array) { - size_t i; - for (i = 0; i < array->count; i++) { - json_value_free(array->items[i]); - } - parson_free(array->items); - parson_free(array); + size_t i; + for (i = 0; i < array->count; i++) { + json_value_free(array->items[i]); + } + parson_free(array->items); + parson_free(array); } /* JSON Value */ -static JSON_Value * json_value_init_string_no_copy(char *string, size_t length) { - JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); - if (!new_value) { - return NULL; - } - new_value->parent = NULL; - new_value->type = JSONString; - new_value->value.string.chars = string; - new_value->value.string.length = length; - return new_value; +static JSON_Value *json_value_init_string_no_copy(char *string, size_t length) { + JSON_Value *new_value = (JSON_Value *)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONString; + new_value->value.string.chars = string; + new_value->value.string.length = length; + return new_value; } /* Parser */ static JSON_Status skip_quotes(const char **string) { - if (**string != '\"') { + if (**string != '\"') { + return JSONFailure; + } + SKIP_CHAR(string); + while (**string != '\"') { + if (**string == '\0') { + return JSONFailure; + } else if (**string == '\\') { + SKIP_CHAR(string); + if (**string == '\0') { return JSONFailure; + } } SKIP_CHAR(string); - while (**string != '\"') { - if (**string == '\0') { - return JSONFailure; - } else if (**string == '\\') { - SKIP_CHAR(string); - if (**string == '\0') { - return JSONFailure; - } - } - SKIP_CHAR(string); - } - SKIP_CHAR(string); - return JSONSuccess; + } + SKIP_CHAR(string); + return JSONSuccess; } static JSON_Status parse_utf16(const char **unprocessed, char **processed) { - unsigned int cp, lead, trail; - char *processed_ptr = *processed; - const char *unprocessed_ptr = *unprocessed; - JSON_Status status = JSONFailure; - unprocessed_ptr++; /* skips u */ - status = parse_utf16_hex(unprocessed_ptr, &cp); - if (status != JSONSuccess) { - return JSONFailure; + unsigned int cp, lead, trail; + char *processed_ptr = *processed; + const char *unprocessed_ptr = *unprocessed; + JSON_Status status = JSONFailure; + unprocessed_ptr++; /* skips u */ + status = parse_utf16_hex(unprocessed_ptr, &cp); + if (status != JSONSuccess) { + return JSONFailure; + } + if (cp < 0x80) { + processed_ptr[0] = (char)cp; /* 0xxxxxxx */ + } else if (cp < 0x800) { + processed_ptr[0] = ((cp >> 6) & 0x1F) | 0xC0; /* 110xxxxx */ + processed_ptr[1] = ((cp)&0x3F) | 0x80; /* 10xxxxxx */ + processed_ptr += 1; + } else if (cp < 0xD800 || cp > 0xDFFF) { + processed_ptr[0] = ((cp >> 12) & 0x0F) | 0xE0; /* 1110xxxx */ + processed_ptr[1] = ((cp >> 6) & 0x3F) | 0x80; /* 10xxxxxx */ + processed_ptr[2] = ((cp)&0x3F) | 0x80; /* 10xxxxxx */ + processed_ptr += 2; + } else if (cp >= 0xD800 && cp <= 0xDBFF) { /* lead surrogate (0xD800..0xDBFF) */ + lead = cp; + unprocessed_ptr += 4; /* should always be within the buffer, otherwise previous sscanf would fail */ + if (*unprocessed_ptr++ != '\\' || *unprocessed_ptr++ != 'u') { + return JSONFailure; } - if (cp < 0x80) { - processed_ptr[0] = (char)cp; /* 0xxxxxxx */ - } else if (cp < 0x800) { - processed_ptr[0] = ((cp >> 6) & 0x1F) | 0xC0; /* 110xxxxx */ - processed_ptr[1] = ((cp) & 0x3F) | 0x80; /* 10xxxxxx */ - processed_ptr += 1; - } else if (cp < 0xD800 || cp > 0xDFFF) { - processed_ptr[0] = ((cp >> 12) & 0x0F) | 0xE0; /* 1110xxxx */ - processed_ptr[1] = ((cp >> 6) & 0x3F) | 0x80; /* 10xxxxxx */ - processed_ptr[2] = ((cp) & 0x3F) | 0x80; /* 10xxxxxx */ - processed_ptr += 2; - } else if (cp >= 0xD800 && cp <= 0xDBFF) { /* lead surrogate (0xD800..0xDBFF) */ - lead = cp; - unprocessed_ptr += 4; /* should always be within the buffer, otherwise previous sscanf would fail */ - if (*unprocessed_ptr++ != '\\' || *unprocessed_ptr++ != 'u') { - return JSONFailure; - } - status = parse_utf16_hex(unprocessed_ptr, &trail); - if (status != JSONSuccess || trail < 0xDC00 || trail > 0xDFFF) { /* valid trail surrogate? (0xDC00..0xDFFF) */ - return JSONFailure; - } - cp = ((((lead - 0xD800) & 0x3FF) << 10) | ((trail - 0xDC00) & 0x3FF)) + 0x010000; - processed_ptr[0] = (((cp >> 18) & 0x07) | 0xF0); /* 11110xxx */ - processed_ptr[1] = (((cp >> 12) & 0x3F) | 0x80); /* 10xxxxxx */ - processed_ptr[2] = (((cp >> 6) & 0x3F) | 0x80); /* 10xxxxxx */ - processed_ptr[3] = (((cp) & 0x3F) | 0x80); /* 10xxxxxx */ - processed_ptr += 3; - } else { /* trail surrogate before lead surrogate */ - return JSONFailure; + status = parse_utf16_hex(unprocessed_ptr, &trail); + if (status != JSONSuccess || trail < 0xDC00 || trail > 0xDFFF) { /* valid trail surrogate? (0xDC00..0xDFFF) */ + return JSONFailure; } - unprocessed_ptr += 3; - *processed = processed_ptr; - *unprocessed = unprocessed_ptr; - return JSONSuccess; + cp = ((((lead - 0xD800) & 0x3FF) << 10) | ((trail - 0xDC00) & 0x3FF)) + 0x010000; + processed_ptr[0] = (((cp >> 18) & 0x07) | 0xF0); /* 11110xxx */ + processed_ptr[1] = (((cp >> 12) & 0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr[2] = (((cp >> 6) & 0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr[3] = (((cp)&0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr += 3; + } else { /* trail surrogate before lead surrogate */ + return JSONFailure; + } + unprocessed_ptr += 3; + *processed = processed_ptr; + *unprocessed = unprocessed_ptr; + return JSONSuccess; } - /* Copies and processes passed string up to supplied length. Example: "\u006Corem ipsum" -> lorem ipsum */ -static char* process_string(const char *input, size_t input_len, size_t *output_len) { - const char *input_ptr = input; - size_t initial_size = (input_len + 1) * sizeof(char); - size_t final_size = 0; - char *output = NULL, *output_ptr = NULL, *resized_output = NULL; - output = (char*)parson_malloc(initial_size); - if (output == NULL) { - goto error; - } - output_ptr = output; - while ((*input_ptr != '\0') && (size_t)(input_ptr - input) < input_len) { - if (*input_ptr == '\\') { - input_ptr++; - switch (*input_ptr) { - case '\"': *output_ptr = '\"'; break; - case '\\': *output_ptr = '\\'; break; - case '/': *output_ptr = '/'; break; - case 'b': *output_ptr = '\b'; break; - case 'f': *output_ptr = '\f'; break; - case 'n': *output_ptr = '\n'; break; - case 'r': *output_ptr = '\r'; break; - case 't': *output_ptr = '\t'; break; - case 'u': - if (parse_utf16(&input_ptr, &output_ptr) != JSONSuccess) { - goto error; - } - break; - default: - goto error; - } - } else if ((unsigned char)*input_ptr < 0x20) { - goto error; /* 0x00-0x19 are invalid characters for json string (http://www.ietf.org/rfc/rfc4627.txt) */ - } else { - *output_ptr = *input_ptr; +static char *process_string(const char *input, size_t input_len, size_t *output_len) { + const char *input_ptr = input; + size_t initial_size = (input_len + 1) * sizeof(char); + size_t final_size = 0; + char *output = NULL, *output_ptr = NULL, *resized_output = NULL; + output = (char *)parson_malloc(initial_size); + if (output == NULL) { + goto error; + } + output_ptr = output; + while ((*input_ptr != '\0') && (size_t)(input_ptr - input) < input_len) { + if (*input_ptr == '\\') { + input_ptr++; + switch (*input_ptr) { + case '\"': + *output_ptr = '\"'; + break; + case '\\': + *output_ptr = '\\'; + break; + case '/': + *output_ptr = '/'; + break; + case 'b': + *output_ptr = '\b'; + break; + case 'f': + *output_ptr = '\f'; + break; + case 'n': + *output_ptr = '\n'; + break; + case 'r': + *output_ptr = '\r'; + break; + case 't': + *output_ptr = '\t'; + break; + case 'u': + if (parse_utf16(&input_ptr, &output_ptr) != JSONSuccess) { + goto error; } - output_ptr++; - input_ptr++; - } - *output_ptr = '\0'; - /* resize to new length */ - final_size = (size_t)(output_ptr-output) + 1; - /* todo: don't resize if final_size == initial_size */ - resized_output = (char*)parson_malloc(final_size); - if (resized_output == NULL) { + break; + default: goto error; + } + } else if ((unsigned char)*input_ptr < 0x20) { + goto error; /* 0x00-0x19 are invalid characters for json string (http://www.ietf.org/rfc/rfc4627.txt) */ + } else { + *output_ptr = *input_ptr; } - memcpy(resized_output, output, final_size); - *output_len = final_size - 1; - parson_free(output); - return resized_output; + output_ptr++; + input_ptr++; + } + *output_ptr = '\0'; + /* resize to new length */ + final_size = (size_t)(output_ptr - output) + 1; + /* todo: don't resize if final_size == initial_size */ + resized_output = (char *)parson_malloc(final_size); + if (resized_output == NULL) { + goto error; + } + memcpy(resized_output, output, final_size); + *output_len = final_size - 1; + parson_free(output); + return resized_output; error: - parson_free(output); - return NULL; + parson_free(output); + return NULL; } /* Return processed contents of a string between quotes and skips passed argument to a matching quote. */ -static char * get_quoted_string(const char **string, size_t *output_string_len) { - const char *string_start = *string; - size_t input_string_len = 0; - JSON_Status status = skip_quotes(string); +static char *get_quoted_string(const char **string, size_t *output_string_len) { + const char *string_start = *string; + size_t input_string_len = 0; + JSON_Status status = skip_quotes(string); + if (status != JSONSuccess) { + return NULL; + } + input_string_len = *string - string_start - 2; /* length without quotes */ + return process_string(string_start + 1, input_string_len, output_string_len); +} + +static JSON_Value *parse_value(const char **string, size_t nesting) { + if (nesting > MAX_NESTING) { + return NULL; + } + SKIP_WHITESPACES(string); + switch (**string) { + case '{': + return parse_object_value(string, nesting + 1); + case '[': + return parse_array_value(string, nesting + 1); + case '\"': + return parse_string_value(string); + case 'f': + case 't': + return parse_boolean_value(string); + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return parse_number_value(string); + case 'n': + return parse_null_value(string); + default: + return NULL; + } +} + +static JSON_Value *parse_object_value(const char **string, size_t nesting) { + JSON_Status status = JSONFailure; + JSON_Value *output_value = NULL, *new_value = NULL; + JSON_Object *output_object = NULL; + char *new_key = NULL; + + output_value = json_value_init_object(); + if (output_value == NULL) { + return NULL; + } + if (**string != '{') { + json_value_free(output_value); + return NULL; + } + output_object = json_value_get_object(output_value); + SKIP_CHAR(string); + SKIP_WHITESPACES(string); + if (**string == '}') { /* empty object */ + SKIP_CHAR(string); + return output_value; + } + while (**string != '\0') { + size_t key_len = 0; + new_key = get_quoted_string(string, &key_len); + /* We do not support key names with embedded \0 chars */ + if (!new_key) { + json_value_free(output_value); + return NULL; + } + if (key_len != strlen(new_key)) { + parson_free(new_key); + json_value_free(output_value); + return NULL; + } + SKIP_WHITESPACES(string); + if (**string != ':') { + parson_free(new_key); + json_value_free(output_value); + return NULL; + } + SKIP_CHAR(string); + new_value = parse_value(string, nesting); + if (new_value == NULL) { + parson_free(new_key); + json_value_free(output_value); + return NULL; + } + status = json_object_add(output_object, new_key, new_value); if (status != JSONSuccess) { - return NULL; - } - input_string_len = *string - string_start - 2; /* length without quotes */ - return process_string(string_start + 1, input_string_len, output_string_len); -} - -static JSON_Value * parse_value(const char **string, size_t nesting) { - if (nesting > MAX_NESTING) { - return NULL; + parson_free(new_key); + json_value_free(new_value); + json_value_free(output_value); + return NULL; } SKIP_WHITESPACES(string); - switch (**string) { - case '{': - return parse_object_value(string, nesting + 1); - case '[': - return parse_array_value(string, nesting + 1); - case '\"': - return parse_string_value(string); - case 'f': case 't': - return parse_boolean_value(string); - case '-': - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - return parse_number_value(string); - case 'n': - return parse_null_value(string); - default: - return NULL; + if (**string != ',') { + break; } -} - -static JSON_Value * parse_object_value(const char **string, size_t nesting) { - JSON_Status status = JSONFailure; - JSON_Value *output_value = NULL, *new_value = NULL; - JSON_Object *output_object = NULL; - char *new_key = NULL; - - output_value = json_value_init_object(); - if (output_value == NULL) { - return NULL; - } - if (**string != '{') { - json_value_free(output_value); - return NULL; - } - output_object = json_value_get_object(output_value); SKIP_CHAR(string); SKIP_WHITESPACES(string); - if (**string == '}') { /* empty object */ - SKIP_CHAR(string); - return output_value; - } - while (**string != '\0') { - size_t key_len = 0; - new_key = get_quoted_string(string, &key_len); - /* We do not support key names with embedded \0 chars */ - if (!new_key) { - json_value_free(output_value); - return NULL; - } - if (key_len != strlen(new_key)) { - parson_free(new_key); - json_value_free(output_value); - return NULL; - } - SKIP_WHITESPACES(string); - if (**string != ':') { - parson_free(new_key); - json_value_free(output_value); - return NULL; - } - SKIP_CHAR(string); - new_value = parse_value(string, nesting); - if (new_value == NULL) { - parson_free(new_key); - json_value_free(output_value); - return NULL; - } - status = json_object_add(output_object, new_key, new_value); - if (status != JSONSuccess) { - parson_free(new_key); - json_value_free(new_value); - json_value_free(output_value); - return NULL; - } - SKIP_WHITESPACES(string); - if (**string != ',') { - break; - } - SKIP_CHAR(string); - SKIP_WHITESPACES(string); - if (**string == '}') { - break; - } - } - SKIP_WHITESPACES(string); - if (**string != '}') { - json_value_free(output_value); - return NULL; + if (**string == '}') { + break; } + } + SKIP_WHITESPACES(string); + if (**string != '}') { + json_value_free(output_value); + return NULL; + } + SKIP_CHAR(string); + return output_value; +} + +static JSON_Value *parse_array_value(const char **string, size_t nesting) { + JSON_Value *output_value = NULL, *new_array_value = NULL; + JSON_Array *output_array = NULL; + output_value = json_value_init_array(); + if (output_value == NULL) { + return NULL; + } + if (**string != '[') { + json_value_free(output_value); + return NULL; + } + output_array = json_value_get_array(output_value); + SKIP_CHAR(string); + SKIP_WHITESPACES(string); + if (**string == ']') { /* empty array */ SKIP_CHAR(string); return output_value; -} - -static JSON_Value * parse_array_value(const char **string, size_t nesting) { - JSON_Value *output_value = NULL, *new_array_value = NULL; - JSON_Array *output_array = NULL; - output_value = json_value_init_array(); - if (output_value == NULL) { - return NULL; + } + while (**string != '\0') { + new_array_value = parse_value(string, nesting); + if (new_array_value == NULL) { + json_value_free(output_value); + return NULL; } - if (**string != '[') { - json_value_free(output_value); - return NULL; - } - output_array = json_value_get_array(output_value); - SKIP_CHAR(string); - SKIP_WHITESPACES(string); - if (**string == ']') { /* empty array */ - SKIP_CHAR(string); - return output_value; - } - while (**string != '\0') { - new_array_value = parse_value(string, nesting); - if (new_array_value == NULL) { - json_value_free(output_value); - return NULL; - } - if (json_array_add(output_array, new_array_value) != JSONSuccess) { - json_value_free(new_array_value); - json_value_free(output_value); - return NULL; - } - SKIP_WHITESPACES(string); - if (**string != ',') { - break; - } - SKIP_CHAR(string); - SKIP_WHITESPACES(string); - if (**string == ']') { - break; - } + if (json_array_add(output_array, new_array_value) != JSONSuccess) { + json_value_free(new_array_value); + json_value_free(output_value); + return NULL; } SKIP_WHITESPACES(string); - if (**string != ']' || /* Trim array after parsing is over */ - json_array_resize(output_array, json_array_get_count(output_array)) != JSONSuccess) { - json_value_free(output_value); - return NULL; + if (**string != ',') { + break; } SKIP_CHAR(string); - return output_value; -} - -static JSON_Value * parse_string_value(const char **string) { - JSON_Value *value = NULL; - size_t new_string_len = 0; - char *new_string = get_quoted_string(string, &new_string_len); - if (new_string == NULL) { - return NULL; - } - value = json_value_init_string_no_copy(new_string, new_string_len); - if (value == NULL) { - parson_free(new_string); - return NULL; - } - return value; -} - -static JSON_Value * parse_boolean_value(const char **string) { - size_t true_token_size = SIZEOF_TOKEN("true"); - size_t false_token_size = SIZEOF_TOKEN("false"); - if (strncmp("true", *string, true_token_size) == 0) { - *string += true_token_size; - return json_value_init_boolean(1); - } else if (strncmp("false", *string, false_token_size) == 0) { - *string += false_token_size; - return json_value_init_boolean(0); + SKIP_WHITESPACES(string); + if (**string == ']') { + break; } + } + SKIP_WHITESPACES(string); + if (**string != ']' || /* Trim array after parsing is over */ + json_array_resize(output_array, json_array_get_count(output_array)) != JSONSuccess) { + json_value_free(output_value); return NULL; + } + SKIP_CHAR(string); + return output_value; } -static JSON_Value * parse_number_value(const char **string) { - char *end; - double number = 0; - errno = 0; - number = strtod(*string, &end); - if (errno == ERANGE && (number <= -HUGE_VAL || number >= HUGE_VAL)) { - return NULL; - } - if ((errno && errno != ERANGE) || !is_decimal(*string, end - *string)) { - return NULL; - } - *string = end; - return json_value_init_number(number); -} - -static JSON_Value * parse_null_value(const char **string) { - size_t token_size = SIZEOF_TOKEN("null"); - if (strncmp("null", *string, token_size) == 0) { - *string += token_size; - return json_value_init_null(); - } +static JSON_Value *parse_string_value(const char **string) { + JSON_Value *value = NULL; + size_t new_string_len = 0; + char *new_string = get_quoted_string(string, &new_string_len); + if (new_string == NULL) { return NULL; + } + value = json_value_init_string_no_copy(new_string, new_string_len); + if (value == NULL) { + parson_free(new_string); + return NULL; + } + return value; +} + +static JSON_Value *parse_boolean_value(const char **string) { + size_t true_token_size = SIZEOF_TOKEN("true"); + size_t false_token_size = SIZEOF_TOKEN("false"); + if (strncmp("true", *string, true_token_size) == 0) { + *string += true_token_size; + return json_value_init_boolean(1); + } else if (strncmp("false", *string, false_token_size) == 0) { + *string += false_token_size; + return json_value_init_boolean(0); + } + return NULL; +} + +static JSON_Value *parse_number_value(const char **string) { + char *end; + double number = 0; + errno = 0; + number = strtod(*string, &end); + if (errno == ERANGE && (number <= -HUGE_VAL || number >= HUGE_VAL)) { + return NULL; + } + if ((errno && errno != ERANGE) || !is_decimal(*string, end - *string)) { + return NULL; + } + *string = end; + return json_value_init_number(number); +} + +static JSON_Value *parse_null_value(const char **string) { + size_t token_size = SIZEOF_TOKEN("null"); + if (strncmp("null", *string, token_size) == 0) { + *string += token_size; + return json_value_init_null(); + } + return NULL; } /* Serialization */ -#define APPEND_STRING(str) do { written = append_string(buf, (str));\ - if (written < 0) { return -1; }\ - if (buf != NULL) { buf += written; }\ - written_total += written; } while(0) +#define APPEND_STRING(str) \ + do { \ + written = append_string(buf, (str)); \ + if (written < 0) { \ + return -1; \ + } \ + if (buf != NULL) { \ + buf += written; \ + } \ + written_total += written; \ + } while (0) -#define APPEND_INDENT(level) do { written = append_indent(buf, (level));\ - if (written < 0) { return -1; }\ - if (buf != NULL) { buf += written; }\ - written_total += written; } while(0) +#define APPEND_INDENT(level) \ + do { \ + written = append_indent(buf, (level)); \ + if (written < 0) { \ + return -1; \ + } \ + if (buf != NULL) { \ + buf += written; \ + } \ + written_total += written; \ + } while (0) -static int json_serialize_to_buffer_r(const JSON_Value *value, char *buf, int level, parson_bool_t is_pretty, char *num_buf) -{ - const char *key = NULL, *string = NULL; - JSON_Value *temp_value = NULL; - JSON_Array *array = NULL; - JSON_Object *object = NULL; - size_t i = 0, count = 0; - double num = 0.0; - int written = -1, written_total = 0; - size_t len = 0; +static int json_serialize_to_buffer_r(const JSON_Value *value, char *buf, int level, parson_bool_t is_pretty, char *num_buf) { + const char *key = NULL, *string = NULL; + JSON_Value *temp_value = NULL; + JSON_Array *array = NULL; + JSON_Object *object = NULL; + size_t i = 0, count = 0; + double num = 0.0; + int written = -1, written_total = 0; + size_t len = 0; - switch (json_value_get_type(value)) { - case JSONArray: - array = json_value_get_array(value); - count = json_array_get_count(array); - APPEND_STRING("["); - if (count > 0 && is_pretty) { - APPEND_STRING("\n"); - } - for (i = 0; i < count; i++) { - if (is_pretty) { - APPEND_INDENT(level+1); - } - temp_value = json_array_get_value(array, i); - written = json_serialize_to_buffer_r(temp_value, buf, level+1, is_pretty, num_buf); - if (written < 0) { - return -1; - } - if (buf != NULL) { - buf += written; - } - written_total += written; - if (i < (count - 1)) { - APPEND_STRING(","); - } - if (is_pretty) { - APPEND_STRING("\n"); - } - } - if (count > 0 && is_pretty) { - APPEND_INDENT(level); - } - APPEND_STRING("]"); - return written_total; - case JSONObject: - object = json_value_get_object(value); - count = json_object_get_count(object); - APPEND_STRING("{"); - if (count > 0 && is_pretty) { - APPEND_STRING("\n"); - } - for (i = 0; i < count; i++) { - key = json_object_get_name(object, i); - if (key == NULL) { - return -1; - } - if (is_pretty) { - APPEND_INDENT(level+1); - } - /* We do not support key names with embedded \0 chars */ - written = json_serialize_string(key, strlen(key), buf); - if (written < 0) { - return -1; - } - if (buf != NULL) { - buf += written; - } - written_total += written; - APPEND_STRING(":"); - if (is_pretty) { - APPEND_STRING(" "); - } - temp_value = json_object_get_value_at(object, i); - written = json_serialize_to_buffer_r(temp_value, buf, level+1, is_pretty, num_buf); - if (written < 0) { - return -1; - } - if (buf != NULL) { - buf += written; - } - written_total += written; - if (i < (count - 1)) { - APPEND_STRING(","); - } - if (is_pretty) { - APPEND_STRING("\n"); - } - } - if (count > 0 && is_pretty) { - APPEND_INDENT(level); - } - APPEND_STRING("}"); - return written_total; - case JSONString: - string = json_value_get_string(value); - if (string == NULL) { - return -1; - } - len = json_value_get_string_len(value); - written = json_serialize_string(string, len, buf); - if (written < 0) { - return -1; - } - if (buf != NULL) { - buf += written; - } - written_total += written; - return written_total; - case JSONBoolean: - if (json_value_get_boolean(value)) { - APPEND_STRING("true"); - } else { - APPEND_STRING("false"); - } - return written_total; - case JSONNumber: - num = json_value_get_number(value); - if (buf != NULL) { - num_buf = buf; - } - if (parson_float_format) { - written = sprintf(num_buf, parson_float_format, num); - } else { - written = sprintf(num_buf, PARSON_DEFAULT_FLOAT_FORMAT, num); - } - if (written < 0) { - return -1; - } - if (buf != NULL) { - buf += written; - } - written_total += written; - return written_total; - case JSONNull: - APPEND_STRING("null"); - return written_total; - case JSONError: - return -1; - default: - return -1; + switch (json_value_get_type(value)) { + case JSONArray: + array = json_value_get_array(value); + count = json_array_get_count(array); + APPEND_STRING("["); + if (count > 0 && is_pretty) { + APPEND_STRING("\n"); } + for (i = 0; i < count; i++) { + if (is_pretty) { + APPEND_INDENT(level + 1); + } + temp_value = json_array_get_value(array, i); + written = json_serialize_to_buffer_r(temp_value, buf, level + 1, is_pretty, num_buf); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + if (i < (count - 1)) { + APPEND_STRING(","); + } + if (is_pretty) { + APPEND_STRING("\n"); + } + } + if (count > 0 && is_pretty) { + APPEND_INDENT(level); + } + APPEND_STRING("]"); + return written_total; + case JSONObject: + object = json_value_get_object(value); + count = json_object_get_count(object); + APPEND_STRING("{"); + if (count > 0 && is_pretty) { + APPEND_STRING("\n"); + } + for (i = 0; i < count; i++) { + key = json_object_get_name(object, i); + if (key == NULL) { + return -1; + } + if (is_pretty) { + APPEND_INDENT(level + 1); + } + /* We do not support key names with embedded \0 chars */ + written = json_serialize_string(key, strlen(key), buf); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + APPEND_STRING(":"); + if (is_pretty) { + APPEND_STRING(" "); + } + temp_value = json_object_get_value_at(object, i); + written = json_serialize_to_buffer_r(temp_value, buf, level + 1, is_pretty, num_buf); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + if (i < (count - 1)) { + APPEND_STRING(","); + } + if (is_pretty) { + APPEND_STRING("\n"); + } + } + if (count > 0 && is_pretty) { + APPEND_INDENT(level); + } + APPEND_STRING("}"); + return written_total; + case JSONString: + string = json_value_get_string(value); + if (string == NULL) { + return -1; + } + len = json_value_get_string_len(value); + written = json_serialize_string(string, len, buf); + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + return written_total; + case JSONBoolean: + if (json_value_get_boolean(value)) { + APPEND_STRING("true"); + } else { + APPEND_STRING("false"); + } + return written_total; + case JSONNumber: + num = json_value_get_number(value); + if (buf != NULL) { + num_buf = buf; + } + if (parson_float_format) { + written = sprintf(num_buf, parson_float_format, num); + } else { + written = sprintf(num_buf, PARSON_DEFAULT_FLOAT_FORMAT, num); + } + if (written < 0) { + return -1; + } + if (buf != NULL) { + buf += written; + } + written_total += written; + return written_total; + case JSONNull: + APPEND_STRING("null"); + return written_total; + case JSONError: + return -1; + default: + return -1; + } } static int json_serialize_string(const char *string, size_t len, char *buf) { - size_t i = 0; - char c = '\0'; - int written = -1, written_total = 0; - APPEND_STRING("\""); - for (i = 0; i < len; i++) { - c = string[i]; - switch (c) { - case '\"': APPEND_STRING("\\\""); break; - case '\\': APPEND_STRING("\\\\"); break; - case '\b': APPEND_STRING("\\b"); break; - case '\f': APPEND_STRING("\\f"); break; - case '\n': APPEND_STRING("\\n"); break; - case '\r': APPEND_STRING("\\r"); break; - case '\t': APPEND_STRING("\\t"); break; - case '\x00': APPEND_STRING("\\u0000"); break; - case '\x01': APPEND_STRING("\\u0001"); break; - case '\x02': APPEND_STRING("\\u0002"); break; - case '\x03': APPEND_STRING("\\u0003"); break; - case '\x04': APPEND_STRING("\\u0004"); break; - case '\x05': APPEND_STRING("\\u0005"); break; - case '\x06': APPEND_STRING("\\u0006"); break; - case '\x07': APPEND_STRING("\\u0007"); break; - /* '\x08' duplicate: '\b' */ - /* '\x09' duplicate: '\t' */ - /* '\x0a' duplicate: '\n' */ - case '\x0b': APPEND_STRING("\\u000b"); break; - /* '\x0c' duplicate: '\f' */ - /* '\x0d' duplicate: '\r' */ - case '\x0e': APPEND_STRING("\\u000e"); break; - case '\x0f': APPEND_STRING("\\u000f"); break; - case '\x10': APPEND_STRING("\\u0010"); break; - case '\x11': APPEND_STRING("\\u0011"); break; - case '\x12': APPEND_STRING("\\u0012"); break; - case '\x13': APPEND_STRING("\\u0013"); break; - case '\x14': APPEND_STRING("\\u0014"); break; - case '\x15': APPEND_STRING("\\u0015"); break; - case '\x16': APPEND_STRING("\\u0016"); break; - case '\x17': APPEND_STRING("\\u0017"); break; - case '\x18': APPEND_STRING("\\u0018"); break; - case '\x19': APPEND_STRING("\\u0019"); break; - case '\x1a': APPEND_STRING("\\u001a"); break; - case '\x1b': APPEND_STRING("\\u001b"); break; - case '\x1c': APPEND_STRING("\\u001c"); break; - case '\x1d': APPEND_STRING("\\u001d"); break; - case '\x1e': APPEND_STRING("\\u001e"); break; - case '\x1f': APPEND_STRING("\\u001f"); break; - case '/': - if (parson_escape_slashes) { - APPEND_STRING("\\/"); /* to make json embeddable in xml\/html */ - } else { - APPEND_STRING("/"); - } - break; - default: - if (buf != NULL) { - buf[0] = c; - buf += 1; - } - written_total += 1; - break; - } + size_t i = 0; + char c = '\0'; + int written = -1, written_total = 0; + APPEND_STRING("\""); + for (i = 0; i < len; i++) { + c = string[i]; + switch (c) { + case '\"': + APPEND_STRING("\\\""); + break; + case '\\': + APPEND_STRING("\\\\"); + break; + case '\b': + APPEND_STRING("\\b"); + break; + case '\f': + APPEND_STRING("\\f"); + break; + case '\n': + APPEND_STRING("\\n"); + break; + case '\r': + APPEND_STRING("\\r"); + break; + case '\t': + APPEND_STRING("\\t"); + break; + case '\x00': + APPEND_STRING("\\u0000"); + break; + case '\x01': + APPEND_STRING("\\u0001"); + break; + case '\x02': + APPEND_STRING("\\u0002"); + break; + case '\x03': + APPEND_STRING("\\u0003"); + break; + case '\x04': + APPEND_STRING("\\u0004"); + break; + case '\x05': + APPEND_STRING("\\u0005"); + break; + case '\x06': + APPEND_STRING("\\u0006"); + break; + case '\x07': + APPEND_STRING("\\u0007"); + break; + /* '\x08' duplicate: '\b' */ + /* '\x09' duplicate: '\t' */ + /* '\x0a' duplicate: '\n' */ + case '\x0b': + APPEND_STRING("\\u000b"); + break; + /* '\x0c' duplicate: '\f' */ + /* '\x0d' duplicate: '\r' */ + case '\x0e': + APPEND_STRING("\\u000e"); + break; + case '\x0f': + APPEND_STRING("\\u000f"); + break; + case '\x10': + APPEND_STRING("\\u0010"); + break; + case '\x11': + APPEND_STRING("\\u0011"); + break; + case '\x12': + APPEND_STRING("\\u0012"); + break; + case '\x13': + APPEND_STRING("\\u0013"); + break; + case '\x14': + APPEND_STRING("\\u0014"); + break; + case '\x15': + APPEND_STRING("\\u0015"); + break; + case '\x16': + APPEND_STRING("\\u0016"); + break; + case '\x17': + APPEND_STRING("\\u0017"); + break; + case '\x18': + APPEND_STRING("\\u0018"); + break; + case '\x19': + APPEND_STRING("\\u0019"); + break; + case '\x1a': + APPEND_STRING("\\u001a"); + break; + case '\x1b': + APPEND_STRING("\\u001b"); + break; + case '\x1c': + APPEND_STRING("\\u001c"); + break; + case '\x1d': + APPEND_STRING("\\u001d"); + break; + case '\x1e': + APPEND_STRING("\\u001e"); + break; + case '\x1f': + APPEND_STRING("\\u001f"); + break; + case '/': + if (parson_escape_slashes) { + APPEND_STRING("\\/"); /* to make json embeddable in xml\/html */ + } else { + APPEND_STRING("/"); + } + break; + default: + if (buf != NULL) { + buf[0] = c; + buf += 1; + } + written_total += 1; + break; } - APPEND_STRING("\""); - return written_total; + } + APPEND_STRING("\""); + return written_total; } static int append_indent(char *buf, int level) { - int i; - int written = -1, written_total = 0; - for (i = 0; i < level; i++) { - APPEND_STRING(" "); - } - return written_total; + int i; + int written = -1, written_total = 0; + for (i = 0; i < level; i++) { + APPEND_STRING(" "); + } + return written_total; } static int append_string(char *buf, const char *string) { - if (buf == NULL) { - return (int)strlen(string); - } - return sprintf(buf, "%s", string); + if (buf == NULL) { + return (int)strlen(string); + } + return sprintf(buf, "%s", string); } #undef APPEND_STRING #undef APPEND_INDENT /* Parser API */ -JSON_Value * json_parse_file(const char *filename) { - char *file_contents = read_file(filename); - JSON_Value *output_value = NULL; - if (file_contents == NULL) { - return NULL; - } - output_value = json_parse_string(file_contents); - parson_free(file_contents); - return output_value; +JSON_Value *json_parse_file(const char *filename) { + char *file_contents = read_file(filename); + JSON_Value *output_value = NULL; + if (file_contents == NULL) { + return NULL; + } + output_value = json_parse_string(file_contents); + parson_free(file_contents); + return output_value; } -JSON_Value * json_parse_file_with_comments(const char *filename) { - char *file_contents = read_file(filename); - JSON_Value *output_value = NULL; - if (file_contents == NULL) { - return NULL; - } - output_value = json_parse_string_with_comments(file_contents); - parson_free(file_contents); - return output_value; +JSON_Value *json_parse_file_with_comments(const char *filename) { + char *file_contents = read_file(filename); + JSON_Value *output_value = NULL; + if (file_contents == NULL) { + return NULL; + } + output_value = json_parse_string_with_comments(file_contents); + parson_free(file_contents); + return output_value; } -JSON_Value * json_parse_string(const char *string) { - if (string == NULL) { - return NULL; - } - if (string[0] == '\xEF' && string[1] == '\xBB' && string[2] == '\xBF') { - string = string + 3; /* Support for UTF-8 BOM */ - } - return parse_value((const char**)&string, 0); +JSON_Value *json_parse_string(const char *string) { + if (string == NULL) { + return NULL; + } + if (string[0] == '\xEF' && string[1] == '\xBB' && string[2] == '\xBF') { + string = string + 3; /* Support for UTF-8 BOM */ + } + return parse_value((const char **)&string, 0); } -JSON_Value * json_parse_string_with_comments(const char *string) { - JSON_Value *result = NULL; - char *string_mutable_copy = NULL, *string_mutable_copy_ptr = NULL; - string_mutable_copy = parson_strdup(string); - if (string_mutable_copy == NULL) { - return NULL; - } - remove_comments(string_mutable_copy, "/*", "*/"); - remove_comments(string_mutable_copy, "//", "\n"); - string_mutable_copy_ptr = string_mutable_copy; - result = parse_value((const char**)&string_mutable_copy_ptr, 0); - parson_free(string_mutable_copy); - return result; +JSON_Value *json_parse_string_with_comments(const char *string) { + JSON_Value *result = NULL; + char *string_mutable_copy = NULL, *string_mutable_copy_ptr = NULL; + string_mutable_copy = parson_strdup(string); + if (string_mutable_copy == NULL) { + return NULL; + } + remove_comments(string_mutable_copy, "/*", "*/"); + remove_comments(string_mutable_copy, "//", "\n"); + string_mutable_copy_ptr = string_mutable_copy; + result = parse_value((const char **)&string_mutable_copy_ptr, 0); + parson_free(string_mutable_copy); + return result; } /* JSON Object API */ -JSON_Value * json_object_get_value(const JSON_Object *object, const char *name) { - if (object == NULL || name == NULL) { - return NULL; - } - return json_object_getn_value(object, name, strlen(name)); +JSON_Value *json_object_get_value(const JSON_Object *object, const char *name) { + if (object == NULL || name == NULL) { + return NULL; + } + return json_object_getn_value(object, name, strlen(name)); } -const char * json_object_get_string(const JSON_Object *object, const char *name) { - return json_value_get_string(json_object_get_value(object, name)); +const char *json_object_get_string(const JSON_Object *object, const char *name) { + return json_value_get_string(json_object_get_value(object, name)); } size_t json_object_get_string_len(const JSON_Object *object, const char *name) { - return json_value_get_string_len(json_object_get_value(object, name)); + return json_value_get_string_len(json_object_get_value(object, name)); } double json_object_get_number(const JSON_Object *object, const char *name) { - return json_value_get_number(json_object_get_value(object, name)); + return json_value_get_number(json_object_get_value(object, name)); } -JSON_Object * json_object_get_object(const JSON_Object *object, const char *name) { - return json_value_get_object(json_object_get_value(object, name)); +JSON_Object *json_object_get_object(const JSON_Object *object, const char *name) { + return json_value_get_object(json_object_get_value(object, name)); } -JSON_Array * json_object_get_array(const JSON_Object *object, const char *name) { - return json_value_get_array(json_object_get_value(object, name)); +JSON_Array *json_object_get_array(const JSON_Object *object, const char *name) { + return json_value_get_array(json_object_get_value(object, name)); } int json_object_get_boolean(const JSON_Object *object, const char *name) { - return json_value_get_boolean(json_object_get_value(object, name)); + return json_value_get_boolean(json_object_get_value(object, name)); } -JSON_Value * json_object_dotget_value(const JSON_Object *object, const char *name) { - const char *dot_position = strchr(name, '.'); - if (!dot_position) { - return json_object_get_value(object, name); - } - object = json_value_get_object(json_object_getn_value(object, name, dot_position - name)); - return json_object_dotget_value(object, dot_position + 1); +JSON_Value *json_object_dotget_value(const JSON_Object *object, const char *name) { + const char *dot_position = strchr(name, '.'); + if (!dot_position) { + return json_object_get_value(object, name); + } + object = json_value_get_object(json_object_getn_value(object, name, dot_position - name)); + return json_object_dotget_value(object, dot_position + 1); } -const char * json_object_dotget_string(const JSON_Object *object, const char *name) { - return json_value_get_string(json_object_dotget_value(object, name)); +const char *json_object_dotget_string(const JSON_Object *object, const char *name) { + return json_value_get_string(json_object_dotget_value(object, name)); } size_t json_object_dotget_string_len(const JSON_Object *object, const char *name) { - return json_value_get_string_len(json_object_dotget_value(object, name)); + return json_value_get_string_len(json_object_dotget_value(object, name)); } double json_object_dotget_number(const JSON_Object *object, const char *name) { - return json_value_get_number(json_object_dotget_value(object, name)); + return json_value_get_number(json_object_dotget_value(object, name)); } -JSON_Object * json_object_dotget_object(const JSON_Object *object, const char *name) { - return json_value_get_object(json_object_dotget_value(object, name)); +JSON_Object *json_object_dotget_object(const JSON_Object *object, const char *name) { + return json_value_get_object(json_object_dotget_value(object, name)); } -JSON_Array * json_object_dotget_array(const JSON_Object *object, const char *name) { - return json_value_get_array(json_object_dotget_value(object, name)); +JSON_Array *json_object_dotget_array(const JSON_Object *object, const char *name) { + return json_value_get_array(json_object_dotget_value(object, name)); } int json_object_dotget_boolean(const JSON_Object *object, const char *name) { - return json_value_get_boolean(json_object_dotget_value(object, name)); + return json_value_get_boolean(json_object_dotget_value(object, name)); } size_t json_object_get_count(const JSON_Object *object) { - return object ? object->count : 0; + return object ? object->count : 0; } -const char * json_object_get_name(const JSON_Object *object, size_t index) { - if (object == NULL || index >= json_object_get_count(object)) { - return NULL; - } - return object->names[index]; +const char *json_object_get_name(const JSON_Object *object, size_t index) { + if (object == NULL || index >= json_object_get_count(object)) { + return NULL; + } + return object->names[index]; } -JSON_Value * json_object_get_value_at(const JSON_Object *object, size_t index) { - if (object == NULL || index >= json_object_get_count(object)) { - return NULL; - } - return object->values[index]; +JSON_Value *json_object_get_value_at(const JSON_Object *object, size_t index) { + if (object == NULL || index >= json_object_get_count(object)) { + return NULL; + } + return object->values[index]; } JSON_Value *json_object_get_wrapping_value(const JSON_Object *object) { - if (!object) { - return NULL; - } - return object->wrapping_value; + if (!object) { + return NULL; + } + return object->wrapping_value; } -int json_object_has_value (const JSON_Object *object, const char *name) { - return json_object_get_value(object, name) != NULL; +int json_object_has_value(const JSON_Object *object, const char *name) { + return json_object_get_value(object, name) != NULL; } int json_object_has_value_of_type(const JSON_Object *object, const char *name, JSON_Value_Type type) { - JSON_Value *val = json_object_get_value(object, name); - return val != NULL && json_value_get_type(val) == type; + JSON_Value *val = json_object_get_value(object, name); + return val != NULL && json_value_get_type(val) == type; } -int json_object_dothas_value (const JSON_Object *object, const char *name) { - return json_object_dotget_value(object, name) != NULL; +int json_object_dothas_value(const JSON_Object *object, const char *name) { + return json_object_dotget_value(object, name) != NULL; } int json_object_dothas_value_of_type(const JSON_Object *object, const char *name, JSON_Value_Type type) { - JSON_Value *val = json_object_dotget_value(object, name); - return val != NULL && json_value_get_type(val) == type; + JSON_Value *val = json_object_dotget_value(object, name); + return val != NULL && json_value_get_type(val) == type; } /* JSON Array API */ -JSON_Value * json_array_get_value(const JSON_Array *array, size_t index) { - if (array == NULL || index >= json_array_get_count(array)) { - return NULL; - } - return array->items[index]; +JSON_Value *json_array_get_value(const JSON_Array *array, size_t index) { + if (array == NULL || index >= json_array_get_count(array)) { + return NULL; + } + return array->items[index]; } -const char * json_array_get_string(const JSON_Array *array, size_t index) { - return json_value_get_string(json_array_get_value(array, index)); +const char *json_array_get_string(const JSON_Array *array, size_t index) { + return json_value_get_string(json_array_get_value(array, index)); } size_t json_array_get_string_len(const JSON_Array *array, size_t index) { - return json_value_get_string_len(json_array_get_value(array, index)); + return json_value_get_string_len(json_array_get_value(array, index)); } double json_array_get_number(const JSON_Array *array, size_t index) { - return json_value_get_number(json_array_get_value(array, index)); + return json_value_get_number(json_array_get_value(array, index)); } -JSON_Object * json_array_get_object(const JSON_Array *array, size_t index) { - return json_value_get_object(json_array_get_value(array, index)); +JSON_Object *json_array_get_object(const JSON_Array *array, size_t index) { + return json_value_get_object(json_array_get_value(array, index)); } -JSON_Array * json_array_get_array(const JSON_Array *array, size_t index) { - return json_value_get_array(json_array_get_value(array, index)); +JSON_Array *json_array_get_array(const JSON_Array *array, size_t index) { + return json_value_get_array(json_array_get_value(array, index)); } int json_array_get_boolean(const JSON_Array *array, size_t index) { - return json_value_get_boolean(json_array_get_value(array, index)); + return json_value_get_boolean(json_array_get_value(array, index)); } size_t json_array_get_count(const JSON_Array *array) { - return array ? array->count : 0; + return array ? array->count : 0; } -JSON_Value * json_array_get_wrapping_value(const JSON_Array *array) { - if (!array) { - return NULL; - } - return array->wrapping_value; +JSON_Value *json_array_get_wrapping_value(const JSON_Array *array) { + if (!array) { + return NULL; + } + return array->wrapping_value; } /* JSON Value API */ JSON_Value_Type json_value_get_type(const JSON_Value *value) { - return value ? value->type : JSONError; + return value ? value->type : JSONError; } -JSON_Object * json_value_get_object(const JSON_Value *value) { - return json_value_get_type(value) == JSONObject ? value->value.object : NULL; +JSON_Object *json_value_get_object(const JSON_Value *value) { + return json_value_get_type(value) == JSONObject ? value->value.object : NULL; } -JSON_Array * json_value_get_array(const JSON_Value *value) { - return json_value_get_type(value) == JSONArray ? value->value.array : NULL; +JSON_Array *json_value_get_array(const JSON_Value *value) { + return json_value_get_type(value) == JSONArray ? value->value.array : NULL; } -static const JSON_String * json_value_get_string_desc(const JSON_Value *value) { - return json_value_get_type(value) == JSONString ? &value->value.string : NULL; +static const JSON_String *json_value_get_string_desc(const JSON_Value *value) { + return json_value_get_type(value) == JSONString ? &value->value.string : NULL; } -const char * json_value_get_string(const JSON_Value *value) { - const JSON_String *str = json_value_get_string_desc(value); - return str ? str->chars : NULL; +const char *json_value_get_string(const JSON_Value *value) { + const JSON_String *str = json_value_get_string_desc(value); + return str ? str->chars : NULL; } size_t json_value_get_string_len(const JSON_Value *value) { - const JSON_String *str = json_value_get_string_desc(value); - return str ? str->length : 0; + const JSON_String *str = json_value_get_string_desc(value); + return str ? str->length : 0; } double json_value_get_number(const JSON_Value *value) { - return json_value_get_type(value) == JSONNumber ? value->value.number : 0; + return json_value_get_type(value) == JSONNumber ? value->value.number : 0; } int json_value_get_boolean(const JSON_Value *value) { - return json_value_get_type(value) == JSONBoolean ? value->value.boolean : -1; + return json_value_get_type(value) == JSONBoolean ? value->value.boolean : -1; } -JSON_Value * json_value_get_parent (const JSON_Value *value) { - return value ? value->parent : NULL; +JSON_Value *json_value_get_parent(const JSON_Value *value) { + return value ? value->parent : NULL; } void json_value_free(JSON_Value *value) { - switch (json_value_get_type(value)) { - case JSONObject: - json_object_free(value->value.object); - break; - case JSONString: - parson_free(value->value.string.chars); - break; - case JSONArray: - json_array_free(value->value.array); - break; - default: - break; - } - parson_free(value); + switch (json_value_get_type(value)) { + case JSONObject: + json_object_free(value->value.object); + break; + case JSONString: + parson_free(value->value.string.chars); + break; + case JSONArray: + json_array_free(value->value.array); + break; + default: + break; + } + parson_free(value); } -JSON_Value * json_value_init_object(void) { - JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); - if (!new_value) { - return NULL; - } - new_value->parent = NULL; - new_value->type = JSONObject; - new_value->value.object = json_object_make(new_value); - if (!new_value->value.object) { - parson_free(new_value); - return NULL; - } - return new_value; +JSON_Value *json_value_init_object(void) { + JSON_Value *new_value = (JSON_Value *)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONObject; + new_value->value.object = json_object_make(new_value); + if (!new_value->value.object) { + parson_free(new_value); + return NULL; + } + return new_value; } -JSON_Value * json_value_init_array(void) { - JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); - if (!new_value) { - return NULL; - } - new_value->parent = NULL; - new_value->type = JSONArray; - new_value->value.array = json_array_make(new_value); - if (!new_value->value.array) { - parson_free(new_value); - return NULL; - } - return new_value; +JSON_Value *json_value_init_array(void) { + JSON_Value *new_value = (JSON_Value *)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONArray; + new_value->value.array = json_array_make(new_value); + if (!new_value->value.array) { + parson_free(new_value); + return NULL; + } + return new_value; } -JSON_Value * json_value_init_string(const char *string) { - if (string == NULL) { - return NULL; - } - return json_value_init_string_with_len(string, strlen(string)); +JSON_Value *json_value_init_string(const char *string) { + if (string == NULL) { + return NULL; + } + return json_value_init_string_with_len(string, strlen(string)); } -JSON_Value * json_value_init_string_with_len(const char *string, size_t length) { - char *copy = NULL; - JSON_Value *value; - if (string == NULL) { - return NULL; - } - if (!is_valid_utf8(string, length)) { - return NULL; - } - copy = parson_strndup(string, length); - if (copy == NULL) { - return NULL; - } - value = json_value_init_string_no_copy(copy, length); - if (value == NULL) { - parson_free(copy); - } - return value; +JSON_Value *json_value_init_string_with_len(const char *string, size_t length) { + char *copy = NULL; + JSON_Value *value; + if (string == NULL) { + return NULL; + } + if (!is_valid_utf8(string, length)) { + return NULL; + } + copy = parson_strndup(string, length); + if (copy == NULL) { + return NULL; + } + value = json_value_init_string_no_copy(copy, length); + if (value == NULL) { + parson_free(copy); + } + return value; } -JSON_Value * json_value_init_number(double number) { - JSON_Value *new_value = NULL; - if (IS_NUMBER_INVALID(number)) { - return NULL; - } - new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); - if (new_value == NULL) { - return NULL; - } - new_value->parent = NULL; - new_value->type = JSONNumber; - new_value->value.number = number; - return new_value; +JSON_Value *json_value_init_number(double number) { + JSON_Value *new_value = NULL; + if (IS_NUMBER_INVALID(number)) { + return NULL; + } + new_value = (JSON_Value *)parson_malloc(sizeof(JSON_Value)); + if (new_value == NULL) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONNumber; + new_value->value.number = number; + return new_value; } -JSON_Value * json_value_init_boolean(int boolean) { - JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); - if (!new_value) { - return NULL; - } - new_value->parent = NULL; - new_value->type = JSONBoolean; - new_value->value.boolean = boolean ? 1 : 0; - return new_value; +JSON_Value *json_value_init_boolean(int boolean) { + JSON_Value *new_value = (JSON_Value *)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONBoolean; + new_value->value.boolean = boolean ? 1 : 0; + return new_value; } -JSON_Value * json_value_init_null(void) { - JSON_Value *new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value)); - if (!new_value) { - return NULL; - } - new_value->parent = NULL; - new_value->type = JSONNull; - return new_value; +JSON_Value *json_value_init_null(void) { + JSON_Value *new_value = (JSON_Value *)parson_malloc(sizeof(JSON_Value)); + if (!new_value) { + return NULL; + } + new_value->parent = NULL; + new_value->type = JSONNull; + return new_value; } -JSON_Value * json_value_deep_copy(const JSON_Value *value) { - size_t i = 0; - JSON_Value *return_value = NULL, *temp_value_copy = NULL, *temp_value = NULL; - const JSON_String *temp_string = NULL; - const char *temp_key = NULL; - char *temp_string_copy = NULL; - JSON_Array *temp_array = NULL, *temp_array_copy = NULL; - JSON_Object *temp_object = NULL, *temp_object_copy = NULL; - JSON_Status res = JSONFailure; - char *key_copy = NULL; +JSON_Value *json_value_deep_copy(const JSON_Value *value) { + size_t i = 0; + JSON_Value *return_value = NULL, *temp_value_copy = NULL, *temp_value = NULL; + const JSON_String *temp_string = NULL; + const char *temp_key = NULL; + char *temp_string_copy = NULL; + JSON_Array *temp_array = NULL, *temp_array_copy = NULL; + JSON_Object *temp_object = NULL, *temp_object_copy = NULL; + JSON_Status res = JSONFailure; + char *key_copy = NULL; - switch (json_value_get_type(value)) { - case JSONArray: - temp_array = json_value_get_array(value); - return_value = json_value_init_array(); - if (return_value == NULL) { - return NULL; - } - temp_array_copy = json_value_get_array(return_value); - for (i = 0; i < json_array_get_count(temp_array); i++) { - temp_value = json_array_get_value(temp_array, i); - temp_value_copy = json_value_deep_copy(temp_value); - if (temp_value_copy == NULL) { - json_value_free(return_value); - return NULL; - } - if (json_array_add(temp_array_copy, temp_value_copy) != JSONSuccess) { - json_value_free(return_value); - json_value_free(temp_value_copy); - return NULL; - } - } - return return_value; - case JSONObject: - temp_object = json_value_get_object(value); - return_value = json_value_init_object(); - if (!return_value) { - return NULL; - } - temp_object_copy = json_value_get_object(return_value); - for (i = 0; i < json_object_get_count(temp_object); i++) { - temp_key = json_object_get_name(temp_object, i); - temp_value = json_object_get_value(temp_object, temp_key); - temp_value_copy = json_value_deep_copy(temp_value); - if (!temp_value_copy) { - json_value_free(return_value); - return NULL; - } - key_copy = parson_strdup(temp_key); - if (!key_copy) { - json_value_free(temp_value_copy); - json_value_free(return_value); - return NULL; - } - res = json_object_add(temp_object_copy, key_copy, temp_value_copy); - if (res != JSONSuccess) { - parson_free(key_copy); - json_value_free(temp_value_copy); - json_value_free(return_value); - return NULL; - } - } - return return_value; - case JSONBoolean: - return json_value_init_boolean(json_value_get_boolean(value)); - case JSONNumber: - return json_value_init_number(json_value_get_number(value)); - case JSONString: - temp_string = json_value_get_string_desc(value); - if (temp_string == NULL) { - return NULL; - } - temp_string_copy = parson_strndup(temp_string->chars, temp_string->length); - if (temp_string_copy == NULL) { - return NULL; - } - return_value = json_value_init_string_no_copy(temp_string_copy, temp_string->length); - if (return_value == NULL) { - parson_free(temp_string_copy); - } - return return_value; - case JSONNull: - return json_value_init_null(); - case JSONError: - return NULL; - default: - return NULL; + switch (json_value_get_type(value)) { + case JSONArray: + temp_array = json_value_get_array(value); + return_value = json_value_init_array(); + if (return_value == NULL) { + return NULL; } + temp_array_copy = json_value_get_array(return_value); + for (i = 0; i < json_array_get_count(temp_array); i++) { + temp_value = json_array_get_value(temp_array, i); + temp_value_copy = json_value_deep_copy(temp_value); + if (temp_value_copy == NULL) { + json_value_free(return_value); + return NULL; + } + if (json_array_add(temp_array_copy, temp_value_copy) != JSONSuccess) { + json_value_free(return_value); + json_value_free(temp_value_copy); + return NULL; + } + } + return return_value; + case JSONObject: + temp_object = json_value_get_object(value); + return_value = json_value_init_object(); + if (!return_value) { + return NULL; + } + temp_object_copy = json_value_get_object(return_value); + for (i = 0; i < json_object_get_count(temp_object); i++) { + temp_key = json_object_get_name(temp_object, i); + temp_value = json_object_get_value(temp_object, temp_key); + temp_value_copy = json_value_deep_copy(temp_value); + if (!temp_value_copy) { + json_value_free(return_value); + return NULL; + } + key_copy = parson_strdup(temp_key); + if (!key_copy) { + json_value_free(temp_value_copy); + json_value_free(return_value); + return NULL; + } + res = json_object_add(temp_object_copy, key_copy, temp_value_copy); + if (res != JSONSuccess) { + parson_free(key_copy); + json_value_free(temp_value_copy); + json_value_free(return_value); + return NULL; + } + } + return return_value; + case JSONBoolean: + return json_value_init_boolean(json_value_get_boolean(value)); + case JSONNumber: + return json_value_init_number(json_value_get_number(value)); + case JSONString: + temp_string = json_value_get_string_desc(value); + if (temp_string == NULL) { + return NULL; + } + temp_string_copy = parson_strndup(temp_string->chars, temp_string->length); + if (temp_string_copy == NULL) { + return NULL; + } + return_value = json_value_init_string_no_copy(temp_string_copy, temp_string->length); + if (return_value == NULL) { + parson_free(temp_string_copy); + } + return return_value; + case JSONNull: + return json_value_init_null(); + case JSONError: + return NULL; + default: + return NULL; + } } size_t json_serialization_size(const JSON_Value *value) { - char num_buf[PARSON_NUM_BUF_SIZE]; /* recursively allocating buffer on stack is a bad idea, so let's do it only once */ - int res = json_serialize_to_buffer_r(value, NULL, 0, PARSON_FALSE, num_buf); - return res < 0 ? 0 : (size_t)(res) + 1; + char num_buf[PARSON_NUM_BUF_SIZE]; /* recursively allocating buffer on stack is a bad idea, so let's do it only once */ + int res = json_serialize_to_buffer_r(value, NULL, 0, PARSON_FALSE, num_buf); + return res < 0 ? 0 : (size_t)(res) + 1; } JSON_Status json_serialize_to_buffer(const JSON_Value *value, char *buf, size_t buf_size_in_bytes) { - int written = -1; - size_t needed_size_in_bytes = json_serialization_size(value); - if (needed_size_in_bytes == 0 || buf_size_in_bytes < needed_size_in_bytes) { - return JSONFailure; - } - written = json_serialize_to_buffer_r(value, buf, 0, PARSON_FALSE, NULL); - if (written < 0) { - return JSONFailure; - } - return JSONSuccess; + int written = -1; + size_t needed_size_in_bytes = json_serialization_size(value); + if (needed_size_in_bytes == 0 || buf_size_in_bytes < needed_size_in_bytes) { + return JSONFailure; + } + written = json_serialize_to_buffer_r(value, buf, 0, PARSON_FALSE, NULL); + if (written < 0) { + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_serialize_to_file(const JSON_Value *value, const char *filename) { - JSON_Status return_code = JSONSuccess; - FILE *fp = NULL; - char *serialized_string = json_serialize_to_string(value); - if (serialized_string == NULL) { - return JSONFailure; - } - fp = fopen(filename, "w"); - if (fp == NULL) { - json_free_serialized_string(serialized_string); - return JSONFailure; - } - if (fputs(serialized_string, fp) == EOF) { - return_code = JSONFailure; - } - if (fclose(fp) == EOF) { - return_code = JSONFailure; - } + JSON_Status return_code = JSONSuccess; + FILE *fp = NULL; + char *serialized_string = json_serialize_to_string(value); + if (serialized_string == NULL) { + return JSONFailure; + } + fp = fopen(filename, "w"); + if (fp == NULL) { json_free_serialized_string(serialized_string); - return return_code; + return JSONFailure; + } + if (fputs(serialized_string, fp) == EOF) { + return_code = JSONFailure; + } + if (fclose(fp) == EOF) { + return_code = JSONFailure; + } + json_free_serialized_string(serialized_string); + return return_code; } -char * json_serialize_to_string(const JSON_Value *value) { - JSON_Status serialization_result = JSONFailure; - size_t buf_size_bytes = json_serialization_size(value); - char *buf = NULL; - if (buf_size_bytes == 0) { - return NULL; - } - buf = (char*)parson_malloc(buf_size_bytes); - if (buf == NULL) { - return NULL; - } - serialization_result = json_serialize_to_buffer(value, buf, buf_size_bytes); - if (serialization_result != JSONSuccess) { - json_free_serialized_string(buf); - return NULL; - } - return buf; +char *json_serialize_to_string(const JSON_Value *value) { + JSON_Status serialization_result = JSONFailure; + size_t buf_size_bytes = json_serialization_size(value); + char *buf = NULL; + if (buf_size_bytes == 0) { + return NULL; + } + buf = (char *)parson_malloc(buf_size_bytes); + if (buf == NULL) { + return NULL; + } + serialization_result = json_serialize_to_buffer(value, buf, buf_size_bytes); + if (serialization_result != JSONSuccess) { + json_free_serialized_string(buf); + return NULL; + } + return buf; } size_t json_serialization_size_pretty(const JSON_Value *value) { - char num_buf[PARSON_NUM_BUF_SIZE]; /* recursively allocating buffer on stack is a bad idea, so let's do it only once */ - int res = json_serialize_to_buffer_r(value, NULL, 0, PARSON_TRUE, num_buf); - return res < 0 ? 0 : (size_t)(res) + 1; + char num_buf[PARSON_NUM_BUF_SIZE]; /* recursively allocating buffer on stack is a bad idea, so let's do it only once */ + int res = json_serialize_to_buffer_r(value, NULL, 0, PARSON_TRUE, num_buf); + return res < 0 ? 0 : (size_t)(res) + 1; } JSON_Status json_serialize_to_buffer_pretty(const JSON_Value *value, char *buf, size_t buf_size_in_bytes) { - int written = -1; - size_t needed_size_in_bytes = json_serialization_size_pretty(value); - if (needed_size_in_bytes == 0 || buf_size_in_bytes < needed_size_in_bytes) { - return JSONFailure; - } - written = json_serialize_to_buffer_r(value, buf, 0, PARSON_TRUE, NULL); - if (written < 0) { - return JSONFailure; - } - return JSONSuccess; + int written = -1; + size_t needed_size_in_bytes = json_serialization_size_pretty(value); + if (needed_size_in_bytes == 0 || buf_size_in_bytes < needed_size_in_bytes) { + return JSONFailure; + } + written = json_serialize_to_buffer_r(value, buf, 0, PARSON_TRUE, NULL); + if (written < 0) { + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_serialize_to_file_pretty(const JSON_Value *value, const char *filename) { - JSON_Status return_code = JSONSuccess; - FILE *fp = NULL; - char *serialized_string = json_serialize_to_string_pretty(value); - if (serialized_string == NULL) { - return JSONFailure; - } - fp = fopen(filename, "w"); - if (fp == NULL) { - json_free_serialized_string(serialized_string); - return JSONFailure; - } - if (fputs(serialized_string, fp) == EOF) { - return_code = JSONFailure; - } - if (fclose(fp) == EOF) { - return_code = JSONFailure; - } + JSON_Status return_code = JSONSuccess; + FILE *fp = NULL; + char *serialized_string = json_serialize_to_string_pretty(value); + if (serialized_string == NULL) { + return JSONFailure; + } + fp = fopen(filename, "w"); + if (fp == NULL) { json_free_serialized_string(serialized_string); - return return_code; + return JSONFailure; + } + if (fputs(serialized_string, fp) == EOF) { + return_code = JSONFailure; + } + if (fclose(fp) == EOF) { + return_code = JSONFailure; + } + json_free_serialized_string(serialized_string); + return return_code; } -char * json_serialize_to_string_pretty(const JSON_Value *value) { - JSON_Status serialization_result = JSONFailure; - size_t buf_size_bytes = json_serialization_size_pretty(value); - char *buf = NULL; - if (buf_size_bytes == 0) { - return NULL; - } - buf = (char*)parson_malloc(buf_size_bytes); - if (buf == NULL) { - return NULL; - } - serialization_result = json_serialize_to_buffer_pretty(value, buf, buf_size_bytes); - if (serialization_result != JSONSuccess) { - json_free_serialized_string(buf); - return NULL; - } - return buf; +char *json_serialize_to_string_pretty(const JSON_Value *value) { + JSON_Status serialization_result = JSONFailure; + size_t buf_size_bytes = json_serialization_size_pretty(value); + char *buf = NULL; + if (buf_size_bytes == 0) { + return NULL; + } + buf = (char *)parson_malloc(buf_size_bytes); + if (buf == NULL) { + return NULL; + } + serialization_result = json_serialize_to_buffer_pretty(value, buf, buf_size_bytes); + if (serialization_result != JSONSuccess) { + json_free_serialized_string(buf); + return NULL; + } + return buf; } void json_free_serialized_string(char *string) { - parson_free(string); + parson_free(string); } JSON_Status json_array_remove(JSON_Array *array, size_t ix) { - size_t to_move_bytes = 0; - if (array == NULL || ix >= json_array_get_count(array)) { - return JSONFailure; - } - json_value_free(json_array_get_value(array, ix)); - to_move_bytes = (json_array_get_count(array) - 1 - ix) * sizeof(JSON_Value*); - memmove(array->items + ix, array->items + ix + 1, to_move_bytes); - array->count -= 1; - return JSONSuccess; + size_t to_move_bytes = 0; + if (array == NULL || ix >= json_array_get_count(array)) { + return JSONFailure; + } + json_value_free(json_array_get_value(array, ix)); + to_move_bytes = (json_array_get_count(array) - 1 - ix) * sizeof(JSON_Value *); + memmove(array->items + ix, array->items + ix + 1, to_move_bytes); + array->count -= 1; + return JSONSuccess; } JSON_Status json_array_replace_value(JSON_Array *array, size_t ix, JSON_Value *value) { - if (array == NULL || value == NULL || value->parent != NULL || ix >= json_array_get_count(array)) { - return JSONFailure; - } - json_value_free(json_array_get_value(array, ix)); - value->parent = json_array_get_wrapping_value(array); - array->items[ix] = value; - return JSONSuccess; + if (array == NULL || value == NULL || value->parent != NULL || ix >= json_array_get_count(array)) { + return JSONFailure; + } + json_value_free(json_array_get_value(array, ix)); + value->parent = json_array_get_wrapping_value(array); + array->items[ix] = value; + return JSONSuccess; } -JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char* string) { - JSON_Value *value = json_value_init_string(string); - if (value == NULL) { - return JSONFailure; - } - if (json_array_replace_value(array, i, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; +JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char *string) { + JSON_Value *value = json_value_init_string(string); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_replace_string_with_len(JSON_Array *array, size_t i, const char *string, size_t len) { - JSON_Value *value = json_value_init_string_with_len(string, len); - if (value == NULL) { - return JSONFailure; - } - if (json_array_replace_value(array, i, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_string_with_len(string, len); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_replace_number(JSON_Array *array, size_t i, double number) { - JSON_Value *value = json_value_init_number(number); - if (value == NULL) { - return JSONFailure; - } - if (json_array_replace_value(array, i, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_number(number); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_replace_boolean(JSON_Array *array, size_t i, int boolean) { - JSON_Value *value = json_value_init_boolean(boolean); - if (value == NULL) { - return JSONFailure; - } - if (json_array_replace_value(array, i, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_boolean(boolean); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_replace_null(JSON_Array *array, size_t i) { - JSON_Value *value = json_value_init_null(); - if (value == NULL) { - return JSONFailure; - } - if (json_array_replace_value(array, i, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_null(); + if (value == NULL) { + return JSONFailure; + } + if (json_array_replace_value(array, i, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_clear(JSON_Array *array) { - size_t i = 0; - if (array == NULL) { - return JSONFailure; - } - for (i = 0; i < json_array_get_count(array); i++) { - json_value_free(json_array_get_value(array, i)); - } - array->count = 0; - return JSONSuccess; + size_t i = 0; + if (array == NULL) { + return JSONFailure; + } + for (i = 0; i < json_array_get_count(array); i++) { + json_value_free(json_array_get_value(array, i)); + } + array->count = 0; + return JSONSuccess; } JSON_Status json_array_append_value(JSON_Array *array, JSON_Value *value) { - if (array == NULL || value == NULL || value->parent != NULL) { - return JSONFailure; - } - return json_array_add(array, value); + if (array == NULL || value == NULL || value->parent != NULL) { + return JSONFailure; + } + return json_array_add(array, value); } JSON_Status json_array_append_string(JSON_Array *array, const char *string) { - JSON_Value *value = json_value_init_string(string); - if (value == NULL) { - return JSONFailure; - } - if (json_array_append_value(array, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_string(string); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_append_string_with_len(JSON_Array *array, const char *string, size_t len) { - JSON_Value *value = json_value_init_string_with_len(string, len); - if (value == NULL) { - return JSONFailure; - } - if (json_array_append_value(array, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_string_with_len(string, len); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_append_number(JSON_Array *array, double number) { - JSON_Value *value = json_value_init_number(number); - if (value == NULL) { - return JSONFailure; - } - if (json_array_append_value(array, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_number(number); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_append_boolean(JSON_Array *array, int boolean) { - JSON_Value *value = json_value_init_boolean(boolean); - if (value == NULL) { - return JSONFailure; - } - if (json_array_append_value(array, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_boolean(boolean); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_array_append_null(JSON_Array *array) { - JSON_Value *value = json_value_init_null(); - if (value == NULL) { - return JSONFailure; - } - if (json_array_append_value(array, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_null(); + if (value == NULL) { + return JSONFailure; + } + if (json_array_append_value(array, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value) { - unsigned long hash = 0; - parson_bool_t found = PARSON_FALSE; - size_t cell_ix = 0; - size_t item_ix = 0; - JSON_Value *old_value = NULL; - char *key_copy = NULL; + unsigned long hash = 0; + parson_bool_t found = PARSON_FALSE; + size_t cell_ix = 0; + size_t item_ix = 0; + JSON_Value *old_value = NULL; + char *key_copy = NULL; - if (!object || !name || !value || value->parent) { - return JSONFailure; - } - hash = hash_string(name, strlen(name)); - found = PARSON_FALSE; - cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found); - if (found) { - item_ix = object->cells[cell_ix]; - old_value = object->values[item_ix]; - json_value_free(old_value); - object->values[item_ix] = value; - value->parent = json_object_get_wrapping_value(object); - return JSONSuccess; - } - if (object->count >= object->item_capacity) { - JSON_Status res = json_object_grow_and_rehash(object); - if (res != JSONSuccess) { - return JSONFailure; - } - cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found); - } - key_copy = parson_strdup(name); - if (!key_copy) { - return JSONFailure; - } - object->names[object->count] = key_copy; - object->cells[cell_ix] = object->count; - object->values[object->count] = value; - object->cell_ixs[object->count] = cell_ix; - object->hashes[object->count] = hash; - object->count++; + if (!object || !name || !value || value->parent) { + return JSONFailure; + } + hash = hash_string(name, strlen(name)); + found = PARSON_FALSE; + cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found); + if (found) { + item_ix = object->cells[cell_ix]; + old_value = object->values[item_ix]; + json_value_free(old_value); + object->values[item_ix] = value; value->parent = json_object_get_wrapping_value(object); return JSONSuccess; + } + if (object->count >= object->item_capacity) { + JSON_Status res = json_object_grow_and_rehash(object); + if (res != JSONSuccess) { + return JSONFailure; + } + cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found); + } + key_copy = parson_strdup(name); + if (!key_copy) { + return JSONFailure; + } + object->names[object->count] = key_copy; + object->cells[cell_ix] = object->count; + object->values[object->count] = value; + object->cell_ixs[object->count] = cell_ix; + object->hashes[object->count] = hash; + object->count++; + value->parent = json_object_get_wrapping_value(object); + return JSONSuccess; } JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string) { - JSON_Value *value = json_value_init_string(string); - JSON_Status status = json_object_set_value(object, name, value); - if (status != JSONSuccess) { - json_value_free(value); - } - return status; + JSON_Value *value = json_value_init_string(string); + JSON_Status status = json_object_set_value(object, name, value); + if (status != JSONSuccess) { + json_value_free(value); + } + return status; } JSON_Status json_object_set_string_with_len(JSON_Object *object, const char *name, const char *string, size_t len) { - JSON_Value *value = json_value_init_string_with_len(string, len); - JSON_Status status = json_object_set_value(object, name, value); - if (status != JSONSuccess) { - json_value_free(value); - } - return status; + JSON_Value *value = json_value_init_string_with_len(string, len); + JSON_Status status = json_object_set_value(object, name, value); + if (status != JSONSuccess) { + json_value_free(value); + } + return status; } JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number) { - JSON_Value *value = json_value_init_number(number); - JSON_Status status = json_object_set_value(object, name, value); - if (status != JSONSuccess) { - json_value_free(value); - } - return status; + JSON_Value *value = json_value_init_number(number); + JSON_Status status = json_object_set_value(object, name, value); + if (status != JSONSuccess) { + json_value_free(value); + } + return status; } JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean) { - JSON_Value *value = json_value_init_boolean(boolean); - JSON_Status status = json_object_set_value(object, name, value); - if (status != JSONSuccess) { - json_value_free(value); - } - return status; + JSON_Value *value = json_value_init_boolean(boolean); + JSON_Status status = json_object_set_value(object, name, value); + if (status != JSONSuccess) { + json_value_free(value); + } + return status; } JSON_Status json_object_set_null(JSON_Object *object, const char *name) { - JSON_Value *value = json_value_init_null(); - JSON_Status status = json_object_set_value(object, name, value); - if (status != JSONSuccess) { - json_value_free(value); - } - return status; + JSON_Value *value = json_value_init_null(); + JSON_Status status = json_object_set_value(object, name, value); + if (status != JSONSuccess) { + json_value_free(value); + } + return status; } JSON_Status json_object_dotset_value(JSON_Object *object, const char *name, JSON_Value *value) { - const char *dot_pos = NULL; - JSON_Value *temp_value = NULL, *new_value = NULL; - JSON_Object *temp_object = NULL, *new_object = NULL; - JSON_Status status = JSONFailure; - size_t name_len = 0; - char *name_copy = NULL; - - if (object == NULL || name == NULL || value == NULL) { - return JSONFailure; + const char *dot_pos = NULL; + JSON_Value *temp_value = NULL, *new_value = NULL; + JSON_Object *temp_object = NULL, *new_object = NULL; + JSON_Status status = JSONFailure; + size_t name_len = 0; + char *name_copy = NULL; + + if (object == NULL || name == NULL || value == NULL) { + return JSONFailure; + } + dot_pos = strchr(name, '.'); + if (dot_pos == NULL) { + return json_object_set_value(object, name, value); + } + name_len = dot_pos - name; + temp_value = json_object_getn_value(object, name, name_len); + if (temp_value) { + /* Don't overwrite existing non-object (unlike json_object_set_value, but it shouldn't be changed at this point) */ + if (json_value_get_type(temp_value) != JSONObject) { + return JSONFailure; } - dot_pos = strchr(name, '.'); - if (dot_pos == NULL) { - return json_object_set_value(object, name, value); - } - name_len = dot_pos - name; - temp_value = json_object_getn_value(object, name, name_len); - if (temp_value) { - /* Don't overwrite existing non-object (unlike json_object_set_value, but it shouldn't be changed at this point) */ - if (json_value_get_type(temp_value) != JSONObject) { - return JSONFailure; - } - temp_object = json_value_get_object(temp_value); - return json_object_dotset_value(temp_object, dot_pos + 1, value); - } - new_value = json_value_init_object(); - if (new_value == NULL) { - return JSONFailure; - } - new_object = json_value_get_object(new_value); - status = json_object_dotset_value(new_object, dot_pos + 1, value); - if (status != JSONSuccess) { - json_value_free(new_value); - return JSONFailure; - } - name_copy = parson_strndup(name, name_len); - if (!name_copy) { - json_object_dotremove_internal(new_object, dot_pos + 1, 0); - json_value_free(new_value); - return JSONFailure; - } - status = json_object_add(object, name_copy, new_value); - if (status != JSONSuccess) { - parson_free(name_copy); - json_object_dotremove_internal(new_object, dot_pos + 1, 0); - json_value_free(new_value); - return JSONFailure; - } - return JSONSuccess; + temp_object = json_value_get_object(temp_value); + return json_object_dotset_value(temp_object, dot_pos + 1, value); + } + new_value = json_value_init_object(); + if (new_value == NULL) { + return JSONFailure; + } + new_object = json_value_get_object(new_value); + status = json_object_dotset_value(new_object, dot_pos + 1, value); + if (status != JSONSuccess) { + json_value_free(new_value); + return JSONFailure; + } + name_copy = parson_strndup(name, name_len); + if (!name_copy) { + json_object_dotremove_internal(new_object, dot_pos + 1, 0); + json_value_free(new_value); + return JSONFailure; + } + status = json_object_add(object, name_copy, new_value); + if (status != JSONSuccess) { + parson_free(name_copy); + json_object_dotremove_internal(new_object, dot_pos + 1, 0); + json_value_free(new_value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_object_dotset_string(JSON_Object *object, const char *name, const char *string) { - JSON_Value *value = json_value_init_string(string); - if (value == NULL) { - return JSONFailure; - } - if (json_object_dotset_value(object, name, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_string(string); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_object_dotset_string_with_len(JSON_Object *object, const char *name, const char *string, size_t len) { - JSON_Value *value = json_value_init_string_with_len(string, len); - if (value == NULL) { - return JSONFailure; - } - if (json_object_dotset_value(object, name, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_string_with_len(string, len); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_object_dotset_number(JSON_Object *object, const char *name, double number) { - JSON_Value *value = json_value_init_number(number); - if (value == NULL) { - return JSONFailure; - } - if (json_object_dotset_value(object, name, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_number(number); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_object_dotset_boolean(JSON_Object *object, const char *name, int boolean) { - JSON_Value *value = json_value_init_boolean(boolean); - if (value == NULL) { - return JSONFailure; - } - if (json_object_dotset_value(object, name, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_boolean(boolean); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_object_dotset_null(JSON_Object *object, const char *name) { - JSON_Value *value = json_value_init_null(); - if (value == NULL) { - return JSONFailure; - } - if (json_object_dotset_value(object, name, value) != JSONSuccess) { - json_value_free(value); - return JSONFailure; - } - return JSONSuccess; + JSON_Value *value = json_value_init_null(); + if (value == NULL) { + return JSONFailure; + } + if (json_object_dotset_value(object, name, value) != JSONSuccess) { + json_value_free(value); + return JSONFailure; + } + return JSONSuccess; } JSON_Status json_object_remove(JSON_Object *object, const char *name) { - return json_object_remove_internal(object, name, PARSON_TRUE); + return json_object_remove_internal(object, name, PARSON_TRUE); } JSON_Status json_object_dotremove(JSON_Object *object, const char *name) { - return json_object_dotremove_internal(object, name, PARSON_TRUE); + return json_object_dotremove_internal(object, name, PARSON_TRUE); } JSON_Status json_object_clear(JSON_Object *object) { - size_t i = 0; - if (object == NULL) { - return JSONFailure; - } - for (i = 0; i < json_object_get_count(object); i++) { - parson_free(object->names[i]); - json_value_free(object->values[i]); - } - object->count = 0; - return JSONSuccess; + size_t i = 0; + if (object == NULL) { + return JSONFailure; + } + for (i = 0; i < json_object_get_count(object); i++) { + parson_free(object->names[i]); + json_value_free(object->values[i]); + } + object->count = 0; + return JSONSuccess; } JSON_Status json_validate(const JSON_Value *schema, const JSON_Value *value) { - JSON_Value *temp_schema_value = NULL, *temp_value = NULL; - JSON_Array *schema_array = NULL, *value_array = NULL; - JSON_Object *schema_object = NULL, *value_object = NULL; - JSON_Value_Type schema_type = JSONError, value_type = JSONError; - const char *key = NULL; - size_t i = 0, count = 0; - if (schema == NULL || value == NULL) { + JSON_Value *temp_schema_value = NULL, *temp_value = NULL; + JSON_Array *schema_array = NULL, *value_array = NULL; + JSON_Object *schema_object = NULL, *value_object = NULL; + JSON_Value_Type schema_type = JSONError, value_type = JSONError; + const char *key = NULL; + size_t i = 0, count = 0; + if (schema == NULL || value == NULL) { + return JSONFailure; + } + schema_type = json_value_get_type(schema); + value_type = json_value_get_type(value); + if (schema_type != value_type && schema_type != JSONNull) { /* null represents all values */ + return JSONFailure; + } + switch (schema_type) { + case JSONArray: + schema_array = json_value_get_array(schema); + value_array = json_value_get_array(value); + count = json_array_get_count(schema_array); + if (count == 0) { + return JSONSuccess; /* Empty array allows all types */ + } + /* Get first value from array, rest is ignored */ + temp_schema_value = json_array_get_value(schema_array, 0); + for (i = 0; i < json_array_get_count(value_array); i++) { + temp_value = json_array_get_value(value_array, i); + if (json_validate(temp_schema_value, temp_value) != JSONSuccess) { return JSONFailure; + } } - schema_type = json_value_get_type(schema); - value_type = json_value_get_type(value); - if (schema_type != value_type && schema_type != JSONNull) { /* null represents all values */ + return JSONSuccess; + case JSONObject: + schema_object = json_value_get_object(schema); + value_object = json_value_get_object(value); + count = json_object_get_count(schema_object); + if (count == 0) { + return JSONSuccess; /* Empty object allows all objects */ + } else if (json_object_get_count(value_object) < count) { + return JSONFailure; /* Tested object mustn't have less name-value pairs than schema */ + } + for (i = 0; i < count; i++) { + key = json_object_get_name(schema_object, i); + temp_schema_value = json_object_get_value(schema_object, key); + temp_value = json_object_get_value(value_object, key); + if (temp_value == NULL) { return JSONFailure; + } + if (json_validate(temp_schema_value, temp_value) != JSONSuccess) { + return JSONFailure; + } } - switch (schema_type) { - case JSONArray: - schema_array = json_value_get_array(schema); - value_array = json_value_get_array(value); - count = json_array_get_count(schema_array); - if (count == 0) { - return JSONSuccess; /* Empty array allows all types */ - } - /* Get first value from array, rest is ignored */ - temp_schema_value = json_array_get_value(schema_array, 0); - for (i = 0; i < json_array_get_count(value_array); i++) { - temp_value = json_array_get_value(value_array, i); - if (json_validate(temp_schema_value, temp_value) != JSONSuccess) { - return JSONFailure; - } - } - return JSONSuccess; - case JSONObject: - schema_object = json_value_get_object(schema); - value_object = json_value_get_object(value); - count = json_object_get_count(schema_object); - if (count == 0) { - return JSONSuccess; /* Empty object allows all objects */ - } else if (json_object_get_count(value_object) < count) { - return JSONFailure; /* Tested object mustn't have less name-value pairs than schema */ - } - for (i = 0; i < count; i++) { - key = json_object_get_name(schema_object, i); - temp_schema_value = json_object_get_value(schema_object, key); - temp_value = json_object_get_value(value_object, key); - if (temp_value == NULL) { - return JSONFailure; - } - if (json_validate(temp_schema_value, temp_value) != JSONSuccess) { - return JSONFailure; - } - } - return JSONSuccess; - case JSONString: case JSONNumber: case JSONBoolean: case JSONNull: - return JSONSuccess; /* equality already tested before switch */ - case JSONError: default: - return JSONFailure; - } + return JSONSuccess; + case JSONString: + case JSONNumber: + case JSONBoolean: + case JSONNull: + return JSONSuccess; /* equality already tested before switch */ + case JSONError: + default: + return JSONFailure; + } } int json_value_equals(const JSON_Value *a, const JSON_Value *b) { - JSON_Object *a_object = NULL, *b_object = NULL; - JSON_Array *a_array = NULL, *b_array = NULL; - const JSON_String *a_string = NULL, *b_string = NULL; - const char *key = NULL; - size_t a_count = 0, b_count = 0, i = 0; - JSON_Value_Type a_type, b_type; - a_type = json_value_get_type(a); - b_type = json_value_get_type(b); - if (a_type != b_type) { + JSON_Object *a_object = NULL, *b_object = NULL; + JSON_Array *a_array = NULL, *b_array = NULL; + const JSON_String *a_string = NULL, *b_string = NULL; + const char *key = NULL; + size_t a_count = 0, b_count = 0, i = 0; + JSON_Value_Type a_type, b_type; + a_type = json_value_get_type(a); + b_type = json_value_get_type(b); + if (a_type != b_type) { + return PARSON_FALSE; + } + switch (a_type) { + case JSONArray: + a_array = json_value_get_array(a); + b_array = json_value_get_array(b); + a_count = json_array_get_count(a_array); + b_count = json_array_get_count(b_array); + if (a_count != b_count) { + return PARSON_FALSE; + } + for (i = 0; i < a_count; i++) { + if (!json_value_equals(json_array_get_value(a_array, i), + json_array_get_value(b_array, i))) { return PARSON_FALSE; + } } - switch (a_type) { - case JSONArray: - a_array = json_value_get_array(a); - b_array = json_value_get_array(b); - a_count = json_array_get_count(a_array); - b_count = json_array_get_count(b_array); - if (a_count != b_count) { - return PARSON_FALSE; - } - for (i = 0; i < a_count; i++) { - if (!json_value_equals(json_array_get_value(a_array, i), - json_array_get_value(b_array, i))) { - return PARSON_FALSE; - } - } - return PARSON_TRUE; - case JSONObject: - a_object = json_value_get_object(a); - b_object = json_value_get_object(b); - a_count = json_object_get_count(a_object); - b_count = json_object_get_count(b_object); - if (a_count != b_count) { - return PARSON_FALSE; - } - for (i = 0; i < a_count; i++) { - key = json_object_get_name(a_object, i); - if (!json_value_equals(json_object_get_value(a_object, key), - json_object_get_value(b_object, key))) { - return PARSON_FALSE; - } - } - return PARSON_TRUE; - case JSONString: - a_string = json_value_get_string_desc(a); - b_string = json_value_get_string_desc(b); - if (a_string == NULL || b_string == NULL) { - return PARSON_FALSE; /* shouldn't happen */ - } - return a_string->length == b_string->length && - memcmp(a_string->chars, b_string->chars, a_string->length) == 0; - case JSONBoolean: - return json_value_get_boolean(a) == json_value_get_boolean(b); - case JSONNumber: - return fabs(json_value_get_number(a) - json_value_get_number(b)) < 0.000001; /* EPSILON */ - case JSONError: - return PARSON_TRUE; - case JSONNull: - return PARSON_TRUE; - default: - return PARSON_TRUE; + return PARSON_TRUE; + case JSONObject: + a_object = json_value_get_object(a); + b_object = json_value_get_object(b); + a_count = json_object_get_count(a_object); + b_count = json_object_get_count(b_object); + if (a_count != b_count) { + return PARSON_FALSE; } + for (i = 0; i < a_count; i++) { + key = json_object_get_name(a_object, i); + if (!json_value_equals(json_object_get_value(a_object, key), + json_object_get_value(b_object, key))) { + return PARSON_FALSE; + } + } + return PARSON_TRUE; + case JSONString: + a_string = json_value_get_string_desc(a); + b_string = json_value_get_string_desc(b); + if (a_string == NULL || b_string == NULL) { + return PARSON_FALSE; /* shouldn't happen */ + } + return a_string->length == b_string->length && + memcmp(a_string->chars, b_string->chars, a_string->length) == 0; + case JSONBoolean: + return json_value_get_boolean(a) == json_value_get_boolean(b); + case JSONNumber: + return fabs(json_value_get_number(a) - json_value_get_number(b)) < 0.000001; /* EPSILON */ + case JSONError: + return PARSON_TRUE; + case JSONNull: + return PARSON_TRUE; + default: + return PARSON_TRUE; + } } JSON_Value_Type json_type(const JSON_Value *value) { - return json_value_get_type(value); + return json_value_get_type(value); } -JSON_Object * json_object (const JSON_Value *value) { - return json_value_get_object(value); +JSON_Object *json_object(const JSON_Value *value) { + return json_value_get_object(value); } -JSON_Array * json_array(const JSON_Value *value) { - return json_value_get_array(value); +JSON_Array *json_array(const JSON_Value *value) { + return json_value_get_array(value); } -const char * json_string(const JSON_Value *value) { - return json_value_get_string(value); +const char *json_string(const JSON_Value *value) { + return json_value_get_string(value); } size_t json_string_len(const JSON_Value *value) { - return json_value_get_string_len(value); + return json_value_get_string_len(value); } double json_number(const JSON_Value *value) { - return json_value_get_number(value); + return json_value_get_number(value); } int json_boolean(const JSON_Value *value) { - return json_value_get_boolean(value); + return json_value_get_boolean(value); } void json_set_allocation_functions(JSON_Malloc_Function malloc_fun, JSON_Free_Function free_fun) { - parson_malloc = malloc_fun; - parson_free = free_fun; + parson_malloc = malloc_fun; + parson_free = free_fun; } void json_set_escape_slashes(int escape_slashes) { - parson_escape_slashes = escape_slashes; + parson_escape_slashes = escape_slashes; } void json_set_float_serialization_format(const char *format) { - if (parson_float_format) { - parson_free(parson_float_format); - } - if (!format) { - parson_float_format = NULL; - return; - } - parson_float_format = parson_strdup(format); + if (parson_float_format) { + parson_free(parson_float_format); + } + if (!format) { + parson_float_format = NULL; + return; + } + parson_float_format = parson_strdup(format); } diff --git a/source/engine/parson.h b/source/engine/parson.h index fa431f9..81bc110 100644 --- a/source/engine/parson.h +++ b/source/engine/parson.h @@ -27,8 +27,7 @@ #define parson_parson_h #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #if 0 } /* unconfuse xcode */ @@ -40,32 +39,32 @@ extern "C" #define PARSON_VERSION_STRING "1.4.0" -#include /* size_t */ +#include /* size_t */ /* Types and enums */ typedef struct json_object_t JSON_Object; -typedef struct json_array_t JSON_Array; -typedef struct json_value_t JSON_Value; +typedef struct json_array_t JSON_Array; +typedef struct json_value_t JSON_Value; enum json_value_type { - JSONError = -1, - JSONNull = 1, - JSONString = 2, - JSONNumber = 3, - JSONObject = 4, - JSONArray = 5, - JSONBoolean = 6 + JSONError = -1, + JSONNull = 1, + JSONString = 2, + JSONNumber = 3, + JSONObject = 4, + JSONArray = 5, + JSONBoolean = 6 }; typedef int JSON_Value_Type; enum json_result_t { - JSONSuccess = 0, - JSONFailure = -1 + JSONSuccess = 0, + JSONFailure = -1 }; typedef int JSON_Status; -typedef void * (*JSON_Malloc_Function)(size_t); -typedef void (*JSON_Free_Function)(void *); +typedef void *(*JSON_Malloc_Function)(size_t); +typedef void (*JSON_Free_Function)(void *); /* Call only once, before calling any other function from parson API. If not called, malloc and free from stdlib will be used for all allocations */ @@ -81,35 +80,35 @@ void json_set_escape_slashes(int escape_slashes); void json_set_float_serialization_format(const char *format); /* Parses first JSON value in a file, returns NULL in case of error */ -JSON_Value * json_parse_file(const char *filename); +JSON_Value *json_parse_file(const char *filename); /* Parses first JSON value in a file and ignores comments (/ * * / and //), returns NULL in case of error */ -JSON_Value * json_parse_file_with_comments(const char *filename); +JSON_Value *json_parse_file_with_comments(const char *filename); /* Parses first JSON value in a string, returns NULL in case of error */ -JSON_Value * json_parse_string(const char *string); +JSON_Value *json_parse_string(const char *string); /* Parses first JSON value in a string and ignores comments (/ * * / and //), returns NULL in case of error */ -JSON_Value * json_parse_string_with_comments(const char *string); +JSON_Value *json_parse_string_with_comments(const char *string); /* Serialization */ -size_t json_serialization_size(const JSON_Value *value); /* returns 0 on fail */ +size_t json_serialization_size(const JSON_Value *value); /* returns 0 on fail */ JSON_Status json_serialize_to_buffer(const JSON_Value *value, char *buf, size_t buf_size_in_bytes); JSON_Status json_serialize_to_file(const JSON_Value *value, const char *filename); -char * json_serialize_to_string(const JSON_Value *value); +char *json_serialize_to_string(const JSON_Value *value); /* Pretty serialization */ -size_t json_serialization_size_pretty(const JSON_Value *value); /* returns 0 on fail */ +size_t json_serialization_size_pretty(const JSON_Value *value); /* returns 0 on fail */ JSON_Status json_serialize_to_buffer_pretty(const JSON_Value *value, char *buf, size_t buf_size_in_bytes); JSON_Status json_serialize_to_file_pretty(const JSON_Value *value, const char *filename); -char * json_serialize_to_string_pretty(const JSON_Value *value); +char *json_serialize_to_string_pretty(const JSON_Value *value); -void json_free_serialized_string(char *string); /* frees string from json_serialize_to_string and json_serialize_to_string_pretty */ +void json_free_serialized_string(char *string); /* frees string from json_serialize_to_string and json_serialize_to_string_pretty */ /* Comparing */ -int json_value_equals(const JSON_Value *a, const JSON_Value *b); +int json_value_equals(const JSON_Value *a, const JSON_Value *b); /* Validation This is *NOT* JSON Schema. It validates json by checking if object have identically @@ -126,45 +125,45 @@ JSON_Status json_validate(const JSON_Value *schema, const JSON_Value *value); /* * JSON Object */ -JSON_Value * json_object_get_value (const JSON_Object *object, const char *name); -const char * json_object_get_string (const JSON_Object *object, const char *name); -size_t json_object_get_string_len(const JSON_Object *object, const char *name); /* doesn't account for last null character */ -JSON_Object * json_object_get_object (const JSON_Object *object, const char *name); -JSON_Array * json_object_get_array (const JSON_Object *object, const char *name); -double json_object_get_number (const JSON_Object *object, const char *name); /* returns 0 on fail */ -int json_object_get_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */ +JSON_Value *json_object_get_value(const JSON_Object *object, const char *name); +const char *json_object_get_string(const JSON_Object *object, const char *name); +size_t json_object_get_string_len(const JSON_Object *object, const char *name); /* doesn't account for last null character */ +JSON_Object *json_object_get_object(const JSON_Object *object, const char *name); +JSON_Array *json_object_get_array(const JSON_Object *object, const char *name); +double json_object_get_number(const JSON_Object *object, const char *name); /* returns 0 on fail */ +int json_object_get_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */ /* dotget functions enable addressing values with dot notation in nested objects, just like in structs or c++/java/c# objects (e.g. objectA.objectB.value). Because valid names in JSON can contain dots, some values may be inaccessible this way. */ -JSON_Value * json_object_dotget_value (const JSON_Object *object, const char *name); -const char * json_object_dotget_string (const JSON_Object *object, const char *name); -size_t json_object_dotget_string_len(const JSON_Object *object, const char *name); /* doesn't account for last null character */ -JSON_Object * json_object_dotget_object (const JSON_Object *object, const char *name); -JSON_Array * json_object_dotget_array (const JSON_Object *object, const char *name); -double json_object_dotget_number (const JSON_Object *object, const char *name); /* returns 0 on fail */ -int json_object_dotget_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */ +JSON_Value *json_object_dotget_value(const JSON_Object *object, const char *name); +const char *json_object_dotget_string(const JSON_Object *object, const char *name); +size_t json_object_dotget_string_len(const JSON_Object *object, const char *name); /* doesn't account for last null character */ +JSON_Object *json_object_dotget_object(const JSON_Object *object, const char *name); +JSON_Array *json_object_dotget_array(const JSON_Object *object, const char *name); +double json_object_dotget_number(const JSON_Object *object, const char *name); /* returns 0 on fail */ +int json_object_dotget_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */ /* Functions to get available names */ -size_t json_object_get_count (const JSON_Object *object); -const char * json_object_get_name (const JSON_Object *object, size_t index); -JSON_Value * json_object_get_value_at(const JSON_Object *object, size_t index); -JSON_Value * json_object_get_wrapping_value(const JSON_Object *object); +size_t json_object_get_count(const JSON_Object *object); +const char *json_object_get_name(const JSON_Object *object, size_t index); +JSON_Value *json_object_get_value_at(const JSON_Object *object, size_t index); +JSON_Value *json_object_get_wrapping_value(const JSON_Object *object); /* Functions to check if object has a value with a specific name. Returned value is 1 if object has * a value and 0 if it doesn't. dothas functions behave exactly like dotget functions. */ -int json_object_has_value (const JSON_Object *object, const char *name); +int json_object_has_value(const JSON_Object *object, const char *name); int json_object_has_value_of_type(const JSON_Object *object, const char *name, JSON_Value_Type type); -int json_object_dothas_value (const JSON_Object *object, const char *name); +int json_object_dothas_value(const JSON_Object *object, const char *name); int json_object_dothas_value_of_type(const JSON_Object *object, const char *name, JSON_Value_Type type); /* Creates new name-value pair or frees and replaces old value with a new one. * json_object_set_value does not copy passed value so it shouldn't be freed afterwards. */ JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value); JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string); -JSON_Status json_object_set_string_with_len(JSON_Object *object, const char *name, const char *string, size_t len); /* length shouldn't include last null character */ +JSON_Status json_object_set_string_with_len(JSON_Object *object, const char *name, const char *string, size_t len); /* length shouldn't include last null character */ JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number); JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean); JSON_Status json_object_set_null(JSON_Object *object, const char *name); @@ -190,15 +189,15 @@ JSON_Status json_object_clear(JSON_Object *object); /* *JSON Array */ -JSON_Value * json_array_get_value (const JSON_Array *array, size_t index); -const char * json_array_get_string (const JSON_Array *array, size_t index); -size_t json_array_get_string_len(const JSON_Array *array, size_t index); /* doesn't account for last null character */ -JSON_Object * json_array_get_object (const JSON_Array *array, size_t index); -JSON_Array * json_array_get_array (const JSON_Array *array, size_t index); -double json_array_get_number (const JSON_Array *array, size_t index); /* returns 0 on fail */ -int json_array_get_boolean(const JSON_Array *array, size_t index); /* returns -1 on fail */ -size_t json_array_get_count (const JSON_Array *array); -JSON_Value * json_array_get_wrapping_value(const JSON_Array *array); +JSON_Value *json_array_get_value(const JSON_Array *array, size_t index); +const char *json_array_get_string(const JSON_Array *array, size_t index); +size_t json_array_get_string_len(const JSON_Array *array, size_t index); /* doesn't account for last null character */ +JSON_Object *json_array_get_object(const JSON_Array *array, size_t index); +JSON_Array *json_array_get_array(const JSON_Array *array, size_t index); +double json_array_get_number(const JSON_Array *array, size_t index); /* returns 0 on fail */ +int json_array_get_boolean(const JSON_Array *array, size_t index); /* returns -1 on fail */ +size_t json_array_get_count(const JSON_Array *array); +JSON_Value *json_array_get_wrapping_value(const JSON_Array *array); /* Frees and removes value at given index, does nothing and returns JSONFailure if index doesn't exist. * Order of values in array may change during execution. */ @@ -208,7 +207,7 @@ JSON_Status json_array_remove(JSON_Array *array, size_t i); * Does nothing and returns JSONFailure if index doesn't exist. * json_array_replace_value does not copy passed value so it shouldn't be freed afterwards. */ JSON_Status json_array_replace_value(JSON_Array *array, size_t i, JSON_Value *value); -JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char* string); +JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char *string); JSON_Status json_array_replace_string_with_len(JSON_Array *array, size_t i, const char *string, size_t len); /* length shouldn't include last null character */ JSON_Status json_array_replace_number(JSON_Array *array, size_t i, double number); JSON_Status json_array_replace_boolean(JSON_Array *array, size_t i, int boolean); @@ -229,33 +228,33 @@ JSON_Status json_array_append_null(JSON_Array *array); /* *JSON Value */ -JSON_Value * json_value_init_object (void); -JSON_Value * json_value_init_array (void); -JSON_Value * json_value_init_string (const char *string); /* copies passed string */ -JSON_Value * json_value_init_string_with_len(const char *string, size_t length); /* copies passed string, length shouldn't include last null character */ -JSON_Value * json_value_init_number (double number); -JSON_Value * json_value_init_boolean(int boolean); -JSON_Value * json_value_init_null (void); -JSON_Value * json_value_deep_copy (const JSON_Value *value); -void json_value_free (JSON_Value *value); +JSON_Value *json_value_init_object(void); +JSON_Value *json_value_init_array(void); +JSON_Value *json_value_init_string(const char *string); /* copies passed string */ +JSON_Value *json_value_init_string_with_len(const char *string, size_t length); /* copies passed string, length shouldn't include last null character */ +JSON_Value *json_value_init_number(double number); +JSON_Value *json_value_init_boolean(int boolean); +JSON_Value *json_value_init_null(void); +JSON_Value *json_value_deep_copy(const JSON_Value *value); +void json_value_free(JSON_Value *value); -JSON_Value_Type json_value_get_type (const JSON_Value *value); -JSON_Object * json_value_get_object (const JSON_Value *value); -JSON_Array * json_value_get_array (const JSON_Value *value); -const char * json_value_get_string (const JSON_Value *value); -size_t json_value_get_string_len(const JSON_Value *value); /* doesn't account for last null character */ -double json_value_get_number (const JSON_Value *value); -int json_value_get_boolean(const JSON_Value *value); -JSON_Value * json_value_get_parent (const JSON_Value *value); +JSON_Value_Type json_value_get_type(const JSON_Value *value); +JSON_Object *json_value_get_object(const JSON_Value *value); +JSON_Array *json_value_get_array(const JSON_Value *value); +const char *json_value_get_string(const JSON_Value *value); +size_t json_value_get_string_len(const JSON_Value *value); /* doesn't account for last null character */ +double json_value_get_number(const JSON_Value *value); +int json_value_get_boolean(const JSON_Value *value); +JSON_Value *json_value_get_parent(const JSON_Value *value); /* Same as above, but shorter */ -JSON_Value_Type json_type (const JSON_Value *value); -JSON_Object * json_object (const JSON_Value *value); -JSON_Array * json_array (const JSON_Value *value); -const char * json_string (const JSON_Value *value); -size_t json_string_len(const JSON_Value *value); /* doesn't account for last null character */ -double json_number (const JSON_Value *value); -int json_boolean(const JSON_Value *value); +JSON_Value_Type json_type(const JSON_Value *value); +JSON_Object *json_object(const JSON_Value *value); +JSON_Array *json_array(const JSON_Value *value); +const char *json_string(const JSON_Value *value); +size_t json_string_len(const JSON_Value *value); /* doesn't account for last null character */ +double json_number(const JSON_Value *value); +int json_boolean(const JSON_Value *value); #ifdef __cplusplus } diff --git a/source/engine/particle.c b/source/engine/particle.c index 58aad74..3185f53 100644 --- a/source/engine/particle.c +++ b/source/engine/particle.c @@ -1,58 +1,48 @@ #include "particle.h" #include "stb_ds.h" -struct emitter make_emitter() -{ - struct emitter e = { 0 }; - return e; +struct emitter make_emitter() { + struct emitter e = {0}; + return e; } -struct emitter set_emitter(struct emitter e) -{ - arrsetlen(e.particles, e.max); +struct emitter set_emitter(struct emitter e) { + arrsetlen(e.particles, e.max); - e.first = &e.particles[0]; + e.first = &e.particles[0]; - for (int i = 0; i < arrlen(e.particles)-1; i++) { - e.particles[i].next = &e.particles[i+1]; - } - - return e; -} - -void free_emitter(struct emitter e) -{ - arrfree(e.particles); -} - -void start_emitter(struct emitter e) -{ - -} - -void pause_emitter(struct emitter e) -{ - -} - -void stop_emitter(struct emitter e) -{ - -} - -void emitter_step(struct emitter e, double dt) -{ - for (int i = 0; i < arrlen(e.particles); i++) { - if (e.particles[i].life <= 0) - continue; - - e.particles[i].pos = cpvadd(e.particles[i].pos, cpvmult(e.particles[i].v, dt)); - e.particles[i].angle += e.particles[i].av * dt; - e.particles[i].life -= dt; - - if (e.particles[i].life <= 0) { - e.particles[i].next = e.first; - e.first = &e.particles[i]; - } + for (int i = 0; i < arrlen(e.particles) - 1; i++) { + e.particles[i].next = &e.particles[i + 1]; + } + + return e; +} + +void free_emitter(struct emitter e) { + arrfree(e.particles); +} + +void start_emitter(struct emitter e) { +} + +void pause_emitter(struct emitter e) { +} + +void stop_emitter(struct emitter e) { +} + +void emitter_step(struct emitter e, double dt) { + for (int i = 0; i < arrlen(e.particles); i++) { + if (e.particles[i].life <= 0) + continue; + + e.particles[i].pos = cpvadd(e.particles[i].pos, cpvmult(e.particles[i].v, dt)); + e.particles[i].angle += e.particles[i].av * dt; + e.particles[i].life -= dt; + + if (e.particles[i].life <= 0) { + e.particles[i].next = e.first; + e.first = &e.particles[i]; } + } } diff --git a/source/engine/resources.c b/source/engine/resources.c index 29d3ec9..9503e02 100644 --- a/source/engine/resources.c +++ b/source/engine/resources.c @@ -1,17 +1,17 @@ #include "resources.h" #include "config.h" -#include -#include -#include -#include -#include "vec.h" -#include -#include -#include -#include -#include #include "log.h" +#include "vec.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -31,111 +31,101 @@ static const char *cur_ext = NULL; struct dirent *c_dirent = NULL; struct vec *c_vec = NULL; -char pathbuf[MAXPATH+1]; +char pathbuf[MAXPATH + 1]; -void resources_init() -{ - prefabs = vec_make(MAXNAME, 25); +void resources_init() { + prefabs = vec_make(MAXNAME, 25); - DATA_PATH = malloc(MAXPATH); - getcwd(DATA_PATH, MAXPATH); - strncat(DATA_PATH, "/", MAXPATH); + DATA_PATH = malloc(MAXPATH); + getcwd(DATA_PATH, MAXPATH); + strncat(DATA_PATH, "/", MAXPATH); - if (!PREF_PATH) - PREF_PATH = strdup("./tmp/"); + if (!PREF_PATH) + PREF_PATH = strdup("./tmp/"); } -char *get_filename_from_path(char *path, int extension) -{ - char *dirpos = strrchr(path, '/'); - if (!dirpos) - dirpos = path; +char *get_filename_from_path(char *path, int extension) { + char *dirpos = strrchr(path, '/'); + if (!dirpos) + dirpos = path; - char *end = strrchr(path, '\0'); + char *end = strrchr(path, '\0'); - int offset = 0; - if (!extension) { - char *ext = strrchr(path, '.'); - offset = end - ext; - YughInfo("Making %s without extension ..."); - } + int offset = 0; + if (!extension) { + char *ext = strrchr(path, '.'); + offset = end - ext; + YughInfo("Making %s without extension ..."); + } - char *filename = malloc(sizeof(char) * (end - dirpos - offset + 1)); - strncpy(filename, dirpos, end - dirpos - offset); - return filename; + char *filename = malloc(sizeof(char) * (end - dirpos - offset + 1)); + strncpy(filename, dirpos, end - dirpos - offset); + return filename; } -char *get_directory_from_path(char *path) -{ - const char *dirpos = strrchr(path, '/'); - char *directory = (char *) malloc(sizeof(char) * (dirpos - path + 1)); - strncpy(directory, path, dirpos - path); - return directory; +char *get_directory_from_path(char *path) { + const char *dirpos = strrchr(path, '/'); + char *directory = (char *)malloc(sizeof(char) * (dirpos - path + 1)); + strncpy(directory, path, dirpos - path); + return directory; } -FILE *res_open(char *path, const char *tag) -{ - strncpy(pathbuf, DATA_PATH, MAXPATH); - strncat(pathbuf, path, MAXPATH); - FILE *f = fopen(pathbuf, tag); - return f; +FILE *res_open(char *path, const char *tag) { + strncpy(pathbuf, DATA_PATH, MAXPATH); + strncat(pathbuf, path, MAXPATH); + FILE *f = fopen(pathbuf, tag); + return f; } -static int ext_check(const char *path, const struct stat *sb, int typeflag) -{ - if (typeflag == FTW_F) { - const char *ext = strrchr(path, '.'); - if (ext != NULL && !strcmp(ext, cur_ext)) - vec_add(c_vec, path); - } +static int ext_check(const char *path, const struct stat *sb, int typeflag) { + if (typeflag == FTW_F) { + const char *ext = strrchr(path, '.'); + if (ext != NULL && !strcmp(ext, cur_ext)) + vec_add(c_vec, path); + } - return 0; + return 0; } -void fill_extensions(struct vec *vec, const char *path, const char *ext) -{ - c_vec = vec; - cur_ext = ext; - vec_clear(c_vec); - ftw(".", ext_check, 10); +void fill_extensions(struct vec *vec, const char *path, const char *ext) { + c_vec = vec; + cur_ext = ext; + vec_clear(c_vec); + ftw(".", ext_check, 10); } -void findPrefabs() -{ - fill_extensions(prefabs, DATA_PATH, EXT_PREFAB); +void findPrefabs() { + fill_extensions(prefabs, DATA_PATH, EXT_PREFAB); } char *str_replace_ext(const char *s, const char *newext) { - static char ret[256]; + static char ret[256]; - strncpy(ret, s, 256); - char *ext = strrchr(ret, '.'); - strncpy(ext, newext, 10); + strncpy(ret, s, 256); + char *ext = strrchr(ret, '.'); + strncpy(ext, newext, 10); - return ret; + return ret; } -FILE *path_open(const char *tag, const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - vsprintf(pathbuf, fmt, args); - va_end(args); +FILE *path_open(const char *tag, const char *fmt, ...) { + va_list args; + va_start(args, fmt); + vsprintf(pathbuf, fmt, args); + va_end(args); - FILE *f = fopen(pathbuf, tag); - return f; + FILE *f = fopen(pathbuf, tag); + return f; } -char *make_path(const char *file) -{ - strncpy(pathbuf, DATA_PATH, MAXPATH); - strncat(pathbuf, file, MAXPATH); - return pathbuf; +char *make_path(const char *file) { + strncpy(pathbuf, DATA_PATH, MAXPATH); + strncat(pathbuf, file, MAXPATH); + return pathbuf; } -char *strdup(const char *s) -{ - char *new = malloc(sizeof(char)*(strlen(s)+1)); - strcpy(new, s); - return new; +char *strdup(const char *s) { + char *new = malloc(sizeof(char) * (strlen(s) + 1)); + strcpy(new, s); + return new; } diff --git a/source/engine/resources.h b/source/engine/resources.h index e11f610..b0a9241 100644 --- a/source/engine/resources.h +++ b/source/engine/resources.h @@ -1,8 +1,6 @@ #ifndef RESOURCES_H #define RESOURCES_H - - #include struct vec; diff --git a/source/engine/script.c b/source/engine/script.c index 069bf98..55216a8 100644 --- a/source/engine/script.c +++ b/source/engine/script.c @@ -1,7 +1,7 @@ #include "script.h" -#include "stdio.h" #include "log.h" +#include "stdio.h" #include "ffi.h" #include "font.h" @@ -10,39 +10,38 @@ #include "stb_ds.h" -#include "time.h" #include "sys/stat.h" #include "sys/types.h" +#include "time.h" JSContext *js = NULL; JSRuntime *rt = NULL; static int load_prefab(const char *fpath, const struct stat *sb, int typeflag) { - if (typeflag != FTW_F) - return 0; - - if (!strcmp(".prefab", strrchr(fpath, '.'))) - script_dofile(fpath); - + if (typeflag != FTW_F) return 0; + + if (!strcmp(".prefab", strrchr(fpath, '.'))) + script_dofile(fpath); + + return 0; } -void script_startup() -{ - rt = JS_NewRuntime(); - JS_SetMaxStackSize(rt,0); - js = JS_NewContext(rt); - ffi_load(); +void script_startup() { + rt = JS_NewRuntime(); + JS_SetMaxStackSize(rt, 0); + js = JS_NewContext(rt); + ffi_load(); } JSValue num_cache[100] = {0}; void script_init() { - /* Load all prefabs into memory */ - script_dofile("scripts/engine.js"); + /* Load all prefabs into memory */ + script_dofile("scripts/engine.js"); - for (int i = 0; i < 100; i++) - num_cache[i] = int2js(i); + for (int i = 0; i < 100; i++) + num_cache[i] = int2js(i); } void script_run(const char *script) { @@ -52,72 +51,68 @@ void script_run(const char *script) { struct callee stacktrace_callee; time_t file_mod_secs(const char *file) { - struct stat attr; - stat(file, &attr); - return attr.st_mtime; + struct stat attr; + stat(file, &attr); + return attr.st_mtime; } -void js_stacktrace() -{ +void js_stacktrace() { call_callee(&stacktrace_callee); return; } -void js_dump_stack() -{ +void js_dump_stack() { js_stacktrace(); return; - + JSValue exception = JS_GetException(js); if (JS_IsNull(exception)) return; JSValue val = JS_GetPropertyStr(js, exception, "stack"); if (!JS_IsUndefined(val)) { const char *name = JS_ToCString(js, JS_GetPropertyStr(js, exception, "name")); const char *msg = JS_ToCString(js, JS_GetPropertyStr(js, exception, "message")); - const char *stack = JS_ToCString(js, val); - YughError("%s :: %s\n%s", name, msg, stack); + const char *stack = JS_ToCString(js, val); + YughError("%s :: %s\n%s", name, msg, stack); - JS_FreeCString(js, name); - JS_FreeCString(js, msg); - JS_FreeCString(js, stack); - } + JS_FreeCString(js, name); + JS_FreeCString(js, msg); + JS_FreeCString(js, stack); + } } +int js_print_exception(JSValue v) { + if (JS_IsException(v)) { + JSValue exception = JS_GetException(js); + JSValue val = JS_GetPropertyStr(js, exception, "stack"); + if (!JS_IsUndefined(val)) { + const char *name = JS_ToCString(js, JS_GetPropertyStr(js, exception, "name")); + const char *msg = JS_ToCString(js, JS_GetPropertyStr(js, exception, "message")); + const char *stack = JS_ToCString(js, val); + YughWarn("%s :: %s\n%s", name, msg, stack); -int js_print_exception(JSValue v) -{ - if (JS_IsException(v)) { - JSValue exception = JS_GetException(js); - JSValue val = JS_GetPropertyStr(js, exception, "stack"); - if (!JS_IsUndefined(val)) { - const char *name = JS_ToCString(js, JS_GetPropertyStr(js, exception, "name")); - const char *msg = JS_ToCString(js, JS_GetPropertyStr(js, exception, "message")); - const char *stack = JS_ToCString(js, val); - YughWarn("%s :: %s\n%s", name, msg, stack); + JS_FreeCString(js, name); + JS_FreeCString(js, msg); + JS_FreeCString(js, stack); + } - JS_FreeCString(js, name); - JS_FreeCString(js, msg); - JS_FreeCString(js, stack); - } - - return 1; - } - - return 0; + return 1; + } + + return 0; } int script_dofile(const char *file) { - YughInfo("Doing script %s", file); - const char *script = slurp_text(file); - if (!script) { - YughError("Can't find file %s.", file); - return 0; - } - JSValue obj = JS_Eval(js, script, strlen(script), file, 0); - js_print_exception(obj); - JS_FreeValue(js, obj); + YughInfo("Doing script %s", file); + const char *script = slurp_text(file); + if (!script) { + YughError("Can't find file %s.", file); + return 0; + } + JSValue obj = JS_Eval(js, script, strlen(script), file, 0); + js_print_exception(obj); + JS_FreeValue(js, obj); - return file_mod_secs(file); + return file_mod_secs(file); } /* env is an object in the scripting environment; @@ -129,17 +124,14 @@ void script_eval_w_env(const char *s, JSValue env) { JS_FreeValue(js, v); } -void script_call_sym(JSValue sym) -{ +void script_call_sym(JSValue sym) { struct callee c; c.fn = sym; c.obj = JS_GetGlobalObject(js); call_callee(&c); } - -JSValue js_callee_exec(struct callee *c, int argc, JSValue *argv) -{ +JSValue js_callee_exec(struct callee *c, int argc, JSValue *argv) { JSValue ret = JS_Call(js, c->fn, c->obj, argc, argv); js_print_exception(ret); JS_FreeValue(js, ret); @@ -150,29 +142,25 @@ void call_callee(struct callee *c) { js_callee_exec(c, 0, NULL); } -void callee_dbl(struct callee c, double d) -{ +void callee_dbl(struct callee c, double d) { JSValue v = num2js(d); js_callee_exec(&c, 1, &v); JS_FreeValue(js, v); } -void callee_int(struct callee c, int i) -{ +void callee_int(struct callee c, int i) { JSValue v = int2js(i); js_callee_exec(&c, 1, &v); JS_FreeValue(js, v); } -void callee_vec2(struct callee c, cpVect vec) -{ +void callee_vec2(struct callee c, cpVect vec) { JSValue v = vec2js(vec); js_callee_exec(&c, 1, &v); JS_FreeValue(js, v); } -void script_callee(struct callee c, int argc, JSValue *argv) -{ +void script_callee(struct callee c, int argc, JSValue *argv) { js_callee_exec(&c, argc, argv); } @@ -193,7 +181,7 @@ void register_nk_gui(struct callee c) { nk_gui_callee = c; } void call_nk_gui() { js_callee_exec(&nk_gui_callee, 0, NULL); } static struct callee physupdate_callee; -void register_physics(struct callee c) { physupdate_callee = c;} +void register_physics(struct callee c) { physupdate_callee = c; } void call_physics(double dt) { callee_dbl(physupdate_callee, dt); } struct callee debug_callee; diff --git a/source/engine/shader.c b/source/engine/shader.c index f1426d1..dfc7245 100644 --- a/source/engine/shader.c +++ b/source/engine/shader.c @@ -1,15 +1,15 @@ #include "shader.h" -#include "render.h" #include "config.h" -#include -#include -#include +#include "font.h" #include "log.h" +#include "render.h" #include "resources.h" #include "stb_ds.h" #include "timer.h" -#include "font.h" +#include +#include +#include #include "time.h" @@ -17,110 +17,104 @@ static struct shader *shaders; -struct shader *MakeShader(const char *vertpath, const char *fragpath) -{ - if (arrcap(shaders) == 0) - arrsetcap(shaders, 20); +struct shader *MakeShader(const char *vertpath, const char *fragpath) { + if (arrcap(shaders) == 0) + arrsetcap(shaders, 20); - struct shader init = { - .vertpath = vertpath, - .fragpath = fragpath }; - shader_compile(&init); - arrput(shaders, init); - return &arrlast(shaders); + struct shader init = { + .vertpath = vertpath, + .fragpath = fragpath}; + shader_compile(&init); + arrput(shaders, init); + return &arrlast(shaders); } -int shader_compile_error(int shader) -{ -/* - GLint success = 0; - GLchar infoLog[ERROR_BUFFER] = { '\0' }; +int shader_compile_error(int shader) { + /* + GLint success = 0; + GLchar infoLog[ERROR_BUFFER] = { '\0' }; - glGetShaderiv(shader, GL_COMPILE_STATUS, &success); - if (success) return 0; + glGetShaderiv(shader, GL_COMPILE_STATUS, &success); + if (success) return 0; - glGetShaderInfoLog(shader, ERROR_BUFFER, NULL, infoLog); - YughLog(0, LOG_ERROR, "Shader compilation error.\nLog: %s", infoLog); + glGetShaderInfoLog(shader, ERROR_BUFFER, NULL, infoLog); + YughLog(0, LOG_ERROR, "Shader compilation error.\nLog: %s", infoLog); - return 1; -*/ + return 1; + */ } -int shader_link_error(int shader) -{ -/* - GLint success = 0; - GLchar infoLog[ERROR_BUFFER] = { '\0' }; +int shader_link_error(int shader) { + /* + GLint success = 0; + GLchar infoLog[ERROR_BUFFER] = { '\0' }; - glGetProgramiv(shader, GL_LINK_STATUS, &success); - if (success) return 0; + glGetProgramiv(shader, GL_LINK_STATUS, &success); + if (success) return 0; - glGetProgramInfoLog(shader, ERROR_BUFFER, NULL, infoLog); - YughLog(0, LOG_ERROR, "Shader link error.\nLog: %s", infoLog); + glGetProgramInfoLog(shader, ERROR_BUFFER, NULL, infoLog); + YughLog(0, LOG_ERROR, "Shader link error.\nLog: %s", infoLog); - return 1; -*/ + return 1; + */ } -int load_shader_from_file(const char *path, int type) -{ - char spath[MAXPATH] = {'\0'}; +int load_shader_from_file(const char *path, int type) { + char spath[MAXPATH] = {'\0'}; - sprintf(spath, "%s%s", "shaders/", path); - FILE *f = fopen(make_path(spath), "r'"); - if (!path) - perror(spath), exit(1); + sprintf(spath, "%s%s", "shaders/", path); + FILE *f = fopen(make_path(spath), "r'"); + if (!path) + perror(spath), exit(1); - char *buf; - long int fsize; - fseek(f, 0, SEEK_END); - fsize = ftell(f); - buf = malloc(fsize+1); - rewind(f); - size_t r = fread(buf, sizeof(char), fsize, f); - buf[r] = '\0'; + char *buf; + long int fsize; + fseek(f, 0, SEEK_END); + fsize = ftell(f); + buf = malloc(fsize + 1); + rewind(f); + size_t r = fread(buf, sizeof(char), fsize, f); + buf[r] = '\0'; - fclose(f); + fclose(f); -/* - GLuint id = glCreateShader(type); - const char *code = buf; - glShaderSource(id, 1, &code, NULL); - glCompileShader(id); - if (shader_compile_error(id)) { - YughError("Error with shader %s.", path); - return 0; - } + /* + GLuint id = glCreateShader(type); + const char *code = buf; + glShaderSource(id, 1, &code, NULL); + glCompileShader(id); + if (shader_compile_error(id)) { + YughError("Error with shader %s.", path); + return 0; + } - free(buf); - + free(buf); - return id; - */ + + return id; + */ } -void shader_compile(struct shader *shader) -{ - YughInfo("Making shader with %s and %s.", shader->vertpath, shader->fragpath); - char spath[MAXPATH]; - sprintf(spath,"%s%s", "shaders/", shader->vertpath); - const char *vsrc = slurp_text(spath); - sprintf(spath, "%s%s", "shaders/", shader->fragpath); - const char *fsrc = slurp_text(spath); +void shader_compile(struct shader *shader) { + YughInfo("Making shader with %s and %s.", shader->vertpath, shader->fragpath); + char spath[MAXPATH]; + sprintf(spath, "%s%s", "shaders/", shader->vertpath); + const char *vsrc = slurp_text(spath); + sprintf(spath, "%s%s", "shaders/", shader->fragpath); + const char *fsrc = slurp_text(spath); - shader->shd = sg_make_shader(&(sg_shader_desc){ + shader->shd = sg_make_shader(&(sg_shader_desc){ .vs.source = vsrc, .fs.source = fsrc, .label = shader->vertpath, - }); - - free(vsrc); - free(fsrc); + }); + + free(vsrc); + free(fsrc); } -void shader_use(struct shader *shader) -{ -// glUseProgram(shader->id); +void shader_use(struct shader *shader) { + // glUseProgram(shader->id); } /* void shader_setbool(struct shader *shader, const char *name, int val) @@ -171,16 +165,13 @@ void shader_setUBO(struct shader *shader, const char *name, unsigned int index) */ -void shader_compile_all() -{ - for (int i = 0; i < arrlen(shaders); i++) - shader_compile(&shaders[i]); +void shader_compile_all() { + for (int i = 0; i < arrlen(shaders); i++) + shader_compile(&shaders[i]); } -void shader_setvec3(struct shader *shader, const char *name, mfloat_t val[3]) -{ -// glUniform3fv(glGetUniformLocation(shader->id, name), 1, val); +void shader_setvec3(struct shader *shader, const char *name, mfloat_t val[3]) { + // glUniform3fv(glGetUniformLocation(shader->id, name), 1, val); } -void shader_setmat4(struct shader *shader, const char *name, mfloat_t val[16]) -{ -// glUniformMatrix4fv(glGetUniformLocation(shader->id, name), 1, GL_FALSE, val); +void shader_setmat4(struct shader *shader, const char *name, mfloat_t val[16]) { + // glUniformMatrix4fv(glGetUniformLocation(shader->id, name), 1, GL_FALSE, val); } diff --git a/source/engine/shader.h b/source/engine/shader.h index e9f8c7e..a1e102f 100644 --- a/source/engine/shader.h +++ b/source/engine/shader.h @@ -5,9 +5,9 @@ #include "sokol/sokol_gfx.h" struct shader { - sg_shader shd; - const char *vertpath; - const char *fragpath; + sg_shader shd; + const char *vertpath; + const char *fragpath; }; void shader_compile_all(); diff --git a/source/engine/sound.c b/source/engine/sound.c index 5e54b4b..fa4331b 100644 --- a/source/engine/sound.c +++ b/source/engine/sound.c @@ -1,20 +1,20 @@ #include "sound.h" -#include "resources.h" -#include -#include "log.h" -#include "string.h" -#include "math.h" #include "limits.h" -#include "time.h" +#include "log.h" +#include "math.h" #include "music.h" +#include "resources.h" #include "stb_vorbis.h" +#include "string.h" +#include "time.h" +#include #include "samplerate.h" #include "stb_ds.h" -#include "mix.h" #include "dsp.h" +#include "mix.h" #include "miniaudio.h" @@ -25,85 +25,81 @@ #include "tml.h" static struct { - char *key; - struct wav *value; + char *key; + struct wav *value; } *wavhash = NULL; -static struct wav change_channels(struct wav w, int ch) -{ - short *data = w.data; - int samples = ch * w.frames; - short *new = malloc(sizeof(short)*samples); +static struct wav change_channels(struct wav w, int ch) { + short *data = w.data; + int samples = ch * w.frames; + short *new = malloc(sizeof(short) * samples); - if (ch > w.ch) { - /* Sets all new channels equal to the first one */ - for (int i = 0; i < w.frames; i++) { - for (int j = 0; j < ch; j++) - new[i*ch+j] = data[i]; - } - } else { - /* Simple method; just use first N channels present in wav */ - for (int i = 0; i < w.frames; i++) - for (int j = 0; j < ch; j++) - new[i*ch+j] = data[i*ch+j]; + if (ch > w.ch) { + /* Sets all new channels equal to the first one */ + for (int i = 0; i < w.frames; i++) { + for (int j = 0; j < ch; j++) + new[i * ch + j] = data[i]; } + } else { + /* Simple method; just use first N channels present in wav */ + for (int i = 0; i < w.frames; i++) + for (int j = 0; j < ch; j++) + new[i * ch + j] = data[i * ch + j]; + } - free (w.data); - w.data = new; - return w; + free(w.data); + w.data = new; + return w; } -static struct wav change_samplerate(struct wav w, int rate) -{ - float ratio = (float)rate/w.samplerate; - int outframes = w.frames * ratio; - SRC_DATA ssrc; - float floatdata[w.frames*w.ch]; - src_short_to_float_array(w.data, floatdata, w.frames*w.ch); - float resampled[w.ch*outframes]; +static struct wav change_samplerate(struct wav w, int rate) { + float ratio = (float)rate / w.samplerate; + int outframes = w.frames * ratio; + SRC_DATA ssrc; + float floatdata[w.frames * w.ch]; + src_short_to_float_array(w.data, floatdata, w.frames * w.ch); + float resampled[w.ch * outframes]; - ssrc.data_in = floatdata; - ssrc.data_out = resampled; - ssrc.input_frames = w.frames; - ssrc.output_frames = outframes; - ssrc.src_ratio = ratio; + ssrc.data_in = floatdata; + ssrc.data_out = resampled; + ssrc.input_frames = w.frames; + ssrc.output_frames = outframes; + ssrc.src_ratio = ratio; - src_simple(&ssrc, SRC_SINC_BEST_QUALITY, w.ch); + src_simple(&ssrc, SRC_SINC_BEST_QUALITY, w.ch); - short *newdata = malloc(sizeof(short)*outframes*w.ch); - src_float_to_short_array(resampled, newdata, outframes*w.ch); + short *newdata = malloc(sizeof(short) * outframes * w.ch); + src_float_to_short_array(resampled, newdata, outframes * w.ch); - free(w.data); - w.data = newdata; - w.samplerate = rate; + free(w.data); + w.data = newdata; + w.samplerate = rate; - return w; + return w; } -void wav_norm_gain(struct wav *w, double lv) -{ - short tarmax = db2short(lv); - short max = 0; - short *s = w->data; - for (int i = 0; i < w->frames; i++) { - for (int j = 0; j < w->ch; j++) { - max = (abs(s[i*w->ch + j]) > max) ? abs(s[i*w->ch + j]) : max; - } +void wav_norm_gain(struct wav *w, double lv) { + short tarmax = db2short(lv); + short max = 0; + short *s = w->data; + for (int i = 0; i < w->frames; i++) { + for (int j = 0; j < w->ch; j++) { + max = (abs(s[i * w->ch + j]) > max) ? abs(s[i * w->ch + j]) : max; } + } - float mult = (float)max / tarmax; + float mult = (float)max / tarmax; - for (int i = 0; i < w->frames; i++) { - for (int j = 0; j < w->ch; j++) { - s[i*w->ch + j] *= mult; - } + for (int i = 0; i < w->frames; i++) { + for (int j = 0; j < w->ch; j++) { + s[i * w->ch + j] *= mult; } + } } static ma_engine *engine; -void sound_init() -{ +void sound_init() { ma_result result; engine = malloc(sizeof(*engine)); result = ma_engine_init(NULL, engine); @@ -111,66 +107,61 @@ void sound_init() return; } return; - + mixer_init(); } -struct wav *make_sound(const char *wav) -{ - int index = shgeti(wavhash, wav); - if (index != -1) return wavhash[index].value; +struct wav *make_sound(const char *wav) { + int index = shgeti(wavhash, wav); + if (index != -1) return wavhash[index].value; - struct wav mwav; -// mwav.data = drwav_open_file_and_read_pcm_frames_s16(wav, &mwav.ch, &mwav.samplerate, &mwav.frames, NULL); + struct wav mwav; + // mwav.data = drwav_open_file_and_read_pcm_frames_s16(wav, &mwav.ch, &mwav.samplerate, &mwav.frames, NULL); - if (mwav.samplerate != SAMPLERATE) { - YughInfo("Changing samplerate of %s from %d to %d.", wav, mwav.samplerate, SAMPLERATE); -// mwav = change_samplerate(mwav, SAMPLERATE); - } + if (mwav.samplerate != SAMPLERATE) { + YughInfo("Changing samplerate of %s from %d to %d.", wav, mwav.samplerate, SAMPLERATE); + // mwav = change_samplerate(mwav, SAMPLERATE); + } - if (mwav.ch != CHANNELS) { - YughInfo("Changing channels of %s from %d to %d.", wav, mwav.ch, CHANNELS); - mwav = change_channels(mwav, CHANNELS); - } + if (mwav.ch != CHANNELS) { + YughInfo("Changing channels of %s from %d to %d.", wav, mwav.ch, CHANNELS); + mwav = change_channels(mwav, CHANNELS); + } - mwav.gain = 1.f; + mwav.gain = 1.f; - struct wav *newwav = malloc(sizeof(*newwav)); - *newwav = mwav; + struct wav *newwav = malloc(sizeof(*newwav)); + *newwav = mwav; - if (shlen(wavhash) == 0) sh_new_arena(wavhash); + if (shlen(wavhash) == 0) sh_new_arena(wavhash); - shput(wavhash, wav, newwav); + shput(wavhash, wav, newwav); - return newwav; + return newwav; } -void free_sound(const char *wav) -{ - struct wav *w = shget(wavhash, wav); - if (w == NULL) return; +void free_sound(const char *wav) { + struct wav *w = shget(wavhash, wav); + if (w == NULL) return; - free(w->data); - free(w); - shdel(wavhash, wav); + free(w->data); + free(w); + shdel(wavhash, wav); } -struct soundstream *soundstream_make() -{ - struct soundstream *new = malloc(sizeof(*new)); - new->buf = circbuf_make(sizeof(short), BUF_FRAMES*CHANNELS*2); - return new; +struct soundstream *soundstream_make() { + struct soundstream *new = malloc(sizeof(*new)); + new->buf = circbuf_make(sizeof(short), BUF_FRAMES * CHANNELS * 2); + return new; } -void mini_sound(char *path) -{ +void mini_sound(char *path) { ma_engine_play_sound(engine, path, NULL); } static ma_sound music_sound; -void mini_music_play(char *path) -{ +void mini_music_play(char *path) { ma_sound_uninit(&music_sound); int result = ma_sound_init_from_file(engine, path, MA_SOUND_FLAG_NO_SPATIALIZATION, NULL, NULL, &music_sound); if (result != MA_SUCCESS) { @@ -181,163 +172,139 @@ void mini_music_play(char *path) ma_sound_start(&music_sound); } -void mini_music_pause() -{ +void mini_music_pause() { ma_sound_stop(&music_sound); } -void mini_music_stop() -{ +void mini_music_stop() { ma_sound_stop(&music_sound); } -void mini_master(float v) -{ +void mini_master(float v) { ma_engine_set_volume(engine, v); } -void kill_oneshot(struct sound *s) -{ - free(s); +void kill_oneshot(struct sound *s) { + free(s); } void play_oneshot(struct wav *wav) { - struct sound *new = malloc(sizeof(*new)); - new->data = wav; - new->bus = first_free_bus(dsp_filter(new, sound_fillbuf)); - new->playing=1; - new->loop=0; - new->frame = 0; - new->endcb = kill_oneshot; - + struct sound *new = malloc(sizeof(*new)); + new->data = wav; + new->bus = first_free_bus(dsp_filter(new, sound_fillbuf)); + new->playing = 1; + new->loop = 0; + new->frame = 0; + new->endcb = kill_oneshot; } -struct sound *play_sound(struct wav *wav) -{ - struct sound *new = calloc(1, sizeof(*new)); - new->data = wav; +struct sound *play_sound(struct wav *wav) { + struct sound *new = calloc(1, sizeof(*new)); + new->data = wav; - new->bus = first_free_bus(dsp_filter(new, sound_fillbuf)); - new->playing = 1; + new->bus = first_free_bus(dsp_filter(new, sound_fillbuf)); + new->playing = 1; - return new; + return new; } -int sound_playing(const struct sound *s) -{ - return s->playing; +int sound_playing(const struct sound *s) { + return s->playing; } -int sound_paused(const struct sound *s) -{ - return (!s->playing && s->frame < s->data->frames); +int sound_paused(const struct sound *s) { + return (!s->playing && s->frame < s->data->frames); } -void sound_pause(struct sound *s) -{ - s->playing = 0; - bus_free(s->bus); +void sound_pause(struct sound *s) { + s->playing = 0; + bus_free(s->bus); } -void sound_resume(struct sound *s) -{ - s->playing = 1; - s->bus = first_free_bus(dsp_filter(s, sound_fillbuf)); +void sound_resume(struct sound *s) { + s->playing = 1; + s->bus = first_free_bus(dsp_filter(s, sound_fillbuf)); } -void sound_stop(struct sound *s) -{ - s->playing = 0; - s->frame = 0; - bus_free(s->bus); +void sound_stop(struct sound *s) { + s->playing = 0; + s->frame = 0; + bus_free(s->bus); } -int sound_finished(const struct sound *s) -{ - return !s->playing && s->frame == s->data->frames; +int sound_finished(const struct sound *s) { + return !s->playing && s->frame == s->data->frames; } -int sound_stopped(const struct sound *s) -{ - return !s->playing && s->frame == 0; +int sound_stopped(const struct sound *s) { + return !s->playing && s->frame == 0; } -struct mp3 make_music(const char *mp3) -{ -// drmp3 new; -// if (!drmp3_init_file(&new, mp3, NULL)) { -// YughError("Could not open mp3 file %s.", mp3); -// } +struct mp3 make_music(const char *mp3) { + // drmp3 new; + // if (!drmp3_init_file(&new, mp3, NULL)) { + // YughError("Could not open mp3 file %s.", mp3); + // } - struct mp3 newmp3 = {}; - return newmp3; + struct mp3 newmp3 = {}; + return newmp3; } -void close_audio_device(int device) -{ +void close_audio_device(int device) { } -int open_device(const char *adriver) -{ - return 0; +int open_device(const char *adriver) { + return 0; } -void sound_fillbuf(struct sound *s, short *buf, int n) -{ - float gainmult = pct2mult(s->data->gain); +void sound_fillbuf(struct sound *s, short *buf, int n) { + float gainmult = pct2mult(s->data->gain); - short *in = s->data->data; - for (int i = 0; i < n; i++) { - for (int j = 0; j < CHANNELS; j++) buf[i*CHANNELS+j] = in[s->frame+j] * gainmult; - s->frame++; - if (s->frame == s->data->frames) { + short *in = s->data->data; + for (int i = 0; i < n; i++) { + for (int j = 0; j < CHANNELS; j++) + buf[i * CHANNELS + j] = in[s->frame + j] * gainmult; + s->frame++; + if (s->frame == s->data->frames) { - bus_free(s->bus); - s->bus = NULL; - s->endcb(s); - return; - } + bus_free(s->bus); + s->bus = NULL; + s->endcb(s); + return; } + } } -void mp3_fillbuf(struct sound *s, short *buf, int n) -{ - +void mp3_fillbuf(struct sound *s, short *buf, int n) { } -void soundstream_fillbuf(struct soundstream *s, short *buf, int n) -{ - int max = s->buf->write - s->buf->read; - int lim = (max < n*CHANNELS) ? max : n*CHANNELS; - for (int i = 0; i < lim; i++) { - buf[i] = cbuf_shift(s->buf); - } +void soundstream_fillbuf(struct soundstream *s, short *buf, int n) { + int max = s->buf->write - s->buf->read; + int lim = (max < n * CHANNELS) ? max : n * CHANNELS; + for (int i = 0; i < lim; i++) { + buf[i] = cbuf_shift(s->buf); + } } -float short2db(short val) -{ - return 20*log10(abs(val) / SHRT_MAX); +float short2db(short val) { + return 20 * log10(abs(val) / SHRT_MAX); } -short db2short(float db) -{ - return pow(10, db/20.f) * SHRT_MAX; +short db2short(float db) { + return pow(10, db / 20.f) * SHRT_MAX; } -short short_gain(short val, float db) -{ - return (short)(pow(10, db/20.f) * val); +short short_gain(short val, float db) { + return (short)(pow(10, db / 20.f) * val); } -float pct2db(float pct) -{ - if (pct <= 0) return -72.f; +float pct2db(float pct) { + if (pct <= 0) return -72.f; - return 10*log2(pct); + return 10 * log2(pct); } -float pct2mult(float pct) -{ - if (pct <= 0) return 0.f; +float pct2mult(float pct) { + if (pct <= 0) return 0.f; - return pow(10, 0.5*log2(pct)); + return pow(10, 0.5 * log2(pct)); } diff --git a/source/engine/sprite.c b/source/engine/sprite.c index 1339958..b4cd5b8 100644 --- a/source/engine/sprite.c +++ b/source/engine/sprite.c @@ -1,263 +1,240 @@ #include "sprite.h" -#include "timer.h" -#include "render.h" -#include "openglrender.h" -#include "texture.h" -#include "shader.h" #include "datastream.h" -#include "gameobject.h" -#include -#include "stb_ds.h" -#include "log.h" #include "font.h" +#include "gameobject.h" +#include "log.h" +#include "openglrender.h" +#include "render.h" +#include "shader.h" +#include "stb_ds.h" +#include "texture.h" +#include "timer.h" +#include -struct TextureOptions TEX_SPRITE = { 1, 0, 0 }; +struct TextureOptions TEX_SPRITE = {1, 0, 0}; static struct sprite *sprites; static int first = -1; -sg_pipeline pip_sprite; -sg_bindings bind_sprite; +static sg_pipeline pip_sprite; +static sg_bindings bind_sprite; +static int sprite_c = 0; -int make_sprite(int go) -{ - struct sprite sprite = { - .color = {1.f, 1.f, 1.f}, - .size = {1.f, 1.f}, - .tex = texture_loadfromfile(NULL), - .go = go, - .next = -1, - .layer = 0, - .enabled = 1 }; +int make_sprite(int go) { + struct sprite sprite = { + .color = {1.f, 1.f, 1.f}, + .size = {1.f, 1.f}, + .tex = texture_loadfromfile(NULL), + .go = go, + .next = -1, + .layer = 0, + .enabled = 1}; - if (first<0) { - arrput(sprites, sprite); - arrlast(sprites).id = arrlen(sprites)-1; - return arrlen(sprites)-1; - } else { - int slot = first; - first = id2sprite(first)->next; - *id2sprite(slot) = sprite; + if (first < 0) { + arrput(sprites, sprite); + arrlast(sprites).id = arrlen(sprites) - 1; + return arrlen(sprites) - 1; + } else { + int slot = first; + first = id2sprite(first)->next; + *id2sprite(slot) = sprite; - return slot; - } + return slot; + } } -void sprite_delete(int id) -{ - struct sprite *sp = id2sprite(id); - sp->go = -1; - sp->next = first; - first = id; +void sprite_delete(int id) { + struct sprite *sp = id2sprite(id); + sp->go = -1; + sp->next = first; + first = id; } -void sprite_enabled(int id, int e) -{ - sprites[id].enabled = e; +void sprite_enabled(int id, int e) { + sprites[id].enabled = e; } struct sprite *id2sprite(int id) { - if (id < 0) return NULL; - return &sprites[id]; + if (id < 0) return NULL; + return &sprites[id]; } static sprite_count = 0; -void sprite_flush() -{ +void sprite_flush() { sprite_count = 0; } -void sprite_io(struct sprite *sprite, FILE *f, int read) -{ - char path[100]; - if (read) { - //fscanf(f, "%s", &path); - for (int i = 0; i < 100; i++) { - path[i] = fgetc(f); +void sprite_io(struct sprite *sprite, FILE *f, int read) { + char path[100]; + if (read) { + // fscanf(f, "%s", &path); + for (int i = 0; i < 100; i++) { + path[i] = fgetc(f); - if (path[i] == '\0') break; - } - fread(sprite, sizeof(*sprite), 1, f); - sprite_loadtex(sprite, path, ST_UNIT); - } else { - fputs(tex_get_path(sprite->tex), f); - fputc('\0', f); - fwrite(sprite, sizeof(*sprite), 1, f); + if (path[i] == '\0') break; } + fread(sprite, sizeof(*sprite), 1, f); + sprite_loadtex(sprite, path, ST_UNIT); + } else { + fputs(tex_get_path(sprite->tex), f); + fputc('\0', f); + fwrite(sprite, sizeof(*sprite), 1, f); + } } -void sprite_draw_all() -{ - sg_apply_pipeline(pip_sprite); - - static struct sprite **layers[5]; - - for (int i = 0; i < 5; i++) - arrfree(layers[i]); - - for (int i = 0; i < arrlen(sprites); i++) { - if (sprites[i].go >= 0 && sprites[i].enabled) arrpush(layers[sprites[i].layer], &sprites[i]); - } +void sprite_draw_all() { + sg_apply_pipeline(pip_sprite); - for (int i = 4; i >= 0; i--) - for (int j = 0; j < arrlen(layers[i]); j++) - sprite_draw(layers[i][j]); + static struct sprite **layers[5]; + + for (int i = 0; i < 5; i++) + arrfree(layers[i]); + + for (int i = 0; i < arrlen(sprites); i++) { + if (sprites[i].go >= 0 && sprites[i].enabled) arrpush(layers[sprites[i].layer], &sprites[i]); + } + + for (int i = 4; i >= 0; i--) + for (int j = 0; j < arrlen(layers[i]); j++) + sprite_draw(layers[i][j]); } -void sprite_loadtex(struct sprite *sprite, const char *path, struct glrect frame) -{ - sprite->tex = texture_loadfromfile(path); - sprite_setframe(sprite, &frame); +void sprite_loadtex(struct sprite *sprite, const char *path, struct glrect frame) { + sprite->tex = texture_loadfromfile(path); + sprite_setframe(sprite, &frame); } -void sprite_settex(struct sprite *sprite, struct Texture *tex) -{ - sprite->tex = tex; - sprite_setframe(sprite, &ST_UNIT); +void sprite_settex(struct sprite *sprite, struct Texture *tex) { + sprite->tex = tex; + sprite_setframe(sprite, &ST_UNIT); } sg_shader shader_sprite; -void sprite_initialize() -{ - shader_sprite = sg_make_shader(&(sg_shader_desc){ +void sprite_initialize() { + shader_sprite = sg_make_shader(&(sg_shader_desc){ .vs.source = slurp_text("shaders/spritevert.glsl"), .fs.source = slurp_text("shaders/spritefrag.glsl"), .vs.uniform_blocks[0] = { - .size = 64, - .layout = SG_UNIFORMLAYOUT_STD140, - .uniforms = { [0] = { .name = "mpv", .type = SG_UNIFORMTYPE_MAT4 }} - }, + .size = 64, + .layout = SG_UNIFORMLAYOUT_STD140, + .uniforms = {[0] = {.name = "mpv", .type = SG_UNIFORMTYPE_MAT4}}}, .fs.images[0] = { - .name = "image", - .image_type = SG_IMAGETYPE_2D, - .sampler_type = SG_SAMPLERTYPE_FLOAT, + .name = "image", + .image_type = SG_IMAGETYPE_2D, + .sampler_type = SG_SAMPLERTYPE_FLOAT, }, - .fs.uniform_blocks[0] = { - .size = 12, - .uniforms = { [0] = { .name = "spriteColor", .type = SG_UNIFORMTYPE_FLOAT3 }} - } - }); + .fs.uniform_blocks[0] = {.size = 12, .uniforms = {[0] = {.name = "spriteColor", .type = SG_UNIFORMTYPE_FLOAT3}}}}); - pip_sprite = sg_make_pipeline(&(sg_pipeline_desc){ + pip_sprite = sg_make_pipeline(&(sg_pipeline_desc){ .shader = shader_sprite, .layout = { - .attrs = { - [0].format=SG_VERTEXFORMAT_FLOAT4 - } - }, + .attrs = { + [0].format = SG_VERTEXFORMAT_FLOAT4}}, .primitive_type = SG_PRIMITIVETYPE_TRIANGLE_STRIP, - .label = "sprite pipeline" - }); + .label = "sprite pipeline"}); - bind_sprite.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ - .size = sizeof(float)*16*500, + bind_sprite.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ + .size = sizeof(float) * 16 * 500, .type = SG_BUFFERTYPE_VERTEXBUFFER, .usage = SG_USAGE_STREAM, .label = "sprite vertex buffer", - }); + }); } void tex_draw(struct Texture *tex, float pos[2], float angle, float size[2], float offset[2], struct glrect r, float color[3]) { - float model[16] = { 0.f }; - mfloat_t r_model[16] = { 0.f }; - memcpy(model, UNITMAT4, sizeof(UNITMAT4)); - memcpy(r_model, UNITMAT4, sizeof(UNITMAT4)); + float model[16] = {0.f}; + mfloat_t r_model[16] = {0.f}; + memcpy(model, UNITMAT4, sizeof(UNITMAT4)); + memcpy(r_model, UNITMAT4, sizeof(UNITMAT4)); - mfloat_t t_scale[2] = { tex->width * st_s_w(r) * size[0], tex->height * st_s_h(r) * size[1] }; - mfloat_t t_offset[2] = { offset[0] * t_scale[0] * size[0], offset[1] * t_scale[1] * size[1]}; + mfloat_t t_scale[2] = {tex->width * st_s_w(r) * size[0], tex->height * st_s_h(r) * size[1]}; + mfloat_t t_offset[2] = {offset[0] * t_scale[0] * size[0], offset[1] * t_scale[1] * size[1]}; - mat4_translate_vec2(model, t_offset); + mat4_translate_vec2(model, t_offset); - mat4_scale_vec2(model, t_scale); - mat4_rotation_z(r_model, angle); + mat4_scale_vec2(model, t_scale); + mat4_rotation_z(r_model, angle); - mat4_multiply(model, r_model, model); + mat4_multiply(model, r_model, model); - mat4_translate_vec2(model, pos); - mat4_multiply(model, projection,model); - - float vertices[] = { - 0.f, 0.f, r.s0, r.t1, - 1, 0.f, r.s1, r.t1, - 0.f, 1, r.s0, r.t0, - 1.f, 1.f, r.s1, r.t0 - }; + mat4_translate_vec2(model, pos); + mat4_multiply(model, projection, model); - bind_sprite.fs_images[0] = tex->id; - sg_append_buffer(bind_sprite.vertex_buffers[0], SG_RANGE_REF(vertices)); + float vertices[] = { + 0.f, 0.f, r.s0, r.t1, + 1, 0.f, r.s1, r.t1, + 0.f, 1, r.s0, r.t0, + 1.f, 1.f, r.s1, r.t0}; - sg_apply_bindings(&bind_sprite); + bind_sprite.fs_images[0] = tex->id; + sg_append_buffer(bind_sprite.vertex_buffers[0], SG_RANGE_REF(vertices)); + sg_apply_bindings(&bind_sprite); + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(model)); - - sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(model)); - float c[3]; - for (int i = 0; i < 3; i++) c[i] = color[i]; - sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, SG_RANGE_REF(c)); + sg_range c = { + .ptr = color, + .size = sizeof(float) * 3}; + sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, &c); - sg_draw(sprite_count*4,4,1); - sprite_count++; + sg_draw(sprite_count * 4, 4, 1); + sprite_count++; } -void sprite_draw(struct sprite *sprite) -{ - struct gameobject *go = id2go(sprite->go); +void sprite_draw(struct sprite *sprite) { + struct gameobject *go = id2go(sprite->go); - if (sprite->tex) { - cpVect cpos = cpBodyGetPosition(go->body); - float pos[2] = {cpos.x, cpos.y}; - float size[2] = { sprite->size[0] * go->scale * go->flipx, sprite->size[1] * go->scale * go->flipy }; - tex_draw(sprite->tex, pos, cpBodyGetAngle(go->body), size, sprite->pos, sprite->frame, sprite->color); - } + if (sprite->tex) { + cpVect cpos = cpBodyGetPosition(go->body); + float pos[2] = {cpos.x, cpos.y}; + float size[2] = {sprite->size[0] * go->scale * go->flipx, sprite->size[1] * go->scale * go->flipy}; + tex_draw(sprite->tex, pos, cpBodyGetAngle(go->body), size, sprite->pos, sprite->frame, sprite->color); + } } -void sprite_setanim(struct sprite *sprite, struct TexAnim *anim, int frame) -{ - if (!sprite) return; - sprite->tex = anim->tex; - sprite->frame = anim->st_frames[frame]; +void sprite_setanim(struct sprite *sprite, struct TexAnim *anim, int frame) { + if (!sprite) return; + sprite->tex = anim->tex; + sprite->frame = anim->st_frames[frame]; } void gui_draw_img(const char *img, float x, float y) { - sg_apply_pipeline(pip_sprite); - struct Texture *tex = texture_loadfromfile(img); - float pos[2] = {x, y}; - float size[2] = {1.f, 1.f}; - float offset[2] = { 0.f, 0.f }; - float white[3] = {0.3f,1.f,1.f}; - tex_draw(tex, pos, 0.f, size, offset, tex_get_rect(tex), white); + sg_apply_pipeline(pip_sprite); + struct Texture *tex = texture_loadfromfile(img); + float pos[2] = {x, y}; + float size[2] = {1.f, 1.f}; + float offset[2] = {0.f, 0.f}; + float white[3] = {1.f, 1.f, 1.f}; + tex_draw(tex, pos, 0.f, size, offset, tex_get_rect(tex), white); } -void sprite_setframe(struct sprite *sprite, struct glrect *frame) -{ - sprite->frame = *frame; +void sprite_setframe(struct sprite *sprite, struct glrect *frame) { + sprite->frame = *frame; } -void video_draw(struct datastream *stream, mfloat_t position[2], mfloat_t size[2], float rotate, mfloat_t color[3]) -{ - shader_use(vid_shader); +void video_draw(struct datastream *stream, mfloat_t position[2], mfloat_t size[2], float rotate, mfloat_t color[3]) { + shader_use(vid_shader); - static mfloat_t model[16]; - memcpy(model, UNITMAT4, sizeof(UNITMAT4)); - mat4_translate_vec2(model, position); - mat4_scale_vec2(model, size); + static mfloat_t model[16]; + memcpy(model, UNITMAT4, sizeof(UNITMAT4)); + mat4_translate_vec2(model, position); + mat4_scale_vec2(model, size); - shader_setmat4(vid_shader, "model", model); - shader_setvec3(vid_shader, "spriteColor", color); -/* - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, stream->texture_y); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, stream->texture_cb); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, stream->texture_cr); + shader_setmat4(vid_shader, "model", model); + shader_setvec3(vid_shader, "spriteColor", color); + /* + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, stream->texture_y); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, stream->texture_cb); + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, stream->texture_cr); - // TODO: video bind VAO - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); -*/ + // TODO: video bind VAO + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + */ } - diff --git a/source/engine/texture.c b/source/engine/texture.c index a5575a7..1eb2904 100644 --- a/source/engine/texture.c +++ b/source/engine/texture.c @@ -1,208 +1,184 @@ #include "texture.h" -#include "render.h" -#include -#include -#include #include "log.h" -#include -#include "util.h" +#include "render.h" #include "sokol/sokol_gfx.h" +#include "util.h" +#include +#include +#include +#include -struct glrect ST_UNIT = { 0.f, 1.f, 0.f, 1.f }; +struct glrect ST_UNIT = {0.f, 1.f, 0.f, 1.f}; static struct { - char *key; - struct Texture *value; + char *key; + struct Texture *value; } *texhash = NULL; struct Texture *tex_default; -struct Texture *texture_notex() -{ +struct Texture *texture_notex() { return texture_pullfromfile("./icons/no_tex.png"); } /* If an empty string or null is put for path, loads default texture */ -struct Texture *texture_pullfromfile(const char *path) -{ - if (!path) return texture_notex(); - - int index = shgeti(texhash, path); - if (index != -1) - return texhash[index].value; +struct Texture *texture_pullfromfile(const char *path) { + if (!path) return texture_notex(); - YughInfo("Loading texture %s.", path); - struct Texture *tex = calloc(1, sizeof(*tex)); - tex->opts.sprite = 1; - tex->opts.mips = 0; - tex->opts.gamma = 0; - - int n; - unsigned char *data = stbi_load(path, &tex->width, &tex->height, &n, 4); + int index = shgeti(texhash, path); + if (index != -1) + return texhash[index].value; - if (data == NULL) { - YughError("STBI failed to load file %s with message: %s\nOpening default instead.", path, stbi_failure_reason()); - return texture_notex(); - } - tex->data = data; + YughInfo("Loading texture %s.", path); + struct Texture *tex = calloc(1, sizeof(*tex)); + tex->opts.sprite = 1; + tex->opts.mips = 0; + tex->opts.gamma = 0; - int filter; - if (tex->opts.sprite) { - if (tex->opts.mips) - filter = SG_FILTER_NEAREST_MIPMAP_NEAREST; - else - filter = SG_FILTER_NEAREST; - } else { - if (tex->opts.mips) - filter = SG_FILTER_LINEAR_MIPMAP_LINEAR; - else - filter = SG_FILTER_LINEAR; - } + int n; + unsigned char *data = stbi_load(path, &tex->width, &tex->height, &n, 4); - tex->id = sg_make_image(&(sg_image_desc){ + if (data == NULL) { + YughError("STBI failed to load file %s with message: %s\nOpening default instead.", path, stbi_failure_reason()); + return texture_notex(); + } + tex->data = data; + + int filter; + if (tex->opts.sprite) { + filter = SG_FILTER_NEAREST; + } else { + filter = SG_FILTER_LINEAR; + } + + tex->id = sg_make_image(&(sg_image_desc){ .type = SG_IMAGETYPE_2D, .width = tex->width, .height = tex->height, .usage = SG_USAGE_IMMUTABLE, .min_filter = filter, .mag_filter = filter, + .max_anisotropy = 16, .data.subimage[0][0] = { - .ptr = data, - .size = tex->width*tex->height*4 - } - }); - + .ptr = data, + .size = tex->width * tex->height * 4}}); - if (shlen(texhash) == 0) - sh_new_arena(texhash); + if (shlen(texhash) == 0) + sh_new_arena(texhash); - shput(texhash, path, tex); + shput(texhash, path, tex); - return tex; + return tex; } -void texture_sync(const char *path) -{ +void texture_sync(const char *path) { YughWarn("Need to implement texture sync."); } char *tex_get_path(struct Texture *tex) { - for (int i = 0; i < shlen(texhash); i++) { - if (tex == texhash[i].value) { - YughInfo("Found key %s", texhash[i].key); - return texhash[i].key; - } + for (int i = 0; i < shlen(texhash); i++) { + if (tex == texhash[i].value) { + YughInfo("Found key %s", texhash[i].key); + return texhash[i].key; } + } - return NULL; + return NULL; } -struct Texture *texture_loadfromfile(const char *path) -{ - struct Texture *new = texture_pullfromfile(path); -/* - if (new->id == 0) { - glGenTextures(1, &new->id); +struct Texture *texture_loadfromfile(const char *path) { + struct Texture *new = texture_pullfromfile(path); + /* + if (new->id == 0) { + glGenTextures(1, &new->id); - //tex_gpu_load(new); + //tex_gpu_load(new); - YughInfo("Loaded texture path %s", path); - } -*/ - return new; + YughInfo("Loaded texture path %s", path); + } + */ + return new; } -void tex_gpu_reload(struct Texture *tex) -{ - tex_gpu_free(tex); +void tex_gpu_reload(struct Texture *tex) { + tex_gpu_free(tex); - //tex_gpu_load(tex); + // tex_gpu_load(tex); } -void anim_calc(struct anim2d *anim) -{ - anim->size[0] = anim->anim->tex->width * st_s_w(anim->anim->st_frames[anim->frame]); - anim->size[1] = anim->anim->tex->height * st_s_h(anim->anim->st_frames[anim->frame]); +void anim_calc(struct anim2d *anim) { + anim->size[0] = anim->anim->tex->width * st_s_w(anim->anim->st_frames[anim->frame]); + anim->size[1] = anim->anim->tex->height * st_s_h(anim->anim->st_frames[anim->frame]); } -void anim_incr(struct anim2d *anim) -{ - anim->frame = (anim->frame + 1) % arrlen(anim->anim->st_frames); +void anim_incr(struct anim2d *anim) { + anim->frame = (anim->frame + 1) % arrlen(anim->anim->st_frames); - if (!anim->anim->loop && anim->frame == arrlen(anim->anim->st_frames)) - anim_pause(anim); + if (!anim->anim->loop && anim->frame == arrlen(anim->anim->st_frames)) + anim_pause(anim); - anim_calc(anim); + anim_calc(anim); } -void anim_decr(struct anim2d *anim) -{ - anim->frame = (anim->frame + arrlen(anim->anim->st_frames) - 1) % arrlen(anim->anim->st_frames); - anim_calc(anim); +void anim_decr(struct anim2d *anim) { + anim->frame = (anim->frame + arrlen(anim->anim->st_frames) - 1) % arrlen(anim->anim->st_frames); + anim_calc(anim); } -struct glrect anim_get_rect(struct anim2d *anim) -{ - return anim->anim->st_frames[anim->frame]; +struct glrect anim_get_rect(struct anim2d *anim) { + return anim->anim->st_frames[anim->frame]; } -void anim_setframe(struct anim2d *anim, int frame) -{ - anim->frame = frame; - anim_calc(anim); +void anim_setframe(struct anim2d *anim, int frame) { + anim->frame = frame; + anim_calc(anim); } -struct TexAnim *anim2d_from_tex(const char *path, int frames, int fps) -{ - struct TexAnim *anim = malloc(sizeof(*anim)); - anim->tex = texture_loadfromfile(path); - texanim_fromframes(anim, frames); - anim->ms = (float)1/fps; +struct TexAnim *anim2d_from_tex(const char *path, int frames, int fps) { + struct TexAnim *anim = malloc(sizeof(*anim)); + anim->tex = texture_loadfromfile(path); + texanim_fromframes(anim, frames); + anim->ms = (float)1 / fps; - return anim; + return anim; } -void texanim_fromframes(struct TexAnim *anim, int frames) -{ - if (anim->st_frames) { - free(anim->st_frames); - } +void texanim_fromframes(struct TexAnim *anim, int frames) { + if (anim->st_frames) { + free(anim->st_frames); + } - arrsetlen(anim->st_frames, frames); + arrsetlen(anim->st_frames, frames); - float width = (float)1/frames; + float width = (float)1 / frames; - for (int i = 0; i < frames; i++) { - anim->st_frames[i].s0 = width*i; - anim->st_frames[i].s1 = width*(i+1); - anim->st_frames[i].t0 = 0.f; - anim->st_frames[i].t1 = 1.f; - } + for (int i = 0; i < frames; i++) { + anim->st_frames[i].s0 = width * i; + anim->st_frames[i].s1 = width * (i + 1); + anim->st_frames[i].t0 = 0.f; + anim->st_frames[i].t1 = 1.f; + } } -void tex_gpu_free(struct Texture *tex) -{ -/* - if (tex->id != 0) { - glDeleteTextures(1, &tex->id); - tex->id = 0; - } -*/ +void tex_gpu_free(struct Texture *tex) { + /* + if (tex->id != 0) { + glDeleteTextures(1, &tex->id); + tex->id = 0; + } + */ } -int anim_frames(struct TexAnim *a) -{ - return arrlen(a->st_frames); +int anim_frames(struct TexAnim *a) { + return arrlen(a->st_frames); } -struct glrect tex_get_rect(struct Texture *tex) -{ - return ST_UNIT; +struct glrect tex_get_rect(struct Texture *tex) { + return ST_UNIT; } -cpVect tex_get_dimensions(struct Texture *tex) -{ +cpVect tex_get_dimensions(struct Texture *tex) { if (!tex) return cpvzero; cpVect d; d.x = tex->width; @@ -210,78 +186,69 @@ cpVect tex_get_dimensions(struct Texture *tex) return d; } -void tex_bind(struct Texture *tex) -{ -/* glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, tex->id); - glBindTexture(GL_TEXTURE_2D_ARRAY, tex->id); -*/ +void tex_bind(struct Texture *tex) { + /* glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, tex->id); + glBindTexture(GL_TEXTURE_2D_ARRAY, tex->id); + */ } /********************** ANIM2D ****************/ -void anim_load(struct anim2d *anim, const char *path) -{ - anim->anim = &texture_pullfromfile(path)->anim; - anim->anim->tex->opts.animation = 1; - anim_stop(anim); - anim_play(anim); +void anim_load(struct anim2d *anim, const char *path) { + anim->anim = &texture_pullfromfile(path)->anim; + anim->anim->tex->opts.animation = 1; + anim_stop(anim); + anim_play(anim); } -void anim_play(struct anim2d *anim) -{ - if (anim->playing) - return; +void anim_play(struct anim2d *anim) { + if (anim->playing) + return; - if (anim->frame == anim_frames(anim->anim)) - anim->frame = 0; - - anim->playing = 1; - - if (anim->timer == NULL) - anim->timer = id2timer(timer_make(1.f / anim->anim->ms, anim_incr, anim, 0)); - else - timerr_settime(anim->timer, 1.f/anim->anim->ms); - - timer_start(anim->timer); -} - -void anim_stop(struct anim2d *anim) -{ - if (!anim->playing) - return; - - anim->playing = 0; + if (anim->frame == anim_frames(anim->anim)) anim->frame = 0; - anim->pausetime = 0; - timer_stop(anim->timer); + + anim->playing = 1; + + if (anim->timer == NULL) + anim->timer = id2timer(timer_make(1.f / anim->anim->ms, anim_incr, anim, 0)); + else + timerr_settime(anim->timer, 1.f / anim->anim->ms); + + timer_start(anim->timer); } -void anim_pause(struct anim2d *anim) -{ - if (!anim->playing) - return; +void anim_stop(struct anim2d *anim) { + if (!anim->playing) + return; - anim->playing = 0; - timer_pause(anim->timer); + anim->playing = 0; + anim->frame = 0; + anim->pausetime = 0; + timer_stop(anim->timer); } -void anim_fwd(struct anim2d *anim) -{ - anim_incr(anim); +void anim_pause(struct anim2d *anim) { + if (!anim->playing) + return; + + anim->playing = 0; + timer_pause(anim->timer); } -void anim_bkwd(struct anim2d *anim) -{ - anim_decr(anim); +void anim_fwd(struct anim2d *anim) { + anim_incr(anim); } -float st_s_w(struct glrect st) -{ - return (st.s1 - st.s0); +void anim_bkwd(struct anim2d *anim) { + anim_decr(anim); } -float st_s_h(struct glrect st) -{ - return (st.t1 - st.t0); +float st_s_w(struct glrect st) { + return (st.s1 - st.s0); +} + +float st_s_h(struct glrect st) { + return (st.t1 - st.t0); } diff --git a/source/engine/thirdparty/Nuklear/nuklear.h b/source/engine/thirdparty/Nuklear/nuklear.h index 2d7b7ab..febee39 100644 --- a/source/engine/thirdparty/Nuklear/nuklear.h +++ b/source/engine/thirdparty/Nuklear/nuklear.h @@ -372,7 +372,7 @@ extern "C" { #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER) #define NK_SIZE_TYPE unsigned __int32 #elif defined(__GNUC__) || defined(__clang__) - #if defined(__x86_64__) || defined(__ppc64__) + #if defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) #define NK_SIZE_TYPE unsigned long #else #define NK_SIZE_TYPE unsigned int @@ -387,7 +387,7 @@ extern "C" { #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER) #define NK_POINTER_TYPE unsigned __int32 #elif defined(__GNUC__) || defined(__clang__) - #if defined(__x86_64__) || defined(__ppc64__) + #if defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) #define NK_POINTER_TYPE unsigned long #else #define NK_POINTER_TYPE unsigned int @@ -432,8 +432,8 @@ NK_STATIC_ASSERT(sizeof(nk_int) == 4); NK_STATIC_ASSERT(sizeof(nk_byte) == 1); NK_STATIC_ASSERT(sizeof(nk_flags) >= 4); NK_STATIC_ASSERT(sizeof(nk_rune) >= 4); -//NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*)); -//NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*)); +NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*)); +NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*)); #ifdef NK_INCLUDE_STANDARD_BOOL NK_STATIC_ASSERT(sizeof(nk_bool) == sizeof(bool)); #else @@ -1127,7 +1127,7 @@ NK_API void nk_input_end(struct nk_context*); /// cfg.curve_segment_count = 22; /// cfg.arc_segment_count = 22; /// cfg.global_alpha = 1.0f; -/// cfg.null = dev->null; +/// cfg.tex_null = dev->tex_null; /// // /// // setup buffers and convert /// struct nk_buffer cmds, verts, idx; @@ -1177,7 +1177,7 @@ struct nk_convert_config { unsigned circle_segment_count; /* number of segments used for circles: default to 22 */ unsigned arc_segment_count; /* number of segments used for arcs: default to 22 */ unsigned curve_segment_count; /* number of segments used for curves: default to 22 */ - struct nk_draw_null_texture null; /* handle to texture with a white pixel for shape drawing */ + struct nk_draw_null_texture tex_null; /* handle to texture with a white pixel for shape drawing */ const struct nk_draw_vertex_layout_element *vertex_layout; /* describes the vertex output format and packing */ nk_size vertex_size; /* sizeof one vertex for vertex packing */ nk_size vertex_alignment; /* vertex alignment: Can be obtained by NK_ALIGNOF */ @@ -6078,7 +6078,6 @@ NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_prop #define STB_RECT_PACK_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION -#define STBTT_STATIC /* Allow consumer to define own STBTT_malloc/STBTT_free, and use the font atlas' allocator otherwise */ #ifndef STBTT_malloc @@ -8440,7 +8439,6 @@ nk_str_append_text_utf8(struct nk_str *str, const char *text, int len) NK_API int nk_str_append_str_utf8(struct nk_str *str, const char *text) { - int runes = 0; int byte_len = 0; int num_runes = 0; int glyph_len = 0; @@ -8454,7 +8452,7 @@ nk_str_append_str_utf8(struct nk_str *str, const char *text) num_runes++; } nk_str_append_text_char(str, text, byte_len); - return runes; + return num_runes; } NK_API int nk_str_append_text_runes(struct nk_str *str, const nk_rune *text, int len) @@ -8569,7 +8567,6 @@ nk_str_insert_text_utf8(struct nk_str *str, int pos, const char *text, int len) NK_API int nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text) { - int runes = 0; int byte_len = 0; int num_runes = 0; int glyph_len = 0; @@ -8583,7 +8580,7 @@ nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text) num_runes++; } nk_str_insert_at_rune(str, pos, text, byte_len); - return runes; + return num_runes; } NK_API int nk_str_insert_text_runes(struct nk_str *str, int pos, const nk_rune *runes, int len) @@ -9564,7 +9561,7 @@ nk_draw_list_add_clip(struct nk_draw_list *list, struct nk_rect rect) NK_ASSERT(list); if (!list) return; if (!list->cmd_count) { - nk_draw_list_push_command(list, rect, list->config.null.texture); + nk_draw_list_push_command(list, rect, list->config.tex_null.texture); } else { struct nk_draw_command *prev = nk_draw_list_command_last(list); if (prev->elem_count == 0) @@ -9919,7 +9916,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p /* fill vertices */ for (i = 0; i < points_count; ++i) { - const struct nk_vec2 uv = list->config.null.uv; + const struct nk_vec2 uv = list->config.tex_null.uv; vtx = nk_draw_vertex(vtx, &list->config, points[i], uv, col); vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+0], uv, col_trans); vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+1], uv, col_trans); @@ -9984,7 +9981,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p /* add vertices */ for (i = 0; i < points_count; ++i) { - const struct nk_vec2 uv = list->config.null.uv; + const struct nk_vec2 uv = list->config.tex_null.uv; vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+0], uv, col_trans); vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+1], uv, col); vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+2], uv, col); @@ -10005,7 +10002,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p for (i1 = 0; i1 < count; ++i1) { float dx, dy; - const struct nk_vec2 uv = list->config.null.uv; + const struct nk_vec2 uv = list->config.tex_null.uv; const nk_size i2 = ((i1+1) == points_count) ? 0 : i1 + 1; const struct nk_vec2 p1 = points[i1]; const struct nk_vec2 p2 = points[i2]; @@ -10115,7 +10112,7 @@ nk_draw_list_fill_poly_convex(struct nk_draw_list *list, /* add vertices + indexes */ for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) { - const struct nk_vec2 uv = list->config.null.uv; + const struct nk_vec2 uv = list->config.tex_null.uv; struct nk_vec2 n0 = normals[i0]; struct nk_vec2 n1 = normals[i1]; struct nk_vec2 dm = nk_vec2_muls(nk_vec2_add(n0, n1), 0.5f); @@ -10152,7 +10149,7 @@ nk_draw_list_fill_poly_convex(struct nk_draw_list *list, if (!vtx || !ids) return; for (i = 0; i < vtx_count; ++i) - vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.null.uv, col); + vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.tex_null.uv, col); for (i = 2; i < points_count; ++i) { ids[0] = (nk_draw_index)index; ids[1] = (nk_draw_index)(index+ i - 1); @@ -10181,8 +10178,8 @@ nk_draw_list_path_line_to(struct nk_draw_list *list, struct nk_vec2 pos) nk_draw_list_add_clip(list, nk_null_rect); cmd = nk_draw_list_command_last(list); - if (cmd && cmd->texture.ptr != list->config.null.texture.ptr) - nk_draw_list_push_image(list, list->config.null.texture); + if (cmd && cmd->texture.ptr != list->config.tex_null.texture.ptr) + nk_draw_list_push_image(list, list->config.tex_null.texture); points = nk_draw_list_alloc_path(list, 1); if (!points) return; @@ -10384,7 +10381,7 @@ nk_draw_list_fill_rect_multi_color(struct nk_draw_list *list, struct nk_rect rec NK_ASSERT(list); if (!list) return; - nk_draw_list_push_image(list, list->config.null.texture); + nk_draw_list_push_image(list, list->config.tex_null.texture); index = (nk_draw_index)list->vertex_count; vtx = nk_draw_list_alloc_vertices(list, 4); idx = nk_draw_list_alloc_elements(list, 6); @@ -10394,10 +10391,10 @@ nk_draw_list_fill_rect_multi_color(struct nk_draw_list *list, struct nk_rect rec idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0); idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3); - vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y), list->config.null.uv, col_left); - vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y), list->config.null.uv, col_top); - vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y + rect.h), list->config.null.uv, col_right); - vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y + rect.h), list->config.null.uv, col_bottom); + vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y), list->config.tex_null.uv, col_left); + vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y), list->config.tex_null.uv, col_top); + vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y + rect.h), list->config.tex_null.uv, col_right); + vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y + rect.h), list->config.tex_null.uv, col_bottom); } NK_API void nk_draw_list_fill_triangle(struct nk_draw_list *list, struct nk_vec2 a, @@ -16513,7 +16510,7 @@ nk_font_chinese_glyph_ranges(void) 0x3000, 0x30FF, 0x31F0, 0x31FF, 0xFF00, 0xFFEF, - 0x4e00, 0x9FAF, + 0x4E00, 0x9FAF, 0 }; return ranges; @@ -16622,7 +16619,7 @@ nk_font_bake_pack(struct nk_font_baker *baker, struct stbtt_fontinfo *font_info = &baker->build[i++].info; font_info->userdata = alloc; - if (!stbtt_InitFont(font_info, (const unsigned char*)it->ttf_blob, 0)) + if (!stbtt_InitFont(font_info, (const unsigned char*)it->ttf_blob, stbtt_GetFontOffsetForIndex((const unsigned char*)it->ttf_blob, 0))) return nk_false; } while ((it = it->n) != config_iter); } @@ -17704,20 +17701,20 @@ failed: } NK_API void nk_font_atlas_end(struct nk_font_atlas *atlas, nk_handle texture, - struct nk_draw_null_texture *null) + struct nk_draw_null_texture *tex_null) { int i = 0; struct nk_font *font_iter; NK_ASSERT(atlas); if (!atlas) { - if (!null) return; - null->texture = texture; - null->uv = nk_vec2(0.5f,0.5f); + if (!tex_null) return; + tex_null->texture = texture; + tex_null->uv = nk_vec2(0.5f,0.5f); } - if (null) { - null->texture = texture; - null->uv.x = (atlas->custom.x + 0.5f)/(float)atlas->tex_width; - null->uv.y = (atlas->custom.y + 0.5f)/(float)atlas->tex_height; + if (tex_null) { + tex_null->texture = texture; + tex_null->uv.x = (atlas->custom.x + 0.5f)/(float)atlas->tex_width; + tex_null->uv.y = (atlas->custom.y + 0.5f)/(float)atlas->tex_height; } for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) { font_iter->texture = texture; @@ -26163,7 +26160,7 @@ nk_textedit_text(struct nk_text_edit *state, const char *text, int total_len) text+text_len, 1)) { nk_textedit_makeundo_insert(state, state->cursor, 1); - ++state->cursor; + state->cursor = NK_MIN(state->cursor + 1, state->string.len); state->has_preferred_x = 0; } } @@ -29657,6 +29654,12 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args) /// - [y]: Minor version with non-breaking API and library changes /// - [z]: Patch version with no direct changes to the API /// +/// - 2022/12/17 (4.10.5) - Fix nk_font_bake_pack() using TTC font offset incorrectly +/// - 2022/10/24 (4.10.4) - Fix nk_str_{append,insert}_str_utf8 always returning 0 +/// - 2022/09/03 (4.10.3) - Renamed the `null` texture variable to `tex_null` +/// - 2022/08/01 (4.10.2) - Fix Apple Silicon with incorrect NK_SITE_TYPE and NK_POINTER_TYPE +/// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than +/// nk_edit_xxx limit /// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug /// - 2022/04/18 (4.9.7) - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to /// only trigger when the mouse position was inside the same button on down diff --git a/source/engine/thirdparty/Nuklear/nuklear_glfw_gl3.h b/source/engine/thirdparty/Nuklear/nuklear_glfw_gl3.h deleted file mode 100644 index 9a11f17..0000000 --- a/source/engine/thirdparty/Nuklear/nuklear_glfw_gl3.h +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Nuklear - 1.32.0 - public domain - * no warrenty implied; use at your own risk. - * authored from 2015-2016 by Micha Mettke - */ -/* - * ============================================================== - * - * API - * - * =============================================================== - */ -#ifndef NK_GLFW_GL3_H_ -#define NK_GLFW_GL3_H_ - -#include -#include - -enum nk_glfw_init_state{ - NK_GLFW3_DEFAULT=0, - NK_GLFW3_INSTALL_CALLBACKS -}; - -#ifndef NK_GLFW_TEXT_MAX -#define NK_GLFW_TEXT_MAX 256 -#endif - -struct nk_glfw_device { - struct nk_buffer cmds; - struct nk_draw_null_texture null; - GLuint vbo, vao, ebo; - GLuint prog; - GLuint vert_shdr; - GLuint frag_shdr; - GLint attrib_pos; - GLint attrib_uv; - GLint attrib_col; - GLint uniform_tex; - GLint uniform_proj; - GLuint font_tex; -}; - -struct nk_glfw { - GLFWwindow *win; - int width, height; - int display_width, display_height; - struct nk_glfw_device ogl; - struct nk_context ctx; - struct nk_font_atlas atlas; - struct nk_vec2 fb_scale; - unsigned int text[NK_GLFW_TEXT_MAX]; - int text_len; - struct nk_vec2 scroll; - double last_button_click; - int is_double_click_down; - struct nk_vec2 double_click_pos; -}; - -NK_API struct nk_context* nk_glfw3_init(struct nk_glfw* glfw, GLFWwindow *win, enum nk_glfw_init_state); -NK_API void nk_glfw3_shutdown(struct nk_glfw* glfw); -NK_API void nk_glfw3_font_stash_begin(struct nk_glfw* glfw, struct nk_font_atlas **atlas); -NK_API void nk_glfw3_font_stash_end(struct nk_glfw* glfw); -NK_API void nk_glfw3_new_frame(struct nk_glfw* glfw); -NK_API void nk_glfw3_render(struct nk_glfw* glfw, enum nk_anti_aliasing, int max_vertex_buffer, int max_element_buffer); - -NK_API void nk_glfw3_device_destroy(struct nk_glfw* glfw); -NK_API void nk_glfw3_device_create(struct nk_glfw* glfw); - -NK_API void nk_glfw3_char_callback(GLFWwindow *win, unsigned int codepoint); -NK_API void nk_gflw3_scroll_callback(GLFWwindow *win, double xoff, double yoff); -NK_API void nk_glfw3_mouse_button_callback(GLFWwindow *win, int button, int action, int mods); - -#endif -/* - * ============================================================== - * - * IMPLEMENTATION - * - * =============================================================== - */ -#ifdef NK_GLFW_GL3_IMPLEMENTATION - -#ifndef NK_GLFW_DOUBLE_CLICK_LO -#define NK_GLFW_DOUBLE_CLICK_LO 0.02 -#endif -#ifndef NK_GLFW_DOUBLE_CLICK_HI -#define NK_GLFW_DOUBLE_CLICK_HI 0.2 -#endif - -struct nk_glfw_vertex { - float position[2]; - float uv[2]; - nk_byte col[4]; -}; - -#ifdef __APPLE__ - #define NK_SHADER_VERSION "#version 150\n" -#else - #define NK_SHADER_VERSION "#version 300 es\n" -#endif - -NK_API void -nk_glfw3_device_create(struct nk_glfw* glfw) -{ - GLint status; - static const GLchar *vertex_shader = - NK_SHADER_VERSION - "uniform mat4 ProjMtx;\n" - "in vec2 Position;\n" - "in vec2 TexCoord;\n" - "in vec4 Color;\n" - "out vec2 Frag_UV;\n" - "out vec4 Frag_Color;\n" - "void main() {\n" - " Frag_UV = TexCoord;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n" - "}\n"; - static const GLchar *fragment_shader = - NK_SHADER_VERSION - "precision mediump float;\n" - "uniform sampler2D Texture;\n" - "in vec2 Frag_UV;\n" - "in vec4 Frag_Color;\n" - "out vec4 Out_Color;\n" - "void main(){\n" - " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" - "}\n"; - - struct nk_glfw_device *dev = &glfw->ogl; - nk_buffer_init_default(&dev->cmds); - dev->prog = glCreateProgram(); - dev->vert_shdr = glCreateShader(GL_VERTEX_SHADER); - dev->frag_shdr = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(dev->vert_shdr, 1, &vertex_shader, 0); - glShaderSource(dev->frag_shdr, 1, &fragment_shader, 0); - glCompileShader(dev->vert_shdr); - glCompileShader(dev->frag_shdr); - glGetShaderiv(dev->vert_shdr, GL_COMPILE_STATUS, &status); - assert(status == GL_TRUE); - glGetShaderiv(dev->frag_shdr, GL_COMPILE_STATUS, &status); - assert(status == GL_TRUE); - glAttachShader(dev->prog, dev->vert_shdr); - glAttachShader(dev->prog, dev->frag_shdr); - glLinkProgram(dev->prog); - glGetProgramiv(dev->prog, GL_LINK_STATUS, &status); - assert(status == GL_TRUE); - - dev->uniform_tex = glGetUniformLocation(dev->prog, "Texture"); - dev->uniform_proj = glGetUniformLocation(dev->prog, "ProjMtx"); - dev->attrib_pos = glGetAttribLocation(dev->prog, "Position"); - dev->attrib_uv = glGetAttribLocation(dev->prog, "TexCoord"); - dev->attrib_col = glGetAttribLocation(dev->prog, "Color"); - - { - /* buffer setup */ - GLsizei vs = sizeof(struct nk_glfw_vertex); - size_t vp = offsetof(struct nk_glfw_vertex, position); - size_t vt = offsetof(struct nk_glfw_vertex, uv); - size_t vc = offsetof(struct nk_glfw_vertex, col); - - glGenBuffers(1, &dev->vbo); - glGenBuffers(1, &dev->ebo); - glGenVertexArrays(1, &dev->vao); - - glBindVertexArray(dev->vao); - glBindBuffer(GL_ARRAY_BUFFER, dev->vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo); - - glEnableVertexAttribArray((GLuint)dev->attrib_pos); - glEnableVertexAttribArray((GLuint)dev->attrib_uv); - glEnableVertexAttribArray((GLuint)dev->attrib_col); - - glVertexAttribPointer((GLuint)dev->attrib_pos, 2, GL_FLOAT, GL_FALSE, vs, (void*)vp); - glVertexAttribPointer((GLuint)dev->attrib_uv, 2, GL_FLOAT, GL_FALSE, vs, (void*)vt); - glVertexAttribPointer((GLuint)dev->attrib_col, 4, GL_UNSIGNED_BYTE, GL_TRUE, vs, (void*)vc); - } - - glBindTexture(GL_TEXTURE_2D, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindVertexArray(0); -} - -NK_INTERN void -nk_glfw3_device_upload_atlas(struct nk_glfw* glfw, const void *image, int width, int height) -{ - struct nk_glfw_device *dev = &glfw->ogl; - glGenTextures(1, &dev->font_tex); - glBindTexture(GL_TEXTURE_2D, dev->font_tex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, image); -} - -NK_API void -nk_glfw3_device_destroy(struct nk_glfw* glfw) -{ - struct nk_glfw_device *dev = &glfw->ogl; - glDetachShader(dev->prog, dev->vert_shdr); - glDetachShader(dev->prog, dev->frag_shdr); - glDeleteShader(dev->vert_shdr); - glDeleteShader(dev->frag_shdr); - glDeleteProgram(dev->prog); - glDeleteTextures(1, &dev->font_tex); - glDeleteBuffers(1, &dev->vbo); - glDeleteBuffers(1, &dev->ebo); - nk_buffer_free(&dev->cmds); -} - -NK_API void -nk_glfw3_render(struct nk_glfw* glfw, enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_buffer) -{ - struct nk_glfw_device *dev = &glfw->ogl; - struct nk_buffer vbuf, ebuf; - GLfloat ortho[4][4] = { - {2.0f, 0.0f, 0.0f, 0.0f}, - {0.0f,-2.0f, 0.0f, 0.0f}, - {0.0f, 0.0f,-1.0f, 0.0f}, - {-1.0f,1.0f, 0.0f, 1.0f}, - }; - ortho[0][0] /= (GLfloat)glfw->width; - ortho[1][1] /= (GLfloat)glfw->height; - - /* setup global state */ - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glEnable(GL_SCISSOR_TEST); - glActiveTexture(GL_TEXTURE0); - - /* setup program */ - glUseProgram(dev->prog); - glUniform1i(dev->uniform_tex, 0); - glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]); - glViewport(0,0,(GLsizei)glfw->display_width,(GLsizei)glfw->display_height); - { - /* convert from command queue into draw list and draw to screen */ - const struct nk_draw_command *cmd; - void *vertices, *elements; - const nk_draw_index *offset = NULL; - - /* allocate vertex and element buffer */ - glBindVertexArray(dev->vao); - glBindBuffer(GL_ARRAY_BUFFER, dev->vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo); - - glBufferData(GL_ARRAY_BUFFER, max_vertex_buffer, NULL, GL_STREAM_DRAW); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, max_element_buffer, NULL, GL_STREAM_DRAW); - - /* load draw vertices & elements directly into vertex + element buffer */ - vertices = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - elements = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); - { - /* fill convert configuration */ - struct nk_convert_config config; - static const struct nk_draw_vertex_layout_element vertex_layout[] = { - {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct nk_glfw_vertex, position)}, - {NK_VERTEX_TEXCOORD, NK_FORMAT_FLOAT, NK_OFFSETOF(struct nk_glfw_vertex, uv)}, - {NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_glfw_vertex, col)}, - {NK_VERTEX_LAYOUT_END} - }; - memset(&config, 0, sizeof(config)); - config.vertex_layout = vertex_layout; - config.vertex_size = sizeof(struct nk_glfw_vertex); - config.vertex_alignment = NK_ALIGNOF(struct nk_glfw_vertex); - config.null = dev->null; - config.circle_segment_count = 22; - config.curve_segment_count = 22; - config.arc_segment_count = 22; - config.global_alpha = 1.0f; - config.shape_AA = AA; - config.line_AA = AA; - - /* setup buffers to load vertices and elements */ - nk_buffer_init_fixed(&vbuf, vertices, (size_t)max_vertex_buffer); - nk_buffer_init_fixed(&ebuf, elements, (size_t)max_element_buffer); - nk_convert(&glfw->ctx, &dev->cmds, &vbuf, &ebuf, &config); - } - glUnmapBuffer(GL_ARRAY_BUFFER); - glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); - - /* iterate over and execute each draw command */ - nk_draw_foreach(cmd, &glfw->ctx, &dev->cmds) - { - if (!cmd->elem_count) continue; - glBindTexture(GL_TEXTURE_2D, (GLuint)cmd->texture.id); - glScissor( - (GLint)(cmd->clip_rect.x * glfw->fb_scale.x), - (GLint)((glfw->height - (GLint)(cmd->clip_rect.y + cmd->clip_rect.h)) * glfw->fb_scale.y), - (GLint)(cmd->clip_rect.w * glfw->fb_scale.x), - (GLint)(cmd->clip_rect.h * glfw->fb_scale.y)); - glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count, GL_UNSIGNED_SHORT, offset); - offset += cmd->elem_count; - } - nk_clear(&glfw->ctx); - nk_buffer_clear(&dev->cmds); - } - - /* default OpenGL state */ - glUseProgram(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindVertexArray(0); - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); -} - -NK_API void -nk_glfw3_char_callback(GLFWwindow *win, unsigned int codepoint) -{ - struct nk_glfw* glfw = glfwGetWindowUserPointer(win); - if (glfw->text_len < NK_GLFW_TEXT_MAX) - glfw->text[glfw->text_len++] = codepoint; -} - -NK_API void -nk_gflw3_scroll_callback(GLFWwindow *win, double xoff, double yoff) -{ - struct nk_glfw* glfw = glfwGetWindowUserPointer(win); - (void)xoff; - glfw->scroll.x += (float)xoff; - glfw->scroll.y += (float)yoff; -} - -NK_API void -nk_glfw3_mouse_button_callback(GLFWwindow* win, int button, int action, int mods) -{ - struct nk_glfw* glfw = glfwGetWindowUserPointer(win); - double x, y; - NK_UNUSED(mods); - if (button != GLFW_MOUSE_BUTTON_LEFT) return; - glfwGetCursorPos(win, &x, &y); - if (action == GLFW_PRESS) { - double dt = glfwGetTime() - glfw->last_button_click; - if (dt > NK_GLFW_DOUBLE_CLICK_LO && dt < NK_GLFW_DOUBLE_CLICK_HI) { - glfw->is_double_click_down = nk_true; - glfw->double_click_pos = nk_vec2((float)x, (float)y); - } - glfw->last_button_click = glfwGetTime(); - } else glfw->is_double_click_down = nk_false; -} - -NK_INTERN void -nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit) -{ - struct nk_glfw* glfw = (struct nk_glfw*)usr.ptr; - const char *text = glfwGetClipboardString(glfw->win); - if (text) nk_textedit_paste(edit, text, nk_strlen(text)); - (void)usr; -} - -NK_INTERN void -nk_glfw3_clipboard_copy(nk_handle usr, const char *text, int len) -{ - struct nk_glfw* glfw = (struct nk_glfw*)usr.ptr; - char *str = 0; - if (!len) return; - str = (char*)malloc((size_t)len+1); - if (!str) return; - memcpy(str, text, (size_t)len); - str[len] = '\0'; - glfwSetClipboardString(glfw->win, str); - free(str); -} - -NK_API struct nk_context* -nk_glfw3_init(struct nk_glfw* glfw, GLFWwindow *win, enum nk_glfw_init_state init_state) -{ - glfwSetWindowUserPointer(win, glfw); - glfw->win = win; - if (init_state == NK_GLFW3_INSTALL_CALLBACKS) { - glfwSetScrollCallback(win, nk_gflw3_scroll_callback); - glfwSetCharCallback(win, nk_glfw3_char_callback); - glfwSetMouseButtonCallback(win, nk_glfw3_mouse_button_callback); - } - nk_init_default(&glfw->ctx, 0); - glfw->ctx.clip.copy = nk_glfw3_clipboard_copy; - glfw->ctx.clip.paste = nk_glfw3_clipboard_paste; - glfw->ctx.clip.userdata = nk_handle_ptr(&glfw); - glfw->last_button_click = 0; - nk_glfw3_device_create(glfw); - - glfw->is_double_click_down = nk_false; - glfw->double_click_pos = nk_vec2(0, 0); - - return &glfw->ctx; -} - -NK_API void -nk_glfw3_font_stash_begin(struct nk_glfw* glfw, struct nk_font_atlas **atlas) -{ - nk_font_atlas_init_default(&glfw->atlas); - nk_font_atlas_begin(&glfw->atlas); - *atlas = &glfw->atlas; -} - -NK_API void -nk_glfw3_font_stash_end(struct nk_glfw* glfw) -{ - const void *image; int w, h; - image = nk_font_atlas_bake(&glfw->atlas, &w, &h, NK_FONT_ATLAS_RGBA32); - nk_glfw3_device_upload_atlas(glfw, image, w, h); - nk_font_atlas_end(&glfw->atlas, nk_handle_id((int)glfw->ogl.font_tex), &glfw->ogl.null); - if (glfw->atlas.default_font) - nk_style_set_font(&glfw->ctx, &glfw->atlas.default_font->handle); -} - -NK_API void -nk_glfw3_new_frame(struct nk_glfw* glfw) -{ - int i; - double x, y; - struct nk_context *ctx = &glfw->ctx; - struct GLFWwindow *win = glfw->win; - - glfwGetWindowSize(win, &glfw->width, &glfw->height); - glfwGetFramebufferSize(win, &glfw->display_width, &glfw->display_height); - glfw->fb_scale.x = (float)glfw->display_width/(float)glfw->width; - glfw->fb_scale.y = (float)glfw->display_height/(float)glfw->height; - - nk_input_begin(ctx); - for (i = 0; i < glfw->text_len; ++i) - nk_input_unicode(ctx, glfw->text[i]); - -#ifdef NK_GLFW_GL3_MOUSE_GRABBING - /* optional grabbing behavior */ - if (ctx->input.mouse.grab) - glfwSetInputMode(glfw.win, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); - else if (ctx->input.mouse.ungrab) - glfwSetInputMode(glfw->win, GLFW_CURSOR, GLFW_CURSOR_NORMAL); -#endif - - nk_input_key(ctx, NK_KEY_DEL, glfwGetKey(win, GLFW_KEY_DELETE) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_ENTER, glfwGetKey(win, GLFW_KEY_ENTER) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TAB, glfwGetKey(win, GLFW_KEY_TAB) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_BACKSPACE, glfwGetKey(win, GLFW_KEY_BACKSPACE) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_UP, glfwGetKey(win, GLFW_KEY_UP) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_DOWN, glfwGetKey(win, GLFW_KEY_DOWN) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TEXT_START, glfwGetKey(win, GLFW_KEY_HOME) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TEXT_END, glfwGetKey(win, GLFW_KEY_END) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_SCROLL_START, glfwGetKey(win, GLFW_KEY_HOME) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_SCROLL_END, glfwGetKey(win, GLFW_KEY_END) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_SCROLL_DOWN, glfwGetKey(win, GLFW_KEY_PAGE_DOWN) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_SCROLL_UP, glfwGetKey(win, GLFW_KEY_PAGE_UP) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_SHIFT, glfwGetKey(win, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS|| - glfwGetKey(win, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS); - - if (glfwGetKey(win, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || - glfwGetKey(win, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS) { - nk_input_key(ctx, NK_KEY_COPY, glfwGetKey(win, GLFW_KEY_C) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_PASTE, glfwGetKey(win, GLFW_KEY_V) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_CUT, glfwGetKey(win, GLFW_KEY_X) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TEXT_UNDO, glfwGetKey(win, GLFW_KEY_Z) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TEXT_REDO, glfwGetKey(win, GLFW_KEY_R) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TEXT_WORD_LEFT, glfwGetKey(win, GLFW_KEY_LEFT) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TEXT_WORD_RIGHT, glfwGetKey(win, GLFW_KEY_RIGHT) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TEXT_LINE_START, glfwGetKey(win, GLFW_KEY_B) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_TEXT_LINE_END, glfwGetKey(win, GLFW_KEY_E) == GLFW_PRESS); - } else { - nk_input_key(ctx, NK_KEY_LEFT, glfwGetKey(win, GLFW_KEY_LEFT) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_RIGHT, glfwGetKey(win, GLFW_KEY_RIGHT) == GLFW_PRESS); - nk_input_key(ctx, NK_KEY_COPY, 0); - nk_input_key(ctx, NK_KEY_PASTE, 0); - nk_input_key(ctx, NK_KEY_CUT, 0); - nk_input_key(ctx, NK_KEY_SHIFT, 0); - } - - glfwGetCursorPos(win, &x, &y); - nk_input_motion(ctx, (int)x, (int)y); -#ifdef NK_GLFW_GL3_MOUSE_GRABBING - if (ctx->input.mouse.grabbed) { - glfwSetCursorPos(glfw->win, ctx->input.mouse.prev.x, ctx->input.mouse.prev.y); - ctx->input.mouse.pos.x = ctx->input.mouse.prev.x; - ctx->input.mouse.pos.y = ctx->input.mouse.prev.y; - } -#endif - nk_input_button(ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS); - nk_input_button(ctx, NK_BUTTON_MIDDLE, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS); - nk_input_button(ctx, NK_BUTTON_RIGHT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS); - nk_input_button(ctx, NK_BUTTON_DOUBLE, (int)glfw->double_click_pos.x, (int)glfw->double_click_pos.y, glfw->is_double_click_down); - nk_input_scroll(ctx, glfw->scroll); - nk_input_end(&glfw->ctx); - glfw->text_len = 0; - glfw->scroll = nk_vec2(0,0); -} - -NK_API -void nk_glfw3_shutdown(struct nk_glfw* glfw) -{ - nk_font_atlas_clear(&glfw->atlas); - nk_free(&glfw->ctx); - nk_glfw3_device_destroy(glfw); - memset(glfw, 0, sizeof(*glfw)); -} - -#endif diff --git a/source/engine/thirdparty/sokol/sokol_color.h b/source/engine/thirdparty/sokol/sokol_color.h new file mode 100644 index 0000000..cc31b44 --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_color.h @@ -0,0 +1,1148 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_COLOR_IMPL) +#define SOKOL_COLOR_IMPL +#endif +#ifndef SOKOL_COLOR_INCLUDED +/* + sokol_color.h -- sg_color utilities + + This header was generated by gen_sokol_color.py. Do not modify it. + + Project URL: https://github.com/floooh/sokol + + Include the following headers before including sokol_color.h: + + sokol_gfx.h + + FEATURE OVERVIEW + ================ + sokol_color.h defines preset colors based on the X11 color names, + alongside utility functions to create and modify sg_color objects. + + The predefined colors are based on the X11 color names: + + https://en.wikipedia.org/wiki/X11_color_names + + This palette is useful for prototyping - lots of programmers are familiar with + these colours due to their use in X11, web development and XNA / MonoGame. They + are also handy when you want to reference a familiar color, but don't want to + write it out by hand. + + COLORS + ====== + The palette is defined using static const (or constexpr if you are using a + C++ compiler) objects. These objects use lowercase names: + + static SOKOL_COLOR_CONSTEXPR sg_color sg_red = SG_RED; + static SOKOL_COLOR_CONSTEXPR sg_color sg_green = SG_GREEN; + static SOKOL_COLOR_CONSTEXPR sg_color sg_blue = SG_BLUE; + + An sg_color preset object like sg_red can be used to initialize + an sg_pass_action: + + sg_pass_action pass_action = { + .colors[0] = { .action=SG_ACTION_CLEAR, .value = sg_red } + }; + + Initializing an object with static storage duration is more complicated + because of C language rules. Technically, a static const is not a + compile-time constant in C. To work around this, the palette is also + defined as a series of brace-enclosed list macro definitions. These + definitions use uppercase names: + + #define SG_RED { 1.0f, 0.0f, 0.0f, 1.0f } + #define SG_GREEN { 0.0f, 1.0f, 0.0f, 1.0f } + #define SG_BLUE { 0.0f, 0.0f, 1.0f, 1.0f } + + A preset macro like SG_RED can be used to initialize objects with static + storage duration: + + static struct { + sg_pass_action pass_action; + } state = { + .pass_action = { + .colors[0] = { .action = SG_ACTION_CLEAR, .value = SG_RED } + } + }; + + A second set of macro definitions exists for colors packed as 32 bit integer + values. These definitions are also uppercase, but use the _RGBA32 suffix: + + #define SG_RED_RGBA32 0xFF0000FF + #define SG_GREEN_RGBA32 0x00FF00FF + #define SG_BLUE_RGBA32 0x0000FFFF + + This is useful if your code makes use of packed colors, as sokol_gl.h does for its + internal vertex format: + + sgl_begin_triangles(); + sgl_v2f_c1i( 0.0f, 0.5f, SG_RED_RGBA32); + sgl_v2f_c1i( 0.5f, -0.5f, SG_GREEN_RGBA32); + sgl_v2f_c1i(-0.5f, -0.5f, SG_BLUE_RGBA32); + sgl_end(); + + UTILITY FUNCTIONS + ================= + + Utility functions for creating colours are provided: + + - sg_make_color_4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) + Create a sg_color object from separate R, G, B, A bytes. + + - sg_make_color_1i(uint32_t rgba) + Create a sg_color object from RGBA bytes packed into a 32-bit unsigned integer. + + - sg_color_lerp(const sg_color* color_a, const sg_color* color_b, float amount) + Linearly interpolate a color. + + - sg_color_lerp_precise(const sg_color* color_a, const sg_color* color_b, float amount) + Linearly interpolate a color. Less efficient but more precise than sg_color_lerp. + + - sg_color_multiply(const sg_color* color, float scale) + Multiply each color component by the scale factor. + + LICENSE + ======= + + zlib/libpng license + + Copyright (c) 2020 Stuart Adams + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_COLOR_INCLUDED (1) + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_color.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_GL_API_DECL) +#define SOKOL_COLOR_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_COLOR_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_COLOR_IMPL) +#define SOKOL_COLOR_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_COLOR_API_DECL __declspec(dllimport) +#else +#define SOKOL_COLOR_API_DECL extern +#endif +#endif + +#ifdef __cplusplus +#define SOKOL_COLOR_CONSTEXPR constexpr +extern "C" { +#else +#define SOKOL_COLOR_CONSTEXPR const +#endif + +SOKOL_COLOR_API_DECL sg_color sg_make_color_4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a); +SOKOL_COLOR_API_DECL sg_color sg_make_color_1i(uint32_t rgba); +SOKOL_COLOR_API_DECL sg_color sg_color_lerp(const sg_color* color_a, const sg_color* color_b, float amount); +SOKOL_COLOR_API_DECL sg_color sg_color_lerp_precise(const sg_color* color_a, const sg_color* color_b, float amount); +SOKOL_COLOR_API_DECL sg_color sg_color_multiply(const sg_color* color, float scale); + +/* Alice Blue color { R:240, G:248, B:255, A:255 } */ +#define SG_ALICE_BLUE { 0.941176471f, 0.97254902f, 1.0f, 1.0f } +/* Antique White color { R:250, G:235, B:215, A:255 } */ +#define SG_ANTIQUE_WHITE { 0.980392157f, 0.921568627f, 0.843137255f, 1.0f } +/* Aqua color { R:0, G:255, B:255, A:255 } */ +#define SG_AQUA { 0.0f, 1.0f, 1.0f, 1.0f } +/* Aquamarine color { R:127, G:255, B:212, A:255 } */ +#define SG_AQUAMARINE { 0.498039216f, 1.0f, 0.831372549f, 1.0f } +/* Azure color { R:240, G:255, B:255, A:255 } */ +#define SG_AZURE { 0.941176471f, 1.0f, 1.0f, 1.0f } +/* Beige color { R:245, G:245, B:220, A:255 } */ +#define SG_BEIGE { 0.960784314f, 0.960784314f, 0.862745098f, 1.0f } +/* Bisque color { R:255, G:228, B:196, A:255 } */ +#define SG_BISQUE { 1.0f, 0.894117647f, 0.768627451f, 1.0f } +/* Black color { R:0, G:0, B:0, A:255 } */ +#define SG_BLACK { 0.0f, 0.0f, 0.0f, 1.0f } +/* Blanched Almond color { R:255, G:235, B:205, A:255 } */ +#define SG_BLANCHED_ALMOND { 1.0f, 0.921568627f, 0.803921569f, 1.0f } +/* Blue color { R:0, G:0, B:255, A:255 } */ +#define SG_BLUE { 0.0f, 0.0f, 1.0f, 1.0f } +/* Blue Violet color { R:138, G:43, B:226, A:255 } */ +#define SG_BLUE_VIOLET { 0.541176471f, 0.168627451f, 0.88627451f, 1.0f } +/* Brown color { R:165, G:42, B:42, A:255 } */ +#define SG_BROWN { 0.647058824f, 0.164705882f, 0.164705882f, 1.0f } +/* Burlywood color { R:222, G:184, B:135, A:255 } */ +#define SG_BURLYWOOD { 0.870588235f, 0.721568627f, 0.529411765f, 1.0f } +/* Cadet Blue color { R:95, G:158, B:160, A:255 } */ +#define SG_CADET_BLUE { 0.37254902f, 0.619607843f, 0.62745098f, 1.0f } +/* Chartreuse color { R:127, G:255, B:0, A:255 } */ +#define SG_CHARTREUSE { 0.498039216f, 1.0f, 0.0f, 1.0f } +/* Chocolate color { R:210, G:105, B:30, A:255 } */ +#define SG_CHOCOLATE { 0.823529412f, 0.411764706f, 0.117647059f, 1.0f } +/* Coral color { R:255, G:127, B:80, A:255 } */ +#define SG_CORAL { 1.0f, 0.498039216f, 0.31372549f, 1.0f } +/* Cornflower Blue color { R:100, G:149, B:237, A:255 } */ +#define SG_CORNFLOWER_BLUE { 0.392156863f, 0.584313725f, 0.929411765f, 1.0f } +/* Cornsilk color { R:255, G:248, B:220, A:255 } */ +#define SG_CORNSILK { 1.0f, 0.97254902f, 0.862745098f, 1.0f } +/* Crimson color { R:220, G:20, B:60, A:255 } */ +#define SG_CRIMSON { 0.862745098f, 0.0784313725f, 0.235294118f, 1.0f } +/* Cyan color { R:0, G:255, B:255, A:255 } */ +#define SG_CYAN { 0.0f, 1.0f, 1.0f, 1.0f } +/* Dark Blue color { R:0, G:0, B:139, A:255 } */ +#define SG_DARK_BLUE { 0.0f, 0.0f, 0.545098039f, 1.0f } +/* Dark Cyan color { R:0, G:139, B:139, A:255 } */ +#define SG_DARK_CYAN { 0.0f, 0.545098039f, 0.545098039f, 1.0f } +/* Dark Goldenrod color { R:184, G:134, B:11, A:255 } */ +#define SG_DARK_GOLDENROD { 0.721568627f, 0.525490196f, 0.0431372549f, 1.0f } +/* Dark Gray color { R:169, G:169, B:169, A:255 } */ +#define SG_DARK_GRAY { 0.662745098f, 0.662745098f, 0.662745098f, 1.0f } +/* Dark Green color { R:0, G:100, B:0, A:255 } */ +#define SG_DARK_GREEN { 0.0f, 0.392156863f, 0.0f, 1.0f } +/* Dark Khaki color { R:189, G:183, B:107, A:255 } */ +#define SG_DARK_KHAKI { 0.741176471f, 0.717647059f, 0.419607843f, 1.0f } +/* Dark Magenta color { R:139, G:0, B:139, A:255 } */ +#define SG_DARK_MAGENTA { 0.545098039f, 0.0f, 0.545098039f, 1.0f } +/* Dark Olive Green color { R:85, G:107, B:47, A:255 } */ +#define SG_DARK_OLIVE_GREEN { 0.333333333f, 0.419607843f, 0.184313725f, 1.0f } +/* Dark Orange color { R:255, G:140, B:0, A:255 } */ +#define SG_DARK_ORANGE { 1.0f, 0.549019608f, 0.0f, 1.0f } +/* Dark Orchid color { R:153, G:50, B:204, A:255 } */ +#define SG_DARK_ORCHID { 0.6f, 0.196078431f, 0.8f, 1.0f } +/* Dark Red color { R:139, G:0, B:0, A:255 } */ +#define SG_DARK_RED { 0.545098039f, 0.0f, 0.0f, 1.0f } +/* Dark Salmon color { R:233, G:150, B:122, A:255 } */ +#define SG_DARK_SALMON { 0.91372549f, 0.588235294f, 0.478431373f, 1.0f } +/* Dark Sea Green color { R:143, G:188, B:143, A:255 } */ +#define SG_DARK_SEA_GREEN { 0.560784314f, 0.737254902f, 0.560784314f, 1.0f } +/* Dark Slate Blue color { R:72, G:61, B:139, A:255 } */ +#define SG_DARK_SLATE_BLUE { 0.282352941f, 0.239215686f, 0.545098039f, 1.0f } +/* Dark Slate Gray color { R:47, G:79, B:79, A:255 } */ +#define SG_DARK_SLATE_GRAY { 0.184313725f, 0.309803922f, 0.309803922f, 1.0f } +/* Dark Turquoise color { R:0, G:206, B:209, A:255 } */ +#define SG_DARK_TURQUOISE { 0.0f, 0.807843137f, 0.819607843f, 1.0f } +/* Dark Violet color { R:148, G:0, B:211, A:255 } */ +#define SG_DARK_VIOLET { 0.580392157f, 0.0f, 0.82745098f, 1.0f } +/* Deep Pink color { R:255, G:20, B:147, A:255 } */ +#define SG_DEEP_PINK { 1.0f, 0.0784313725f, 0.576470588f, 1.0f } +/* Deep Sky Blue color { R:0, G:191, B:255, A:255 } */ +#define SG_DEEP_SKY_BLUE { 0.0f, 0.749019608f, 1.0f, 1.0f } +/* Dim Gray color { R:105, G:105, B:105, A:255 } */ +#define SG_DIM_GRAY { 0.411764706f, 0.411764706f, 0.411764706f, 1.0f } +/* Dodger Blue color { R:30, G:144, B:255, A:255 } */ +#define SG_DODGER_BLUE { 0.117647059f, 0.564705882f, 1.0f, 1.0f } +/* Firebrick color { R:178, G:34, B:34, A:255 } */ +#define SG_FIREBRICK { 0.698039216f, 0.133333333f, 0.133333333f, 1.0f } +/* Floral White color { R:255, G:250, B:240, A:255 } */ +#define SG_FLORAL_WHITE { 1.0f, 0.980392157f, 0.941176471f, 1.0f } +/* Forest Green color { R:34, G:139, B:34, A:255 } */ +#define SG_FOREST_GREEN { 0.133333333f, 0.545098039f, 0.133333333f, 1.0f } +/* Fuchsia color { R:255, G:0, B:255, A:255 } */ +#define SG_FUCHSIA { 1.0f, 0.0f, 1.0f, 1.0f } +/* Gainsboro color { R:220, G:220, B:220, A:255 } */ +#define SG_GAINSBORO { 0.862745098f, 0.862745098f, 0.862745098f, 1.0f } +/* Ghost White color { R:248, G:248, B:255, A:255 } */ +#define SG_GHOST_WHITE { 0.97254902f, 0.97254902f, 1.0f, 1.0f } +/* Gold color { R:255, G:215, B:0, A:255 } */ +#define SG_GOLD { 1.0f, 0.843137255f, 0.0f, 1.0f } +/* Goldenrod color { R:218, G:165, B:32, A:255 } */ +#define SG_GOLDENROD { 0.854901961f, 0.647058824f, 0.125490196f, 1.0f } +/* Gray color { R:190, G:190, B:190, A:255 } */ +#define SG_GRAY { 0.745098039f, 0.745098039f, 0.745098039f, 1.0f } +/* Web Gray color { R:128, G:128, B:128, A:255 } */ +#define SG_WEB_GRAY { 0.501960784f, 0.501960784f, 0.501960784f, 1.0f } +/* Green color { R:0, G:255, B:0, A:255 } */ +#define SG_GREEN { 0.0f, 1.0f, 0.0f, 1.0f } +/* Web Green color { R:0, G:128, B:0, A:255 } */ +#define SG_WEB_GREEN { 0.0f, 0.501960784f, 0.0f, 1.0f } +/* Green Yellow color { R:173, G:255, B:47, A:255 } */ +#define SG_GREEN_YELLOW { 0.678431373f, 1.0f, 0.184313725f, 1.0f } +/* Honeydew color { R:240, G:255, B:240, A:255 } */ +#define SG_HONEYDEW { 0.941176471f, 1.0f, 0.941176471f, 1.0f } +/* Hot Pink color { R:255, G:105, B:180, A:255 } */ +#define SG_HOT_PINK { 1.0f, 0.411764706f, 0.705882353f, 1.0f } +/* Indian Red color { R:205, G:92, B:92, A:255 } */ +#define SG_INDIAN_RED { 0.803921569f, 0.360784314f, 0.360784314f, 1.0f } +/* Indigo color { R:75, G:0, B:130, A:255 } */ +#define SG_INDIGO { 0.294117647f, 0.0f, 0.509803922f, 1.0f } +/* Ivory color { R:255, G:255, B:240, A:255 } */ +#define SG_IVORY { 1.0f, 1.0f, 0.941176471f, 1.0f } +/* Khaki color { R:240, G:230, B:140, A:255 } */ +#define SG_KHAKI { 0.941176471f, 0.901960784f, 0.549019608f, 1.0f } +/* Lavender color { R:230, G:230, B:250, A:255 } */ +#define SG_LAVENDER { 0.901960784f, 0.901960784f, 0.980392157f, 1.0f } +/* Lavender Blush color { R:255, G:240, B:245, A:255 } */ +#define SG_LAVENDER_BLUSH { 1.0f, 0.941176471f, 0.960784314f, 1.0f } +/* Lawn Green color { R:124, G:252, B:0, A:255 } */ +#define SG_LAWN_GREEN { 0.48627451f, 0.988235294f, 0.0f, 1.0f } +/* Lemon Chiffon color { R:255, G:250, B:205, A:255 } */ +#define SG_LEMON_CHIFFON { 1.0f, 0.980392157f, 0.803921569f, 1.0f } +/* Light Blue color { R:173, G:216, B:230, A:255 } */ +#define SG_LIGHT_BLUE { 0.678431373f, 0.847058824f, 0.901960784f, 1.0f } +/* Light Coral color { R:240, G:128, B:128, A:255 } */ +#define SG_LIGHT_CORAL { 0.941176471f, 0.501960784f, 0.501960784f, 1.0f } +/* Light Cyan color { R:224, G:255, B:255, A:255 } */ +#define SG_LIGHT_CYAN { 0.878431373f, 1.0f, 1.0f, 1.0f } +/* Light Goldenrod color { R:250, G:250, B:210, A:255 } */ +#define SG_LIGHT_GOLDENROD { 0.980392157f, 0.980392157f, 0.823529412f, 1.0f } +/* Light Gray color { R:211, G:211, B:211, A:255 } */ +#define SG_LIGHT_GRAY { 0.82745098f, 0.82745098f, 0.82745098f, 1.0f } +/* Light Green color { R:144, G:238, B:144, A:255 } */ +#define SG_LIGHT_GREEN { 0.564705882f, 0.933333333f, 0.564705882f, 1.0f } +/* Light Pink color { R:255, G:182, B:193, A:255 } */ +#define SG_LIGHT_PINK { 1.0f, 0.71372549f, 0.756862745f, 1.0f } +/* Light Salmon color { R:255, G:160, B:122, A:255 } */ +#define SG_LIGHT_SALMON { 1.0f, 0.62745098f, 0.478431373f, 1.0f } +/* Light Sea Green color { R:32, G:178, B:170, A:255 } */ +#define SG_LIGHT_SEA_GREEN { 0.125490196f, 0.698039216f, 0.666666667f, 1.0f } +/* Light Sky Blue color { R:135, G:206, B:250, A:255 } */ +#define SG_LIGHT_SKY_BLUE { 0.529411765f, 0.807843137f, 0.980392157f, 1.0f } +/* Light Slate Gray color { R:119, G:136, B:153, A:255 } */ +#define SG_LIGHT_SLATE_GRAY { 0.466666667f, 0.533333333f, 0.6f, 1.0f } +/* Light Steel Blue color { R:176, G:196, B:222, A:255 } */ +#define SG_LIGHT_STEEL_BLUE { 0.690196078f, 0.768627451f, 0.870588235f, 1.0f } +/* Light Yellow color { R:255, G:255, B:224, A:255 } */ +#define SG_LIGHT_YELLOW { 1.0f, 1.0f, 0.878431373f, 1.0f } +/* Lime color { R:0, G:255, B:0, A:255 } */ +#define SG_LIME { 0.0f, 1.0f, 0.0f, 1.0f } +/* Lime Green color { R:50, G:205, B:50, A:255 } */ +#define SG_LIME_GREEN { 0.196078431f, 0.803921569f, 0.196078431f, 1.0f } +/* Linen color { R:250, G:240, B:230, A:255 } */ +#define SG_LINEN { 0.980392157f, 0.941176471f, 0.901960784f, 1.0f } +/* Magenta color { R:255, G:0, B:255, A:255 } */ +#define SG_MAGENTA { 1.0f, 0.0f, 1.0f, 1.0f } +/* Maroon color { R:176, G:48, B:96, A:255 } */ +#define SG_MAROON { 0.690196078f, 0.188235294f, 0.376470588f, 1.0f } +/* Web Maroon color { R:128, G:0, B:0, A:255 } */ +#define SG_WEB_MAROON { 0.501960784f, 0.0f, 0.0f, 1.0f } +/* Medium Aquamarine color { R:102, G:205, B:170, A:255 } */ +#define SG_MEDIUM_AQUAMARINE { 0.4f, 0.803921569f, 0.666666667f, 1.0f } +/* Medium Blue color { R:0, G:0, B:205, A:255 } */ +#define SG_MEDIUM_BLUE { 0.0f, 0.0f, 0.803921569f, 1.0f } +/* Medium Orchid color { R:186, G:85, B:211, A:255 } */ +#define SG_MEDIUM_ORCHID { 0.729411765f, 0.333333333f, 0.82745098f, 1.0f } +/* Medium Purple color { R:147, G:112, B:219, A:255 } */ +#define SG_MEDIUM_PURPLE { 0.576470588f, 0.439215686f, 0.858823529f, 1.0f } +/* Medium Sea Green color { R:60, G:179, B:113, A:255 } */ +#define SG_MEDIUM_SEA_GREEN { 0.235294118f, 0.701960784f, 0.443137255f, 1.0f } +/* Medium Slate Blue color { R:123, G:104, B:238, A:255 } */ +#define SG_MEDIUM_SLATE_BLUE { 0.482352941f, 0.407843137f, 0.933333333f, 1.0f } +/* Medium Spring Green color { R:0, G:250, B:154, A:255 } */ +#define SG_MEDIUM_SPRING_GREEN { 0.0f, 0.980392157f, 0.603921569f, 1.0f } +/* Medium Turquoise color { R:72, G:209, B:204, A:255 } */ +#define SG_MEDIUM_TURQUOISE { 0.282352941f, 0.819607843f, 0.8f, 1.0f } +/* Medium Violet Red color { R:199, G:21, B:133, A:255 } */ +#define SG_MEDIUM_VIOLET_RED { 0.780392157f, 0.0823529412f, 0.521568627f, 1.0f } +/* Midnight Blue color { R:25, G:25, B:112, A:255 } */ +#define SG_MIDNIGHT_BLUE { 0.0980392157f, 0.0980392157f, 0.439215686f, 1.0f } +/* Mint Cream color { R:245, G:255, B:250, A:255 } */ +#define SG_MINT_CREAM { 0.960784314f, 1.0f, 0.980392157f, 1.0f } +/* Misty Rose color { R:255, G:228, B:225, A:255 } */ +#define SG_MISTY_ROSE { 1.0f, 0.894117647f, 0.882352941f, 1.0f } +/* Moccasin color { R:255, G:228, B:181, A:255 } */ +#define SG_MOCCASIN { 1.0f, 0.894117647f, 0.709803922f, 1.0f } +/* Navajo White color { R:255, G:222, B:173, A:255 } */ +#define SG_NAVAJO_WHITE { 1.0f, 0.870588235f, 0.678431373f, 1.0f } +/* Navy Blue color { R:0, G:0, B:128, A:255 } */ +#define SG_NAVY_BLUE { 0.0f, 0.0f, 0.501960784f, 1.0f } +/* Old Lace color { R:253, G:245, B:230, A:255 } */ +#define SG_OLD_LACE { 0.992156863f, 0.960784314f, 0.901960784f, 1.0f } +/* Olive color { R:128, G:128, B:0, A:255 } */ +#define SG_OLIVE { 0.501960784f, 0.501960784f, 0.0f, 1.0f } +/* Olive Drab color { R:107, G:142, B:35, A:255 } */ +#define SG_OLIVE_DRAB { 0.419607843f, 0.556862745f, 0.137254902f, 1.0f } +/* Orange color { R:255, G:165, B:0, A:255 } */ +#define SG_ORANGE { 1.0f, 0.647058824f, 0.0f, 1.0f } +/* Orange Red color { R:255, G:69, B:0, A:255 } */ +#define SG_ORANGE_RED { 1.0f, 0.270588235f, 0.0f, 1.0f } +/* Orchid color { R:218, G:112, B:214, A:255 } */ +#define SG_ORCHID { 0.854901961f, 0.439215686f, 0.839215686f, 1.0f } +/* Pale Goldenrod color { R:238, G:232, B:170, A:255 } */ +#define SG_PALE_GOLDENROD { 0.933333333f, 0.909803922f, 0.666666667f, 1.0f } +/* Pale Green color { R:152, G:251, B:152, A:255 } */ +#define SG_PALE_GREEN { 0.596078431f, 0.984313725f, 0.596078431f, 1.0f } +/* Pale Turquoise color { R:175, G:238, B:238, A:255 } */ +#define SG_PALE_TURQUOISE { 0.68627451f, 0.933333333f, 0.933333333f, 1.0f } +/* Pale Violet Red color { R:219, G:112, B:147, A:255 } */ +#define SG_PALE_VIOLET_RED { 0.858823529f, 0.439215686f, 0.576470588f, 1.0f } +/* Papaya Whip color { R:255, G:239, B:213, A:255 } */ +#define SG_PAPAYA_WHIP { 1.0f, 0.937254902f, 0.835294118f, 1.0f } +/* Peach Puff color { R:255, G:218, B:185, A:255 } */ +#define SG_PEACH_PUFF { 1.0f, 0.854901961f, 0.725490196f, 1.0f } +/* Peru color { R:205, G:133, B:63, A:255 } */ +#define SG_PERU { 0.803921569f, 0.521568627f, 0.247058824f, 1.0f } +/* Pink color { R:255, G:192, B:203, A:255 } */ +#define SG_PINK { 1.0f, 0.752941176f, 0.796078431f, 1.0f } +/* Plum color { R:221, G:160, B:221, A:255 } */ +#define SG_PLUM { 0.866666667f, 0.62745098f, 0.866666667f, 1.0f } +/* Powder Blue color { R:176, G:224, B:230, A:255 } */ +#define SG_POWDER_BLUE { 0.690196078f, 0.878431373f, 0.901960784f, 1.0f } +/* Purple color { R:160, G:32, B:240, A:255 } */ +#define SG_PURPLE { 0.62745098f, 0.125490196f, 0.941176471f, 1.0f } +/* Web Purple color { R:128, G:0, B:128, A:255 } */ +#define SG_WEB_PURPLE { 0.501960784f, 0.0f, 0.501960784f, 1.0f } +/* Rebecca Purple color { R:102, G:51, B:153, A:255 } */ +#define SG_REBECCA_PURPLE { 0.4f, 0.2f, 0.6f, 1.0f } +/* Red color { R:255, G:0, B:0, A:255 } */ +#define SG_RED { 1.0f, 0.0f, 0.0f, 1.0f } +/* Rosy Brown color { R:188, G:143, B:143, A:255 } */ +#define SG_ROSY_BROWN { 0.737254902f, 0.560784314f, 0.560784314f, 1.0f } +/* Royal Blue color { R:65, G:105, B:225, A:255 } */ +#define SG_ROYAL_BLUE { 0.254901961f, 0.411764706f, 0.882352941f, 1.0f } +/* Saddle Brown color { R:139, G:69, B:19, A:255 } */ +#define SG_SADDLE_BROWN { 0.545098039f, 0.270588235f, 0.0745098039f, 1.0f } +/* Salmon color { R:250, G:128, B:114, A:255 } */ +#define SG_SALMON { 0.980392157f, 0.501960784f, 0.447058824f, 1.0f } +/* Sandy Brown color { R:244, G:164, B:96, A:255 } */ +#define SG_SANDY_BROWN { 0.956862745f, 0.643137255f, 0.376470588f, 1.0f } +/* Sea Green color { R:46, G:139, B:87, A:255 } */ +#define SG_SEA_GREEN { 0.180392157f, 0.545098039f, 0.341176471f, 1.0f } +/* Seashell color { R:255, G:245, B:238, A:255 } */ +#define SG_SEASHELL { 1.0f, 0.960784314f, 0.933333333f, 1.0f } +/* Sienna color { R:160, G:82, B:45, A:255 } */ +#define SG_SIENNA { 0.62745098f, 0.321568627f, 0.176470588f, 1.0f } +/* Silver color { R:192, G:192, B:192, A:255 } */ +#define SG_SILVER { 0.752941176f, 0.752941176f, 0.752941176f, 1.0f } +/* Sky Blue color { R:135, G:206, B:235, A:255 } */ +#define SG_SKY_BLUE { 0.529411765f, 0.807843137f, 0.921568627f, 1.0f } +/* Slate Blue color { R:106, G:90, B:205, A:255 } */ +#define SG_SLATE_BLUE { 0.415686275f, 0.352941176f, 0.803921569f, 1.0f } +/* Slate Gray color { R:112, G:128, B:144, A:255 } */ +#define SG_SLATE_GRAY { 0.439215686f, 0.501960784f, 0.564705882f, 1.0f } +/* Snow color { R:255, G:250, B:250, A:255 } */ +#define SG_SNOW { 1.0f, 0.980392157f, 0.980392157f, 1.0f } +/* Spring Green color { R:0, G:255, B:127, A:255 } */ +#define SG_SPRING_GREEN { 0.0f, 1.0f, 0.498039216f, 1.0f } +/* Steel Blue color { R:70, G:130, B:180, A:255 } */ +#define SG_STEEL_BLUE { 0.274509804f, 0.509803922f, 0.705882353f, 1.0f } +/* Tan color { R:210, G:180, B:140, A:255 } */ +#define SG_TAN { 0.823529412f, 0.705882353f, 0.549019608f, 1.0f } +/* Teal color { R:0, G:128, B:128, A:255 } */ +#define SG_TEAL { 0.0f, 0.501960784f, 0.501960784f, 1.0f } +/* Thistle color { R:216, G:191, B:216, A:255 } */ +#define SG_THISTLE { 0.847058824f, 0.749019608f, 0.847058824f, 1.0f } +/* Tomato color { R:255, G:99, B:71, A:255 } */ +#define SG_TOMATO { 1.0f, 0.388235294f, 0.278431373f, 1.0f } +/* Transparent color { R:0, G:0, B:0, A:0 } */ +#define SG_TRANSPARENT { 0.0f, 0.0f, 0.0f, 0.0f } +/* Turquoise color { R:64, G:224, B:208, A:255 } */ +#define SG_TURQUOISE { 0.250980392f, 0.878431373f, 0.815686275f, 1.0f } +/* Violet color { R:238, G:130, B:238, A:255 } */ +#define SG_VIOLET { 0.933333333f, 0.509803922f, 0.933333333f, 1.0f } +/* Wheat color { R:245, G:222, B:179, A:255 } */ +#define SG_WHEAT { 0.960784314f, 0.870588235f, 0.701960784f, 1.0f } +/* White color { R:255, G:255, B:255, A:255 } */ +#define SG_WHITE { 1.0f, 1.0f, 1.0f, 1.0f } +/* White Smoke color { R:245, G:245, B:245, A:255 } */ +#define SG_WHITE_SMOKE { 0.960784314f, 0.960784314f, 0.960784314f, 1.0f } +/* Yellow color { R:255, G:255, B:0, A:255 } */ +#define SG_YELLOW { 1.0f, 1.0f, 0.0f, 1.0f } +/* Yellow Green color { R:154, G:205, B:50, A:255 } */ +#define SG_YELLOW_GREEN { 0.603921569f, 0.803921569f, 0.196078431f, 1.0f } + +/* Alice Blue color { R:240, G:248, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_alice_blue = SG_ALICE_BLUE; +/* Antique White color { R:250, G:235, B:215, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_antique_white = SG_ANTIQUE_WHITE; +/* Aqua color { R:0, G:255, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_aqua = SG_AQUA; +/* Aquamarine color { R:127, G:255, B:212, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_aquamarine = SG_AQUAMARINE; +/* Azure color { R:240, G:255, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_azure = SG_AZURE; +/* Beige color { R:245, G:245, B:220, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_beige = SG_BEIGE; +/* Bisque color { R:255, G:228, B:196, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_bisque = SG_BISQUE; +/* Black color { R:0, G:0, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_black = SG_BLACK; +/* Blanched Almond color { R:255, G:235, B:205, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_blanched_almond = SG_BLANCHED_ALMOND; +/* Blue color { R:0, G:0, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_blue = SG_BLUE; +/* Blue Violet color { R:138, G:43, B:226, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_blue_violet = SG_BLUE_VIOLET; +/* Brown color { R:165, G:42, B:42, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_brown = SG_BROWN; +/* Burlywood color { R:222, G:184, B:135, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_burlywood = SG_BURLYWOOD; +/* Cadet Blue color { R:95, G:158, B:160, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_cadet_blue = SG_CADET_BLUE; +/* Chartreuse color { R:127, G:255, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_chartreuse = SG_CHARTREUSE; +/* Chocolate color { R:210, G:105, B:30, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_chocolate = SG_CHOCOLATE; +/* Coral color { R:255, G:127, B:80, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_coral = SG_CORAL; +/* Cornflower Blue color { R:100, G:149, B:237, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_cornflower_blue = SG_CORNFLOWER_BLUE; +/* Cornsilk color { R:255, G:248, B:220, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_cornsilk = SG_CORNSILK; +/* Crimson color { R:220, G:20, B:60, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_crimson = SG_CRIMSON; +/* Cyan color { R:0, G:255, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_cyan = SG_CYAN; +/* Dark Blue color { R:0, G:0, B:139, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_blue = SG_DARK_BLUE; +/* Dark Cyan color { R:0, G:139, B:139, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_cyan = SG_DARK_CYAN; +/* Dark Goldenrod color { R:184, G:134, B:11, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_goldenrod = SG_DARK_GOLDENROD; +/* Dark Gray color { R:169, G:169, B:169, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_gray = SG_DARK_GRAY; +/* Dark Green color { R:0, G:100, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_green = SG_DARK_GREEN; +/* Dark Khaki color { R:189, G:183, B:107, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_khaki = SG_DARK_KHAKI; +/* Dark Magenta color { R:139, G:0, B:139, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_magenta = SG_DARK_MAGENTA; +/* Dark Olive Green color { R:85, G:107, B:47, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_olive_green = SG_DARK_OLIVE_GREEN; +/* Dark Orange color { R:255, G:140, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_orange = SG_DARK_ORANGE; +/* Dark Orchid color { R:153, G:50, B:204, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_orchid = SG_DARK_ORCHID; +/* Dark Red color { R:139, G:0, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_red = SG_DARK_RED; +/* Dark Salmon color { R:233, G:150, B:122, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_salmon = SG_DARK_SALMON; +/* Dark Sea Green color { R:143, G:188, B:143, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_sea_green = SG_DARK_SEA_GREEN; +/* Dark Slate Blue color { R:72, G:61, B:139, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_slate_blue = SG_DARK_SLATE_BLUE; +/* Dark Slate Gray color { R:47, G:79, B:79, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_slate_gray = SG_DARK_SLATE_GRAY; +/* Dark Turquoise color { R:0, G:206, B:209, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_turquoise = SG_DARK_TURQUOISE; +/* Dark Violet color { R:148, G:0, B:211, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dark_violet = SG_DARK_VIOLET; +/* Deep Pink color { R:255, G:20, B:147, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_deep_pink = SG_DEEP_PINK; +/* Deep Sky Blue color { R:0, G:191, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_deep_sky_blue = SG_DEEP_SKY_BLUE; +/* Dim Gray color { R:105, G:105, B:105, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dim_gray = SG_DIM_GRAY; +/* Dodger Blue color { R:30, G:144, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_dodger_blue = SG_DODGER_BLUE; +/* Firebrick color { R:178, G:34, B:34, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_firebrick = SG_FIREBRICK; +/* Floral White color { R:255, G:250, B:240, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_floral_white = SG_FLORAL_WHITE; +/* Forest Green color { R:34, G:139, B:34, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_forest_green = SG_FOREST_GREEN; +/* Fuchsia color { R:255, G:0, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_fuchsia = SG_FUCHSIA; +/* Gainsboro color { R:220, G:220, B:220, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_gainsboro = SG_GAINSBORO; +/* Ghost White color { R:248, G:248, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_ghost_white = SG_GHOST_WHITE; +/* Gold color { R:255, G:215, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_gold = SG_GOLD; +/* Goldenrod color { R:218, G:165, B:32, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_goldenrod = SG_GOLDENROD; +/* Gray color { R:190, G:190, B:190, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_gray = SG_GRAY; +/* Web Gray color { R:128, G:128, B:128, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_web_gray = SG_WEB_GRAY; +/* Green color { R:0, G:255, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_green = SG_GREEN; +/* Web Green color { R:0, G:128, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_web_green = SG_WEB_GREEN; +/* Green Yellow color { R:173, G:255, B:47, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_green_yellow = SG_GREEN_YELLOW; +/* Honeydew color { R:240, G:255, B:240, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_honeydew = SG_HONEYDEW; +/* Hot Pink color { R:255, G:105, B:180, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_hot_pink = SG_HOT_PINK; +/* Indian Red color { R:205, G:92, B:92, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_indian_red = SG_INDIAN_RED; +/* Indigo color { R:75, G:0, B:130, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_indigo = SG_INDIGO; +/* Ivory color { R:255, G:255, B:240, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_ivory = SG_IVORY; +/* Khaki color { R:240, G:230, B:140, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_khaki = SG_KHAKI; +/* Lavender color { R:230, G:230, B:250, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_lavender = SG_LAVENDER; +/* Lavender Blush color { R:255, G:240, B:245, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_lavender_blush = SG_LAVENDER_BLUSH; +/* Lawn Green color { R:124, G:252, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_lawn_green = SG_LAWN_GREEN; +/* Lemon Chiffon color { R:255, G:250, B:205, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_lemon_chiffon = SG_LEMON_CHIFFON; +/* Light Blue color { R:173, G:216, B:230, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_blue = SG_LIGHT_BLUE; +/* Light Coral color { R:240, G:128, B:128, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_coral = SG_LIGHT_CORAL; +/* Light Cyan color { R:224, G:255, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_cyan = SG_LIGHT_CYAN; +/* Light Goldenrod color { R:250, G:250, B:210, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_goldenrod = SG_LIGHT_GOLDENROD; +/* Light Gray color { R:211, G:211, B:211, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_gray = SG_LIGHT_GRAY; +/* Light Green color { R:144, G:238, B:144, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_green = SG_LIGHT_GREEN; +/* Light Pink color { R:255, G:182, B:193, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_pink = SG_LIGHT_PINK; +/* Light Salmon color { R:255, G:160, B:122, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_salmon = SG_LIGHT_SALMON; +/* Light Sea Green color { R:32, G:178, B:170, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_sea_green = SG_LIGHT_SEA_GREEN; +/* Light Sky Blue color { R:135, G:206, B:250, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_sky_blue = SG_LIGHT_SKY_BLUE; +/* Light Slate Gray color { R:119, G:136, B:153, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_slate_gray = SG_LIGHT_SLATE_GRAY; +/* Light Steel Blue color { R:176, G:196, B:222, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_steel_blue = SG_LIGHT_STEEL_BLUE; +/* Light Yellow color { R:255, G:255, B:224, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_light_yellow = SG_LIGHT_YELLOW; +/* Lime color { R:0, G:255, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_lime = SG_LIME; +/* Lime Green color { R:50, G:205, B:50, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_lime_green = SG_LIME_GREEN; +/* Linen color { R:250, G:240, B:230, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_linen = SG_LINEN; +/* Magenta color { R:255, G:0, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_magenta = SG_MAGENTA; +/* Maroon color { R:176, G:48, B:96, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_maroon = SG_MAROON; +/* Web Maroon color { R:128, G:0, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_web_maroon = SG_WEB_MAROON; +/* Medium Aquamarine color { R:102, G:205, B:170, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_aquamarine = SG_MEDIUM_AQUAMARINE; +/* Medium Blue color { R:0, G:0, B:205, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_blue = SG_MEDIUM_BLUE; +/* Medium Orchid color { R:186, G:85, B:211, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_orchid = SG_MEDIUM_ORCHID; +/* Medium Purple color { R:147, G:112, B:219, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_purple = SG_MEDIUM_PURPLE; +/* Medium Sea Green color { R:60, G:179, B:113, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_sea_green = SG_MEDIUM_SEA_GREEN; +/* Medium Slate Blue color { R:123, G:104, B:238, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_slate_blue = SG_MEDIUM_SLATE_BLUE; +/* Medium Spring Green color { R:0, G:250, B:154, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_spring_green = SG_MEDIUM_SPRING_GREEN; +/* Medium Turquoise color { R:72, G:209, B:204, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_turquoise = SG_MEDIUM_TURQUOISE; +/* Medium Violet Red color { R:199, G:21, B:133, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_medium_violet_red = SG_MEDIUM_VIOLET_RED; +/* Midnight Blue color { R:25, G:25, B:112, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_midnight_blue = SG_MIDNIGHT_BLUE; +/* Mint Cream color { R:245, G:255, B:250, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_mint_cream = SG_MINT_CREAM; +/* Misty Rose color { R:255, G:228, B:225, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_misty_rose = SG_MISTY_ROSE; +/* Moccasin color { R:255, G:228, B:181, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_moccasin = SG_MOCCASIN; +/* Navajo White color { R:255, G:222, B:173, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_navajo_white = SG_NAVAJO_WHITE; +/* Navy Blue color { R:0, G:0, B:128, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_navy_blue = SG_NAVY_BLUE; +/* Old Lace color { R:253, G:245, B:230, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_old_lace = SG_OLD_LACE; +/* Olive color { R:128, G:128, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_olive = SG_OLIVE; +/* Olive Drab color { R:107, G:142, B:35, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_olive_drab = SG_OLIVE_DRAB; +/* Orange color { R:255, G:165, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_orange = SG_ORANGE; +/* Orange Red color { R:255, G:69, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_orange_red = SG_ORANGE_RED; +/* Orchid color { R:218, G:112, B:214, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_orchid = SG_ORCHID; +/* Pale Goldenrod color { R:238, G:232, B:170, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_pale_goldenrod = SG_PALE_GOLDENROD; +/* Pale Green color { R:152, G:251, B:152, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_pale_green = SG_PALE_GREEN; +/* Pale Turquoise color { R:175, G:238, B:238, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_pale_turquoise = SG_PALE_TURQUOISE; +/* Pale Violet Red color { R:219, G:112, B:147, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_pale_violet_red = SG_PALE_VIOLET_RED; +/* Papaya Whip color { R:255, G:239, B:213, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_papaya_whip = SG_PAPAYA_WHIP; +/* Peach Puff color { R:255, G:218, B:185, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_peach_puff = SG_PEACH_PUFF; +/* Peru color { R:205, G:133, B:63, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_peru = SG_PERU; +/* Pink color { R:255, G:192, B:203, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_pink = SG_PINK; +/* Plum color { R:221, G:160, B:221, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_plum = SG_PLUM; +/* Powder Blue color { R:176, G:224, B:230, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_powder_blue = SG_POWDER_BLUE; +/* Purple color { R:160, G:32, B:240, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_purple = SG_PURPLE; +/* Web Purple color { R:128, G:0, B:128, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_web_purple = SG_WEB_PURPLE; +/* Rebecca Purple color { R:102, G:51, B:153, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_rebecca_purple = SG_REBECCA_PURPLE; +/* Red color { R:255, G:0, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_red = SG_RED; +/* Rosy Brown color { R:188, G:143, B:143, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_rosy_brown = SG_ROSY_BROWN; +/* Royal Blue color { R:65, G:105, B:225, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_royal_blue = SG_ROYAL_BLUE; +/* Saddle Brown color { R:139, G:69, B:19, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_saddle_brown = SG_SADDLE_BROWN; +/* Salmon color { R:250, G:128, B:114, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_salmon = SG_SALMON; +/* Sandy Brown color { R:244, G:164, B:96, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_sandy_brown = SG_SANDY_BROWN; +/* Sea Green color { R:46, G:139, B:87, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_sea_green = SG_SEA_GREEN; +/* Seashell color { R:255, G:245, B:238, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_seashell = SG_SEASHELL; +/* Sienna color { R:160, G:82, B:45, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_sienna = SG_SIENNA; +/* Silver color { R:192, G:192, B:192, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_silver = SG_SILVER; +/* Sky Blue color { R:135, G:206, B:235, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_sky_blue = SG_SKY_BLUE; +/* Slate Blue color { R:106, G:90, B:205, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_slate_blue = SG_SLATE_BLUE; +/* Slate Gray color { R:112, G:128, B:144, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_slate_gray = SG_SLATE_GRAY; +/* Snow color { R:255, G:250, B:250, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_snow = SG_SNOW; +/* Spring Green color { R:0, G:255, B:127, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_spring_green = SG_SPRING_GREEN; +/* Steel Blue color { R:70, G:130, B:180, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_steel_blue = SG_STEEL_BLUE; +/* Tan color { R:210, G:180, B:140, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_tan = SG_TAN; +/* Teal color { R:0, G:128, B:128, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_teal = SG_TEAL; +/* Thistle color { R:216, G:191, B:216, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_thistle = SG_THISTLE; +/* Tomato color { R:255, G:99, B:71, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_tomato = SG_TOMATO; +/* Transparent color { R:0, G:0, B:0, A:0 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_transparent = SG_TRANSPARENT; +/* Turquoise color { R:64, G:224, B:208, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_turquoise = SG_TURQUOISE; +/* Violet color { R:238, G:130, B:238, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_violet = SG_VIOLET; +/* Wheat color { R:245, G:222, B:179, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_wheat = SG_WHEAT; +/* White color { R:255, G:255, B:255, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_white = SG_WHITE; +/* White Smoke color { R:245, G:245, B:245, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_white_smoke = SG_WHITE_SMOKE; +/* Yellow color { R:255, G:255, B:0, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_yellow = SG_YELLOW; +/* Yellow Green color { R:154, G:205, B:50, A:255 } */ +static SOKOL_COLOR_CONSTEXPR sg_color sg_yellow_green = SG_YELLOW_GREEN; + +/* Alice Blue color { R:240, G:248, B:255, A:255 } */ +#define SG_ALICE_BLUE_RGBA32 0xF0F8FFFF +/* Antique White color { R:250, G:235, B:215, A:255 } */ +#define SG_ANTIQUE_WHITE_RGBA32 0xFAEBD7FF +/* Aqua color { R:0, G:255, B:255, A:255 } */ +#define SG_AQUA_RGBA32 0x00FFFFFF +/* Aquamarine color { R:127, G:255, B:212, A:255 } */ +#define SG_AQUAMARINE_RGBA32 0x7FFFD4FF +/* Azure color { R:240, G:255, B:255, A:255 } */ +#define SG_AZURE_RGBA32 0xF0FFFFFF +/* Beige color { R:245, G:245, B:220, A:255 } */ +#define SG_BEIGE_RGBA32 0xF5F5DCFF +/* Bisque color { R:255, G:228, B:196, A:255 } */ +#define SG_BISQUE_RGBA32 0xFFE4C4FF +/* Black color { R:0, G:0, B:0, A:255 } */ +#define SG_BLACK_RGBA32 0x000000FF +/* Blanched Almond color { R:255, G:235, B:205, A:255 } */ +#define SG_BLANCHED_ALMOND_RGBA32 0xFFEBCDFF +/* Blue color { R:0, G:0, B:255, A:255 } */ +#define SG_BLUE_RGBA32 0x0000FFFF +/* Blue Violet color { R:138, G:43, B:226, A:255 } */ +#define SG_BLUE_VIOLET_RGBA32 0x8A2BE2FF +/* Brown color { R:165, G:42, B:42, A:255 } */ +#define SG_BROWN_RGBA32 0xA52A2AFF +/* Burlywood color { R:222, G:184, B:135, A:255 } */ +#define SG_BURLYWOOD_RGBA32 0xDEB887FF +/* Cadet Blue color { R:95, G:158, B:160, A:255 } */ +#define SG_CADET_BLUE_RGBA32 0x5F9EA0FF +/* Chartreuse color { R:127, G:255, B:0, A:255 } */ +#define SG_CHARTREUSE_RGBA32 0x7FFF00FF +/* Chocolate color { R:210, G:105, B:30, A:255 } */ +#define SG_CHOCOLATE_RGBA32 0xD2691EFF +/* Coral color { R:255, G:127, B:80, A:255 } */ +#define SG_CORAL_RGBA32 0xFF7F50FF +/* Cornflower Blue color { R:100, G:149, B:237, A:255 } */ +#define SG_CORNFLOWER_BLUE_RGBA32 0x6495EDFF +/* Cornsilk color { R:255, G:248, B:220, A:255 } */ +#define SG_CORNSILK_RGBA32 0xFFF8DCFF +/* Crimson color { R:220, G:20, B:60, A:255 } */ +#define SG_CRIMSON_RGBA32 0xDC143CFF +/* Cyan color { R:0, G:255, B:255, A:255 } */ +#define SG_CYAN_RGBA32 0x00FFFFFF +/* Dark Blue color { R:0, G:0, B:139, A:255 } */ +#define SG_DARK_BLUE_RGBA32 0x00008BFF +/* Dark Cyan color { R:0, G:139, B:139, A:255 } */ +#define SG_DARK_CYAN_RGBA32 0x008B8BFF +/* Dark Goldenrod color { R:184, G:134, B:11, A:255 } */ +#define SG_DARK_GOLDENROD_RGBA32 0xB8860BFF +/* Dark Gray color { R:169, G:169, B:169, A:255 } */ +#define SG_DARK_GRAY_RGBA32 0xA9A9A9FF +/* Dark Green color { R:0, G:100, B:0, A:255 } */ +#define SG_DARK_GREEN_RGBA32 0x006400FF +/* Dark Khaki color { R:189, G:183, B:107, A:255 } */ +#define SG_DARK_KHAKI_RGBA32 0xBDB76BFF +/* Dark Magenta color { R:139, G:0, B:139, A:255 } */ +#define SG_DARK_MAGENTA_RGBA32 0x8B008BFF +/* Dark Olive Green color { R:85, G:107, B:47, A:255 } */ +#define SG_DARK_OLIVE_GREEN_RGBA32 0x556B2FFF +/* Dark Orange color { R:255, G:140, B:0, A:255 } */ +#define SG_DARK_ORANGE_RGBA32 0xFF8C00FF +/* Dark Orchid color { R:153, G:50, B:204, A:255 } */ +#define SG_DARK_ORCHID_RGBA32 0x9932CCFF +/* Dark Red color { R:139, G:0, B:0, A:255 } */ +#define SG_DARK_RED_RGBA32 0x8B0000FF +/* Dark Salmon color { R:233, G:150, B:122, A:255 } */ +#define SG_DARK_SALMON_RGBA32 0xE9967AFF +/* Dark Sea Green color { R:143, G:188, B:143, A:255 } */ +#define SG_DARK_SEA_GREEN_RGBA32 0x8FBC8FFF +/* Dark Slate Blue color { R:72, G:61, B:139, A:255 } */ +#define SG_DARK_SLATE_BLUE_RGBA32 0x483D8BFF +/* Dark Slate Gray color { R:47, G:79, B:79, A:255 } */ +#define SG_DARK_SLATE_GRAY_RGBA32 0x2F4F4FFF +/* Dark Turquoise color { R:0, G:206, B:209, A:255 } */ +#define SG_DARK_TURQUOISE_RGBA32 0x00CED1FF +/* Dark Violet color { R:148, G:0, B:211, A:255 } */ +#define SG_DARK_VIOLET_RGBA32 0x9400D3FF +/* Deep Pink color { R:255, G:20, B:147, A:255 } */ +#define SG_DEEP_PINK_RGBA32 0xFF1493FF +/* Deep Sky Blue color { R:0, G:191, B:255, A:255 } */ +#define SG_DEEP_SKY_BLUE_RGBA32 0x00BFFFFF +/* Dim Gray color { R:105, G:105, B:105, A:255 } */ +#define SG_DIM_GRAY_RGBA32 0x696969FF +/* Dodger Blue color { R:30, G:144, B:255, A:255 } */ +#define SG_DODGER_BLUE_RGBA32 0x1E90FFFF +/* Firebrick color { R:178, G:34, B:34, A:255 } */ +#define SG_FIREBRICK_RGBA32 0xB22222FF +/* Floral White color { R:255, G:250, B:240, A:255 } */ +#define SG_FLORAL_WHITE_RGBA32 0xFFFAF0FF +/* Forest Green color { R:34, G:139, B:34, A:255 } */ +#define SG_FOREST_GREEN_RGBA32 0x228B22FF +/* Fuchsia color { R:255, G:0, B:255, A:255 } */ +#define SG_FUCHSIA_RGBA32 0xFF00FFFF +/* Gainsboro color { R:220, G:220, B:220, A:255 } */ +#define SG_GAINSBORO_RGBA32 0xDCDCDCFF +/* Ghost White color { R:248, G:248, B:255, A:255 } */ +#define SG_GHOST_WHITE_RGBA32 0xF8F8FFFF +/* Gold color { R:255, G:215, B:0, A:255 } */ +#define SG_GOLD_RGBA32 0xFFD700FF +/* Goldenrod color { R:218, G:165, B:32, A:255 } */ +#define SG_GOLDENROD_RGBA32 0xDAA520FF +/* Gray color { R:190, G:190, B:190, A:255 } */ +#define SG_GRAY_RGBA32 0xBEBEBEFF +/* Web Gray color { R:128, G:128, B:128, A:255 } */ +#define SG_WEB_GRAY_RGBA32 0x808080FF +/* Green color { R:0, G:255, B:0, A:255 } */ +#define SG_GREEN_RGBA32 0x00FF00FF +/* Web Green color { R:0, G:128, B:0, A:255 } */ +#define SG_WEB_GREEN_RGBA32 0x008000FF +/* Green Yellow color { R:173, G:255, B:47, A:255 } */ +#define SG_GREEN_YELLOW_RGBA32 0xADFF2FFF +/* Honeydew color { R:240, G:255, B:240, A:255 } */ +#define SG_HONEYDEW_RGBA32 0xF0FFF0FF +/* Hot Pink color { R:255, G:105, B:180, A:255 } */ +#define SG_HOT_PINK_RGBA32 0xFF69B4FF +/* Indian Red color { R:205, G:92, B:92, A:255 } */ +#define SG_INDIAN_RED_RGBA32 0xCD5C5CFF +/* Indigo color { R:75, G:0, B:130, A:255 } */ +#define SG_INDIGO_RGBA32 0x4B0082FF +/* Ivory color { R:255, G:255, B:240, A:255 } */ +#define SG_IVORY_RGBA32 0xFFFFF0FF +/* Khaki color { R:240, G:230, B:140, A:255 } */ +#define SG_KHAKI_RGBA32 0xF0E68CFF +/* Lavender color { R:230, G:230, B:250, A:255 } */ +#define SG_LAVENDER_RGBA32 0xE6E6FAFF +/* Lavender Blush color { R:255, G:240, B:245, A:255 } */ +#define SG_LAVENDER_BLUSH_RGBA32 0xFFF0F5FF +/* Lawn Green color { R:124, G:252, B:0, A:255 } */ +#define SG_LAWN_GREEN_RGBA32 0x7CFC00FF +/* Lemon Chiffon color { R:255, G:250, B:205, A:255 } */ +#define SG_LEMON_CHIFFON_RGBA32 0xFFFACDFF +/* Light Blue color { R:173, G:216, B:230, A:255 } */ +#define SG_LIGHT_BLUE_RGBA32 0xADD8E6FF +/* Light Coral color { R:240, G:128, B:128, A:255 } */ +#define SG_LIGHT_CORAL_RGBA32 0xF08080FF +/* Light Cyan color { R:224, G:255, B:255, A:255 } */ +#define SG_LIGHT_CYAN_RGBA32 0xE0FFFFFF +/* Light Goldenrod color { R:250, G:250, B:210, A:255 } */ +#define SG_LIGHT_GOLDENROD_RGBA32 0xFAFAD2FF +/* Light Gray color { R:211, G:211, B:211, A:255 } */ +#define SG_LIGHT_GRAY_RGBA32 0xD3D3D3FF +/* Light Green color { R:144, G:238, B:144, A:255 } */ +#define SG_LIGHT_GREEN_RGBA32 0x90EE90FF +/* Light Pink color { R:255, G:182, B:193, A:255 } */ +#define SG_LIGHT_PINK_RGBA32 0xFFB6C1FF +/* Light Salmon color { R:255, G:160, B:122, A:255 } */ +#define SG_LIGHT_SALMON_RGBA32 0xFFA07AFF +/* Light Sea Green color { R:32, G:178, B:170, A:255 } */ +#define SG_LIGHT_SEA_GREEN_RGBA32 0x20B2AAFF +/* Light Sky Blue color { R:135, G:206, B:250, A:255 } */ +#define SG_LIGHT_SKY_BLUE_RGBA32 0x87CEFAFF +/* Light Slate Gray color { R:119, G:136, B:153, A:255 } */ +#define SG_LIGHT_SLATE_GRAY_RGBA32 0x778899FF +/* Light Steel Blue color { R:176, G:196, B:222, A:255 } */ +#define SG_LIGHT_STEEL_BLUE_RGBA32 0xB0C4DEFF +/* Light Yellow color { R:255, G:255, B:224, A:255 } */ +#define SG_LIGHT_YELLOW_RGBA32 0xFFFFE0FF +/* Lime color { R:0, G:255, B:0, A:255 } */ +#define SG_LIME_RGBA32 0x00FF00FF +/* Lime Green color { R:50, G:205, B:50, A:255 } */ +#define SG_LIME_GREEN_RGBA32 0x32CD32FF +/* Linen color { R:250, G:240, B:230, A:255 } */ +#define SG_LINEN_RGBA32 0xFAF0E6FF +/* Magenta color { R:255, G:0, B:255, A:255 } */ +#define SG_MAGENTA_RGBA32 0xFF00FFFF +/* Maroon color { R:176, G:48, B:96, A:255 } */ +#define SG_MAROON_RGBA32 0xB03060FF +/* Web Maroon color { R:128, G:0, B:0, A:255 } */ +#define SG_WEB_MAROON_RGBA32 0x800000FF +/* Medium Aquamarine color { R:102, G:205, B:170, A:255 } */ +#define SG_MEDIUM_AQUAMARINE_RGBA32 0x66CDAAFF +/* Medium Blue color { R:0, G:0, B:205, A:255 } */ +#define SG_MEDIUM_BLUE_RGBA32 0x0000CDFF +/* Medium Orchid color { R:186, G:85, B:211, A:255 } */ +#define SG_MEDIUM_ORCHID_RGBA32 0xBA55D3FF +/* Medium Purple color { R:147, G:112, B:219, A:255 } */ +#define SG_MEDIUM_PURPLE_RGBA32 0x9370DBFF +/* Medium Sea Green color { R:60, G:179, B:113, A:255 } */ +#define SG_MEDIUM_SEA_GREEN_RGBA32 0x3CB371FF +/* Medium Slate Blue color { R:123, G:104, B:238, A:255 } */ +#define SG_MEDIUM_SLATE_BLUE_RGBA32 0x7B68EEFF +/* Medium Spring Green color { R:0, G:250, B:154, A:255 } */ +#define SG_MEDIUM_SPRING_GREEN_RGBA32 0x00FA9AFF +/* Medium Turquoise color { R:72, G:209, B:204, A:255 } */ +#define SG_MEDIUM_TURQUOISE_RGBA32 0x48D1CCFF +/* Medium Violet Red color { R:199, G:21, B:133, A:255 } */ +#define SG_MEDIUM_VIOLET_RED_RGBA32 0xC71585FF +/* Midnight Blue color { R:25, G:25, B:112, A:255 } */ +#define SG_MIDNIGHT_BLUE_RGBA32 0x191970FF +/* Mint Cream color { R:245, G:255, B:250, A:255 } */ +#define SG_MINT_CREAM_RGBA32 0xF5FFFAFF +/* Misty Rose color { R:255, G:228, B:225, A:255 } */ +#define SG_MISTY_ROSE_RGBA32 0xFFE4E1FF +/* Moccasin color { R:255, G:228, B:181, A:255 } */ +#define SG_MOCCASIN_RGBA32 0xFFE4B5FF +/* Navajo White color { R:255, G:222, B:173, A:255 } */ +#define SG_NAVAJO_WHITE_RGBA32 0xFFDEADFF +/* Navy Blue color { R:0, G:0, B:128, A:255 } */ +#define SG_NAVY_BLUE_RGBA32 0x000080FF +/* Old Lace color { R:253, G:245, B:230, A:255 } */ +#define SG_OLD_LACE_RGBA32 0xFDF5E6FF +/* Olive color { R:128, G:128, B:0, A:255 } */ +#define SG_OLIVE_RGBA32 0x808000FF +/* Olive Drab color { R:107, G:142, B:35, A:255 } */ +#define SG_OLIVE_DRAB_RGBA32 0x6B8E23FF +/* Orange color { R:255, G:165, B:0, A:255 } */ +#define SG_ORANGE_RGBA32 0xFFA500FF +/* Orange Red color { R:255, G:69, B:0, A:255 } */ +#define SG_ORANGE_RED_RGBA32 0xFF4500FF +/* Orchid color { R:218, G:112, B:214, A:255 } */ +#define SG_ORCHID_RGBA32 0xDA70D6FF +/* Pale Goldenrod color { R:238, G:232, B:170, A:255 } */ +#define SG_PALE_GOLDENROD_RGBA32 0xEEE8AAFF +/* Pale Green color { R:152, G:251, B:152, A:255 } */ +#define SG_PALE_GREEN_RGBA32 0x98FB98FF +/* Pale Turquoise color { R:175, G:238, B:238, A:255 } */ +#define SG_PALE_TURQUOISE_RGBA32 0xAFEEEEFF +/* Pale Violet Red color { R:219, G:112, B:147, A:255 } */ +#define SG_PALE_VIOLET_RED_RGBA32 0xDB7093FF +/* Papaya Whip color { R:255, G:239, B:213, A:255 } */ +#define SG_PAPAYA_WHIP_RGBA32 0xFFEFD5FF +/* Peach Puff color { R:255, G:218, B:185, A:255 } */ +#define SG_PEACH_PUFF_RGBA32 0xFFDAB9FF +/* Peru color { R:205, G:133, B:63, A:255 } */ +#define SG_PERU_RGBA32 0xCD853FFF +/* Pink color { R:255, G:192, B:203, A:255 } */ +#define SG_PINK_RGBA32 0xFFC0CBFF +/* Plum color { R:221, G:160, B:221, A:255 } */ +#define SG_PLUM_RGBA32 0xDDA0DDFF +/* Powder Blue color { R:176, G:224, B:230, A:255 } */ +#define SG_POWDER_BLUE_RGBA32 0xB0E0E6FF +/* Purple color { R:160, G:32, B:240, A:255 } */ +#define SG_PURPLE_RGBA32 0xA020F0FF +/* Web Purple color { R:128, G:0, B:128, A:255 } */ +#define SG_WEB_PURPLE_RGBA32 0x800080FF +/* Rebecca Purple color { R:102, G:51, B:153, A:255 } */ +#define SG_REBECCA_PURPLE_RGBA32 0x663399FF +/* Red color { R:255, G:0, B:0, A:255 } */ +#define SG_RED_RGBA32 0xFF0000FF +/* Rosy Brown color { R:188, G:143, B:143, A:255 } */ +#define SG_ROSY_BROWN_RGBA32 0xBC8F8FFF +/* Royal Blue color { R:65, G:105, B:225, A:255 } */ +#define SG_ROYAL_BLUE_RGBA32 0x4169E1FF +/* Saddle Brown color { R:139, G:69, B:19, A:255 } */ +#define SG_SADDLE_BROWN_RGBA32 0x8B4513FF +/* Salmon color { R:250, G:128, B:114, A:255 } */ +#define SG_SALMON_RGBA32 0xFA8072FF +/* Sandy Brown color { R:244, G:164, B:96, A:255 } */ +#define SG_SANDY_BROWN_RGBA32 0xF4A460FF +/* Sea Green color { R:46, G:139, B:87, A:255 } */ +#define SG_SEA_GREEN_RGBA32 0x2E8B57FF +/* Seashell color { R:255, G:245, B:238, A:255 } */ +#define SG_SEASHELL_RGBA32 0xFFF5EEFF +/* Sienna color { R:160, G:82, B:45, A:255 } */ +#define SG_SIENNA_RGBA32 0xA0522DFF +/* Silver color { R:192, G:192, B:192, A:255 } */ +#define SG_SILVER_RGBA32 0xC0C0C0FF +/* Sky Blue color { R:135, G:206, B:235, A:255 } */ +#define SG_SKY_BLUE_RGBA32 0x87CEEBFF +/* Slate Blue color { R:106, G:90, B:205, A:255 } */ +#define SG_SLATE_BLUE_RGBA32 0x6A5ACDFF +/* Slate Gray color { R:112, G:128, B:144, A:255 } */ +#define SG_SLATE_GRAY_RGBA32 0x708090FF +/* Snow color { R:255, G:250, B:250, A:255 } */ +#define SG_SNOW_RGBA32 0xFFFAFAFF +/* Spring Green color { R:0, G:255, B:127, A:255 } */ +#define SG_SPRING_GREEN_RGBA32 0x00FF7FFF +/* Steel Blue color { R:70, G:130, B:180, A:255 } */ +#define SG_STEEL_BLUE_RGBA32 0x4682B4FF +/* Tan color { R:210, G:180, B:140, A:255 } */ +#define SG_TAN_RGBA32 0xD2B48CFF +/* Teal color { R:0, G:128, B:128, A:255 } */ +#define SG_TEAL_RGBA32 0x008080FF +/* Thistle color { R:216, G:191, B:216, A:255 } */ +#define SG_THISTLE_RGBA32 0xD8BFD8FF +/* Tomato color { R:255, G:99, B:71, A:255 } */ +#define SG_TOMATO_RGBA32 0xFF6347FF +/* Transparent color { R:0, G:0, B:0, A:0 } */ +#define SG_TRANSPARENT_RGBA32 0x00000000 +/* Turquoise color { R:64, G:224, B:208, A:255 } */ +#define SG_TURQUOISE_RGBA32 0x40E0D0FF +/* Violet color { R:238, G:130, B:238, A:255 } */ +#define SG_VIOLET_RGBA32 0xEE82EEFF +/* Wheat color { R:245, G:222, B:179, A:255 } */ +#define SG_WHEAT_RGBA32 0xF5DEB3FF +/* White color { R:255, G:255, B:255, A:255 } */ +#define SG_WHITE_RGBA32 0xFFFFFFFF +/* White Smoke color { R:245, G:245, B:245, A:255 } */ +#define SG_WHITE_SMOKE_RGBA32 0xF5F5F5FF +/* Yellow color { R:255, G:255, B:0, A:255 } */ +#define SG_YELLOW_RGBA32 0xFFFF00FF +/* Yellow Green color { R:154, G:205, B:50, A:255 } */ +#define SG_YELLOW_GREEN_RGBA32 0x9ACD32FF + +#ifdef __cplusplus +} /* extern "C" */ + +inline sg_color sg_make_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + return sg_make_color_4b(r, g, b, a); +} + +inline sg_color sg_make_color(uint32_t rgba) { + return sg_make_color_1i(rgba); +} + +inline sg_color sg_color_lerp(const sg_color& color_a, const sg_color& color_b, float amount) { + return sg_color_lerp(&color_a, &color_b, amount); +} + +inline sg_color sg_color_lerp_precise(const sg_color& color_a, const sg_color& color_b, float amount) { + return sg_color_lerp_precise(&color_a, &color_b, amount); +} + +inline sg_color sg_color_multiply(const sg_color& color, float scale) { + return sg_color_multiply(&color, scale); +} + +#endif /* __cplusplus */ + +#endif /* SOKOL_COLOR_INCLUDED */ + +/*-- IMPLEMENTATION ----------------------------------------------------------*/ +#ifdef SOKOL_COLOR_IMPL +#define SOKOL_COLOR_IMPL_INCLUDED (1) + +#ifndef SOKOL_API_IMPL + #define SOKOL_API_IMPL +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif + +static inline float _sg_color_clamp(float v, float low, float high) { + if (v < low) { + return low; + } else if (v > high) { + return high; + } + return v; +} + +static inline float _sg_color_lerp(float a, float b, float amount) { + return a + (b - a) * amount; +} + +static inline float _sg_color_lerp_precise(float a, float b, float amount) { + return ((1.0f - amount) * a) + (b * amount); +} + +SOKOL_API_IMPL sg_color sg_make_color_4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + sg_color result; + result.r = r / 255.0f; + result.g = g / 255.0f; + result.b = b / 255.0f; + result.a = a / 255.0f; + return result; +} + +SOKOL_API_IMPL sg_color sg_make_color_1i(uint32_t rgba) { + return sg_make_color_4b( + (uint8_t)(rgba >> 24), + (uint8_t)(rgba >> 16), + (uint8_t)(rgba >> 8), + (uint8_t)(rgba >> 0) + ); +} + +SOKOL_API_IMPL sg_color sg_color_lerp(const sg_color* color_a, const sg_color* color_b, float amount) { + SOKOL_ASSERT(color_a); + SOKOL_ASSERT(color_b); + amount = _sg_color_clamp(amount, 0.0f, 1.0f); + sg_color result; + result.r = _sg_color_lerp(color_a->r, color_b->r, amount); + result.g = _sg_color_lerp(color_a->g, color_b->g, amount); + result.b = _sg_color_lerp(color_a->b, color_b->b, amount); + result.a = _sg_color_lerp(color_a->a, color_b->a, amount); + return result; +} + +SOKOL_API_IMPL sg_color sg_color_lerp_precise(const sg_color* color_a, const sg_color* color_b, float amount) { + SOKOL_ASSERT(color_a); + SOKOL_ASSERT(color_b); + amount = _sg_color_clamp(amount, 0.0f, 1.0f); + sg_color result; + result.r = _sg_color_lerp_precise(color_a->r, color_b->r, amount); + result.g = _sg_color_lerp_precise(color_a->g, color_b->g, amount); + result.b = _sg_color_lerp_precise(color_a->b, color_b->b, amount); + result.a = _sg_color_lerp_precise(color_a->a, color_b->a, amount); + return result; +} + +SOKOL_API_IMPL sg_color sg_color_multiply(const sg_color* color, float scale) { + SOKOL_ASSERT(color); + sg_color result; + result.r = color->r * scale; + result.g = color->g * scale; + result.b = color->b * scale; + result.a = color->a * scale; + return result; +} + +#endif /* SOKOL_COLOR_IMPL */ diff --git a/source/engine/thirdparty/sokol/sokol_debugtext.h b/source/engine/thirdparty/sokol/sokol_debugtext.h new file mode 100644 index 0000000..eed0436 --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_debugtext.h @@ -0,0 +1,4644 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_DEBUGTEXT_IMPL) +#define SOKOL_DEBUGTEXT_IMPL +#endif +#ifndef SOKOL_DEBUGTEXT_INCLUDED +/* + sokol_debugtext.h - simple ASCII debug text rendering on top of sokol_gfx.h + + Project URL: https://github.com/floooh/sokol + + Do this: + #define SOKOL_IMPL or + #define SOKOL_DEBUGTEXT_IMPL + before you include this file in *one* C or C++ file to create the + implementation. + + The following defines are used by the implementation to select the + platform-specific embedded shader code (these are the same defines as + used by sokol_gfx.h and sokol_app.h): + + SOKOL_GLCORE33 + SOKOL_GLES3 + SOKOL_D3D11 + SOKOL_METAL + SOKOL_WGPU + + ...optionally provide the following macros to override defaults: + + SOKOL_VSNPRINTF - the function name of an alternative vsnprintf() function (default: vsnprintf) + SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) + SOKOL_DEBUGTEXT_API_DECL - public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_DEBUGTEXT_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) + + If sokol_debugtext.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + On Windows, SOKOL_DLL will define SOKOL_DEBUGTEXT_API_DECL as __declspec(dllexport) + or __declspec(dllimport) as needed. + + Include the following headers before including sokol_debugtext.h: + + sokol_gfx.h + + FEATURES AND CONCEPTS + ===================== + - renders 8-bit ASCII text as fixed-size 8x8 pixel characters + - comes with 6 embedded 8-bit home computer fonts (each taking up 2 KBytes) + - easily plug in your own fonts + - create multiple contexts for rendering text in different layers or render passes + + STEP BY STEP + ============ + + --- to initialize sokol-debugtext, call sdtx_setup() *after* initializing + sokol-gfx: + + sdtx_setup(&(sdtx_desc_t){ ... }); + + To see any warnings and errors, you should always install a logging callback. + The easiest way is via sokol_log.h: + + #include "sokol_log.h" + + sdtx_setup(&(sdtx_desc_t){ + .logger.func = slog_func, + }); + + --- configure sokol-debugtext by populating the sdtx_desc_t struct: + + .context_pool_size (default: 8) + The max number of text contexts that can be created. + + .printf_buf_size (default: 4096) + The size of the internal text formatting buffer used by + sdtx_printf() and sdtx_vprintf(). + + .fonts (default: none) + An array of sdtx_font_desc_t structs used to configure the + fonts that can be used for rendering. To use all builtin + fonts call sdtx_setup() like this (in C99): + + sdtx_setup(&sdtx_desc_t){ + .fonts = { + [0] = sdtx_font_kc853(), + [1] = sdtx_font_kc854(), + [2] = sdtx_font_z1013(), + [3] = sdtx_font_cpc(), + [4] = sdtx_font_c64(), + [5] = sdtx_font_oric() + } + }); + + For documentation on how to use you own font data, search + below for "USING YOUR OWN FONT DATA". + + .context + The setup parameters for the default text context. This will + be active right after sdtx_setup(), or when calling + sdtx_set_context(SDTX_DEFAULT_CONTEXT): + + .max_commands (default: 4096) + The max number of render commands that can be recorded + into the internal command buffer. This directly translates + to the number of render layer changes in a single frame. + + .char_buf_size (default: 4096) + The number of characters that can be rendered per frame in this + context, defines the size of an internal fixed-size vertex + buffer. Any additional characters will be silently ignored. + + .canvas_width (default: 640) + .canvas_height (default: 480) + The 'virtual canvas size' in pixels. This defines how big + characters will be rendered relative to the default framebuffer + dimensions. Each character occupies a grid of 8x8 'virtual canvas + pixels' (so a virtual canvas size of 640x480 means that 80x60 characters + fit on the screen). For rendering in a resizeable window, you + should dynamically update the canvas size in each frame by + calling sdtx_canvas(w, h). + + .tab_width (default: 4) + The width of a tab character in number of character cells. + + .color_format (default: 0) + .depth_format (default: 0) + .sample_count (default: 0) + The pixel format description for the default context needed + for creating the context's sg_pipeline object. When + rendering to the default framebuffer you can leave those + zero-initialized, in this case the proper values will be + filled in by sokol-gfx. You only need to provide non-default + values here when rendering to render targets with different + pixel format attributes than the default framebuffer. + + --- Before starting to render text, optionally call sdtx_canvas() to + dynamically resize the virtual canvas. This is recommended when + rendering to a resizeable window. The virtual canvas size can + also be used to scale text in relation to the display resolution. + + Examples when using sokol-app: + + - to render characters at 8x8 'physical pixels': + + sdtx_canvas(sapp_width(), sapp_height()); + + - to render characters at 16x16 physical pixels: + + sdtx_canvas(sapp_width()/2.0f, sapp_heigth()/2.0f); + + Do *not* use integer math here, since this will not look nice + when the render target size isn't divisible by 2. + + --- Optionally define the origin for the character grid with: + + sdtx_origin(x, y); + + The provided coordinates are in character grid cells, not in + virtual canvas pixels. E.g. to set the origin to 2 character tiles + from the left and top border: + + sdtx_origin(2, 2); + + You can define fractions, e.g. to start rendering half + a character tile from the top-left corner: + + sdtx_origin(0.5f, 0.5f); + + --- Optionally set a different font by calling: + + sdtx_font(font_index) + + sokol-debugtext provides 8 font slots which can be populated + with the builtin fonts or with user-provided font data, so + 'font_index' must be a number from 0 to 7. + + --- Position the text cursor with one of the following calls. All arguments + are in character grid cells as floats and relative to the + origin defined with sdtx_origin(): + + sdtx_pos(x, y) - sets absolute cursor position + sdtx_pos_x(x) - only set absolute x cursor position + sdtx_pos_y(y) - only set absolute y cursor position + + sdtx_move(x, y) - move cursor relative in x and y direction + sdtx_move_x(x) - move cursor relative only in x direction + sdtx_move_y(y) - move cursor relative only in y direction + + sdtx_crlf() - set cursor to beginning of next line + (same as sdtx_pos_x(0) + sdtx_move_y(1)) + sdtx_home() - resets the cursor to the origin + (same as sdtx_pos(0, 0)) + + --- Set a new text color with any of the following functions: + + sdtx_color3b(r, g, b) - RGB 0..255, A=255 + sdtx_color3f(r, g, b) - RGB 0.0f..1.0f, A=1.0f + sdtx_color4b(r, g, b, a) - RGBA 0..255 + sdtx_color4f(r, g, b, a) - RGBA 0.0f..1.0f + sdtx_color1i(uint32_t rgba) - ABGR (0xAABBGGRR) + + --- Output 8-bit ASCII text with the following functions: + + sdtx_putc(c) - output a single character + + sdtx_puts(str) - output a null-terminated C string, note that + this will *not* append a newline (so it behaves + differently than the CRT's puts() function) + + sdtx_putr(str, len) - 'put range' output the first 'len' characters of + a C string or until the zero character is encountered + + sdtx_printf(fmt, ...) - output with printf-formatting, note that you + can inject your own printf-compatible function + by overriding the SOKOL_VSNPRINTF define before + including the implementation + + sdtx_vprintf(fmt, args) - same as sdtx_printf() but with the arguments + provided in a va_list + + - Note that the text will not yet be rendered, only recorded for rendering + at a later time, the actual rendering happens when sdtx_draw() is called + inside a sokol-gfx render pass. + - This means also you can output text anywhere in the frame, it doesn't + have to be inside a render pass. + - Note that character codes <32 are reserved as control characters + and won't render anything. Currently only the following control + characters are implemented: + + \r - carriage return (same as sdtx_pos_x(0)) + \n - carriage return + line feed (same as stdx_crlf()) + \t - a tab character + + --- You can 'record' text into render layers, this allows to mix/interleave + sokol-debugtext rendering with other rendering operations inside + sokol-gfx render passes. To start recording text into a different render + layer, call: + + sdtx_layer(int layer_id) + + ...outside a sokol-gfx render pass. + + --- finally, from within a sokol-gfx render pass, call: + + sdtx_draw() + + ...for non-layered rendering, or to draw a specific layer: + + sdtx_draw_layer(int layer_id) + + NOTE that sdtx_draw() is equivalent to: + + sdtx_draw_layer(0) + + ...so sdtx_draw() will *NOT* render all text layers, instead it will + only render the 'default layer' 0. + + --- at the end of a frame (defined by the call to sg_commit()), sokol-debugtext + will rewind all contexts: + + - the internal vertex index is set to 0 + - the internal command index is set to 0 + - the current layer id is set to 0 + - the current font is set to 0 + - the cursor position is reset + + + RENDERING WITH MULTIPLE CONTEXTS + ================================ + Use multiple text contexts if you need to render debug text in different + sokol-gfx render passes, or want to render text to different layers + in the same render pass, each with its own set of parameters. + + To create a new text context call: + + sdtx_context ctx = sdtx_make_context(&(sdtx_context_desc_t){ ... }); + + The creation parameters in the sdtx_context_desc_t struct are the same + as already described above in the sdtx_setup() function: + + .char_buf_size -- max number of characters rendered in one frame, default: 4096 + .canvas_width -- the initial virtual canvas width, default: 640 + .canvas_height -- the initial virtual canvas height, default: 400 + .tab_width -- tab width in number of characters, default: 4 + .color_format -- color pixel format of target render pass + .depth_format -- depth pixel format of target render pass + .sample_count -- MSAA sample count of target render pass + + To make a new context the active context, call: + + sdtx_set_context(ctx) + + ...and after that call the text output functions as described above, and + finally, inside a sokol-gfx render pass, call sdtx_draw() to actually + render the text for this context. + + A context keeps track of the following parameters: + + - the active font + - the virtual canvas size + - the origin position + - the current cursor position + - the current tab width + - the current color + - and the current layer-id + + You can get the currently active context with: + + sdtx_get_context() + + To make the default context current, call sdtx_set_context() with the + special SDTX_DEFAULT_CONTEXT handle: + + sdtx_set_context(SDTX_DEFAULT_CONTEXT) + + Alternatively, use the function sdtx_default_context() to get the default + context handle: + + sdtx_set_context(sdtx_default_context()); + + To destroy a context, call: + + sdtx_destroy_context(ctx) + + If a context is set as active that no longer exists, all sokol-debugtext + functions that require an active context will silently fail. + + You can directly draw the recorded text in a specific context without + setting the active context: + + sdtx_context_draw(ctx) + sdtx_context_draw_layer(ctx, layer_id) + + USING YOUR OWN FONT DATA + ======================== + + Instead of the built-in fonts you can also plug your own font data + into sokol-debugtext by providing one or several sdtx_font_desc_t + structures in the sdtx_setup call. + + For instance to use a built-in font at slot 0, and a user-font at + font slot 1, the sdtx_setup() call might look like this: + + sdtx_setup(&sdtx_desc_t){ + .fonts = { + [0] = sdtx_font_kc853(), + [1] = { + .data = { + .ptr = my_font_data, + .size = sizeof(my_font_data) + }, + .first_char = ..., + .last_char = ... + } + } + }); + + Where 'my_font_data' is a byte array where every character is described + by 8 bytes arranged like this: + + bits + 7 6 5 4 3 2 1 0 + . . . X X . . . byte 0: 0x18 + . . X X X X . . byte 1: 0x3C + . X X . . X X . byte 2: 0x66 + . X X . . X X . byte 3: 0x66 + . X X X X X X . byte 4: 0x7E + . X X . . X X . byte 5: 0x66 + . X X . . X X . byte 6: 0x66 + . . . . . . . . byte 7: 0x00 + + A complete font consists of 256 characters, resulting in 2048 bytes for + the font data array (but note that the character codes 0..31 will never + be rendered). + + If you provide such a complete font data array, you can drop the .first_char + and .last_char initialization parameters since those default to 0 and 255, + note that you can also use the SDTX_RANGE() helper macro to build the + .data item: + + sdtx_setup(&sdtx_desc_t){ + .fonts = { + [0] = sdtx_font_kc853(), + [1] = { + .data = SDTX_RANGE(my_font_data) + } + } + }); + + If the font doesn't define all 256 character tiles, or you don't need an + entire 256-character font and want to save a couple of bytes, use the + .first_char and .last_char initialization parameters to define a sub-range. + For instance if the font only contains the characters between the Space + (ASCII code 32) and uppercase character 'Z' (ASCII code 90): + + sdtx_setup(&sdtx_desc_t){ + .fonts = { + [0] = sdtx_font_kc853(), + [1] = { + .data = SDTX_RANGE(my_font_data), + .first_char = 32, // could also write ' ' + .last_char = 90 // could also write 'Z' + } + } + }); + + Character tiles that haven't been defined in the font will be rendered + as a solid 8x8 quad. + + + MEMORY ALLOCATION OVERRIDE + ========================== + You can override the memory allocation functions at initialization time + like this: + + void* my_alloc(size_t size, void* user_data) { + return malloc(size); + } + + void my_free(void* ptr, void* user_data) { + free(ptr); + } + + ... + sdtx_setup(&(sdtx_desc_t){ + // ... + .allocator = { + .alloc = my_alloc, + .free = my_free, + .user_data = ...; + } + }); + ... + + If no overrides are provided, malloc and free will be used. + + + ERROR REPORTING AND LOGGING + =========================== + To get any logging information at all you need to provide a logging callback in the setup call, + the easiest way is to use sokol_log.h: + + #include "sokol_log.h" + + sdtx_setup(&(sdtx_desc_t){ + // ... + .logger.func = slog_func + }); + + To override logging with your own callback, first write a logging function like this: + + void my_log(const char* tag, // e.g. 'sdtx' + uint32_t log_level, // 0=panic, 1=error, 2=warn, 3=info + uint32_t log_item_id, // SDTX_LOGITEM_* + const char* message_or_null, // a message string, may be nullptr in release mode + uint32_t line_nr, // line number in sokol_debugtext.h + const char* filename_or_null, // source filename, may be nullptr in release mode + void* user_data) + { + ... + } + + ...and then setup sokol-debugtext like this: + + sdtx_setup(&(sdtx_desc_t){ + .logger = { + .func = my_log, + .user_data = my_user_data, + } + }); + + The provided logging function must be reentrant (e.g. be callable from + different threads). + + If you don't want to provide your own custom logger it is highly recommended to use + the standard logger in sokol_log.h instead, otherwise you won't see any warnings or + errors. + + + LICENSE + ======= + zlib/libpng license + + Copyright (c) 2020 Andre Weissflog + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_DEBUGTEXT_INCLUDED (1) +#include +#include +#include // size_t +#include // va_list + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_debugtext.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_DEBUGTEXT_API_DECL) +#define SOKOL_DEBUGTEXT_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_DEBUGTEXT_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_DEBUGTEXT_IMPL) +#define SOKOL_DEBUGTEXT_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_DEBUGTEXT_API_DECL __declspec(dllimport) +#else +#define SOKOL_DEBUGTEXT_API_DECL extern +#endif +#endif + +#if defined(__GNUC__) +#define SOKOL_DEBUGTEXT_PRINTF_ATTR __attribute__((format(printf, 1, 2))) +#else +#define SOKOL_DEBUGTEXT_PRINTF_ATTR +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + sdtx_log_item_t + + Log items are defined via X-Macros, and expanded to an + enum 'sdtx_log_item' - and in debug mode only - corresponding strings. + + Used as parameter in the logging callback. +*/ +#define _SDTX_LOG_ITEMS \ + _SDTX_LOGITEM_XMACRO(OK, "Ok") \ + _SDTX_LOGITEM_XMACRO(MALLOC_FAILED, "memory allocation failed") \ + _SDTX_LOGITEM_XMACRO(ADD_COMMIT_LISTENER_FAILED, "sg_add_commit_listener() failed") \ + _SDTX_LOGITEM_XMACRO(COMMAND_BUFFER_FULL, "command buffer full (adjust via sdtx_context_desc_t.max_commands)") \ + _SDTX_LOGITEM_XMACRO(CONTEXT_POOL_EXHAUSTED, "context pool exhausted (adjust via sdtx_desc_t.context_pool_size)") \ + _SDTX_LOGITEM_XMACRO(CANNOT_DESTROY_DEFAULT_CONTEXT, "cannot destroy default context") \ + +#define _SDTX_LOGITEM_XMACRO(item,msg) SDTX_LOGITEM_##item, +typedef enum sdtx_log_item_t { + _SDTX_LOG_ITEMS +} sdtx_log_item_t; +#undef _SDTX_LOGITEM_XMACRO + +/* + sdtx_logger_t + + Used in sdtx_desc_t to provide a custom logging and error reporting + callback to sokol-debugtext. +*/ +typedef struct sdtx_logger_t { + void (*func)( + const char* tag, // always "sdtx" + uint32_t log_level, // 0=panic, 1=error, 2=warning, 3=info + uint32_t log_item_id, // SDTX_LOGITEM_* + const char* message_or_null, // a message string, may be nullptr in release mode + uint32_t line_nr, // line number in sokol_debugtext.h + const char* filename_or_null, // source filename, may be nullptr in release mode + void* user_data); + void* user_data; +} sdtx_logger_t; + +/* a rendering context handle */ +typedef struct sdtx_context { uint32_t id; } sdtx_context; + +/* the default context handle */ +static const sdtx_context SDTX_DEFAULT_CONTEXT = { 0x00010001 }; + +/* + sdtx_range is a pointer-size-pair struct used to pass memory + blobs into sokol-debugtext. When initialized from a value type + (array or struct), use the SDTX_RANGE() macro to build + an sdtx_range struct. +*/ +typedef struct sdtx_range { + const void* ptr; + size_t size; +} sdtx_range; + +// disabling this for every includer isn't great, but the warning is also quite pointless +#if defined(_MSC_VER) +#pragma warning(disable:4221) /* /W4 only: nonstandard extension used: 'x': cannot be initialized using address of automatic variable 'y' */ +#pragma warning(disable:4204) /* VS2015: nonstandard extension used: non-constant aggregate initializer */ +#endif +#if defined(__cplusplus) +#define SDTX_RANGE(x) sdtx_range{ &x, sizeof(x) } +#else +#define SDTX_RANGE(x) (sdtx_range){ &x, sizeof(x) } +#endif + +/* + sdtx_font_desc_t + + Describes the pixel data of a font. A font consists of up to + 256 8x8 character tiles, where each character tile is described + by 8 consecutive bytes, each byte describing 8 pixels. + + For instance the character 'A' could look like this (this is also + how most home computers used to describe their fonts in ROM): + + bits + 7 6 5 4 3 2 1 0 + . . . X X . . . byte 0: 0x18 + . . X X X X . . byte 1: 0x3C + . X X . . X X . byte 2: 0x66 + . X X . . X X . byte 3: 0x66 + . X X X X X X . byte 4: 0x7E + . X X . . X X . byte 5: 0x66 + . X X . . X X . byte 6: 0x66 + . . . . . . . . byte 7: 0x00 + */ +#define SDTX_MAX_FONTS (8) + +typedef struct sdtx_font_desc_t { + sdtx_range data; // pointer to and size of font pixel data + uint8_t first_char; // first character index in font pixel data + uint8_t last_char; // last character index in font pixel data, inclusive (default: 255) +} sdtx_font_desc_t; + +/* + sdtx_context_desc_t + + Describes the initialization parameters of a rendering context. Creating + additional rendering contexts is useful if you want to render in + different sokol-gfx rendering passes, or when rendering several layers + of text. +*/ +typedef struct sdtx_context_desc_t { + int max_commands; // max number of draw commands, each layer transition counts as a command, default: 4096 + int char_buf_size; // max number of characters rendered in one frame, default: 4096 + float canvas_width; // the initial virtual canvas width, default: 640 + float canvas_height; // the initial virtual canvas height, default: 400 + int tab_width; // tab width in number of characters, default: 4 + sg_pixel_format color_format; // color pixel format of target render pass + sg_pixel_format depth_format; // depth pixel format of target render pass + int sample_count; // MSAA sample count of target render pass +} sdtx_context_desc_t; + +/* + sdtx_allocator_t + + Used in sdtx_desc_t to provide custom memory-alloc and -free functions + to sokol_debugtext.h. If memory management should be overridden, both the + alloc and free function must be provided (e.g. it's not valid to + override one function but not the other). +*/ +typedef struct sdtx_allocator_t { + void* (*alloc)(size_t size, void* user_data); + void (*free)(void* ptr, void* user_data); + void* user_data; +} sdtx_allocator_t; + +/* + sdtx_desc_t + + Describes the sokol-debugtext API initialization parameters. Passed + to the sdtx_setup() function. + + NOTE: to populate the fonts item array with builtin fonts, use any + of the following functions: + + sdtx_font_kc853() + sdtx_font_kc854() + sdtx_font_z1013() + sdtx_font_cpc() + sdtx_font_c64() + sdtx_font_oric() +*/ +typedef struct sdtx_desc_t { + int context_pool_size; // max number of rendering contexts that can be created, default: 8 + int printf_buf_size; // size of internal buffer for snprintf(), default: 4096 + sdtx_font_desc_t fonts[SDTX_MAX_FONTS]; // up to 8 fonts descriptions + sdtx_context_desc_t context; // the default context creation parameters + sdtx_allocator_t allocator; // optional memory allocation overrides (default: malloc/free) + sdtx_logger_t logger; // optional log override function (default: NO LOGGING) +} sdtx_desc_t; + +/* initialization/shutdown */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_setup(const sdtx_desc_t* desc); +SOKOL_DEBUGTEXT_API_DECL void sdtx_shutdown(void); + +/* builtin font data (use to populate sdtx_desc.font[]) */ +SOKOL_DEBUGTEXT_API_DECL sdtx_font_desc_t sdtx_font_kc853(void); +SOKOL_DEBUGTEXT_API_DECL sdtx_font_desc_t sdtx_font_kc854(void); +SOKOL_DEBUGTEXT_API_DECL sdtx_font_desc_t sdtx_font_z1013(void); +SOKOL_DEBUGTEXT_API_DECL sdtx_font_desc_t sdtx_font_cpc(void); +SOKOL_DEBUGTEXT_API_DECL sdtx_font_desc_t sdtx_font_c64(void); +SOKOL_DEBUGTEXT_API_DECL sdtx_font_desc_t sdtx_font_oric(void); + +/* context functions */ +SOKOL_DEBUGTEXT_API_DECL sdtx_context sdtx_make_context(const sdtx_context_desc_t* desc); +SOKOL_DEBUGTEXT_API_DECL void sdtx_destroy_context(sdtx_context ctx); +SOKOL_DEBUGTEXT_API_DECL void sdtx_set_context(sdtx_context ctx); +SOKOL_DEBUGTEXT_API_DECL sdtx_context sdtx_get_context(void); +SOKOL_DEBUGTEXT_API_DECL sdtx_context sdtx_default_context(void); + +/* drawing functions (call inside sokol-gfx render pass) */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_draw(void); +SOKOL_DEBUGTEXT_API_DECL void sdtx_context_draw(sdtx_context ctx); +SOKOL_DEBUGTEXT_API_DECL void sdtx_draw_layer(int layer_id); +SOKOL_DEBUGTEXT_API_DECL void sdtx_context_draw_layer(sdtx_context ctx, int layer_id); + +/* switch render layer */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_layer(int layer_id); + +/* switch to a different font */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_font(int font_index); + +/* set a new virtual canvas size in screen pixels */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_canvas(float w, float h); + +/* set a new origin in character grid coordinates */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_origin(float x, float y); + +/* cursor movement functions (relative to origin in character grid coordinates) */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_home(void); +SOKOL_DEBUGTEXT_API_DECL void sdtx_pos(float x, float y); +SOKOL_DEBUGTEXT_API_DECL void sdtx_pos_x(float x); +SOKOL_DEBUGTEXT_API_DECL void sdtx_pos_y(float y); +SOKOL_DEBUGTEXT_API_DECL void sdtx_move(float dx, float dy); +SOKOL_DEBUGTEXT_API_DECL void sdtx_move_x(float dx); +SOKOL_DEBUGTEXT_API_DECL void sdtx_move_y(float dy); +SOKOL_DEBUGTEXT_API_DECL void sdtx_crlf(void); + +/* set the current text color */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_color3b(uint8_t r, uint8_t g, uint8_t b); // RGB 0..255, A=255 +SOKOL_DEBUGTEXT_API_DECL void sdtx_color3f(float r, float g, float b); // RGB 0.0f..1.0f, A=1.0f +SOKOL_DEBUGTEXT_API_DECL void sdtx_color4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a); // RGBA 0..255 +SOKOL_DEBUGTEXT_API_DECL void sdtx_color4f(float r, float g, float b, float a); // RGBA 0.0f..1.0f +SOKOL_DEBUGTEXT_API_DECL void sdtx_color1i(uint32_t rgba); // ABGR 0xAABBGGRR + +/* text rendering */ +SOKOL_DEBUGTEXT_API_DECL void sdtx_putc(char c); +SOKOL_DEBUGTEXT_API_DECL void sdtx_puts(const char* str); // does NOT append newline! +SOKOL_DEBUGTEXT_API_DECL void sdtx_putr(const char* str, int len); // 'put range', also stops at zero-char +SOKOL_DEBUGTEXT_API_DECL int sdtx_printf(const char* fmt, ...) SOKOL_DEBUGTEXT_PRINTF_ATTR; +SOKOL_DEBUGTEXT_API_DECL int sdtx_vprintf(const char* fmt, va_list args); + +#ifdef __cplusplus +} /* extern "C" */ +/* C++ const-ref wrappers */ +inline void sdtx_setup(const sdtx_desc_t& desc) { return sdtx_setup(&desc); } +inline sdtx_context sdtx_make_context(const sdtx_context_desc_t& desc) { return sdtx_make_context(&desc); } +#endif +#endif /* SOKOL_DEBUGTEXT_INCLUDED */ + +// ██ ███ ███ ██████ ██ ███████ ███ ███ ███████ ███ ██ ████████ █████ ████████ ██ ██████ ███ ██ +// ██ ████ ████ ██ ██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ +// ██ ██ ████ ██ ██████ ██ █████ ██ ████ ██ █████ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ████ ██ ██ ██ ██ ██ ██████ ██ ████ +// +// >>implementation +#ifdef SOKOL_DEBUGTEXT_IMPL +#define SOKOL_DEBUGTEXT_IMPL_INCLUDED (1) + +#if defined(SOKOL_MALLOC) || defined(SOKOL_CALLOC) || defined(SOKOL_FREE) +#error "SOKOL_MALLOC/CALLOC/FREE macros are no longer supported, please use sdtx_desc_t.allocator to override memory allocation functions" +#endif + +#include // memset +#include // fmodf +#include // for vsnprintf +#include // malloc/free + +#ifndef SOKOL_API_IMPL + #define SOKOL_API_IMPL +#endif +#ifndef SOKOL_DEBUG + #ifndef NDEBUG + #define SOKOL_DEBUG + #endif +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif + +#ifndef SOKOL_UNREACHABLE + #define SOKOL_UNREACHABLE SOKOL_ASSERT(false) +#endif +#ifndef _SOKOL_UNUSED + #define _SOKOL_UNUSED(x) (void)(x) +#endif + +#ifndef SOKOL_VSNPRINTF +#include +#define SOKOL_VSNPRINTF vsnprintf +#endif + +#define _sdtx_def(val, def) (((val) == 0) ? (def) : (val)) +#define _SDTX_INIT_COOKIE (0xACBAABCA) + +#define _SDTX_DEFAULT_MAX_COMMANDS (4096) +#define _SDTX_DEFAULT_CONTEXT_POOL_SIZE (8) +#define _SDTX_DEFAULT_CHAR_BUF_SIZE (4096) +#define _SDTX_DEFAULT_PRINTF_BUF_SIZE (4096) +#define _SDTX_DEFAULT_CANVAS_WIDTH (640) +#define _SDTX_DEFAULT_CANVAS_HEIGHT (480) +#define _SDTX_DEFAULT_TAB_WIDTH (4) +#define _SDTX_DEFAULT_COLOR (0xFF00FFFF) +#define _SDTX_INVALID_SLOT_INDEX (0) +#define _SDTX_SLOT_SHIFT (16) +#define _SDTX_MAX_POOL_SIZE (1<<_SDTX_SLOT_SHIFT) +#define _SDTX_SLOT_MASK (_SDTX_MAX_POOL_SIZE-1) + +/* embedded font data */ +static const uint8_t _sdtx_font_kc853[2048] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xFF, // 00 + 0x00, 0x00, 0x22, 0x72, 0x22, 0x3E, 0x00, 0x00, // 01 + 0x00, 0x00, 0x12, 0x32, 0x7E, 0x32, 0x12, 0x00, // 02 + 0x7E, 0x81, 0xB9, 0xA5, 0xB9, 0xA5, 0xB9, 0x81, // 03 + 0x55, 0xFF, 0x55, 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 04 + 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 05 + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, // 06 + 0x00, 0x00, 0x3C, 0x42, 0x42, 0x7E, 0x00, 0x00, // 07 + 0x00, 0x10, 0x30, 0x7E, 0x30, 0x10, 0x00, 0x00, // 08 + 0x00, 0x08, 0x0C, 0x7E, 0x0C, 0x08, 0x00, 0x00, // 09 + 0x00, 0x10, 0x10, 0x10, 0x7C, 0x38, 0x10, 0x00, // 0A + 0x08, 0x1C, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x00, // 0B + 0x38, 0x30, 0x28, 0x08, 0x08, 0x08, 0x3E, 0x00, // 0C + 0x00, 0x00, 0x12, 0x32, 0x7E, 0x30, 0x10, 0x00, // 0D + 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, // 0E + 0x3E, 0x7C, 0x7C, 0x3E, 0x3E, 0x7C, 0xF8, 0xF8, // 0F + 0x38, 0x30, 0x28, 0x04, 0x04, 0x04, 0x04, 0x00, // 10 + 0x7F, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x08, 0x00, // 11 + 0x00, 0x08, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x7F, // 12 + 0x7E, 0x81, 0x9D, 0xA1, 0xB9, 0x85, 0x85, 0xB9, // 13 + 0x00, 0x3C, 0x42, 0x5A, 0x5A, 0x42, 0x3C, 0x00, // 14 + 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11, // 15 + 0x00, 0x7F, 0x22, 0x72, 0x27, 0x22, 0x7F, 0x00, // 16 + 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88, // 17 + 0x00, 0x01, 0x09, 0x0D, 0x7F, 0x0D, 0x09, 0x01, // 18 + 0x00, 0x90, 0xB0, 0xFE, 0xB0, 0x90, 0x00, 0x00, // 19 + 0x00, 0x08, 0x7C, 0x06, 0x7C, 0x08, 0x00, 0x00, // 1A + 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, // 1B + 0x7E, 0x81, 0xA1, 0xA1, 0xA1, 0xA1, 0xBD, 0x81, // 1C + 0x7E, 0x81, 0xB9, 0xA5, 0xB9, 0xA5, 0xA5, 0x81, // 1D + 0x7E, 0x81, 0x99, 0xA1, 0xA1, 0xA1, 0x99, 0x81, // 1E + 0x00, 0x10, 0x3E, 0x60, 0x3E, 0x10, 0x00, 0x00, // 1F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 20 + 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00, // 21 + 0x00, 0x66, 0x66, 0xCC, 0x00, 0x00, 0x00, 0x00, // 22 + 0x00, 0x36, 0x7F, 0x36, 0x36, 0x7F, 0x36, 0x00, // 23 + 0x18, 0x3E, 0x6C, 0x3E, 0x1B, 0x1B, 0x7E, 0x18, // 24 + 0x00, 0x63, 0x66, 0x0C, 0x18, 0x36, 0x66, 0x00, // 25 + 0x18, 0x24, 0x28, 0x11, 0x2A, 0x44, 0x4A, 0x31, // 26 + 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, // 27 + 0x00, 0x18, 0x30, 0x30, 0x30, 0x30, 0x18, 0x00, // 28 + 0x00, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, 0x00, // 29 + 0x00, 0x00, 0x24, 0x18, 0x7E, 0x18, 0x24, 0x00, // 2A + 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, // 2B + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, // 2C + 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, // 2D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, // 2E + 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x00, 0x00, // 2F + 0x00, 0x3C, 0x6E, 0x6E, 0x76, 0x76, 0x3C, 0x00, // 30 + 0x00, 0x1C, 0x3C, 0x0C, 0x0C, 0x0C, 0x3E, 0x00, // 31 + 0x00, 0x3C, 0x66, 0x06, 0x3C, 0x60, 0x7E, 0x00, // 32 + 0x00, 0x3C, 0x66, 0x0C, 0x06, 0x66, 0x3C, 0x00, // 33 + 0x00, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x0C, 0x00, // 34 + 0x00, 0x7E, 0x60, 0x7C, 0x06, 0x66, 0x3C, 0x00, // 35 + 0x00, 0x3C, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00, // 36 + 0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, // 37 + 0x00, 0x3C, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, // 38 + 0x00, 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x3C, 0x00, // 39 + 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, // 3A + 0x00, 0x00, 0x18, 0x00, 0x18, 0x18, 0x30, 0x00, // 3B + 0x00, 0x00, 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, // 3C + 0x00, 0x00, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x00, // 3D + 0x00, 0x00, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x00, // 3E + 0x00, 0x3C, 0x66, 0x06, 0x1C, 0x18, 0x00, 0x18, // 3F + 0x3C, 0x42, 0x81, 0x35, 0x49, 0x49, 0x49, 0x36, // 40 + 0x00, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00, // 41 + 0x00, 0x7C, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00, // 42 + 0x00, 0x3C, 0x66, 0x60, 0x60, 0x66, 0x3C, 0x00, // 43 + 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, // 44 + 0x00, 0x7E, 0x60, 0x7C, 0x60, 0x60, 0x7E, 0x00, // 45 + 0x00, 0x7E, 0x60, 0x7C, 0x60, 0x60, 0x60, 0x00, // 46 + 0x00, 0x3C, 0x66, 0x60, 0x6E, 0x66, 0x3C, 0x00, // 47 + 0x00, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, // 48 + 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, // 49 + 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x6C, 0x38, 0x00, // 4A + 0x00, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0x63, 0x00, // 4B + 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E, 0x00, // 4C + 0x00, 0x63, 0x77, 0x6B, 0x63, 0x63, 0x63, 0x00, // 4D + 0x00, 0x63, 0x73, 0x6B, 0x67, 0x63, 0x63, 0x00, // 4E + 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 4F + 0x00, 0x7C, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00, // 50 + 0x00, 0x3C, 0x66, 0x66, 0x6E, 0x66, 0x3A, 0x01, // 51 + 0x00, 0x7C, 0x66, 0x7C, 0x6C, 0x66, 0x63, 0x00, // 52 + 0x00, 0x3C, 0x60, 0x3C, 0x06, 0x66, 0x3C, 0x00, // 53 + 0x00, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // 54 + 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 55 + 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00, // 56 + 0x00, 0x63, 0x63, 0x6B, 0x6B, 0x7F, 0x36, 0x00, // 57 + 0x00, 0x66, 0x3C, 0x18, 0x18, 0x3C, 0x66, 0x00, // 58 + 0x00, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x00, // 59 + 0x00, 0x7E, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00, // 5A + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 5B + 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // 5C + 0x00, 0x7E, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, // 5D + 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, 0x00, 0x00, // 5E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // 5F + 0x7E, 0x81, 0x99, 0xA1, 0xA1, 0x99, 0x81, 0x7E, // 60 + 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3B, 0x00, // 61 + 0x00, 0x60, 0x60, 0x78, 0x6C, 0x6C, 0x78, 0x00, // 62 + 0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C, 0x00, // 63 + 0x00, 0x06, 0x06, 0x1E, 0x36, 0x36, 0x1E, 0x00, // 64 + 0x00, 0x00, 0x38, 0x6C, 0x7C, 0x60, 0x38, 0x00, // 65 + 0x00, 0x1E, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x00, // 66 + 0x00, 0x00, 0x3C, 0x66, 0x66, 0x3F, 0x06, 0x3C, // 67 + 0x00, 0x60, 0x60, 0x6C, 0x76, 0x66, 0x66, 0x00, // 68 + 0x00, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, // 69 + 0x00, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x30, // 6A + 0x00, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0x00, // 6B + 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x00, // 6C + 0x00, 0x00, 0x36, 0x7F, 0x6B, 0x63, 0x63, 0x00, // 6D + 0x00, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x00, // 6E + 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // 6F + 0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, // 70 + 0x00, 0x00, 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x06, // 71 + 0x00, 0x00, 0x36, 0x38, 0x30, 0x30, 0x30, 0x00, // 72 + 0x00, 0x00, 0x1C, 0x30, 0x1C, 0x06, 0x3C, 0x00, // 73 + 0x00, 0x18, 0x18, 0x3C, 0x18, 0x18, 0x0C, 0x00, // 74 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 75 + 0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, 0x18, 0x00, // 76 + 0x00, 0x00, 0x63, 0x63, 0x6B, 0x7F, 0x36, 0x00, // 77 + 0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x00, // 78 + 0x00, 0x00, 0x66, 0x3C, 0x18, 0x30, 0x60, 0x00, // 79 + 0x00, 0x00, 0x7E, 0x0C, 0x18, 0x30, 0x7E, 0x00, // 7A + 0x66, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3B, 0x00, // 7B + 0x66, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // 7C + 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 7D + 0x00, 0x38, 0x6C, 0x78, 0x6C, 0x78, 0x60, 0x60, // 7E + 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, // 7F + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x00, // 80 + 0xFF, 0xFF, 0xDD, 0x8D, 0xDD, 0xC1, 0xFF, 0xFF, // 81 + 0xFF, 0xFF, 0xED, 0xCD, 0x81, 0xCD, 0xED, 0xFF, // 82 + 0x81, 0x7E, 0x46, 0x5A, 0x46, 0x5A, 0x46, 0x7E, // 83 + 0xAA, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0xAA, 0x00, // 84 + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // 85 + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, // 86 + 0xFF, 0xFF, 0xC3, 0xBD, 0xBD, 0x81, 0xFF, 0xFF, // 87 + 0xFF, 0xEF, 0xCF, 0x81, 0xCF, 0xEF, 0xFF, 0xFF, // 88 + 0xFF, 0xF7, 0xF3, 0x81, 0xF3, 0xF7, 0xFF, 0xFF, // 89 + 0xFF, 0xEF, 0xEF, 0xEF, 0x83, 0xC7, 0xEF, 0xFF, // 8A + 0xF7, 0xE3, 0xC1, 0xF7, 0xF7, 0xF7, 0xF7, 0xFF, // 8B + 0xC7, 0xCF, 0xD7, 0xF7, 0xF7, 0xF7, 0xC1, 0xFF, // 8C + 0xFF, 0xFF, 0xED, 0xCD, 0x81, 0xCF, 0xEF, 0xFF, // 8D + 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 8E + 0xC1, 0x83, 0x83, 0xC1, 0xC1, 0x83, 0x07, 0x07, // 8F + 0xC7, 0xCF, 0xD7, 0xFB, 0xFB, 0xFB, 0xFB, 0xFF, // 90 + 0x80, 0xF7, 0xE3, 0xD5, 0xF7, 0xF7, 0xF7, 0xFF, // 91 + 0xFF, 0xF7, 0xF7, 0xF7, 0xD5, 0xE3, 0xF7, 0x80, // 92 + 0x81, 0x7E, 0x62, 0x5E, 0x46, 0x7A, 0x7A, 0x46, // 93 + 0xFF, 0xC3, 0xBD, 0xA5, 0xA5, 0xBD, 0xC3, 0xFF, // 94 + 0x77, 0xBB, 0xDD, 0xEE, 0x77, 0xBB, 0xDD, 0xEE, // 95 + 0xFF, 0x80, 0xDD, 0x8D, 0xD8, 0xDD, 0x80, 0xFF, // 96 + 0xEE, 0xDD, 0xBB, 0x77, 0xEE, 0xDD, 0xBB, 0x77, // 97 + 0xFF, 0xFE, 0xF6, 0xF2, 0x80, 0xF2, 0xF6, 0xFE, // 98 + 0xFF, 0x6F, 0x4F, 0x01, 0x4F, 0x6F, 0xFF, 0xFF, // 99 + 0xFF, 0xF7, 0x83, 0xF9, 0x83, 0xF7, 0xFF, 0xFF, // 9A + 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, // 9B + 0x81, 0x7E, 0x5E, 0x5E, 0x5E, 0x5E, 0x42, 0x7E, // 9C + 0x81, 0x7E, 0x46, 0x5A, 0x46, 0x5A, 0x5A, 0x7E, // 9D + 0x81, 0x7E, 0x66, 0x5E, 0x5E, 0x5E, 0x66, 0x7E, // 9E + 0xFF, 0xEF, 0xC1, 0x9F, 0xC1, 0xEF, 0xFF, 0xFF, // 9F + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // A0 + 0xFF, 0xE7, 0xE7, 0xE7, 0xE7, 0xFF, 0xE7, 0xFF, // A1 + 0xFF, 0x99, 0x99, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, // A2 + 0xFF, 0xC9, 0x80, 0xC9, 0xC9, 0x80, 0xC9, 0xFF, // A3 + 0xE7, 0xC1, 0x93, 0xC1, 0xE4, 0xE4, 0x81, 0xE7, // A4 + 0xFF, 0x9C, 0x99, 0xF3, 0xE7, 0xC9, 0x99, 0xFF, // A5 + 0xE7, 0xDB, 0xD7, 0xEE, 0xD5, 0xBB, 0xB5, 0xCE, // A6 + 0xFF, 0xE7, 0xE7, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, // A7 + 0xFF, 0xE7, 0xCF, 0xCF, 0xCF, 0xCF, 0xE7, 0xFF, // A8 + 0xFF, 0xE7, 0xF3, 0xF3, 0xF3, 0xF3, 0xE7, 0xFF, // A9 + 0xFF, 0xFF, 0xDB, 0xE7, 0x81, 0xE7, 0xDB, 0xFF, // AA + 0xFF, 0xFF, 0xE7, 0xE7, 0x81, 0xE7, 0xE7, 0xFF, // AB + 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xE7, 0xCF, 0xFF, // AC + 0xFF, 0xFF, 0xFF, 0xFF, 0xC1, 0xFF, 0xFF, 0xFF, // AD + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xE7, 0xFF, // AE + 0xF9, 0xF3, 0xE7, 0xCF, 0x9F, 0x3F, 0xFF, 0xFF, // AF + 0xFF, 0xC3, 0x91, 0x91, 0x89, 0x89, 0xC3, 0xFF, // B0 + 0xFF, 0xE3, 0xC3, 0xF3, 0xF3, 0xF3, 0xC1, 0xFF, // B1 + 0xFF, 0xC3, 0x99, 0xF9, 0xC3, 0x9F, 0x81, 0xFF, // B2 + 0xFF, 0xC3, 0x99, 0xF3, 0xF9, 0x99, 0xC3, 0xFF, // B3 + 0xFF, 0xC3, 0x93, 0x33, 0x01, 0xF3, 0xF3, 0xFF, // B4 + 0xFF, 0x81, 0x9F, 0x83, 0xF9, 0x99, 0xC3, 0xFF, // B5 + 0xFF, 0xC3, 0x9F, 0x83, 0x99, 0x99, 0xC3, 0xFF, // B6 + 0xFF, 0x81, 0xF9, 0xF3, 0xE7, 0xCF, 0x9F, 0xFF, // B7 + 0xFF, 0xC3, 0x99, 0xC3, 0x99, 0x99, 0xC3, 0xFF, // B8 + 0xFF, 0xC3, 0x99, 0x99, 0xC1, 0xF9, 0xC3, 0xFF, // B9 + 0xFF, 0xFF, 0xE7, 0xE7, 0xFF, 0xE7, 0xE7, 0xFF, // BA + 0xFF, 0xFF, 0xE7, 0xFF, 0xE7, 0xE7, 0xCF, 0xFF, // BB + 0xFF, 0xFF, 0xE7, 0xCF, 0x9F, 0xCF, 0xE7, 0xFF, // BC + 0xFF, 0xFF, 0xFF, 0xC1, 0xFF, 0xC1, 0xFF, 0xFF, // BD + 0xFF, 0xFF, 0xCF, 0xE7, 0xF3, 0xE7, 0xCF, 0xFF, // BE + 0xFF, 0xC3, 0x99, 0xF9, 0xE3, 0xE7, 0xFF, 0xE7, // BF + 0xC3, 0xBD, 0x7E, 0xCA, 0xB6, 0xB6, 0xB6, 0xC9, // C0 + 0xFF, 0xC3, 0x99, 0x99, 0x81, 0x99, 0x99, 0xFF, // C1 + 0xFF, 0x83, 0x99, 0x83, 0x99, 0x99, 0x83, 0xFF, // C2 + 0xFF, 0xC3, 0x99, 0x9F, 0x9F, 0x99, 0xC3, 0xFF, // C3 + 0xFF, 0x83, 0x99, 0x99, 0x99, 0x99, 0x83, 0xFF, // C4 + 0xFF, 0x81, 0x9F, 0x83, 0x9F, 0x9F, 0x81, 0xFF, // C5 + 0xFF, 0x81, 0x9F, 0x83, 0x9F, 0x9F, 0x9F, 0xFF, // C6 + 0xFF, 0xC3, 0x99, 0x9F, 0x91, 0x99, 0xC3, 0xFF, // C7 + 0xFF, 0x99, 0x99, 0x81, 0x99, 0x99, 0x99, 0xFF, // C8 + 0xFF, 0xC3, 0xE7, 0xE7, 0xE7, 0xE7, 0xC3, 0xFF, // C9 + 0xFF, 0xE1, 0xF3, 0xF3, 0xF3, 0x93, 0xC7, 0xFF, // CA + 0xFF, 0x99, 0x93, 0x87, 0x93, 0x99, 0x9C, 0xFF, // CB + 0xFF, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x81, 0xFF, // CC + 0xFF, 0x9C, 0x88, 0x94, 0x9C, 0x9C, 0x9C, 0xFF, // CD + 0xFF, 0x9C, 0x8C, 0x94, 0x98, 0x9C, 0x9C, 0xFF, // CE + 0xFF, 0xC3, 0x99, 0x99, 0x99, 0x99, 0xC3, 0xFF, // CF + 0xFF, 0x83, 0x99, 0x83, 0x9F, 0x9F, 0x9F, 0xFF, // D0 + 0xFF, 0xC3, 0x99, 0x99, 0x91, 0x99, 0xC5, 0xFE, // D1 + 0xFF, 0x83, 0x99, 0x83, 0x93, 0x99, 0x9C, 0xFF, // D2 + 0xFF, 0xC3, 0x9F, 0xC3, 0xF9, 0x99, 0xC3, 0xFF, // D3 + 0xFF, 0x81, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xFF, // D4 + 0xFF, 0x99, 0x99, 0x99, 0x99, 0x99, 0xC3, 0xFF, // D5 + 0xFF, 0x99, 0x99, 0x99, 0x99, 0xC3, 0xE7, 0xFF, // D6 + 0xFF, 0x9C, 0x9C, 0x94, 0x94, 0x80, 0xC9, 0xFF, // D7 + 0xFF, 0x99, 0xC3, 0xE7, 0xE7, 0xC3, 0x99, 0xFF, // D8 + 0xFF, 0x99, 0xC3, 0xE7, 0xE7, 0xE7, 0xE7, 0xFF, // D9 + 0xFF, 0x81, 0xF3, 0xE7, 0xCF, 0x9F, 0x81, 0xFF, // DA + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // DB + 0xFF, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xFF, // DC + 0xFF, 0x81, 0xF9, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, // DD + 0xFF, 0xFF, 0xFF, 0xF7, 0xE3, 0xC9, 0xFF, 0xFF, // DE + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, // DF + 0x81, 0x7E, 0x66, 0x5E, 0x5E, 0x66, 0x7E, 0x81, // E0 + 0xFF, 0xFF, 0xC3, 0x99, 0x99, 0x99, 0xC4, 0xFF, // E1 + 0xFF, 0x9F, 0x9F, 0x87, 0x93, 0x93, 0x87, 0xFF, // E2 + 0xFF, 0xFF, 0xC3, 0x99, 0x9F, 0x99, 0xC3, 0xFF, // E3 + 0xFF, 0xF9, 0xF9, 0xE1, 0xC9, 0xC9, 0xE1, 0xFF, // E4 + 0xFF, 0xFF, 0xC7, 0x93, 0x83, 0x9F, 0xC7, 0xFF, // E5 + 0xFF, 0xE1, 0xE7, 0x81, 0xE7, 0xE7, 0xE7, 0xFF, // E6 + 0xFF, 0xFF, 0xC3, 0x99, 0x99, 0xC0, 0xF9, 0xC3, // E7 + 0xFF, 0x9F, 0x9F, 0x93, 0x89, 0x99, 0x99, 0xFF, // E8 + 0xFF, 0xE7, 0xFF, 0xE7, 0xE7, 0xE7, 0xE7, 0xFF, // E9 + 0xFF, 0xE7, 0xFF, 0xC7, 0xE7, 0xE7, 0xE7, 0xCF, // EA + 0xFF, 0x9F, 0x99, 0x93, 0x87, 0x93, 0x99, 0xFF, // EB + 0xFF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xE7, 0xFF, // EC + 0xFF, 0xFF, 0xC9, 0x80, 0x94, 0x9C, 0x9C, 0xFF, // ED + 0xFF, 0xFF, 0x83, 0x99, 0x99, 0x99, 0x99, 0xFF, // EE + 0xFF, 0xFF, 0xC3, 0x99, 0x99, 0x99, 0xC3, 0xFF, // EF + 0xFF, 0xFF, 0x83, 0x99, 0x99, 0x83, 0x9F, 0x9F, // F0 + 0xFF, 0xFF, 0xC3, 0x99, 0x99, 0xC1, 0xF9, 0xF9, // F1 + 0xFF, 0xFF, 0xC9, 0xC7, 0xCF, 0xCF, 0xCF, 0xFF, // F2 + 0xFF, 0xFF, 0xE3, 0xCF, 0xE3, 0xF9, 0xC3, 0xFF, // F3 + 0xFF, 0xE7, 0xE7, 0xC3, 0xE7, 0xE7, 0xF3, 0xFF, // F4 + 0xFF, 0xFF, 0x99, 0x99, 0x99, 0x99, 0xC3, 0xFF, // F5 + 0xFF, 0xFF, 0x99, 0x99, 0xC3, 0xC3, 0xE7, 0xFF, // F6 + 0xFF, 0xFF, 0x9C, 0x9C, 0x94, 0x80, 0xC9, 0xFF, // F7 + 0xFF, 0xFF, 0x99, 0xC3, 0xE7, 0xC3, 0x99, 0xFF, // F8 + 0xFF, 0xFF, 0x99, 0xC3, 0xE7, 0xCF, 0x9F, 0xFF, // F9 + 0xFF, 0xFF, 0x81, 0xF3, 0xE7, 0xCF, 0x81, 0xFF, // FA + 0x99, 0xFF, 0xC3, 0x99, 0x99, 0x99, 0xC4, 0xFF, // FB + 0x99, 0xFF, 0xC3, 0x99, 0x99, 0x99, 0xC3, 0xFF, // FC + 0x99, 0xFF, 0x99, 0x99, 0x99, 0x99, 0xC3, 0xFF, // FD + 0xFF, 0xC7, 0x93, 0x87, 0x93, 0x87, 0x9F, 0x9F, // FE + 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, // FF +}; +static const uint8_t _sdtx_font_kc854[2048] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xFF, // 00 + 0x00, 0x00, 0x22, 0x72, 0x22, 0x3E, 0x00, 0x00, // 01 + 0x00, 0x00, 0x12, 0x32, 0x7E, 0x32, 0x12, 0x00, // 02 + 0x7E, 0x81, 0xB9, 0xA5, 0xB9, 0xA5, 0xB9, 0x81, // 03 + 0x55, 0xFF, 0x55, 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 04 + 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 05 + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, // 06 + 0x00, 0x00, 0x3C, 0x42, 0x42, 0x7E, 0x00, 0x00, // 07 + 0x00, 0x10, 0x30, 0x7E, 0x30, 0x10, 0x00, 0x00, // 08 + 0x00, 0x08, 0x0C, 0x7E, 0x0C, 0x08, 0x00, 0x00, // 09 + 0x00, 0x10, 0x10, 0x10, 0x7C, 0x38, 0x10, 0x00, // 0A + 0x08, 0x1C, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x00, // 0B + 0x38, 0x30, 0x28, 0x08, 0x08, 0x08, 0x3E, 0x00, // 0C + 0x00, 0x00, 0x12, 0x32, 0x7E, 0x30, 0x10, 0x00, // 0D + 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, // 0E + 0x3E, 0x7C, 0x7C, 0x3E, 0x3E, 0x7C, 0xF8, 0xF8, // 0F + 0x38, 0x30, 0x28, 0x04, 0x04, 0x04, 0x04, 0x00, // 10 + 0x7F, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x08, 0x00, // 11 + 0x00, 0x08, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x7F, // 12 + 0x7E, 0x81, 0x9D, 0xA1, 0xB9, 0x85, 0x85, 0xB9, // 13 + 0x00, 0x3C, 0x42, 0x5A, 0x5A, 0x42, 0x3C, 0x00, // 14 + 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11, // 15 + 0x00, 0x7F, 0x22, 0x72, 0x27, 0x22, 0x7F, 0x00, // 16 + 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88, // 17 + 0x00, 0x01, 0x09, 0x0D, 0x7F, 0x0D, 0x09, 0x01, // 18 + 0x00, 0x90, 0xB0, 0xFE, 0xB0, 0x90, 0x00, 0x00, // 19 + 0x00, 0x08, 0x7C, 0x06, 0x7C, 0x08, 0x00, 0x00, // 1A + 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, // 1B + 0x7E, 0x81, 0xA1, 0xA1, 0xA1, 0xA1, 0xBD, 0x81, // 1C + 0x7E, 0x81, 0xB9, 0xA5, 0xB9, 0xA5, 0xA5, 0x81, // 1D + 0x7E, 0x81, 0x99, 0xA1, 0xA1, 0xA1, 0x99, 0x81, // 1E + 0x00, 0x10, 0x3E, 0x60, 0x3E, 0x10, 0x00, 0x00, // 1F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 20 + 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x30, 0x00, // 21 + 0x77, 0x33, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, // 22 + 0x36, 0x36, 0xFE, 0x6C, 0xFE, 0xD8, 0xD8, 0x00, // 23 + 0x18, 0x3E, 0x6C, 0x3E, 0x1B, 0x1B, 0x7E, 0x18, // 24 + 0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, // 25 + 0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, // 26 + 0x1C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // 27 + 0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, // 28 + 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, // 29 + 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, // 2A + 0x00, 0x30, 0x30, 0xFC, 0x30, 0x30, 0x00, 0x00, // 2B + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x0C, 0x18, // 2C + 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, // 2D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, // 2E + 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, // 2F + 0x7C, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0x7C, 0x00, // 30 + 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00, // 31 + 0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00, // 32 + 0xFC, 0x18, 0x30, 0x78, 0x0C, 0xCC, 0x78, 0x00, // 33 + 0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00, // 34 + 0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00, // 35 + 0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00, // 36 + 0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00, // 37 + 0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00, // 38 + 0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00, // 39 + 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x00, // 3A + 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, // 3B + 0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00, // 3C + 0x00, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0x00, 0x00, // 3D + 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, // 3E + 0x78, 0xCC, 0x0C, 0x18, 0x30, 0x00, 0x30, 0x00, // 3F + 0x7C, 0xC6, 0xDE, 0xDE, 0xDE, 0xC0, 0x78, 0x00, // 40 + 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00, // 41 + 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, // 42 + 0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, // 43 + 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, // 44 + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, // 45 + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00, // 46 + 0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3C, 0x00, // 47 + 0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00, // 48 + 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, // 49 + 0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, // 4A + 0xE6, 0x66, 0x6C, 0x70, 0x6C, 0x66, 0xE6, 0x00, // 4B + 0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, // 4C + 0xC6, 0xEE, 0xFE, 0xD6, 0xC6, 0xC6, 0xC6, 0x00, // 4D + 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, // 4E + 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, // 4F + 0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, // 50 + 0x78, 0xCC, 0xCC, 0xCC, 0xDC, 0x78, 0x1C, 0x00, // 51 + 0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00, // 52 + 0x7C, 0xC6, 0xF0, 0x3C, 0x0E, 0xC6, 0x7C, 0x00, // 53 + 0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, // 54 + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x00, // 55 + 0xCC, 0xCC, 0xCC, 0x78, 0x78, 0x30, 0x30, 0x00, // 56 + 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00, // 57 + 0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00, // 58 + 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00, // 59 + 0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, // 5A + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 5B + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // 5C + 0x00, 0xFE, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, // 5D + 0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, // 5E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // 5F + 0x3C, 0x42, 0x99, 0xA1, 0xA1, 0x99, 0x42, 0x3C, // 60 + 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, // 61 + 0xE0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0xDC, 0x00, // 62 + 0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00, // 63 + 0x1C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, // 64 + 0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, // 65 + 0x38, 0x6C, 0x60, 0xF0, 0x60, 0x60, 0xF0, 0x00, // 66 + 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, // 67 + 0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, // 68 + 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0xFC, 0x00, // 69 + 0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, // 6A + 0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, // 6B + 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00, // 6C + 0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xC6, 0x00, // 6D + 0x00, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, // 6E + 0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, // 6F + 0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, // 70 + 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, // 71 + 0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0xF0, 0x00, // 72 + 0x00, 0x00, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x00, // 73 + 0x10, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00, // 74 + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, // 75 + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, // 76 + 0x00, 0x00, 0xC6, 0xD6, 0xFE, 0xFE, 0x6C, 0x00, // 77 + 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, // 78 + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, // 79 + 0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00, // 7A + 0x6C, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, // 7B + 0xCC, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, // 7C + 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, // 7D + 0x3C, 0x66, 0x66, 0x6C, 0x66, 0x66, 0x6C, 0xF0, // 7E + 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, // 7F + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x00, // 80 + 0xFF, 0xFF, 0xDD, 0x8D, 0xDD, 0xC1, 0xFF, 0xFF, // 81 + 0xFF, 0xFF, 0xED, 0xCD, 0x81, 0xCD, 0xED, 0xFF, // 82 + 0x81, 0x7E, 0x46, 0x5A, 0x46, 0x5A, 0x46, 0x7E, // 83 + 0xAA, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0xAA, 0x00, // 84 + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // 85 + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, // 86 + 0xFF, 0xFF, 0xC3, 0xBD, 0xBD, 0x81, 0xFF, 0xFF, // 87 + 0xFF, 0xEF, 0xCF, 0x81, 0xCF, 0xEF, 0xFF, 0xFF, // 88 + 0xFF, 0xF7, 0xF3, 0x81, 0xF3, 0xF7, 0xFF, 0xFF, // 89 + 0xFF, 0xEF, 0xEF, 0xEF, 0x83, 0xC7, 0xEF, 0xFF, // 8A + 0xF7, 0xE3, 0xC1, 0xF7, 0xF7, 0xF7, 0xF7, 0xFF, // 8B + 0xC7, 0xCF, 0xD7, 0xF7, 0xF7, 0xF7, 0xC1, 0xFF, // 8C + 0xFF, 0xFF, 0xED, 0xCD, 0x81, 0xCF, 0xEF, 0xFF, // 8D + 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 8E + 0xC1, 0x83, 0x83, 0xC1, 0xC1, 0x83, 0x07, 0x07, // 8F + 0xC7, 0xCF, 0xD7, 0xFB, 0xFB, 0xFB, 0xFB, 0xFF, // 90 + 0x80, 0xF7, 0xE3, 0xD5, 0xF7, 0xF7, 0xF7, 0xFF, // 91 + 0xFF, 0xF7, 0xF7, 0xF7, 0xD5, 0xE3, 0xF7, 0x80, // 92 + 0x81, 0x7E, 0x62, 0x5E, 0x46, 0x7A, 0x7A, 0x46, // 93 + 0xFF, 0xC3, 0xBD, 0xA5, 0xA5, 0xBD, 0xC3, 0xFF, // 94 + 0x77, 0xBB, 0xDD, 0xEE, 0x77, 0xBB, 0xDD, 0xEE, // 95 + 0xFF, 0x80, 0xDD, 0x8D, 0xD8, 0xDD, 0x80, 0xFF, // 96 + 0xEE, 0xDD, 0xBB, 0x77, 0xEE, 0xDD, 0xBB, 0x77, // 97 + 0xFF, 0xFE, 0xF6, 0xF2, 0x80, 0xF2, 0xF6, 0xFE, // 98 + 0xFF, 0x6F, 0x4F, 0x01, 0x4F, 0x6F, 0xFF, 0xFF, // 99 + 0xFF, 0xF7, 0x83, 0xF9, 0x83, 0xF7, 0xFF, 0xFF, // 9A + 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, // 9B + 0x81, 0x7E, 0x5E, 0x5E, 0x5E, 0x5E, 0x42, 0x7E, // 9C + 0x81, 0x7E, 0x46, 0x5A, 0x46, 0x5A, 0x5A, 0x7E, // 9D + 0x81, 0x7E, 0x66, 0x5E, 0x5E, 0x5E, 0x66, 0x7E, // 9E + 0xFF, 0xEF, 0xC1, 0x9F, 0xC1, 0xEF, 0xFF, 0xFF, // 9F + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // A0 + 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xFF, 0xCF, 0xFF, // A1 + 0x88, 0xCC, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // A2 + 0xC9, 0xC9, 0x01, 0x93, 0x01, 0x27, 0x27, 0xFF, // A3 + 0xE7, 0xC1, 0x93, 0xC1, 0xE4, 0xE4, 0x81, 0xE7, // A4 + 0xFF, 0x39, 0x33, 0xE7, 0xCF, 0x99, 0x39, 0xFF, // A5 + 0xC7, 0x93, 0xC7, 0x89, 0x23, 0x33, 0x89, 0xFF, // A6 + 0xE3, 0xF3, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // A7 + 0xE7, 0xCF, 0x9F, 0x9F, 0x9F, 0xCF, 0xE7, 0xFF, // A8 + 0x9F, 0xCF, 0xE7, 0xE7, 0xE7, 0xCF, 0x9F, 0xFF, // A9 + 0xFF, 0x99, 0xC3, 0x00, 0xC3, 0x99, 0xFF, 0xFF, // AA + 0xFF, 0xCF, 0xCF, 0x03, 0xCF, 0xCF, 0xFF, 0xFF, // AB + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0xF3, 0xE7, // AC + 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, // AD + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCF, 0xCF, 0xFF, // AE + 0xF9, 0xF3, 0xE7, 0xCF, 0x9F, 0x3F, 0x7F, 0xFF, // AF + 0x83, 0x39, 0x31, 0x21, 0x09, 0x19, 0x83, 0xFF, // B0 + 0xCF, 0x8F, 0xCF, 0xCF, 0xCF, 0xCF, 0x03, 0xFF, // B1 + 0x87, 0x33, 0xF3, 0xC7, 0x9F, 0x33, 0x03, 0xFF, // B2 + 0x03, 0xE7, 0xCF, 0x87, 0xF3, 0x33, 0x87, 0xFF, // B3 + 0xE3, 0xC3, 0x93, 0x33, 0x01, 0xF3, 0xE1, 0xFF, // B4 + 0x03, 0x3F, 0x07, 0xF3, 0xF3, 0x33, 0x87, 0xFF, // B5 + 0xC7, 0x9F, 0x3F, 0x07, 0x33, 0x33, 0x87, 0xFF, // B6 + 0x03, 0x33, 0xF3, 0xE7, 0xCF, 0xCF, 0xCF, 0xFF, // B7 + 0x87, 0x33, 0x33, 0x87, 0x33, 0x33, 0x87, 0xFF, // B8 + 0x87, 0x33, 0x33, 0x83, 0xF3, 0xE7, 0x8F, 0xFF, // B9 + 0xFF, 0xFF, 0xCF, 0xCF, 0xFF, 0xCF, 0xCF, 0xFF, // BA + 0xFF, 0xFF, 0xCF, 0xCF, 0xFF, 0xCF, 0xCF, 0x9F, // BB + 0xE7, 0xCF, 0x9F, 0x3F, 0x9F, 0xCF, 0xE7, 0xFF, // BC + 0xFF, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, // BD + 0x9F, 0xCF, 0xE7, 0xF3, 0xE7, 0xCF, 0x9F, 0xFF, // BE + 0x87, 0x33, 0xF3, 0xE7, 0xCF, 0xFF, 0xCF, 0xFF, // BF + 0x83, 0x39, 0x21, 0x21, 0x21, 0x3F, 0x87, 0xFF, // C0 + 0xCF, 0x87, 0x33, 0x33, 0x03, 0x33, 0x33, 0xFF, // C1 + 0x03, 0x99, 0x99, 0x83, 0x99, 0x99, 0x03, 0xFF, // C2 + 0xC3, 0x99, 0x3F, 0x3F, 0x3F, 0x99, 0xC3, 0xFF, // C3 + 0x07, 0x93, 0x99, 0x99, 0x99, 0x93, 0x07, 0xFF, // C4 + 0x01, 0x9D, 0x97, 0x87, 0x97, 0x9D, 0x01, 0xFF, // C5 + 0x01, 0x9D, 0x97, 0x87, 0x97, 0x9F, 0x0F, 0xFF, // C6 + 0xC3, 0x99, 0x3F, 0x3F, 0x31, 0x99, 0xC3, 0xFF, // C7 + 0x33, 0x33, 0x33, 0x03, 0x33, 0x33, 0x33, 0xFF, // C8 + 0x87, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0x87, 0xFF, // C9 + 0xE1, 0xF3, 0xF3, 0xF3, 0x33, 0x33, 0x87, 0xFF, // CA + 0x19, 0x99, 0x93, 0x8F, 0x93, 0x99, 0x19, 0xFF, // CB + 0x0F, 0x9F, 0x9F, 0x9F, 0x9D, 0x99, 0x01, 0xFF, // CC + 0x39, 0x11, 0x01, 0x29, 0x39, 0x39, 0x39, 0xFF, // CD + 0x39, 0x19, 0x09, 0x21, 0x31, 0x39, 0x39, 0xFF, // CE + 0xC7, 0x93, 0x39, 0x39, 0x39, 0x93, 0xC7, 0xFF, // CF + 0x03, 0x99, 0x99, 0x83, 0x9F, 0x9F, 0x0F, 0xFF, // D0 + 0x87, 0x33, 0x33, 0x33, 0x23, 0x87, 0xE3, 0xFF, // D1 + 0x03, 0x99, 0x99, 0x83, 0x93, 0x99, 0x19, 0xFF, // D2 + 0x83, 0x39, 0x0F, 0xC3, 0xF1, 0x39, 0x83, 0xFF, // D3 + 0x03, 0x4B, 0xCF, 0xCF, 0xCF, 0xCF, 0x87, 0xFF, // D4 + 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x87, 0xFF, // D5 + 0x33, 0x33, 0x33, 0x87, 0x87, 0xCF, 0xCF, 0xFF, // D6 + 0x39, 0x39, 0x39, 0x29, 0x01, 0x11, 0x39, 0xFF, // D7 + 0x39, 0x39, 0x93, 0xC7, 0x93, 0x39, 0x39, 0xFF, // D8 + 0x33, 0x33, 0x33, 0x87, 0xCF, 0xCF, 0x87, 0xFF, // D9 + 0x01, 0x39, 0x73, 0xE7, 0xCD, 0x99, 0x01, 0xFF, // DA + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // DB + 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xFF, // DC + 0xFF, 0x01, 0xF9, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, // DD + 0xEF, 0xC7, 0x93, 0x39, 0xFF, 0xFF, 0xFF, 0xFF, // DE + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, // DF + 0xC3, 0xBD, 0x66, 0x5E, 0x5E, 0x66, 0xBD, 0xC3, // E0 + 0xFF, 0xFF, 0x87, 0xF3, 0x83, 0x33, 0x89, 0xFF, // E1 + 0x1F, 0x9F, 0x83, 0x99, 0x99, 0x99, 0x23, 0xFF, // E2 + 0xFF, 0xFF, 0x87, 0x33, 0x3F, 0x33, 0x87, 0xFF, // E3 + 0xE3, 0xF3, 0x83, 0x33, 0x33, 0x33, 0x89, 0xFF, // E4 + 0xFF, 0xFF, 0x87, 0x33, 0x03, 0x3F, 0x87, 0xFF, // E5 + 0xC7, 0x93, 0x9F, 0x0F, 0x9F, 0x9F, 0x0F, 0xFF, // E6 + 0xFF, 0xFF, 0x89, 0x33, 0x33, 0x83, 0xF3, 0x07, // E7 + 0x1F, 0x9F, 0x93, 0x89, 0x99, 0x99, 0x19, 0xFF, // E8 + 0xCF, 0xFF, 0x8F, 0xCF, 0xCF, 0xCF, 0x03, 0xFF, // E9 + 0xF3, 0xFF, 0xE3, 0xF3, 0xF3, 0x33, 0x33, 0x87, // EA + 0x1F, 0x9F, 0x99, 0x93, 0x87, 0x93, 0x19, 0xFF, // EB + 0x8F, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0x03, 0xFF, // EC + 0xFF, 0xFF, 0x33, 0x01, 0x01, 0x29, 0x39, 0xFF, // ED + 0xFF, 0xFF, 0x07, 0x33, 0x33, 0x33, 0x33, 0xFF, // EE + 0xFF, 0xFF, 0x87, 0x33, 0x33, 0x33, 0x87, 0xFF, // EF + 0xFF, 0xFF, 0x23, 0x99, 0x99, 0x83, 0x9F, 0x0F, // F0 + 0xFF, 0xFF, 0x89, 0x33, 0x33, 0x83, 0xF3, 0xE1, // F1 + 0xFF, 0xFF, 0x23, 0x89, 0x99, 0x9F, 0x0F, 0xFF, // F2 + 0xFF, 0xFF, 0x83, 0x3F, 0x87, 0xF3, 0x07, 0xFF, // F3 + 0xEF, 0xCF, 0x83, 0xCF, 0xCF, 0xCB, 0xE7, 0xFF, // F4 + 0xFF, 0xFF, 0x33, 0x33, 0x33, 0x33, 0x89, 0xFF, // F5 + 0xFF, 0xFF, 0x33, 0x33, 0x33, 0x87, 0xCF, 0xFF, // F6 + 0xFF, 0xFF, 0x39, 0x29, 0x01, 0x01, 0x93, 0xFF, // F7 + 0xFF, 0xFF, 0x39, 0x93, 0xC7, 0x93, 0x39, 0xFF, // F8 + 0xFF, 0xFF, 0x33, 0x33, 0x33, 0x83, 0xF3, 0x07, // F9 + 0xFF, 0xFF, 0x03, 0x67, 0xCF, 0x9B, 0x03, 0xFF, // FA + 0x93, 0xFF, 0x87, 0xF3, 0x83, 0x33, 0x89, 0xFF, // FB + 0x33, 0xFF, 0x87, 0x33, 0x33, 0x33, 0x87, 0xFF, // FC + 0x33, 0xFF, 0x33, 0x33, 0x33, 0x33, 0x89, 0xFF, // FD + 0xC3, 0x99, 0x99, 0x93, 0x99, 0x99, 0x93, 0x0F, // FE + 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, // FF +}; +static const uint8_t _sdtx_font_z1013[2048] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 00 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 01 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 02 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 03 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 04 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 05 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 06 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 07 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 08 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 09 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0A + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0B + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0C + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0D + 0x00, 0x00, 0x18, 0x24, 0x24, 0x18, 0x24, 0x42, // 0E + 0xDB, 0xA5, 0x81, 0xFF, 0x24, 0x24, 0x24, 0x42, // 0F + 0x08, 0x34, 0x42, 0x81, 0x91, 0x69, 0x09, 0x31, // 10 + 0x42, 0x7E, 0x81, 0xFF, 0x00, 0x00, 0x00, 0x00, // 11 + 0x18, 0x24, 0x42, 0x99, 0xBD, 0x99, 0x42, 0x24, // 12 + 0x7E, 0x42, 0x99, 0xE7, 0x00, 0x00, 0x00, 0x00, // 13 + 0x18, 0xDB, 0xC3, 0x18, 0x99, 0xE7, 0x81, 0x42, // 14 + 0x18, 0x24, 0x18, 0xC3, 0xBD, 0x81, 0x81, 0x42, // 15 + 0x24, 0x7E, 0x81, 0xFF, 0x00, 0x00, 0x00, 0x00, // 16 + 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x3C, 0x7E, // 17 + 0xDB, 0xFF, 0xFF, 0xFF, 0x3C, 0x3C, 0x3C, 0x7E, // 18 + 0x08, 0x3C, 0x7E, 0xFF, 0xFF, 0x6F, 0x0F, 0x3F, // 19 + 0x7E, 0x7E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // 1A + 0x18, 0x3C, 0x7E, 0xE7, 0xC3, 0xE7, 0x7E, 0x3C, // 1B + 0x7E, 0x7E, 0xFF, 0xE7, 0x00, 0x00, 0x00, 0x00, // 1C + 0x18, 0xDB, 0xC3, 0x18, 0x99, 0xFF, 0xFF, 0x7E, // 1D + 0x18, 0x3C, 0x18, 0xC3, 0xFF, 0xFF, 0xFF, 0x7E, // 1E + 0x3C, 0x3C, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // 1F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 20 + 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x00, // 21 + 0x28, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, // 22 + 0x24, 0x7E, 0x24, 0x24, 0x24, 0x7E, 0x24, 0x00, // 23 + 0x10, 0x3C, 0x50, 0x38, 0x14, 0x78, 0x10, 0x00, // 24 + 0x60, 0x64, 0x08, 0x10, 0x20, 0x4C, 0x0C, 0x00, // 25 + 0x10, 0x28, 0x28, 0x30, 0x54, 0x48, 0x34, 0x00, // 26 + 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // 27 + 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, // 28 + 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00, // 29 + 0x00, 0x10, 0x54, 0x38, 0x54, 0x10, 0x00, 0x00, // 2A + 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00, // 2B + 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x20, 0x00, // 2C + 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, // 2D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, // 2E + 0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, // 2F + 0x38, 0x44, 0x44, 0x54, 0x44, 0x44, 0x38, 0x00, // 30 + 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, // 31 + 0x38, 0x44, 0x04, 0x08, 0x10, 0x20, 0x7C, 0x00, // 32 + 0x7C, 0x08, 0x10, 0x08, 0x04, 0x44, 0x38, 0x00, // 33 + 0x08, 0x18, 0x28, 0x48, 0x7C, 0x08, 0x08, 0x00, // 34 + 0x7C, 0x40, 0x78, 0x04, 0x04, 0x44, 0x38, 0x00, // 35 + 0x18, 0x20, 0x40, 0x78, 0x44, 0x44, 0x38, 0x00, // 36 + 0x7C, 0x04, 0x08, 0x10, 0x20, 0x20, 0x20, 0x00, // 37 + 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, 0x00, // 38 + 0x38, 0x44, 0x44, 0x3C, 0x04, 0x08, 0x30, 0x00, // 39 + 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x00, 0x00, // 3A + 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x20, 0x00, // 3B + 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x00, // 3C + 0x00, 0x00, 0x7C, 0x00, 0x7C, 0x00, 0x00, 0x00, // 3D + 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x00, // 3E + 0x38, 0x44, 0x04, 0x08, 0x10, 0x00, 0x10, 0x00, // 3F + 0x38, 0x44, 0x5C, 0x54, 0x5C, 0x40, 0x3C, 0x00, // 40 + 0x38, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x44, 0x00, // 41 + 0x78, 0x24, 0x24, 0x38, 0x24, 0x24, 0x78, 0x00, // 42 + 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x00, // 43 + 0x78, 0x24, 0x24, 0x24, 0x24, 0x24, 0x78, 0x00, // 44 + 0x7C, 0x40, 0x40, 0x78, 0x40, 0x40, 0x7C, 0x00, // 45 + 0x7C, 0x40, 0x40, 0x78, 0x40, 0x40, 0x40, 0x00, // 46 + 0x38, 0x44, 0x40, 0x40, 0x4C, 0x44, 0x3C, 0x00, // 47 + 0x44, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x44, 0x00, // 48 + 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, // 49 + 0x1C, 0x08, 0x08, 0x08, 0x08, 0x48, 0x30, 0x00, // 4A + 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x00, // 4B + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C, 0x00, // 4C + 0x44, 0x6C, 0x54, 0x54, 0x44, 0x44, 0x44, 0x00, // 4D + 0x44, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x44, 0x00, // 4E + 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, // 4F + 0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x00, // 50 + 0x38, 0x44, 0x44, 0x44, 0x54, 0x48, 0x34, 0x00, // 51 + 0x78, 0x44, 0x44, 0x78, 0x50, 0x48, 0x44, 0x00, // 52 + 0x3C, 0x40, 0x40, 0x38, 0x04, 0x04, 0x78, 0x00, // 53 + 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // 54 + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, // 55 + 0x44, 0x44, 0x44, 0x44, 0x44, 0x28, 0x10, 0x00, // 56 + 0x44, 0x44, 0x44, 0x54, 0x54, 0x6C, 0x44, 0x00, // 57 + 0x44, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, 0x00, // 58 + 0x44, 0x44, 0x44, 0x28, 0x10, 0x10, 0x10, 0x00, // 59 + 0x7C, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7C, 0x00, // 5A + 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, // 5B + 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, // 5C + 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, // 5D + 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, // 5E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, // 5F + 0x00, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, // 60 + 0x00, 0x00, 0x34, 0x4C, 0x44, 0x44, 0x3A, 0x00, // 61 + 0x40, 0x40, 0x58, 0x64, 0x44, 0x44, 0x78, 0x00, // 62 + 0x00, 0x00, 0x38, 0x44, 0x40, 0x44, 0x38, 0x00, // 63 + 0x04, 0x04, 0x34, 0x4C, 0x44, 0x44, 0x3A, 0x00, // 64 + 0x00, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x38, 0x00, // 65 + 0x08, 0x10, 0x38, 0x10, 0x10, 0x10, 0x10, 0x00, // 66 + 0x00, 0x00, 0x34, 0x4C, 0x44, 0x3C, 0x04, 0x38, // 67 + 0x40, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, // 68 + 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x08, 0x00, // 69 + 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, // 6A + 0x40, 0x40, 0x48, 0x50, 0x70, 0x48, 0x44, 0x00, // 6B + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x00, // 6C + 0x00, 0x00, 0x68, 0x54, 0x54, 0x54, 0x54, 0x00, // 6D + 0x00, 0x00, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, // 6E + 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, // 6F + 0x00, 0x00, 0x58, 0x64, 0x44, 0x78, 0x40, 0x40, // 70 + 0x00, 0x00, 0x34, 0x4C, 0x44, 0x3C, 0x04, 0x04, // 71 + 0x00, 0x00, 0x58, 0x64, 0x40, 0x40, 0x40, 0x00, // 72 + 0x00, 0x00, 0x38, 0x40, 0x38, 0x04, 0x78, 0x00, // 73 + 0x10, 0x10, 0x38, 0x10, 0x10, 0x10, 0x08, 0x00, // 74 + 0x00, 0x00, 0x44, 0x44, 0x44, 0x4C, 0x34, 0x00, // 75 + 0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x10, 0x00, // 76 + 0x00, 0x00, 0x54, 0x54, 0x54, 0x54, 0x28, 0x00, // 77 + 0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, // 78 + 0x00, 0x00, 0x44, 0x44, 0x44, 0x3C, 0x04, 0x38, // 79 + 0x00, 0x00, 0x7C, 0x08, 0x10, 0x20, 0x7C, 0x00, // 7A + 0x08, 0x10, 0x10, 0x20, 0x10, 0x10, 0x08, 0x00, // 7B + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // 7C + 0x20, 0x10, 0x10, 0x08, 0x10, 0x10, 0x20, 0x00, // 7D + 0x00, 0x00, 0x00, 0x32, 0x4C, 0x00, 0x00, 0x00, // 7E + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 7F + 0xC0, 0x20, 0x10, 0x10, 0x10, 0x10, 0x20, 0xC0, // 80 + 0x03, 0x04, 0x08, 0x08, 0x08, 0x08, 0x04, 0x03, // 81 + 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00, // 82 + 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x81, 0x81, // 83 + 0x10, 0x10, 0x20, 0xC0, 0x00, 0x00, 0x00, 0x00, // 84 + 0x08, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, // 85 + 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x08, 0x08, // 86 + 0x00, 0x00, 0x00, 0x00, 0xC0, 0x20, 0x10, 0x10, // 87 + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, // 88 + 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 89 + 0x00, 0x10, 0x28, 0x44, 0x82, 0x44, 0x28, 0x10, // 8A + 0xFF, 0xEF, 0xC7, 0x83, 0x01, 0x83, 0xC7, 0xEF, // 8B + 0x3C, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3C, // 8C + 0xC3, 0x81, 0x00, 0x00, 0x00, 0x00, 0x81, 0xC3, // 8D + 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, // 8E + 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, // 8F + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, // 90 + 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, // 91 + 0x00, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x30, 0xC0, // 92 + 0x03, 0x0C, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, // 93 + 0x03, 0x0C, 0x30, 0xC0, 0xC0, 0x30, 0x0C, 0x03, // 94 + 0x00, 0x00, 0x00, 0x00, 0xC0, 0x30, 0x0C, 0x03, // 95 + 0xC0, 0x30, 0x0C, 0x03, 0x00, 0x00, 0x00, 0x00, // 96 + 0xC0, 0x30, 0x0C, 0x03, 0x03, 0x0C, 0x30, 0xC0, // 97 + 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, // 98 + 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, // 99 + 0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, // 9A + 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, // 9B + 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, // 9C + 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x81, 0x81, // 9D + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9E + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 9F + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // A0 + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // A1 + 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x00, 0x00, 0x00, // A2 + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x18, 0x18, 0x18, // A3 + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18, 0x18, 0x18, // A4 + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x18, 0x18, 0x18, // A5 + 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x18, 0x18, 0x18, // A6 + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, 0x00, // A7 + 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x18, 0x18, 0x18, // A8 + 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18, // A9 + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00, // AA + 0x80, 0x80, 0x80, 0x40, 0x40, 0x20, 0x18, 0x07, // AB + 0x01, 0x01, 0x01, 0x02, 0x02, 0x04, 0x18, 0xE0, // AC + 0xE0, 0x18, 0x04, 0x02, 0x02, 0x01, 0x01, 0x01, // AD + 0x07, 0x18, 0x20, 0x40, 0x40, 0x80, 0x80, 0x80, // AE + 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81, // AF + 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, // B0 + 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, // B1 + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, // B2 + 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, // B3 + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, // B4 + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // B5 + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // B6 + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, // B7 + 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, // B8 + 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, // B9 + 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, // BA + 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, // BB + 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, // BC + 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, // BD + 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, // BE + 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, // BF + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // C0 + 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // C1 + 0xFF, 0x80, 0x80, 0x9C, 0x9C, 0x9C, 0x80, 0x80, // C2 + 0xFF, 0xFF, 0xFF, 0xE3, 0xE3, 0xE3, 0xFF, 0xFF, // C3 + 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x3C, 0x7E, 0xFF, // C4 + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, // C5 + 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // C6 + 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, // C7 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, // C8 + 0x00, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, // C9 + 0x38, 0x10, 0x92, 0xFE, 0x92, 0x10, 0x38, 0x7C, // CA + 0x00, 0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, // CB + 0x10, 0x38, 0x7C, 0xFE, 0xFE, 0x7C, 0x10, 0x7C, // CC + 0xE7, 0xE7, 0x42, 0xFF, 0xFF, 0x42, 0xE7, 0xE7, // CD + 0xDB, 0xFF, 0xDB, 0x18, 0x18, 0xDB, 0xFF, 0xDB, // CE + 0x3C, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, // CF + 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // D0 + 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // D1 + 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // D2 + 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // D3 + 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, // D4 + 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, // D5 + 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, // D6 + 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, // D7 + 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, // D8 + 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, // D9 + 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, // DA + 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // DB + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, // DC + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, // DD + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, // DE + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, // DF + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, // E0 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, // E1 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, // E2 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFC, // E3 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, // E4 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, // E5 + 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, // E6 + 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // E7 + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // E8 + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, // E9 + 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, // EA + 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // EB + 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // EC + 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ED + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // EE + 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // EF + 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // F0 + 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // F1 + 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, // F2 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, // F3 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // F4 + 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // F5 + 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, // F6 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, // F7 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // F8 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, // F9 + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, // FA + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, // FB + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // FC + 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // FD + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // FE + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // FF +}; +static const uint8_t _sdtx_font_cpc[2048] = { + 0xFF, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xFF, // 00 + 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // 01 + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, // 02 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, // 03 + 0x0C, 0x18, 0x30, 0x7E, 0x0C, 0x18, 0x30, 0x00, // 04 + 0xFF, 0xC3, 0xE7, 0xDB, 0xDB, 0xE7, 0xC3, 0xFF, // 05 + 0x00, 0x01, 0x03, 0x06, 0xCC, 0x78, 0x30, 0x00, // 06 + 0x3C, 0x66, 0xC3, 0xC3, 0xFF, 0x24, 0xE7, 0x00, // 07 + 0x00, 0x00, 0x30, 0x60, 0xFF, 0x60, 0x30, 0x00, // 08 + 0x00, 0x00, 0x0C, 0x06, 0xFF, 0x06, 0x0C, 0x00, // 09 + 0x18, 0x18, 0x18, 0x18, 0xDB, 0x7E, 0x3C, 0x18, // 0A + 0x18, 0x3C, 0x7E, 0xDB, 0x18, 0x18, 0x18, 0x18, // 0B + 0x18, 0x5A, 0x3C, 0x99, 0xDB, 0x7E, 0x3C, 0x18, // 0C + 0x00, 0x03, 0x33, 0x63, 0xFE, 0x60, 0x30, 0x00, // 0D + 0x3C, 0x66, 0xFF, 0xDB, 0xDB, 0xFF, 0x66, 0x3C, // 0E + 0x3C, 0x66, 0xC3, 0xDB, 0xDB, 0xC3, 0x66, 0x3C, // 0F + 0xFF, 0xC3, 0xC3, 0xFF, 0xC3, 0xC3, 0xC3, 0xFF, // 10 + 0x3C, 0x7E, 0xDB, 0xDB, 0xDF, 0xC3, 0x66, 0x3C, // 11 + 0x3C, 0x66, 0xC3, 0xDF, 0xDB, 0xDB, 0x7E, 0x3C, // 12 + 0x3C, 0x66, 0xC3, 0xFB, 0xDB, 0xDB, 0x7E, 0x3C, // 13 + 0x3C, 0x7E, 0xDB, 0xDB, 0xFB, 0xC3, 0x66, 0x3C, // 14 + 0x00, 0x01, 0x33, 0x1E, 0xCE, 0x7B, 0x31, 0x00, // 15 + 0x7E, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xE7, // 16 + 0x03, 0x03, 0x03, 0xFF, 0x03, 0x03, 0x03, 0x00, // 17 + 0xFF, 0x66, 0x3C, 0x18, 0x18, 0x3C, 0x66, 0xFF, // 18 + 0x18, 0x18, 0x3C, 0x3C, 0x3C, 0x3C, 0x18, 0x18, // 19 + 0x3C, 0x66, 0x66, 0x30, 0x18, 0x00, 0x18, 0x00, // 1A + 0x3C, 0x66, 0xC3, 0xFF, 0xC3, 0xC3, 0x66, 0x3C, // 1B + 0xFF, 0xDB, 0xDB, 0xDB, 0xFB, 0xC3, 0xC3, 0xFF, // 1C + 0xFF, 0xC3, 0xC3, 0xFB, 0xDB, 0xDB, 0xDB, 0xFF, // 1D + 0xFF, 0xC3, 0xC3, 0xDF, 0xDB, 0xDB, 0xDB, 0xFF, // 1E + 0xFF, 0xDB, 0xDB, 0xDB, 0xDF, 0xC3, 0xC3, 0xFF, // 1F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 20 + 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00, // 21 + 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, // 22 + 0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, // 23 + 0x18, 0x3E, 0x58, 0x3C, 0x1A, 0x7C, 0x18, 0x00, // 24 + 0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, // 25 + 0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, // 26 + 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // 27 + 0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, // 28 + 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, // 29 + 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, // 2A + 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, // 2B + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, // 2C + 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, // 2D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, // 2E + 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, // 2F + 0x7C, 0xC6, 0xCE, 0xD6, 0xE6, 0xC6, 0x7C, 0x00, // 30 + 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, // 31 + 0x3C, 0x66, 0x06, 0x3C, 0x60, 0x66, 0x7E, 0x00, // 32 + 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00, // 33 + 0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00, // 34 + 0x7E, 0x62, 0x60, 0x7C, 0x06, 0x66, 0x3C, 0x00, // 35 + 0x3C, 0x66, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00, // 36 + 0x7E, 0x66, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x00, // 37 + 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, // 38 + 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C, 0x00, // 39 + 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, // 3A + 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30, // 3B + 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x00, // 3C + 0x00, 0x00, 0x7E, 0x00, 0x00, 0x7E, 0x00, 0x00, // 3D + 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, // 3E + 0x3C, 0x66, 0x66, 0x0C, 0x18, 0x00, 0x18, 0x00, // 3F + 0x7C, 0xC6, 0xDE, 0xDE, 0xDE, 0xC0, 0x7C, 0x00, // 40 + 0x18, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00, // 41 + 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, // 42 + 0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, // 43 + 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, // 44 + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, // 45 + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00, // 46 + 0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3E, 0x00, // 47 + 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, // 48 + 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, // 49 + 0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, // 4A + 0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, // 4B + 0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, // 4C + 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, // 4D + 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, // 4E + 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, // 4F + 0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, // 50 + 0x38, 0x6C, 0xC6, 0xC6, 0xDA, 0xCC, 0x76, 0x00, // 51 + 0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00, // 52 + 0x3C, 0x66, 0x60, 0x3C, 0x06, 0x66, 0x3C, 0x00, // 53 + 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, // 54 + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 55 + 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00, // 56 + 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00, // 57 + 0xC6, 0x6C, 0x38, 0x38, 0x6C, 0xC6, 0xC6, 0x00, // 58 + 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x3C, 0x00, // 59 + 0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, // 5A + 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, // 5B + 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, // 5C + 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, // 5D + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, // 5E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // 5F + 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 + 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, // 61 + 0xE0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0xDC, 0x00, // 62 + 0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C, 0x00, // 63 + 0x1C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, // 64 + 0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // 65 + 0x1C, 0x36, 0x30, 0x78, 0x30, 0x30, 0x78, 0x00, // 66 + 0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x7C, // 67 + 0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, // 68 + 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00, // 69 + 0x06, 0x00, 0x0E, 0x06, 0x06, 0x66, 0x66, 0x3C, // 6A + 0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, // 6B + 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, // 6C + 0x00, 0x00, 0x6C, 0xFE, 0xD6, 0xD6, 0xC6, 0x00, // 6D + 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x00, // 6E + 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // 6F + 0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, // 70 + 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, // 71 + 0x00, 0x00, 0xDC, 0x76, 0x60, 0x60, 0xF0, 0x00, // 72 + 0x00, 0x00, 0x3C, 0x60, 0x3C, 0x06, 0x7C, 0x00, // 73 + 0x30, 0x30, 0x7C, 0x30, 0x30, 0x36, 0x1C, 0x00, // 74 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, // 75 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00, // 76 + 0x00, 0x00, 0xC6, 0xD6, 0xD6, 0xFE, 0x6C, 0x00, // 77 + 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, // 78 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x7C, // 79 + 0x00, 0x00, 0x7E, 0x4C, 0x18, 0x32, 0x7E, 0x00, // 7A + 0x0E, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0E, 0x00, // 7B + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // 7C + 0x70, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x70, 0x00, // 7D + 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 7E + 0xCC, 0x33, 0xCC, 0x33, 0xCC, 0x33, 0xCC, 0x33, // 7F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 + 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, // 81 + 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, // 82 + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // 83 + 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, // 84 + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, // 85 + 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, // 86 + 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, // 87 + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, // 88 + 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, // 89 + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 8A + 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, // 8B + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, // 8C + 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, // 8D + 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, // 8E + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 8F + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // 90 + 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, // 91 + 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, // 92 + 0x18, 0x18, 0x18, 0x1F, 0x0F, 0x00, 0x00, 0x00, // 93 + 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, // 94 + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 95 + 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x18, 0x18, 0x18, // 96 + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x18, 0x18, 0x18, // 97 + 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x00, 0x00, // 98 + 0x18, 0x18, 0x18, 0xF8, 0xF0, 0x00, 0x00, 0x00, // 99 + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 9A + 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 9B + 0x00, 0x00, 0x00, 0xF0, 0xF8, 0x18, 0x18, 0x18, // 9C + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x18, 0x18, 0x18, // 9D + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18, 0x18, 0x18, // 9E + 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x18, 0x18, 0x18, // 9F + 0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, // A0 + 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // A1 + 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // A2 + 0x3C, 0x66, 0x60, 0xF8, 0x60, 0x66, 0xFE, 0x00, // A3 + 0x38, 0x44, 0xBA, 0xA2, 0xBA, 0x44, 0x38, 0x00, // A4 + 0x7E, 0xF4, 0xF4, 0x74, 0x34, 0x34, 0x34, 0x00, // A5 + 0x1E, 0x30, 0x38, 0x6C, 0x38, 0x18, 0xF0, 0x00, // A6 + 0x18, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, // A7 + 0x40, 0xC0, 0x44, 0x4C, 0x54, 0x1E, 0x04, 0x00, // A8 + 0x40, 0xC0, 0x4C, 0x52, 0x44, 0x08, 0x1E, 0x00, // A9 + 0xE0, 0x10, 0x62, 0x16, 0xEA, 0x0F, 0x02, 0x00, // AA + 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x7E, 0x00, // AB + 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00, // AC + 0x00, 0x00, 0x00, 0x7E, 0x06, 0x06, 0x00, 0x00, // AD + 0x18, 0x00, 0x18, 0x30, 0x66, 0x66, 0x3C, 0x00, // AE + 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // AF + 0x00, 0x00, 0x73, 0xDE, 0xCC, 0xDE, 0x73, 0x00, // B0 + 0x7C, 0xC6, 0xC6, 0xFC, 0xC6, 0xC6, 0xF8, 0xC0, // B1 + 0x00, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, // B2 + 0x3C, 0x60, 0x60, 0x3C, 0x66, 0x66, 0x3C, 0x00, // B3 + 0x00, 0x00, 0x1E, 0x30, 0x7C, 0x30, 0x1E, 0x00, // B4 + 0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0x6C, 0x38, 0x00, // B5 + 0x00, 0xC0, 0x60, 0x30, 0x38, 0x6C, 0xC6, 0x00, // B6 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, // B7 + 0x00, 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x00, // B8 + 0x00, 0x00, 0x00, 0x7E, 0xD8, 0xD8, 0x70, 0x00, // B9 + 0x03, 0x06, 0x0C, 0x3C, 0x66, 0x3C, 0x60, 0xC0, // BA + 0x03, 0x06, 0x0C, 0x66, 0x66, 0x3C, 0x60, 0xC0, // BB + 0x00, 0xE6, 0x3C, 0x18, 0x38, 0x6C, 0xC7, 0x00, // BC + 0x00, 0x00, 0x66, 0xC3, 0xDB, 0xDB, 0x7E, 0x00, // BD + 0xFE, 0xC6, 0x60, 0x30, 0x60, 0xC6, 0xFE, 0x00, // BE + 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x6C, 0xEE, 0x00, // BF + 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, // C0 + 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00, // C1 + 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, // C2 + 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, // C3 + 0x18, 0x3C, 0x66, 0xC3, 0x81, 0x00, 0x00, 0x00, // C4 + 0x18, 0x0C, 0x06, 0x03, 0x03, 0x06, 0x0C, 0x18, // C5 + 0x00, 0x00, 0x00, 0x81, 0xC3, 0x66, 0x3C, 0x18, // C6 + 0x18, 0x30, 0x60, 0xC0, 0xC0, 0x60, 0x30, 0x18, // C7 + 0x18, 0x30, 0x60, 0xC1, 0x83, 0x06, 0x0C, 0x18, // C8 + 0x18, 0x0C, 0x06, 0x83, 0xC1, 0x60, 0x30, 0x18, // C9 + 0x18, 0x3C, 0x66, 0xC3, 0xC3, 0x66, 0x3C, 0x18, // CA + 0xC3, 0xE7, 0x7E, 0x3C, 0x3C, 0x7E, 0xE7, 0xC3, // CB + 0x03, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xC0, // CC + 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0E, 0x07, 0x03, // CD + 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, // CE + 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, // CF + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // D0 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // D1 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, // D2 + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // D3 + 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, // D4 + 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, // D5 + 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, // D6 + 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, // D7 + 0xAA, 0x55, 0xAA, 0x55, 0x00, 0x00, 0x00, 0x00, // D8 + 0x0A, 0x05, 0x0A, 0x05, 0x0A, 0x05, 0x0A, 0x05, // D9 + 0x00, 0x00, 0x00, 0x00, 0xAA, 0x55, 0xAA, 0x55, // DA + 0xA0, 0x50, 0xA0, 0x50, 0xA0, 0x50, 0xA0, 0x50, // DB + 0xAA, 0x54, 0xA8, 0x50, 0xA0, 0x40, 0x80, 0x00, // DC + 0xAA, 0x55, 0x2A, 0x15, 0x0A, 0x05, 0x02, 0x01, // DD + 0x01, 0x02, 0x05, 0x0A, 0x15, 0x2A, 0x55, 0xAA, // DE + 0x00, 0x80, 0x40, 0xA0, 0x50, 0xA8, 0x54, 0xAA, // DF + 0x7E, 0xFF, 0x99, 0xFF, 0xBD, 0xC3, 0xFF, 0x7E, // E0 + 0x7E, 0xFF, 0x99, 0xFF, 0xC3, 0xBD, 0xFF, 0x7E, // E1 + 0x38, 0x38, 0xFE, 0xFE, 0xFE, 0x10, 0x38, 0x00, // E2 + 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00, // E3 + 0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, // E4 + 0x10, 0x38, 0x7C, 0xFE, 0xFE, 0x10, 0x38, 0x00, // E5 + 0x00, 0x3C, 0x66, 0xC3, 0xC3, 0x66, 0x3C, 0x00, // E6 + 0x00, 0x3C, 0x7E, 0xFF, 0xFF, 0x7E, 0x3C, 0x00, // E7 + 0x00, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x7E, 0x00, // E8 + 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, // E9 + 0x0F, 0x07, 0x0D, 0x78, 0xCC, 0xCC, 0xCC, 0x78, // EA + 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, // EB + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x7C, 0x38, // EC + 0x18, 0x1C, 0x1E, 0x1B, 0x18, 0x78, 0xF8, 0x70, // ED + 0x99, 0x5A, 0x24, 0xC3, 0xC3, 0x24, 0x5A, 0x99, // EE + 0x10, 0x38, 0x38, 0x38, 0x38, 0x38, 0x7C, 0xD6, // EF + 0x18, 0x3C, 0x7E, 0xFF, 0x18, 0x18, 0x18, 0x18, // F0 + 0x18, 0x18, 0x18, 0x18, 0xFF, 0x7E, 0x3C, 0x18, // F1 + 0x10, 0x30, 0x70, 0xFF, 0xFF, 0x70, 0x30, 0x10, // F2 + 0x08, 0x0C, 0x0E, 0xFF, 0xFF, 0x0E, 0x0C, 0x08, // F3 + 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, // F4 + 0x00, 0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, // F5 + 0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00, // F6 + 0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, // F7 + 0x38, 0x38, 0x92, 0x7C, 0x10, 0x28, 0x28, 0x28, // F8 + 0x38, 0x38, 0x10, 0xFE, 0x10, 0x28, 0x44, 0x82, // F9 + 0x38, 0x38, 0x12, 0x7C, 0x90, 0x28, 0x24, 0x22, // FA + 0x38, 0x38, 0x90, 0x7C, 0x12, 0x28, 0x48, 0x88, // FB + 0x00, 0x3C, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x00, // FC + 0x3C, 0xFF, 0xFF, 0x18, 0x0C, 0x18, 0x30, 0x18, // FD + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, // FE + 0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, // FF +}; +static const uint8_t _sdtx_font_c64[2048] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 00 + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, // 01 + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, // 02 + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 03 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // 04 + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // 05 + 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, // 06 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // 07 + 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0x33, 0x33, // 08 + 0xCC, 0x99, 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66, // 09 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // 0A + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x18, 0x18, 0x18, // 0B + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, // 0C + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, 0x00, // 0D + 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18, // 0E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, // 0F + 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x18, 0x18, 0x18, // 10 + 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 11 + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18, 0x18, 0x18, // 12 + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x18, 0x18, 0x18, // 13 + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // 14 + 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, // 15 + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, // 16 + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 17 + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, // 18 + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, // 19 + 0x01, 0x03, 0x06, 0x6C, 0x78, 0x70, 0x60, 0x00, // 1A + 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, // 1B + 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, // 1C + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00, // 1D + 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, // 1E + 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, // 1F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 20 + 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00, // 21 + 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, // 22 + 0x66, 0x66, 0xFF, 0x66, 0xFF, 0x66, 0x66, 0x00, // 23 + 0x18, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x18, 0x00, // 24 + 0x62, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x46, 0x00, // 25 + 0x3C, 0x66, 0x3C, 0x38, 0x67, 0x66, 0x3F, 0x00, // 26 + 0x06, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // 27 + 0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, // 28 + 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, // 29 + 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, // 2A + 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, // 2B + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, // 2C + 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, // 2D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, // 2E + 0x00, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, // 2F + 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x3C, 0x00, // 30 + 0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x7E, 0x00, // 31 + 0x3C, 0x66, 0x06, 0x0C, 0x30, 0x60, 0x7E, 0x00, // 32 + 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00, // 33 + 0x06, 0x0E, 0x1E, 0x66, 0x7F, 0x06, 0x06, 0x00, // 34 + 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C, 0x00, // 35 + 0x3C, 0x66, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00, // 36 + 0x7E, 0x66, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x00, // 37 + 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, // 38 + 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C, 0x00, // 39 + 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, // 3A + 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30, // 3B + 0x0E, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0E, 0x00, // 3C + 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, // 3D + 0x70, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x70, 0x00, // 3E + 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x00, 0x18, 0x00, // 3F + 0x3C, 0x66, 0x6E, 0x6E, 0x60, 0x62, 0x3C, 0x00, // 40 + 0x18, 0x3C, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, // 41 + 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00, // 42 + 0x3C, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3C, 0x00, // 43 + 0x78, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0x78, 0x00, // 44 + 0x7E, 0x60, 0x60, 0x78, 0x60, 0x60, 0x7E, 0x00, // 45 + 0x7E, 0x60, 0x60, 0x78, 0x60, 0x60, 0x60, 0x00, // 46 + 0x3C, 0x66, 0x60, 0x6E, 0x66, 0x66, 0x3C, 0x00, // 47 + 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, // 48 + 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, // 49 + 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x6C, 0x38, 0x00, // 4A + 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, 0x00, // 4B + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E, 0x00, // 4C + 0x63, 0x77, 0x7F, 0x6B, 0x63, 0x63, 0x63, 0x00, // 4D + 0x66, 0x76, 0x7E, 0x7E, 0x6E, 0x66, 0x66, 0x00, // 4E + 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 4F + 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00, // 50 + 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x0E, 0x00, // 51 + 0x7C, 0x66, 0x66, 0x7C, 0x78, 0x6C, 0x66, 0x00, // 52 + 0x3C, 0x66, 0x60, 0x3C, 0x06, 0x66, 0x3C, 0x00, // 53 + 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // 54 + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 55 + 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00, // 56 + 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00, // 57 + 0x66, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x00, // 58 + 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x00, // 59 + 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00, // 5A + 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, // 5B + 0x0C, 0x12, 0x30, 0x7C, 0x30, 0x62, 0xFC, 0x00, // 5C + 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, // 5D + 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, // 5E + 0x00, 0x10, 0x30, 0x7F, 0x7F, 0x30, 0x10, 0x00, // 5F + 0x3C, 0x66, 0x6E, 0x6E, 0x60, 0x62, 0x3C, 0x00, // 60 + 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // 61 + 0x00, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00, // 62 + 0x00, 0x00, 0x3C, 0x60, 0x60, 0x60, 0x3C, 0x00, // 63 + 0x00, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x00, // 64 + 0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // 65 + 0x00, 0x0E, 0x18, 0x3E, 0x18, 0x18, 0x18, 0x00, // 66 + 0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x7C, // 67 + 0x00, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x00, // 68 + 0x00, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3C, 0x00, // 69 + 0x00, 0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x3C, // 6A + 0x00, 0x60, 0x60, 0x6C, 0x78, 0x6C, 0x66, 0x00, // 6B + 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, // 6C + 0x00, 0x00, 0x66, 0x7F, 0x7F, 0x6B, 0x63, 0x00, // 6D + 0x00, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x00, // 6E + 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // 6F + 0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, // 70 + 0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x06, // 71 + 0x00, 0x00, 0x7C, 0x66, 0x60, 0x60, 0x60, 0x00, // 72 + 0x00, 0x00, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x00, // 73 + 0x00, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x0E, 0x00, // 74 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, // 75 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00, // 76 + 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x3E, 0x36, 0x00, // 77 + 0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x00, // 78 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x0C, 0x78, // 79 + 0x00, 0x00, 0x7E, 0x0C, 0x18, 0x30, 0x7E, 0x00, // 7A + 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, // 7B + 0x0C, 0x12, 0x30, 0x7C, 0x30, 0x62, 0xFC, 0x00, // 7C + 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, // 7D + 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, // 7E + 0x00, 0x10, 0x30, 0x7F, 0x7F, 0x30, 0x10, 0x00, // 7F + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 80 + 0x08, 0x1C, 0x3E, 0x7F, 0x7F, 0x1C, 0x3E, 0x00, // 81 + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 82 + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 83 + 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // 84 + 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, // 85 + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, // 86 + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, // 87 + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, // 88 + 0x00, 0x00, 0x00, 0xE0, 0xF0, 0x38, 0x18, 0x18, // 89 + 0x18, 0x18, 0x1C, 0x0F, 0x07, 0x00, 0x00, 0x00, // 8A + 0x18, 0x18, 0x38, 0xF0, 0xE0, 0x00, 0x00, 0x00, // 8B + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xFF, 0xFF, // 8C + 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0E, 0x07, 0x03, // 8D + 0x03, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xC0, // 8E + 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // 8F + 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // 90 + 0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x7E, 0x3C, 0x00, // 91 + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, // 92 + 0x36, 0x7F, 0x7F, 0x7F, 0x3E, 0x1C, 0x08, 0x00, // 93 + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, // 94 + 0x00, 0x00, 0x00, 0x07, 0x0F, 0x1C, 0x18, 0x18, // 95 + 0xC3, 0xE7, 0x7E, 0x3C, 0x3C, 0x7E, 0xE7, 0xC3, // 96 + 0x00, 0x3C, 0x7E, 0x66, 0x66, 0x7E, 0x3C, 0x00, // 97 + 0x18, 0x18, 0x66, 0x66, 0x18, 0x18, 0x3C, 0x00, // 98 + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, // 99 + 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08, 0x00, // 9A + 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x18, 0x18, 0x18, // 9B + 0xC0, 0xC0, 0x30, 0x30, 0xC0, 0xC0, 0x30, 0x30, // 9C + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 9D + 0x00, 0x00, 0x03, 0x3E, 0x76, 0x36, 0x36, 0x00, // 9E + 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, // 9F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // A0 + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, // A1 + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, // A2 + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // A3 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // A4 + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // A5 + 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, // A6 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // A7 + 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0x33, 0x33, // A8 + 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, // A9 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // AA + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x18, 0x18, 0x18, // AB + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, // AC + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, 0x00, // AD + 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18, // AE + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, // AF + 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x18, 0x18, 0x18, // B0 + 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x00, 0x00, 0x00, // B1 + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18, 0x18, 0x18, // B2 + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x18, 0x18, 0x18, // B3 + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // B4 + 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, // B5 + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, // B6 + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // B7 + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, // B8 + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, // B9 + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, // BA + 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, // BB + 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, // BC + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00, // BD + 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, // BE + 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, // BF + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, // C0 + 0xF7, 0xE3, 0xC1, 0x80, 0x80, 0xE3, 0xC1, 0xFF, // C1 + 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, // C2 + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, // C3 + 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, // C4 + 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // C5 + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, // C6 + 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, // C7 + 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, // C8 + 0xFF, 0xFF, 0xFF, 0x1F, 0x0F, 0xC7, 0xE7, 0xE7, // C9 + 0xE7, 0xE7, 0xE3, 0xF0, 0xF8, 0xFF, 0xFF, 0xFF, // CA + 0xE7, 0xE7, 0xC7, 0x0F, 0x1F, 0xFF, 0xFF, 0xFF, // CB + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, // CC + 0x3F, 0x1F, 0x8F, 0xC7, 0xE3, 0xF1, 0xF8, 0xFC, // CD + 0xFC, 0xF8, 0xF1, 0xE3, 0xC7, 0x8F, 0x1F, 0x3F, // CE + 0x00, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, // CF + 0x00, 0x00, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, // D0 + 0xFF, 0xC3, 0x81, 0x81, 0x81, 0x81, 0xC3, 0xFF, // D1 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, // D2 + 0xC9, 0x80, 0x80, 0x80, 0xC1, 0xE3, 0xF7, 0xFF, // D3 + 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, // D4 + 0xFF, 0xFF, 0xFF, 0xF8, 0xF0, 0xE3, 0xE7, 0xE7, // D5 + 0x3C, 0x18, 0x81, 0xC3, 0xC3, 0x81, 0x18, 0x3C, // D6 + 0xFF, 0xC3, 0x81, 0x99, 0x99, 0x81, 0xC3, 0xFF, // D7 + 0xE7, 0xE7, 0x99, 0x99, 0xE7, 0xE7, 0xC3, 0xFF, // D8 + 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, // D9 + 0xF7, 0xE3, 0xC1, 0x80, 0xC1, 0xE3, 0xF7, 0xFF, // DA + 0xE7, 0xE7, 0xE7, 0x00, 0x00, 0xE7, 0xE7, 0xE7, // DB + 0x3F, 0x3F, 0xCF, 0xCF, 0x3F, 0x3F, 0xCF, 0xCF, // DC + 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, // DD + 0xFF, 0xFF, 0xFC, 0xC1, 0x89, 0xC9, 0xC9, 0xFF, // DE + 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, // DF + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // E0 + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // E1 + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // E2 + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // E3 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, // E4 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, // E5 + 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, // E6 + 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, // E7 + 0xFF, 0xFF, 0xFF, 0xFF, 0x33, 0x33, 0xCC, 0xCC, // E8 + 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, // E9 + 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, // EA + 0xE7, 0xE7, 0xE7, 0xE0, 0xE0, 0xE7, 0xE7, 0xE7, // EB + 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, // EC + 0xE7, 0xE7, 0xE7, 0xE0, 0xE0, 0xFF, 0xFF, 0xFF, // ED + 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0xE7, 0xE7, 0xE7, // EE + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, // EF + 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xE7, 0xE7, 0xE7, // F0 + 0xE7, 0xE7, 0xE7, 0x00, 0x00, 0xFF, 0xFF, 0xFF, // F1 + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xE7, 0xE7, 0xE7, // F2 + 0xE7, 0xE7, 0xE7, 0x07, 0x07, 0xE7, 0xE7, 0xE7, // F3 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, // F4 + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, // F5 + 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, // F6 + 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // F7 + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // F8 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, // F9 + 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0x00, 0x00, // FA + 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, // FB + 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, // FC + 0xE7, 0xE7, 0xE7, 0x07, 0x07, 0xFF, 0xFF, 0xFF, // FD + 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, // FE + 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, // FF +}; +static const uint8_t _sdtx_font_oric[2048] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 00 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 01 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 02 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 03 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 04 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 05 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 06 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 07 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 08 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 09 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0A + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0B + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0C + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 10 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 11 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 12 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 13 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 14 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 15 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 16 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 17 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 18 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 19 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1A + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1B + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1C + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 20 + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x00, // 21 + 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, // 22 + 0x14, 0x14, 0x3E, 0x14, 0x3E, 0x14, 0x14, 0x00, // 23 + 0x08, 0x1E, 0x28, 0x1C, 0x0A, 0x3C, 0x08, 0x00, // 24 + 0x30, 0x32, 0x04, 0x08, 0x10, 0x26, 0x06, 0x00, // 25 + 0x10, 0x28, 0x28, 0x10, 0x2A, 0x24, 0x1A, 0x00, // 26 + 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // 27 + 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, // 28 + 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08, 0x00, // 29 + 0x08, 0x2A, 0x1C, 0x08, 0x1C, 0x2A, 0x08, 0x00, // 2A + 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, // 2B + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, // 2C + 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, // 2D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // 2E + 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, // 2F + 0x1C, 0x22, 0x26, 0x2A, 0x32, 0x22, 0x1C, 0x00, // 30 + 0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, // 31 + 0x1C, 0x22, 0x02, 0x04, 0x08, 0x10, 0x3E, 0x00, // 32 + 0x3E, 0x02, 0x04, 0x0C, 0x02, 0x22, 0x1C, 0x00, // 33 + 0x04, 0x0C, 0x14, 0x24, 0x3E, 0x04, 0x04, 0x00, // 34 + 0x3E, 0x20, 0x3C, 0x02, 0x02, 0x22, 0x1C, 0x00, // 35 + 0x0C, 0x10, 0x20, 0x3C, 0x22, 0x22, 0x1C, 0x00, // 36 + 0x3E, 0x02, 0x04, 0x08, 0x10, 0x10, 0x10, 0x00, // 37 + 0x1C, 0x22, 0x22, 0x1C, 0x22, 0x22, 0x1C, 0x00, // 38 + 0x1C, 0x22, 0x22, 0x1E, 0x02, 0x04, 0x18, 0x00, // 39 + 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, // 3A + 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x08, 0x10, // 3B + 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, // 3C + 0x00, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x00, 0x00, // 3D + 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, // 3E + 0x1C, 0x22, 0x04, 0x08, 0x08, 0x00, 0x08, 0x00, // 3F + 0x1C, 0x22, 0x2A, 0x2E, 0x2C, 0x20, 0x1E, 0x00, // 40 + 0x08, 0x14, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x00, // 41 + 0x3C, 0x22, 0x22, 0x3C, 0x22, 0x22, 0x3C, 0x00, // 42 + 0x1C, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1C, 0x00, // 43 + 0x3C, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3C, 0x00, // 44 + 0x3E, 0x20, 0x20, 0x3C, 0x20, 0x20, 0x3E, 0x00, // 45 + 0x3E, 0x20, 0x20, 0x3C, 0x20, 0x20, 0x20, 0x00, // 46 + 0x1E, 0x20, 0x20, 0x20, 0x26, 0x22, 0x1E, 0x00, // 47 + 0x22, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x22, 0x00, // 48 + 0x1C, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, // 49 + 0x02, 0x02, 0x02, 0x02, 0x02, 0x22, 0x1C, 0x00, // 4A + 0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22, 0x00, // 4B + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3E, 0x00, // 4C + 0x22, 0x36, 0x2A, 0x2A, 0x22, 0x22, 0x22, 0x00, // 4D + 0x22, 0x22, 0x32, 0x2A, 0x26, 0x22, 0x22, 0x00, // 4E + 0x1C, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1C, 0x00, // 4F + 0x3C, 0x22, 0x22, 0x3C, 0x20, 0x20, 0x20, 0x00, // 50 + 0x1C, 0x22, 0x22, 0x22, 0x2A, 0x24, 0x1A, 0x00, // 51 + 0x3C, 0x22, 0x22, 0x3C, 0x28, 0x24, 0x22, 0x00, // 52 + 0x1C, 0x22, 0x20, 0x1C, 0x02, 0x22, 0x1C, 0x00, // 53 + 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, // 54 + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1C, 0x00, // 55 + 0x22, 0x22, 0x22, 0x22, 0x22, 0x14, 0x08, 0x00, // 56 + 0x22, 0x22, 0x22, 0x2A, 0x2A, 0x36, 0x22, 0x00, // 57 + 0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22, 0x00, // 58 + 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x00, // 59 + 0x3E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x3E, 0x00, // 5A + 0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00, // 5B + 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00, // 5C + 0x3C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x3C, 0x00, // 5D + 0x08, 0x14, 0x2A, 0x08, 0x08, 0x08, 0x08, 0x00, // 5E + 0x0E, 0x11, 0x3C, 0x10, 0x3C, 0x11, 0x0E, 0x00, // 5F + 0x0C, 0x12, 0x2D, 0x29, 0x29, 0x2D, 0x12, 0x0C, // 60 + 0x00, 0x00, 0x1C, 0x02, 0x1E, 0x22, 0x1E, 0x00, // 61 + 0x20, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x3C, 0x00, // 62 + 0x00, 0x00, 0x1E, 0x20, 0x20, 0x20, 0x1E, 0x00, // 63 + 0x02, 0x02, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x00, // 64 + 0x00, 0x00, 0x1C, 0x22, 0x3E, 0x20, 0x1E, 0x00, // 65 + 0x0C, 0x12, 0x10, 0x3C, 0x10, 0x10, 0x10, 0x00, // 66 + 0x00, 0x00, 0x1C, 0x22, 0x22, 0x1E, 0x02, 0x1C, // 67 + 0x20, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x22, 0x00, // 68 + 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x1C, 0x00, // 69 + 0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x24, 0x18, // 6A + 0x20, 0x20, 0x22, 0x24, 0x38, 0x24, 0x22, 0x00, // 6B + 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, // 6C + 0x00, 0x00, 0x36, 0x2A, 0x2A, 0x2A, 0x22, 0x00, // 6D + 0x00, 0x00, 0x3C, 0x22, 0x22, 0x22, 0x22, 0x00, // 6E + 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00, // 6F + 0x00, 0x00, 0x3C, 0x22, 0x22, 0x3C, 0x20, 0x20, // 70 + 0x00, 0x00, 0x1E, 0x22, 0x22, 0x1E, 0x02, 0x02, // 71 + 0x00, 0x00, 0x2E, 0x30, 0x20, 0x20, 0x20, 0x00, // 72 + 0x00, 0x00, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x00, // 73 + 0x10, 0x10, 0x3C, 0x10, 0x10, 0x12, 0x0C, 0x00, // 74 + 0x00, 0x00, 0x22, 0x22, 0x22, 0x26, 0x1A, 0x00, // 75 + 0x00, 0x00, 0x22, 0x22, 0x22, 0x14, 0x08, 0x00, // 76 + 0x00, 0x00, 0x22, 0x22, 0x2A, 0x2A, 0x36, 0x00, // 77 + 0x00, 0x00, 0x22, 0x14, 0x08, 0x14, 0x22, 0x00, // 78 + 0x00, 0x00, 0x22, 0x22, 0x22, 0x1E, 0x02, 0x1C, // 79 + 0x00, 0x00, 0x3E, 0x04, 0x08, 0x10, 0x3E, 0x00, // 7A + 0x0E, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0E, 0x00, // 7B + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, // 7C + 0x38, 0x0C, 0x0C, 0x06, 0x0C, 0x0C, 0x38, 0x00, // 7D + 0x2A, 0x15, 0x2A, 0x15, 0x2A, 0x15, 0x2A, 0x15, // 7E + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, // 7F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 81 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 82 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 83 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 84 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 85 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 86 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 87 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 88 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8A + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8B + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8C + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8F + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 91 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 92 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 93 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 94 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 95 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 96 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 97 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 98 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 99 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9A + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9B + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9C + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9E + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9F + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // A0 + 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xFF, 0xF7, 0xFF, // A1 + 0xEB, 0xEB, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // A2 + 0xEB, 0xEB, 0xC1, 0xEB, 0xC1, 0xEB, 0xEB, 0xFF, // A3 + 0xF7, 0xE1, 0xD7, 0xE3, 0xF5, 0xC3, 0xF7, 0xFF, // A4 + 0xCF, 0xCD, 0xFB, 0xF7, 0xEF, 0xD9, 0xF9, 0xFF, // A5 + 0xEF, 0xD7, 0xD7, 0xEF, 0xD5, 0xDB, 0xE5, 0xFF, // A6 + 0xF7, 0xF7, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // A7 + 0xF7, 0xEF, 0xDF, 0xDF, 0xDF, 0xEF, 0xF7, 0xFF, // A8 + 0xF7, 0xFB, 0xFD, 0xFD, 0xFD, 0xFB, 0xF7, 0xFF, // A9 + 0xF7, 0xD5, 0xE3, 0xF7, 0xE3, 0xD5, 0xF7, 0xFF, // AA + 0xFF, 0xF7, 0xF7, 0xC1, 0xF7, 0xF7, 0xFF, 0xFF, // AB + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xF7, 0xEF, // AC + 0xFF, 0xFF, 0xFF, 0xC1, 0xFF, 0xFF, 0xFF, 0xFF, // AD + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, // AE + 0xFF, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xFF, 0xFF, // AF + 0xE3, 0xDD, 0xD9, 0xD5, 0xCD, 0xDD, 0xE3, 0xFF, // B0 + 0xF7, 0xE7, 0xF7, 0xF7, 0xF7, 0xF7, 0xE3, 0xFF, // B1 + 0xE3, 0xDD, 0xFD, 0xFB, 0xF7, 0xEF, 0xC1, 0xFF, // B2 + 0xC1, 0xFD, 0xFB, 0xF3, 0xFD, 0xDD, 0xE3, 0xFF, // B3 + 0xFB, 0xF3, 0xEB, 0xDB, 0xC1, 0xFB, 0xFB, 0xFF, // B4 + 0xC1, 0xDF, 0xC3, 0xFD, 0xFD, 0xDD, 0xE3, 0xFF, // B5 + 0xF3, 0xEF, 0xDF, 0xC3, 0xDD, 0xDD, 0xE3, 0xFF, // B6 + 0xC1, 0xFD, 0xFB, 0xF7, 0xEF, 0xEF, 0xEF, 0xFF, // B7 + 0xE3, 0xDD, 0xDD, 0xE3, 0xDD, 0xDD, 0xE3, 0xFF, // B8 + 0xE3, 0xDD, 0xDD, 0xE1, 0xFD, 0xFB, 0xE7, 0xFF, // B9 + 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, // BA + 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xF7, 0xF7, 0xEF, // BB + 0xFB, 0xF7, 0xEF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFF, // BC + 0xFF, 0xFF, 0xC1, 0xFF, 0xC1, 0xFF, 0xFF, 0xFF, // BD + 0xEF, 0xF7, 0xFB, 0xFD, 0xFB, 0xF7, 0xEF, 0xFF, // BE + 0xE3, 0xDD, 0xFB, 0xF7, 0xF7, 0xFF, 0xF7, 0xFF, // BF + 0xE3, 0xDD, 0xD5, 0xD1, 0xD3, 0xDF, 0xE1, 0xFF, // C0 + 0xF7, 0xEB, 0xDD, 0xDD, 0xC1, 0xDD, 0xDD, 0xFF, // C1 + 0xC3, 0xDD, 0xDD, 0xC3, 0xDD, 0xDD, 0xC3, 0xFF, // C2 + 0xE3, 0xDD, 0xDF, 0xDF, 0xDF, 0xDD, 0xE3, 0xFF, // C3 + 0xC3, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xC3, 0xFF, // C4 + 0xC1, 0xDF, 0xDF, 0xC3, 0xDF, 0xDF, 0xC1, 0xFF, // C5 + 0xC1, 0xDF, 0xDF, 0xC3, 0xDF, 0xDF, 0xDF, 0xFF, // C6 + 0xE1, 0xDF, 0xDF, 0xDF, 0xD9, 0xDD, 0xE1, 0xFF, // C7 + 0xDD, 0xDD, 0xDD, 0xC1, 0xDD, 0xDD, 0xDD, 0xFF, // C8 + 0xE3, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xE3, 0xFF, // C9 + 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xDD, 0xE3, 0xFF, // CA + 0xDD, 0xDB, 0xD7, 0xCF, 0xD7, 0xDB, 0xDD, 0xFF, // CB + 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xC1, 0xFF, // CC + 0xDD, 0xC9, 0xD5, 0xD5, 0xDD, 0xDD, 0xDD, 0xFF, // CD + 0xDD, 0xDD, 0xCD, 0xD5, 0xD9, 0xDD, 0xDD, 0xFF, // CE + 0xE3, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xE3, 0xFF, // CF + 0xC3, 0xDD, 0xDD, 0xC3, 0xDF, 0xDF, 0xDF, 0xFF, // D0 + 0xE3, 0xDD, 0xDD, 0xDD, 0xD5, 0xDB, 0xE5, 0xFF, // D1 + 0xC3, 0xDD, 0xDD, 0xC3, 0xD7, 0xDB, 0xDD, 0xFF, // D2 + 0xE3, 0xDD, 0xDF, 0xE3, 0xFD, 0xDD, 0xE3, 0xFF, // D3 + 0xC1, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xFF, // D4 + 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xE3, 0xFF, // D5 + 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xEB, 0xF7, 0xFF, // D6 + 0xDD, 0xDD, 0xDD, 0xD5, 0xD5, 0xC9, 0xDD, 0xFF, // D7 + 0xDD, 0xDD, 0xEB, 0xF7, 0xEB, 0xDD, 0xDD, 0xFF, // D8 + 0xDD, 0xDD, 0xEB, 0xF7, 0xF7, 0xF7, 0xF7, 0xFF, // D9 + 0xC1, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xC1, 0xFF, // DA + 0xE1, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xE1, 0xFF, // DB + 0xFF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFF, 0xFF, // DC + 0xC3, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xC3, 0xFF, // DD + 0xF7, 0xEB, 0xD5, 0xF7, 0xF7, 0xF7, 0xF7, 0xFF, // DE + 0xF1, 0xEE, 0xC3, 0xEF, 0xC3, 0xEE, 0xF1, 0xFF, // DF + 0xF3, 0xED, 0xD2, 0xD6, 0xD6, 0xD2, 0xED, 0xF3, // E0 + 0xFF, 0xFF, 0xE3, 0xFD, 0xE1, 0xDD, 0xE1, 0xFF, // E1 + 0xDF, 0xDF, 0xC3, 0xDD, 0xDD, 0xDD, 0xC3, 0xFF, // E2 + 0xFF, 0xFF, 0xE1, 0xDF, 0xDF, 0xDF, 0xE1, 0xFF, // E3 + 0xFD, 0xFD, 0xE1, 0xDD, 0xDD, 0xDD, 0xE1, 0xFF, // E4 + 0xFF, 0xFF, 0xE3, 0xDD, 0xC1, 0xDF, 0xE1, 0xFF, // E5 + 0xF3, 0xED, 0xEF, 0xC3, 0xEF, 0xEF, 0xEF, 0xFF, // E6 + 0xFF, 0xFF, 0xE3, 0xDD, 0xDD, 0xE1, 0xFD, 0xE3, // E7 + 0xDF, 0xDF, 0xC3, 0xDD, 0xDD, 0xDD, 0xDD, 0xFF, // E8 + 0xF7, 0xFF, 0xE7, 0xF7, 0xF7, 0xF7, 0xE3, 0xFF, // E9 + 0xFB, 0xFF, 0xF3, 0xFB, 0xFB, 0xFB, 0xDB, 0xE7, // EA + 0xDF, 0xDF, 0xDD, 0xDB, 0xC7, 0xDB, 0xDD, 0xFF, // EB + 0xE7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xE3, 0xFF, // EC + 0xFF, 0xFF, 0xC9, 0xD5, 0xD5, 0xD5, 0xDD, 0xFF, // ED + 0xFF, 0xFF, 0xC3, 0xDD, 0xDD, 0xDD, 0xDD, 0xFF, // EE + 0xFF, 0xFF, 0xE3, 0xDD, 0xDD, 0xDD, 0xE3, 0xFF, // EF + 0xFF, 0xFF, 0xC3, 0xDD, 0xDD, 0xC3, 0xDF, 0xDF, // F0 + 0xFF, 0xFF, 0xE1, 0xDD, 0xDD, 0xE1, 0xFD, 0xFD, // F1 + 0xFF, 0xFF, 0xD1, 0xCF, 0xDF, 0xDF, 0xDF, 0xFF, // F2 + 0xFF, 0xFF, 0xE1, 0xDF, 0xE3, 0xFD, 0xC3, 0xFF, // F3 + 0xEF, 0xEF, 0xC3, 0xEF, 0xEF, 0xED, 0xF3, 0xFF, // F4 + 0xFF, 0xFF, 0xDD, 0xDD, 0xDD, 0xD9, 0xE5, 0xFF, // F5 + 0xFF, 0xFF, 0xDD, 0xDD, 0xDD, 0xEB, 0xF7, 0xFF, // F6 + 0xFF, 0xFF, 0xDD, 0xDD, 0xD5, 0xD5, 0xC9, 0xFF, // F7 + 0xFF, 0xFF, 0xDD, 0xEB, 0xF7, 0xEB, 0xDD, 0xFF, // F8 + 0xFF, 0xFF, 0xDD, 0xDD, 0xDD, 0xE1, 0xFD, 0xE3, // F9 + 0xFF, 0xFF, 0xC1, 0xFB, 0xF7, 0xEF, 0xC1, 0xFF, // FA + 0xF1, 0xE7, 0xE7, 0xCF, 0xE7, 0xE7, 0xF1, 0xFF, // FB + 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, // FC + 0xC7, 0xF3, 0xF3, 0xF9, 0xF3, 0xF3, 0xC7, 0xFF, // FD + 0xD5, 0xEA, 0xD5, 0xEA, 0xD5, 0xEA, 0xD5, 0xEA, // FE + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, // FF +}; + +/* + Embedded source code compiled with: + + sokol-shdc -i debugtext.glsl -o debugtext.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + + (not that for Metal and D3D11 byte code, sokol-shdc must be run + on macOS and Windows) + + @vs vs + in vec2 position; + in vec2 texcoord0; + in vec4 color0; + out vec2 uv; + out vec4 color; + void main() { + gl_Position = vec4(position * vec2(2.0, -2.0) + vec2(-1.0, +1.0), 0.0, 1.0); + uv = texcoord0; + color = color0; + } + @end + + @fs fs + uniform sampler2D tex; + in vec2 uv; + in vec4 color; + out vec4 frag_color; + void main() { + frag_color = texture(tex, uv).xxxx * color; + } + @end + + @program debugtext vs fs +*/ +#if defined(SOKOL_GLCORE33) +static const char _sdtx_vs_src_glsl330[300] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x6c,0x61, + 0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76, + 0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f, + 0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74, + 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65, + 0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74, + 0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69, + 0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a, + 0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x34,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2a, + 0x20,0x76,0x65,0x63,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29, + 0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x2d,0x31,0x2e,0x30,0x2c,0x20,0x31, + 0x2e,0x30,0x29,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72, + 0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; + +static const char _sdtx_fs_src_glsl330[174] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20, + 0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63, + 0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76, + 0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69,0x6e,0x20,0x76, + 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, + 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75, + 0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x2e,0x78,0x78,0x78,0x78, + 0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_GLES3) +static const char _sdtx_vs_src_glsl300es[303] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f, + 0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32, + 0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74, + 0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30, + 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32, + 0x2e,0x30,0x29,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x2d,0x31,0x2e,0x30, + 0x2c,0x20,0x31,0x2e,0x30,0x29,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30, + 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63, + 0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _sdtx_fs_src_glsl300es[247] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x29,0x2e,0x78,0x78,0x78,0x78,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_METAL) +static const uint8_t _sdtx_vs_bytecode_metal_macos[2896] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x50,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0xdd,0xe8,0xa4,0x37,0x8a,0xdc,0xe6, + 0x75,0xeb,0x1f,0xc8,0x20,0x45,0xac,0xb2,0xcb,0x1e,0xd3,0x65,0x26,0x17,0x6c,0x41, + 0xce,0xd8,0x5c,0x1b,0x0b,0xf5,0x82,0x6a,0x2a,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x37,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x22,0x00,0x03,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x56,0x41,0x54,0x59,0x05,0x00,0x03, + 0x00,0x04,0x04,0x06,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54, + 0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x2c,0x0a,0x00,0x00, + 0xff,0xff,0xff,0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x88,0x02,0x00,0x00, + 0x0b,0x82,0x20,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91, + 0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19, + 0x1e,0x04,0x8b,0x62,0x80,0x10,0x45,0x02,0x42,0x92,0x0b,0x42,0x84,0x10,0x32,0x14, + 0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80, + 0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x08,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0, + 0x01,0x00,0x00,0x00,0x51,0x18,0x00,0x00,0x80,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8, + 0xff,0xff,0xff,0xff,0x01,0x90,0x00,0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87, + 0x71,0xa0,0x07,0x76,0xc8,0x87,0x36,0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72, + 0x20,0x87,0x36,0x20,0x87,0x74,0xb0,0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88, + 0x07,0x79,0xa0,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41, + 0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e,0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c, + 0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87, + 0x72,0x98,0x87,0x79,0x68,0x03,0x78,0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72, + 0x68,0x03,0x73,0x80,0x87,0x76,0x08,0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e, + 0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda, + 0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81,0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21, + 0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30, + 0x07,0x79,0x08,0x87,0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87, + 0x72,0x90,0x87,0x36,0x28,0x07,0x76,0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77, + 0x68,0x03,0x76,0x28,0x87,0x70,0x30,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70, + 0x07,0x73,0x98,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1, + 0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08, + 0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87, + 0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41, + 0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d, + 0xca,0x81,0x1c,0xda,0x40,0x1f,0xca,0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0, + 0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80, + 0x70,0x87,0x77,0x68,0x03,0x7a,0x90,0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38, + 0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00, + 0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61,0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1, + 0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e,0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4,0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87, + 0x79,0x08,0x07,0x73,0x28,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a, + 0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d, + 0xe6,0xe1,0x1d,0xcc,0x81,0x1e,0xda,0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00, + 0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x00,0x00,0x00,0x00,0x49,0x18,0x00,0x00, + 0x01,0x00,0x00,0x00,0x13,0x82,0x00,0x00,0x89,0x20,0x00,0x00,0x14,0x00,0x00,0x00, + 0x32,0x22,0x08,0x09,0x20,0x64,0x85,0x04,0x13,0x22,0xa4,0x84,0x04,0x13,0x22,0xe3, + 0x84,0xa1,0x90,0x14,0x12,0x4c,0x88,0x8c,0x0b,0x84,0x84,0x4c,0x10,0x2c,0x33,0x00, + 0xc3,0x08,0x02,0x30,0x8c,0x40,0x00,0x77,0x49,0x53,0x44,0x09,0x93,0xcf,0x00,0x48, + 0x43,0xff,0x0e,0x35,0xf9,0x0f,0x20,0x28,0xc4,0x80,0x87,0x10,0x29,0xc4,0x44,0x08, + 0xd1,0x40,0xc0,0x1c,0x01,0x18,0xa4,0xc0,0x0d,0x23,0x10,0xc7,0x08,0x00,0x00,0x00, + 0x13,0xb2,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60, + 0x87,0x72,0x68,0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03, + 0x37,0x88,0x83,0x38,0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71, + 0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80, + 0x07,0x6d,0x90,0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07, + 0x6d,0x90,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d, + 0x90,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60, + 0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71, + 0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40, + 0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07, + 0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a, + 0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60, + 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07, + 0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78, + 0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10, + 0x07,0x79,0x20,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07, + 0x6d,0x60,0x0f,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72, + 0x50,0x07,0x76,0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20, + 0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07, + 0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d, + 0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x29,0x00, + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xc8,0x02,0x01,0x00,0x00,0x08,0x00,0x00,0x00, + 0x32,0x1e,0x98,0x0c,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0xba, + 0x12,0x18,0x01,0x28,0x82,0x42,0x28,0x08,0xc2,0xb1,0x04,0xe5,0x01,0x00,0x00,0x00, + 0x79,0x18,0x00,0x00,0xdd,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25, + 0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x31,0x18,0x00,0x62,0x50,0xb9, + 0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x1c,0x81,0x21,0x1c,0x04, + 0xd9,0x20,0x08,0x0e,0x8e,0xad,0x0c,0x84,0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e, + 0x2e,0xed,0xcd,0x0d,0x24,0x07,0x46,0xc6,0x25,0x26,0x06,0x04,0xa5,0xad,0x8c,0x2e, + 0x8c,0xcd,0xac,0xac,0x25,0x07,0x46,0xc6,0x25,0x26,0xc6,0x25,0x26,0x65,0x88,0x60, + 0x10,0x43,0x8c,0x23,0x38,0x8a,0x43,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x31, + 0x8e,0x23,0x38,0x82,0x43,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6, + 0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6, + 0x56,0x36,0x44,0x30,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c, + 0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62, + 0x6c,0x65,0x43,0x04,0x63,0x61,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5, + 0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99, + 0x95,0xd1,0x8d,0xa1,0x7d,0x91,0xa5,0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11,0x8c,0x86, + 0x61,0x10,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46, + 0x97,0x66,0x57,0xf6,0x45,0xf6,0x56,0x27,0xc6,0x56,0xf6,0x45,0x96,0x36,0x17,0x26, + 0xc6,0x56,0x36,0x44,0x30,0x1e,0x92,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c, + 0x1a,0x5b,0x99,0x8b,0x5b,0x18,0x5d,0x9a,0x5d,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17, + 0xdb,0x9b,0xdb,0xd9,0x17,0x59,0xda,0x5c,0x98,0x18,0x5b,0xd9,0x10,0xc1,0x88,0x78, + 0x06,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74, + 0x69,0x76,0x65,0x5f,0x77,0x69,0x64,0x65,0x5f,0x76,0x65,0x63,0x74,0x6f,0x72,0x73, + 0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43,0x04,0x63,0x62,0x14,0x96,0x26,0xe7, + 0x62,0x57,0x26,0x47,0x57,0x86,0xf7,0xf5,0x56,0x47,0x07,0x57,0x47,0xc7,0xa5,0x6e, + 0xae,0x4c,0x0e,0x85,0xed,0x6d,0xcc,0x0d,0x26,0x85,0x51,0x58,0x9a,0x9c,0x4b,0x98, + 0xdc,0xd9,0x17,0x5d,0x1e,0x5c,0xd9,0x97,0x5b,0x58,0x5b,0x19,0x0d,0x33,0xb6,0xb7, + 0x30,0x3a,0x19,0x32,0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x6e,0x61,0x6d,0x65, + 0x14,0xea,0xec,0x86,0x30,0x46,0x65,0x58,0xc6,0x65,0x60,0x46,0x66,0x68,0x5c,0xea, + 0xe6,0xca,0xe4,0x50,0xd8,0xde,0xc6,0xdc,0x62,0x52,0x68,0x98,0xb1,0xbd,0x85,0xd1, + 0xd1,0xb0,0x18,0x7b,0x63,0x7b,0x93,0x1b,0xc2,0x18,0x95,0xc1,0x19,0x97,0xd1,0x19, + 0x99,0xe1,0x91,0x09,0x4b,0x93,0x73,0x81,0x7b,0x9b,0x4b,0xa3,0x4b,0x7b,0x73,0xe3, + 0x72,0xc6,0xf6,0x05,0xf5,0x36,0x97,0x46,0x97,0xf6,0xe6,0x36,0x44,0x31,0xc0,0xc0, + 0xb8,0x8c,0xce,0xc8,0x8c,0x30,0x18,0x62,0x18,0x9b,0xf1,0x19,0x62,0x40,0x28,0x2c, + 0x4d,0xce,0xc5,0xae,0x4c,0x8e,0xae,0x0c,0xef,0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x52, + 0x58,0x9a,0x9c,0x0b,0xdb,0xdb,0x58,0x18,0x5d,0xda,0x9b,0xdb,0x57,0x9a,0x1b,0x59, + 0x19,0x1e,0xb3,0xb3,0x32,0xb7,0x32,0xb9,0x30,0xba,0x32,0x32,0x14,0x1c,0xb8,0xb7, + 0xb9,0x34,0xba,0xb4,0x37,0x37,0x22,0x3b,0x99,0x2f,0xb3,0x14,0x22,0x70,0x6f,0x73, + 0x69,0x74,0x69,0x6f,0x6e,0x43,0xa8,0x43,0x30,0xc8,0xc0,0x28,0x83,0x43,0x38,0x02, + 0xc3,0x0c,0x8c,0xcb,0xc0,0x8c,0xcc,0x38,0x03,0x6a,0x67,0x65,0x6e,0x65,0x72,0x61, + 0x74,0x65,0x64,0x28,0x39,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x44,0x76, + 0x32,0x5f,0x66,0x29,0x4c,0xe8,0xca,0xf0,0xc6,0xde,0xde,0xe4,0xc8,0x60,0x86,0x50, + 0x47,0x60,0x90,0x81,0x51,0x06,0x47,0x70,0x04,0x46,0x1a,0x18,0x97,0x81,0x19,0x99, + 0xa1,0x06,0xbc,0xce,0xca,0xdc,0xca,0xe4,0xc2,0xe8,0xca,0xc8,0x50,0x6c,0xc6,0xde, + 0xd8,0xde,0xe4,0x60,0x88,0xec,0x68,0xbe,0xcc,0x52,0x68,0x8c,0xbd,0xb1,0xbd,0xc9, + 0xc1,0x0c,0xa1,0x8e,0xc1,0x20,0x03,0xa3,0x0c,0x8e,0xe1,0x08,0x0c,0x36,0x30,0x2e, + 0xa3,0x33,0x32,0xa3,0x0d,0x86,0x18,0x06,0x1a,0x18,0x6b,0x60,0xb8,0xc1,0x10,0xa3, + 0x00,0x8c,0x31,0x30,0xde,0x60,0x44,0xc4,0x0e,0xec,0x60,0x0f,0xed,0xe0,0x06,0xed, + 0xf0,0x0e,0xe4,0x50,0x0f,0xec,0x50,0x0e,0x6e,0x60,0x0e,0xec,0x10,0x0e,0xe7,0x30, + 0x0f,0x53,0x84,0x60,0x18,0xa1,0xb0,0x03,0x3b,0xd8,0x43,0x3b,0xb8,0x41,0x3a,0x90, + 0x43,0x39,0xb8,0x03,0x3d,0x4c,0x09,0x8a,0x11,0x4b,0x38,0xa4,0x83,0x3c,0xb8,0x81, + 0x3d,0x94,0x83,0x3c,0xcc,0x43,0x3a,0xbc,0x83,0x3b,0x4c,0x09,0x8c,0x11,0x54,0x38, + 0xa4,0x83,0x3c,0xb8,0x01,0x3b,0x84,0x83,0x3b,0x9c,0x43,0x3d,0x84,0xc3,0x39,0x94, + 0xc3,0x2f,0xd8,0x43,0x39,0xc8,0xc3,0x3c,0xa4,0xc3,0x3b,0xb8,0xc3,0x94,0x00,0x19, + 0x31,0x85,0x43,0x3a,0xc8,0x83,0x1b,0x8c,0xc3,0x3b,0xb4,0x03,0x3c,0xa4,0x03,0x3b, + 0x94,0xc3,0x2f,0xbc,0x03,0x3c,0xd0,0x43,0x3a,0xbc,0x83,0x3b,0xcc,0xc3,0x14,0x43, + 0x61,0x1c,0x48,0xa2,0x46,0x28,0xe1,0x90,0x0e,0xf2,0xe0,0x06,0xf6,0x50,0x0e,0xf2, + 0x40,0x0f,0xe5,0x80,0x0f,0x53,0x02,0x38,0x00,0x00,0x00,0x00,0x79,0x18,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88, + 0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6, + 0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce, + 0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8, + 0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48, + 0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11, + 0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e, + 0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89, + 0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b, + 0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37, + 0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78, + 0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81, + 0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1, + 0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c, + 0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39, + 0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc, + 0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58, + 0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87, + 0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f, + 0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e, + 0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66, + 0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b, + 0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0, + 0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e, + 0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc, + 0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3, + 0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07, + 0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00, + 0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x1b,0x00,0x00,0x00, + 0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x94,0x63,0x11,0x40, + 0x60,0x1c,0x73,0x10,0x42,0xc0,0x30,0x74,0x33,0x00,0x14,0x63,0x09,0x20,0x08,0x82, + 0x20,0x18,0x80,0x20,0x08,0x82,0xe0,0x30,0x96,0x00,0x82,0x20,0x88,0xff,0x02,0x08, + 0x82,0x20,0xfe,0xcd,0x00,0x90,0xcc,0x41,0x50,0xd4,0x24,0xd1,0xcc,0x00,0x10,0x8c, + 0x11,0x80,0x20,0x08,0xe2,0xdf,0x08,0xc0,0x0c,0x00,0x00,0x00,0xe6,0x20,0xf2,0xb1, + 0x00,0x81,0xcf,0x20,0x43,0x80,0x30,0x83,0x0c,0x01,0xe2,0xcc,0x36,0x20,0x11,0x30, + 0xdb,0x10,0x44,0xc1,0x6c,0x43,0x30,0x08,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sdtx_fs_bytecode_metal_macos[2925] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x90,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0xea,0x91,0xf4,0xf5,0xea,0xea,0x43, + 0x77,0xcf,0xab,0x49,0x97,0x29,0xd8,0x26,0x5d,0xff,0x05,0x61,0xc6,0x93,0xc7,0x6c, + 0xb2,0x20,0x78,0x63,0x91,0x45,0x5c,0xbe,0x1c,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x70,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x99,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x89,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87, + 0x70,0x30,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74, + 0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e, + 0xde,0xc1,0x1c,0xe8,0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81, + 0x00,0x16,0xa0,0xda,0x80,0x10,0xff,0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5, + 0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,0x18,0x86,0x00,0x2c,0x40,0x05,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44,0x61,0x00,0x00,0x00, + 0x00,0x89,0x20,0x00,0x00,0x21,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x4c,0x33,0x00,0xc3,0x08,0x04,0x70,0x90,0x34,0x45, + 0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x13,0x0a,0xc2,0x30,0x82,0x00,0x1c, + 0x25,0x4d,0x11,0x25,0x4c,0xfe,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0xff,0x34, + 0x46,0x00,0x0c,0x22,0x10,0xc1,0x45,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x12,0xc0,0x3c, + 0x0b,0x11,0xfd,0xd3,0x18,0x01,0x30,0x88,0x60,0x08,0xa5,0x10,0x23,0x94,0x43,0x68, + 0x8e,0x20,0x98,0x23,0x00,0x83,0x61,0x04,0x61,0x29,0x48,0x28,0x67,0x28,0xa6,0x00, + 0xb5,0x81,0x80,0x14,0x58,0xc3,0x08,0xc4,0x32,0x02,0x00,0x00,0x00,0x13,0xb2,0x70, + 0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68, + 0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83, + 0x38,0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78, + 0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90, + 0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e, + 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76, + 0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a, + 0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30, + 0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07, + 0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71, + 0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20, + 0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f, + 0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76, + 0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50, + 0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07, + 0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78, + 0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x49,0x00,0x00,0x08,0x00, + 0x00,0x00,0x00,0x00,0x18,0xc2,0x38,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x64, + 0x81,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c, + 0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50,0x04,0x85,0x50, + 0x10,0x65,0x40,0x70,0x2c,0x41,0x79,0x00,0x00,0x79,0x18,0x00,0x00,0xd9,0x00,0x00, + 0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37, + 0xb7,0x21,0xc6,0x42,0x3c,0x00,0x84,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b, + 0xd3,0x2b,0x1b,0x62,0x2c,0xc2,0x23,0x2c,0x05,0xd9,0x20,0x08,0x0e,0x8e,0xad,0x0c, + 0x84,0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x24,0x07,0x46, + 0xc6,0x25,0x26,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x25,0x07,0x46, + 0xc6,0x25,0x26,0xc6,0x25,0x26,0x65,0x88,0xf0,0x10,0x43,0x8c,0x45,0x58,0x8c,0x65, + 0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x79,0x8e,0x45,0x58,0x84,0x65,0xe0,0x16, + 0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26, + 0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x78,0x12,0x72,0x61, + 0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f, + 0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x61,0x19, + 0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5, + 0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x91,0xa5, + 0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11,0x9e,0x86,0x61,0x10,0x96,0x26,0xe7,0x32,0xf6, + 0xd6,0x06,0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6,0x45,0xf6,0x56, + 0x27,0xc6,0x56,0xf6,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x78,0x1e,0x92, + 0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b,0x5b,0x18,0x5d, + 0x9a,0x5d,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0x59,0xda, + 0x5c,0x98,0x18,0x5b,0xd9,0x10,0xe1,0x89,0x78,0x06,0x61,0x69,0x72,0x2e,0x63,0x6f, + 0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f,0x77,0x69,0x64, + 0x65,0x5f,0x76,0x65,0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c, + 0x65,0x43,0x84,0x67,0x62,0x14,0x96,0x26,0xe7,0x22,0x57,0xe6,0x46,0x56,0x26,0xf7, + 0x45,0x17,0x26,0x77,0x56,0x46,0xc7,0x28,0x2c,0x4d,0xce,0x25,0x4c,0xee,0xec,0x8b, + 0x2e,0x0f,0xae,0xec,0xcb,0x2d,0xac,0xad,0x8c,0x86,0x19,0xdb,0x5b,0x18,0x1d,0x0d, + 0x99,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xb7,0xb0,0xb6,0x32,0x2a,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x43,0x98,0xa7,0x5a,0x86,0xc7,0x7a,0xae, + 0x07,0x7b,0xb2,0x21,0xc2,0xa3,0x51,0x0a,0x4b,0x93,0x73,0x31,0x93,0x0b,0x3b,0x6b, + 0x2b,0x73,0xa3,0xfb,0x4a,0x73,0x83,0xab,0xa3,0xe3,0x52,0x37,0x57,0x26,0x87,0xc2, + 0xf6,0x36,0xe6,0x06,0x93,0x42,0x25,0x2c,0x4d,0xce,0x65,0xac,0xcc,0x8d,0xae,0x4c, + 0x8e,0x4f,0x58,0x9a,0x9c,0x0b,0x5c,0x99,0xdc,0x1c,0x5c,0xd9,0x18,0x5d,0x9a,0x5d, + 0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x0a,0x75,0x76,0x43,0xa4,0x65,0x78,0xb8, + 0xa7,0x7b,0xbc,0xe7,0x7b,0xac,0x07,0x0c,0x1e,0xec,0x09,0x03,0x2e,0x75,0x73,0x65, + 0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x2c,0xc6,0xde,0xd8,0xde,0xe4,0x86,0x48, + 0x8b,0xf0,0x70,0xcf,0x18,0x3c,0xde,0xf3,0x3d,0xd6,0x73,0x3d,0xd8,0x43,0x06,0x5c, + 0xc2,0xd2,0xe4,0x5c,0xe8,0xca,0xf0,0xe8,0xea,0xe4,0xca,0x28,0x85,0xa5,0xc9,0xb9, + 0xb0,0xbd,0x8d,0x85,0xd1,0xa5,0xbd,0xb9,0x7d,0xa5,0xb9,0x91,0x95,0xe1,0x51,0x09, + 0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83,0x63,0x2b,0x23,0x46,0x57,0x86,0x47,0x57,0x27, + 0x57,0x26,0x43,0xc6,0x63,0xc6,0xf6,0x16,0x46,0xc7,0x02,0x32,0x17,0xd6,0x06,0xc7, + 0x56,0xe6,0xc3,0x81,0xae,0x0c,0x6f,0x08,0xb5,0x10,0x8f,0x19,0x3c,0x67,0xb0,0x0c, + 0x8b,0xf0,0xa0,0xc1,0x63,0x3d,0x69,0xf0,0x60,0x8f,0x1a,0x70,0x09,0x4b,0x93,0x73, + 0x99,0x0b,0x6b,0x83,0x63,0x2b,0x93,0xe3,0x31,0x17,0xd6,0x06,0xc7,0x56,0x26,0x47, + 0x84,0xae,0x0c,0x6f,0xaa,0x0d,0x8e,0x4d,0x6e,0x88,0xb4,0x1c,0x0f,0x1b,0x3c,0x67, + 0xb0,0x0c,0x8b,0xf0,0x58,0x4f,0x1b,0x3c,0xd8,0xe3,0x06,0x43,0x90,0x47,0x0c,0x9e, + 0x32,0x78,0xd6,0xe0,0x79,0x83,0x21,0x46,0x02,0x3c,0xdb,0x03,0x07,0x23,0x22,0x76, + 0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x77,0x20,0x87,0x7a,0x60,0x87,0x72,0x70, + 0x03,0x73,0x60,0x87,0x70,0x38,0x87,0x79,0x98,0x22,0x04,0xc3,0x08,0x85,0x1d,0xd8, + 0xc1,0x1e,0xda,0xc1,0x0d,0xd2,0x81,0x1c,0xca,0xc1,0x1d,0xe8,0x61,0x4a,0x50,0x8c, + 0x58,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x61,0x1e,0xd2,0xe1,0x1d, + 0xdc,0x61,0x4a,0x60,0x8c,0xa0,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xd8,0x21,0x1c,0xdc, + 0xe1,0x1c,0xea,0x21,0x1c,0xce,0xa1,0x1c,0x7e,0xc1,0x1e,0xca,0x41,0x1e,0xe6,0x21, + 0x1d,0xde,0xc1,0x1d,0xa6,0x04,0xc8,0x88,0x29,0x1c,0xd2,0x41,0x1e,0xdc,0x60,0x1c, + 0xde,0xa1,0x1d,0xe0,0x21,0x1d,0xd8,0xa1,0x1c,0x7e,0xe1,0x1d,0xe0,0x81,0x1e,0xd2, + 0xe1,0x1d,0xdc,0x61,0x1e,0xa6,0x18,0x0a,0xe3,0x40,0x12,0x35,0x82,0x09,0x87,0x74, + 0x90,0x07,0x37,0x30,0x07,0x79,0x08,0x87,0x73,0x68,0x87,0x72,0x70,0x07,0x7a,0x98, + 0x12,0xc4,0x01,0x00,0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80, + 0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80, + 0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80, + 0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88, + 0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78, + 0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03, + 0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f, + 0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c, + 0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39, + 0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b, + 0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60, + 0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87, + 0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e, + 0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6, + 0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94, + 0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03, + 0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07, + 0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f, + 0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33, + 0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc, + 0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c, + 0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78, + 0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca, + 0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21, + 0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43, + 0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87, + 0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00, + 0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00, + 0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d, + 0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00,0x00,0x0f,0x00,0x00, + 0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x14,0x47,0x00, + 0x88,0x8d,0x00,0x90,0x1a,0x01,0xa8,0x01,0x12,0x33,0x00,0x14,0x66,0x00,0x08,0x8c, + 0x00,0x00,0x00,0x00,0x00,0x23,0x06,0x8a,0x10,0x4c,0x09,0xb2,0x10,0x46,0x11,0x0c, + 0x32,0x04,0x03,0x62,0x01,0x23,0x9f,0xd9,0x06,0x23,0x00,0x32,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sdtx_vs_bytecode_metal_ios[2896] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x50,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0xa2,0x1f,0xa0,0x5e,0xa1,0x48,0x8e, + 0x9f,0xa4,0xc2,0x68,0xf5,0x56,0xca,0xed,0xf9,0xdd,0x8a,0x35,0x42,0xe2,0x79,0x40, + 0xd7,0xab,0x99,0x96,0x7f,0x41,0x4c,0xde,0xb0,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x37,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x22,0x00,0x03,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x56,0x41,0x54,0x59,0x05,0x00,0x03, + 0x00,0x04,0x04,0x06,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54, + 0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x20,0x0a,0x00,0x00, + 0xff,0xff,0xff,0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x85,0x02,0x00,0x00, + 0x0b,0x82,0x20,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91, + 0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19, + 0x1e,0x04,0x8b,0x62,0x80,0x10,0x45,0x02,0x42,0x92,0x0b,0x42,0x84,0x10,0x32,0x14, + 0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80, + 0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x08,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0, + 0x01,0x00,0x00,0x00,0x51,0x18,0x00,0x00,0x80,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8, + 0xff,0xff,0xff,0xff,0x01,0x90,0x00,0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87, + 0x71,0xa0,0x07,0x76,0xc8,0x87,0x36,0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72, + 0x20,0x87,0x36,0x20,0x87,0x74,0xb0,0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88, + 0x07,0x79,0xa0,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41, + 0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e,0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c, + 0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87, + 0x72,0x98,0x87,0x79,0x68,0x03,0x78,0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72, + 0x68,0x03,0x73,0x80,0x87,0x76,0x08,0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e, + 0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda, + 0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81,0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21, + 0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30, + 0x07,0x79,0x08,0x87,0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87, + 0x72,0x90,0x87,0x36,0x28,0x07,0x76,0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77, + 0x68,0x03,0x76,0x28,0x87,0x70,0x30,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70, + 0x07,0x73,0x98,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1, + 0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08, + 0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87, + 0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41, + 0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d, + 0xca,0x81,0x1c,0xda,0x40,0x1f,0xca,0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0, + 0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80, + 0x70,0x87,0x77,0x68,0x03,0x7a,0x90,0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38, + 0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00, + 0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61,0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1, + 0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e,0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4,0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87, + 0x79,0x08,0x07,0x73,0x28,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a, + 0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d, + 0xe6,0xe1,0x1d,0xcc,0x81,0x1e,0xda,0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00, + 0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x00,0x00,0x00,0x00,0x49,0x18,0x00,0x00, + 0x01,0x00,0x00,0x00,0x13,0x82,0x00,0x00,0x89,0x20,0x00,0x00,0x14,0x00,0x00,0x00, + 0x32,0x22,0x08,0x09,0x20,0x64,0x85,0x04,0x13,0x22,0xa4,0x84,0x04,0x13,0x22,0xe3, + 0x84,0xa1,0x90,0x14,0x12,0x4c,0x88,0x8c,0x0b,0x84,0x84,0x4c,0x10,0x2c,0x33,0x00, + 0xc3,0x08,0x02,0x30,0x8c,0x40,0x00,0x77,0x49,0x53,0x44,0x09,0x93,0xcf,0x00,0x48, + 0x43,0xff,0x0e,0x35,0xf9,0x0f,0x20,0x28,0xc4,0x80,0x87,0x10,0x29,0xc4,0x44,0x08, + 0xd1,0x40,0xc0,0x1c,0x01,0x18,0xa4,0xc0,0x0d,0x23,0x10,0xc7,0x08,0x00,0x00,0x00, + 0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60, + 0x87,0x72,0x68,0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80,0x83, + 0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d, + 0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0, + 0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07, + 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76, + 0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a, + 0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30, + 0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07, + 0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74, + 0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0, + 0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07, + 0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a, + 0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72,0x50, + 0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60,0x07, + 0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x75, + 0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xd0, + 0x06,0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07, + 0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07,0x76, + 0xa0,0x07,0x73,0x20,0x07,0x43,0x98,0x02,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80, + 0x2c,0x10,0x00,0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98,0x0c,0x19,0x11,0x4c,0x90, + 0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0xba,0x12,0x18,0x01,0x28,0x82,0x42,0x28,0x08, + 0xc2,0xb1,0x84,0x46,0x00,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0xdc,0x00,0x00,0x00, + 0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7, + 0x21,0xc6,0x31,0x18,0x00,0x62,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3, + 0x2b,0x1b,0x62,0x1c,0x81,0x21,0x1c,0x04,0xd7,0x20,0x08,0x0e,0x8e,0xad,0x0c,0x84, + 0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x24,0x07,0x46,0xc6, + 0x25,0x07,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x25,0x07,0x46,0xc6,0x25, + 0xc7,0xc5,0x26,0x26,0x65,0x88,0x60,0x10,0x43,0x8c,0x23,0x38,0x8a,0x43,0x60,0xd1, + 0x54,0x46,0x17,0xc6,0x36,0x04,0x31,0x8e,0x23,0x38,0x84,0x43,0xe0,0x16,0x96,0x26, + 0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36, + 0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x30,0x12,0x72,0x61,0x69,0x72, + 0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61, + 0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04,0x63,0x21,0x19,0x84,0xa5, + 0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89, + 0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x95,0xb9,0x85,0x89, + 0xb1,0x95,0x0d,0x11,0x8c,0x86,0x61,0x10,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97, + 0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6,0x45,0xf6,0x56,0x27,0xc6,0x56, + 0xf6,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x30,0x1e,0x92,0x41,0x58,0x9a, + 0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b,0x5b,0x18,0x5d,0x9a,0x5d,0xd9, + 0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0x59,0xda,0x5c,0x98,0x18, + 0x5b,0xd9,0x10,0xc1,0x88,0x78,0x06,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69, + 0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f,0x77,0x69,0x64,0x65,0x5f,0x76, + 0x65,0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43,0x04, + 0x63,0x62,0x14,0x96,0x26,0xe7,0x62,0x57,0x26,0x47,0x57,0x86,0xf7,0xf5,0x56,0x47, + 0x07,0x57,0x47,0xc7,0xa5,0x6e,0xae,0x4c,0x0e,0x85,0xed,0x6d,0xcc,0x0d,0x26,0x85, + 0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d,0x1e,0x5c,0xd9,0x97,0x5b,0x58, + 0x5b,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x32,0x61,0x69,0x72,0x2e,0x61,0x72, + 0x67,0x5f,0x6e,0x61,0x6d,0x65,0x14,0xea,0xec,0x86,0x30,0x46,0x65,0x58,0xc6,0x65, + 0x60,0x46,0x66,0x68,0x5c,0xea,0xe6,0xca,0xe4,0x50,0xd8,0xde,0xc6,0xdc,0x62,0x52, + 0x68,0x98,0xb1,0xbd,0x85,0xd1,0xd1,0xb0,0x18,0x7b,0x63,0x7b,0x93,0x1b,0xc2,0x18, + 0x95,0xc1,0x19,0x97,0xd1,0x19,0x99,0xe1,0x91,0x09,0x4b,0x93,0x73,0x81,0x7b,0x9b, + 0x4b,0xa3,0x4b,0x7b,0x73,0xe3,0x72,0xc6,0xf6,0x05,0xf5,0x36,0x97,0x46,0x97,0xf6, + 0xe6,0x36,0x44,0x31,0xc0,0xc0,0xb8,0x8c,0xce,0xc8,0x8c,0x30,0x18,0x62,0x18,0x9b, + 0xf1,0x19,0x62,0x40,0x28,0x2c,0x4d,0xce,0xc5,0xae,0x4c,0x8e,0xae,0x0c,0xef,0x2b, + 0xcd,0x0d,0xae,0x8e,0x8e,0x52,0x58,0x9a,0x9c,0x0b,0xdb,0xdb,0x58,0x18,0x5d,0xda, + 0x9b,0xdb,0x57,0x9a,0x1b,0x59,0x19,0x1e,0xb3,0xb3,0x32,0xb7,0x32,0xb9,0x30,0xba, + 0x32,0x32,0x14,0x1c,0xb8,0xb7,0xb9,0x34,0xba,0xb4,0x37,0x37,0x22,0x3b,0x99,0x2f, + 0xb3,0x14,0x22,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x43,0xa8,0x43,0x30,0xc8, + 0xc0,0x28,0x83,0x43,0x38,0x02,0xc3,0x0c,0x8c,0xcb,0xc0,0x8c,0xcc,0x38,0x03,0x6a, + 0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x28,0x39,0x74,0x65,0x78,0x63,0x6f, + 0x6f,0x72,0x64,0x30,0x44,0x76,0x32,0x5f,0x66,0x29,0x4c,0xe8,0xca,0xf0,0xc6,0xde, + 0xde,0xe4,0xc8,0x60,0x86,0x50,0x47,0x60,0x90,0x81,0x51,0x06,0x47,0x70,0x04,0x46, + 0x1a,0x18,0x97,0x81,0x19,0x99,0xa1,0x06,0xbc,0xce,0xca,0xdc,0xca,0xe4,0xc2,0xe8, + 0xca,0xc8,0x50,0x6c,0xc6,0xde,0xd8,0xde,0xe4,0x60,0x88,0xec,0x68,0xbe,0xcc,0x52, + 0x68,0x8c,0xbd,0xb1,0xbd,0xc9,0xc1,0x0c,0xa1,0x8e,0xc1,0x20,0x03,0xa3,0x0c,0x8e, + 0xe1,0x08,0x0c,0x36,0x30,0x2e,0xa3,0x33,0x32,0xa3,0x0d,0x86,0x18,0x06,0x1a,0x18, + 0x6b,0x60,0xb8,0xc1,0x10,0xa3,0x00,0x8c,0x31,0x30,0xde,0x60,0x44,0xc4,0x0e,0xec, + 0x60,0x0f,0xed,0xe0,0x06,0xed,0xf0,0x0e,0xe4,0x50,0x0f,0xec,0x50,0x0e,0x6e,0x60, + 0x0e,0xec,0x10,0x0e,0xe7,0x30,0x0f,0x53,0x84,0x60,0x18,0xa1,0xb0,0x03,0x3b,0xd8, + 0x43,0x3b,0xb8,0x41,0x3a,0x90,0x43,0x39,0xb8,0x03,0x3d,0x4c,0x09,0x8a,0x11,0x4b, + 0x38,0xa4,0x83,0x3c,0xb8,0x81,0x3d,0x94,0x83,0x3c,0xcc,0x43,0x3a,0xbc,0x83,0x3b, + 0x4c,0x09,0x8c,0x11,0x54,0x38,0xa4,0x83,0x3c,0xb8,0x01,0x3b,0x84,0x83,0x3b,0x9c, + 0x43,0x3d,0x84,0xc3,0x39,0x94,0xc3,0x2f,0xd8,0x43,0x39,0xc8,0xc3,0x3c,0xa4,0xc3, + 0x3b,0xb8,0xc3,0x94,0x00,0x19,0x31,0x85,0x43,0x3a,0xc8,0x83,0x1b,0x8c,0xc3,0x3b, + 0xb4,0x03,0x3c,0xa4,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x03,0x3c,0xd0,0x43,0x3a,0xbc, + 0x83,0x3b,0xcc,0xc3,0x14,0x43,0x61,0x1c,0x48,0xa2,0x46,0x28,0xe1,0x90,0x0e,0xf2, + 0xe0,0x06,0xf6,0x50,0x0e,0xf2,0x40,0x0f,0xe5,0x80,0x0f,0x53,0x02,0x38,0x00,0x00, + 0x79,0x18,0x00,0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66, + 0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73, + 0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e, + 0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b, + 0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b, + 0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20, + 0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0, + 0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61, + 0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83, + 0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87, + 0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76, + 0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98, + 0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30, + 0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61, + 0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43, + 0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b, + 0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7, + 0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18, + 0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90, + 0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1, + 0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d, + 0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24, + 0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c, + 0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d, + 0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54, + 0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4, + 0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18, + 0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00, + 0x02,0x00,0x00,0x00,0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00, + 0x1b,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x94,0x63,0x11,0x40,0x60,0x1c,0x73,0x10,0x42,0xc0,0x30,0x74,0x33,0x00,0x14,0x63, + 0x09,0x20,0x08,0x82,0x20,0x18,0x80,0x20,0x08,0x82,0xe0,0x30,0x96,0x00,0x82,0x20, + 0x88,0xff,0x02,0x08,0x82,0x20,0xfe,0xcd,0x00,0x90,0xcc,0x41,0x50,0xd4,0x24,0xd1, + 0xcc,0x00,0x10,0x8c,0x11,0x80,0x20,0x08,0xe2,0xdf,0x08,0xc0,0x0c,0x00,0x00,0x00, + 0xe6,0x20,0xf2,0xb1,0x00,0x81,0xcf,0x20,0x43,0x80,0x30,0x83,0x0c,0x01,0xe2,0xcc, + 0x36,0x20,0x11,0x30,0xdb,0x10,0x44,0xc1,0x6c,0x43,0x30,0x08,0x19,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sdtx_fs_bytecode_metal_ios[2909] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x5d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x80,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0x2e,0x61,0xb5,0x48,0xc0,0xda,0xe2, + 0xd5,0xd0,0xc4,0x03,0x62,0x19,0xb0,0xc7,0xd7,0x9e,0x78,0x2c,0x20,0x75,0xa7,0xa5, + 0x35,0x9c,0xa0,0x5a,0x3e,0x5d,0xbc,0x8f,0xc9,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x68,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x97,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x89,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87, + 0x70,0x30,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74, + 0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e, + 0xde,0xc1,0x1c,0xe8,0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81, + 0x00,0x16,0xa0,0xda,0x80,0x10,0xff,0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5, + 0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,0x18,0x86,0x00,0x2c,0x40,0x05,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44,0x61,0x00,0x00,0x00, + 0x00,0x89,0x20,0x00,0x00,0x21,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x4c,0x33,0x00,0xc3,0x08,0x04,0x70,0x90,0x34,0x45, + 0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x13,0x0a,0xc2,0x30,0x82,0x00,0x1c, + 0x25,0x4d,0x11,0x25,0x4c,0xfe,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0xff,0x34, + 0x46,0x00,0x0c,0x22,0x10,0xc1,0x45,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x12,0xc0,0x3c, + 0x0b,0x11,0xfd,0xd3,0x18,0x01,0x30,0x88,0x60,0x08,0xa5,0x10,0x23,0x94,0x43,0x68, + 0x8e,0x20,0x98,0x23,0x00,0x83,0x61,0x04,0x61,0x29,0x48,0x28,0x67,0x28,0xa6,0x00, + 0xb5,0x81,0x80,0x14,0x58,0xc3,0x08,0xc4,0x32,0x02,0x00,0x00,0x00,0x13,0xa8,0x70, + 0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68, + 0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80,0x83,0x0d,0xb7,0x51, + 0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78, + 0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60, + 0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07, + 0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a, + 0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30, + 0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76, + 0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0, + 0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06, + 0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6, + 0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x90, + 0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06, + 0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72, + 0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0, + 0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07, + 0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x75,0x10,0x07,0x72, + 0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xd0,0x06,0xf6,0x10, + 0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07, + 0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x73, + 0x20,0x07,0x43,0x98,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x21,0x8c,0x03, + 0x04,0x80,0x00,0x00,0x00,0x00,0x00,0x40,0x16,0x08,0x00,0x00,0x00,0x08,0x00,0x00, + 0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43, + 0x5a,0x23,0x00,0x25,0x50,0x04,0x85,0x50,0x10,0x65,0x40,0x70,0x2c,0xa1,0x11,0x00, + 0x00,0x79,0x18,0x00,0x00,0xd9,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2, + 0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x42,0x3c,0x00,0x84,0x50, + 0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x2c,0xc3,0x23,0x2c, + 0x05,0xd7,0x20,0x08,0x0e,0x8e,0xad,0x0c,0x84,0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c, + 0x6e,0x2e,0xed,0xcd,0x0d,0x24,0x07,0x46,0xc6,0x25,0x07,0x04,0xa5,0xad,0x8c,0x2e, + 0x8c,0xcd,0xac,0xac,0x25,0x07,0x46,0xc6,0x25,0xc7,0xc5,0x26,0x26,0x65,0x88,0xf0, + 0x10,0x43,0x8c,0x65,0x58,0x8c,0x45,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x79, + 0x8e,0x65,0x58,0x84,0x45,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6, + 0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6, + 0x56,0x36,0x44,0x78,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c, + 0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62, + 0x6c,0x65,0x43,0x84,0x67,0x21,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5, + 0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99, + 0x95,0xd1,0x8d,0xa1,0x7d,0x95,0xb9,0x85,0x89,0xb1,0x95,0x0d,0x11,0x9e,0x86,0x61, + 0x10,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97, + 0x66,0x57,0xf6,0x45,0xf6,0x56,0x27,0xc6,0x56,0xf6,0x45,0x96,0x36,0x17,0x26,0xc6, + 0x56,0x36,0x44,0x78,0x1e,0x92,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a, + 0x5b,0x99,0x8b,0x5b,0x18,0x5d,0x9a,0x5d,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb, + 0x9b,0xdb,0xd9,0x17,0x59,0xda,0x5c,0x98,0x18,0x5b,0xd9,0x10,0xe1,0x89,0x78,0x06, + 0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69, + 0x76,0x65,0x5f,0x77,0x69,0x64,0x65,0x5f,0x76,0x65,0x63,0x74,0x6f,0x72,0x73,0x5f, + 0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x62,0x14,0x96,0x26,0xe7,0x22, + 0x57,0xe6,0x46,0x56,0x26,0xf7,0x45,0x17,0x26,0x77,0x56,0x46,0xc7,0x28,0x2c,0x4d, + 0xce,0x25,0x4c,0xee,0xec,0x8b,0x2e,0x0f,0xae,0xec,0xcb,0x2d,0xac,0xad,0x8c,0x86, + 0x19,0xdb,0x5b,0x18,0x1d,0x0d,0x99,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xb7, + 0xb0,0xb6,0x32,0x2a,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x43,0x98, + 0xa7,0x5a,0x84,0xc7,0x7a,0xae,0x07,0x7b,0xb2,0x21,0xc2,0xa3,0x51,0x0a,0x4b,0x93, + 0x73,0x31,0x93,0x0b,0x3b,0x6b,0x2b,0x73,0xa3,0xfb,0x4a,0x73,0x83,0xab,0xa3,0xe3, + 0x52,0x37,0x57,0x26,0x87,0xc2,0xf6,0x36,0xe6,0x06,0x93,0x42,0x25,0x2c,0x4d,0xce, + 0x65,0xac,0xcc,0x8d,0xae,0x4c,0x8e,0x4f,0x58,0x9a,0x9c,0x0b,0x5c,0x99,0xdc,0x1c, + 0x5c,0xd9,0x18,0x5d,0x9a,0x5d,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x0a,0x75, + 0x76,0x43,0xa4,0x45,0x78,0xb8,0xa7,0x7b,0xbc,0xe7,0x7b,0xac,0x07,0x0c,0x1e,0xec, + 0x09,0x03,0x2e,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x2c,0xc6, + 0xde,0xd8,0xde,0xe4,0x86,0x48,0xcb,0xf0,0x70,0xcf,0x18,0x3c,0xde,0xf3,0x3d,0xd6, + 0x73,0x3d,0xd8,0x43,0x06,0x5c,0xc2,0xd2,0xe4,0x5c,0xe8,0xca,0xf0,0xe8,0xea,0xe4, + 0xca,0x28,0x85,0xa5,0xc9,0xb9,0xb0,0xbd,0x8d,0x85,0xd1,0xa5,0xbd,0xb9,0x7d,0xa5, + 0xb9,0x91,0x95,0xe1,0x51,0x09,0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83,0x63,0x2b,0x23, + 0x46,0x57,0x86,0x47,0x57,0x27,0x57,0x26,0x43,0xc6,0x63,0xc6,0xf6,0x16,0x46,0xc7, + 0x02,0x32,0x17,0xd6,0x06,0xc7,0x56,0xe6,0xc3,0x81,0xae,0x0c,0x6f,0x08,0xb5,0x10, + 0x8f,0x19,0x3c,0x67,0xb0,0x08,0xcb,0xf0,0xa0,0xc1,0x63,0x3d,0x69,0xf0,0x60,0x8f, + 0x1a,0x70,0x09,0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83,0x63,0x2b,0x93,0xe3,0x31,0x17, + 0xd6,0x06,0xc7,0x56,0x26,0x47,0x84,0xae,0x0c,0x6f,0xaa,0x0d,0x8e,0x4d,0x6e,0x88, + 0xb4,0x1c,0x0f,0x1b,0x3c,0x67,0xb0,0x08,0xcb,0xf0,0x58,0x4f,0x1b,0x3c,0xd8,0xe3, + 0x06,0x43,0x90,0x47,0x0c,0x9e,0x32,0x78,0xd6,0xe0,0x79,0x83,0x21,0x46,0x02,0x3c, + 0xdb,0x03,0x07,0x23,0x22,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x77,0x20, + 0x87,0x7a,0x60,0x87,0x72,0x70,0x03,0x73,0x60,0x87,0x70,0x38,0x87,0x79,0x98,0x22, + 0x04,0xc3,0x08,0x85,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d,0xd2,0x81,0x1c,0xca,0xc1, + 0x1d,0xe8,0x61,0x4a,0x50,0x8c,0x58,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c, + 0xe4,0x61,0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x4a,0x60,0x8c,0xa0,0xc2,0x21,0x1d,0xe4, + 0xc1,0x0d,0xd8,0x21,0x1c,0xdc,0xe1,0x1c,0xea,0x21,0x1c,0xce,0xa1,0x1c,0x7e,0xc1, + 0x1e,0xca,0x41,0x1e,0xe6,0x21,0x1d,0xde,0xc1,0x1d,0xa6,0x04,0xc8,0x88,0x29,0x1c, + 0xd2,0x41,0x1e,0xdc,0x60,0x1c,0xde,0xa1,0x1d,0xe0,0x21,0x1d,0xd8,0xa1,0x1c,0x7e, + 0xe1,0x1d,0xe0,0x81,0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x1e,0xa6,0x18,0x0a,0xe3,0x40, + 0x12,0x35,0x82,0x09,0x87,0x74,0x90,0x07,0x37,0x30,0x07,0x79,0x08,0x87,0x73,0x68, + 0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0xc4,0x01,0x00,0x00,0x00,0x00,0x79,0x18,0x00, + 0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d, + 0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c, + 0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d, + 0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d, + 0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79, + 0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc, + 0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50, + 0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30, + 0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03, + 0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07, + 0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76, + 0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98, + 0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8, + 0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21, + 0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43, + 0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f, + 0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70, + 0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0, + 0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40, + 0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41, + 0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e, + 0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07, + 0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f, + 0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d, + 0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38, + 0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88, + 0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08, + 0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00, + 0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45, + 0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00, + 0x00,0x61,0x20,0x00,0x00,0x0f,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00, + 0x00,0x06,0x00,0x00,0x00,0x14,0x47,0x00,0x88,0x8d,0x00,0x90,0x1a,0x01,0xa8,0x01, + 0x12,0x33,0x00,0x14,0x66,0x00,0x08,0x8c,0x00,0x00,0x00,0x00,0x00,0x23,0x06,0x8a, + 0x10,0x4c,0x09,0xb2,0x10,0x46,0x11,0x0c,0x32,0x04,0x03,0x62,0x01,0x23,0x9f,0xd9, + 0x06,0x23,0x00,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const char _sdtx_vs_src_metal_sim[624] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28, + 0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65, + 0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74, + 0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64, + 0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74, + 0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e, + 0x65,0x20,0x31,0x32,0x20,0x22,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61, + 0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b, + 0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x32,0x20,0x22,0x22,0x0a,0x20, + 0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x69,0x6e,0x2e, + 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x29,0x20,0x2b,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x2d,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30, + 0x29,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x23,0x6c, + 0x69,0x6e,0x65,0x20,0x31,0x33,0x20,0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75, + 0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,0x30,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x34,0x20,0x22,0x22, + 0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d, + 0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _sdtx_fs_src_metal_sim[475] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d, + 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20, + 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20, + 0x31,0x31,0x20,0x22,0x22,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61, + 0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65, + 0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74,0x65,0x78,0x20,0x5b,0x5b, + 0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x20,0x5b, + 0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f, + 0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31, + 0x31,0x20,0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61, + 0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x28,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x69, + 0x6e,0x2e,0x75,0x76,0x29,0x2e,0x78,0x78,0x78,0x78,0x20,0x2a,0x20,0x69,0x6e,0x2e, + 0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72, + 0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_D3D11) +static const uint8_t _sdtx_vs_bytecode_d3d11[692] = { + 0x44,0x58,0x42,0x43,0x07,0x05,0xa0,0xb3,0x53,0xc1,0x0a,0x0d,0x1e,0xf4,0xe4,0xa6, + 0x91,0xaf,0x4c,0xca,0x01,0x00,0x00,0x00,0xb4,0x02,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0xe4,0x00,0x00,0x00,0x54,0x01,0x00,0x00, + 0x38,0x02,0x00,0x00,0x52,0x44,0x45,0x46,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xfe,0xff, + 0x10,0x81,0x00,0x00,0x1c,0x00,0x00,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66, + 0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64,0x65, + 0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31,0x00, + 0x49,0x53,0x47,0x4e,0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x03,0x00,0x00, + 0x50,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44, + 0x00,0xab,0xab,0xab,0x4f,0x53,0x47,0x4e,0x68,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0c,0x00,0x00,0x50,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x00,0x00,0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x54,0x45,0x58,0x43, + 0x4f,0x4f,0x52,0x44,0x00,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x00,0xab,0xab,0xab,0x53,0x48,0x44,0x52,0xdc,0x00,0x00,0x00,0x40,0x00,0x01,0x00, + 0x37,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x5f,0x00,0x00,0x03,0x32,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x5f,0x00,0x00,0x03, + 0xf2,0x10,0x10,0x00,0x02,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0x32,0x20,0x10,0x00, + 0x00,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00, + 0x67,0x00,0x00,0x04,0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x36,0x00,0x00,0x05,0x32,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00, + 0x01,0x00,0x00,0x00,0x36,0x00,0x00,0x05,0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00, + 0x46,0x1e,0x10,0x00,0x02,0x00,0x00,0x00,0x32,0x00,0x00,0x0f,0x32,0x20,0x10,0x00, + 0x02,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x00,0x00, + 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x02,0x40,0x00,0x00,0x00,0x00,0x80,0xbf,0x00,0x00,0x80,0x3f,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x08,0xc2,0x20,0x10,0x00,0x02,0x00,0x00,0x00, + 0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x80,0x3f,0x3e,0x00,0x00,0x01,0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, +}; +static const uint8_t _sdtx_fs_bytecode_d3d11[620] = { + 0x44,0x58,0x42,0x43,0xcf,0x30,0x5f,0x26,0xe7,0xba,0x36,0x97,0xf8,0x97,0x06,0x8d, + 0x92,0xcc,0x4b,0x8a,0x01,0x00,0x00,0x00,0x6c,0x02,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0x20,0x01,0x00,0x00,0x54,0x01,0x00,0x00, + 0xf0,0x01,0x00,0x00,0x52,0x44,0x45,0x46,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xff,0xff, + 0x10,0x81,0x00,0x00,0x6d,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x69,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x00,0x74,0x65,0x78,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f, + 0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64, + 0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31, + 0x00,0xab,0xab,0xab,0x49,0x53,0x47,0x4e,0x44,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x38,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x2c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65, + 0x74,0x00,0xab,0xab,0x53,0x48,0x44,0x52,0x94,0x00,0x00,0x00,0x40,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x5a,0x00,0x00,0x03,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x58,0x18,0x00,0x04,0x00,0x70,0x10,0x00,0x00,0x00,0x00,0x00,0x55,0x55,0x00,0x00, + 0x62,0x10,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x00,0x03, + 0xf2,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00, + 0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x02,0x01,0x00,0x00,0x00,0x45,0x00,0x00,0x09, + 0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x7e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x38,0x00,0x00,0x07,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x01,0x00,0x00,0x00,0x3e,0x00,0x00,0x01, + 0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +#elif defined(SOKOL_WGPU) +static const uint8_t _sdtx_vs_bytecode_wgpu[1648] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x2e,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x24,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x27,0x00,0x00,0x00,0x29,0x00,0x00,0x00,0x2c,0x00,0x00,0x00, + 0x2d,0x00,0x00,0x00,0x07,0x00,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x37,0x00,0x02,0x00,0x00,0x00,0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65, + 0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e, + 0x74,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f, + 0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64, + 0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x2e,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65, + 0x74,0x2d,0x65,0x6e,0x76,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20, + 0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65, + 0x64,0x20,0x65,0x6e,0x74,0x72,0x79,0x2d,0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61, + 0x69,0x6e,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00, + 0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,0x05,0x00,0x06,0x00, + 0x0c,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x65,0x72,0x56,0x65,0x72,0x74,0x65,0x78, + 0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x06,0x00,0x07,0x00, + 0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74, + 0x53,0x69,0x7a,0x65,0x00,0x00,0x00,0x00,0x06,0x00,0x07,0x00,0x0c,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x67,0x6c,0x5f,0x43,0x6c,0x69,0x70,0x44,0x69,0x73,0x74,0x61, + 0x6e,0x63,0x65,0x00,0x06,0x00,0x07,0x00,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x43,0x75,0x6c,0x6c,0x44,0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x00, + 0x05,0x00,0x03,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00, + 0x13,0x00,0x00,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x00,0x00, + 0x05,0x00,0x03,0x00,0x24,0x00,0x00,0x00,0x75,0x76,0x00,0x00,0x05,0x00,0x05,0x00, + 0x25,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x00,0x00, + 0x05,0x00,0x04,0x00,0x27,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00, + 0x05,0x00,0x04,0x00,0x29,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x00, + 0x05,0x00,0x05,0x00,0x2c,0x00,0x00,0x00,0x67,0x6c,0x5f,0x56,0x65,0x72,0x74,0x65, + 0x78,0x49,0x44,0x00,0x05,0x00,0x06,0x00,0x2d,0x00,0x00,0x00,0x67,0x6c,0x5f,0x49, + 0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x00,0x00,0x00,0x48,0x00,0x05,0x00, + 0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x47,0x00,0x03,0x00, + 0x0c,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x13,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x24,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x25,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x27,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x29,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x2c,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x2d,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00, + 0x21,0x00,0x03,0x00,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00, + 0x07,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x08,0x00,0x00,0x00, + 0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x15,0x00,0x04,0x00,0x09,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x09,0x00,0x00,0x00, + 0x0a,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x04,0x00,0x0b,0x00,0x00,0x00, + 0x07,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x1e,0x00,0x06,0x00,0x0c,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x15,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x40, + 0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0xc0, + 0x2c,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x15,0x00,0x00,0x00, + 0x16,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x19,0x00,0x00,0x00, + 0x00,0x00,0x80,0xbf,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x1a,0x00,0x00,0x00, + 0x00,0x00,0x80,0x3f,0x2c,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x1b,0x00,0x00,0x00, + 0x19,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00, + 0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x21,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x23,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x23,0x00,0x00,0x00, + 0x24,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x12,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x21,0x00,0x00,0x00, + 0x27,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x28,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x28,0x00,0x00,0x00, + 0x29,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x2b,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x2b,0x00,0x00,0x00, + 0x2c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x2b,0x00,0x00,0x00, + 0x2d,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x36,0x00,0x05,0x00,0x03,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xf8,0x00,0x02,0x00, + 0x06,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x14,0x00,0x00,0x00, + 0x13,0x00,0x00,0x00,0x85,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x18,0x00,0x00,0x00, + 0x14,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x81,0x00,0x05,0x00,0x11,0x00,0x00,0x00, + 0x1c,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x51,0x00,0x05,0x00, + 0x07,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x51,0x00,0x05,0x00,0x07,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x1c,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x50,0x00,0x07,0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x1d,0x00,0x00,0x00,0x1a,0x00,0x00,0x00, + 0x41,0x00,0x05,0x00,0x21,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x0e,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x22,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x08,0x00,0x04,0x00,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x25,0x00,0x00,0x00, + 0x3e,0x00,0x03,0x00,0x24,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x08,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x29,0x00,0x00,0x00,0x3e,0x00,0x03,0x00, + 0x27,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +static const uint8_t _sdtx_fs_bytecode_wgpu[940] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x1a,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x08,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x10,0x00,0x03,0x00,0x05,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x00,0x03,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x37,0x00,0x02,0x00,0x00,0x00, + 0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64, + 0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69, + 0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x30,0x30,0x0a,0x2f,0x2f, + 0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73, + 0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c, + 0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50, + 0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d, + 0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x2e,0x30,0x0a,0x2f,0x2f, + 0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73, + 0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x6f,0x70, + 0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65, + 0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x65,0x6e,0x74,0x72,0x79,0x2d, + 0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x0a,0x23,0x6c,0x69,0x6e,0x65, + 0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00,0x0a,0x00,0x00,0x00,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x05,0x00,0x03,0x00,0x0e,0x00,0x00,0x00, + 0x74,0x65,0x78,0x00,0x05,0x00,0x03,0x00,0x12,0x00,0x00,0x00,0x75,0x76,0x00,0x00, + 0x05,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0a,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x21,0x00,0x03,0x00,0x04,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x19,0x00,0x09,0x00,0x0b,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x1b,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x36,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x0c,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x10,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x57,0x00,0x05,0x00, + 0x08,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x4f,0x00,0x09,0x00,0x08,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x14,0x00,0x00,0x00, + 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,0x00, + 0x17,0x00,0x00,0x00,0x85,0x00,0x05,0x00,0x08,0x00,0x00,0x00,0x19,0x00,0x00,0x00, + 0x15,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x0a,0x00,0x00,0x00, + 0x19,0x00,0x00,0x00,0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +#elif defined(SOKOL_DUMMY_BACKEND) +static const char* _sdtx_vs_src_dummy = ""; +static const char* _sdtx_fs_src_dummy = ""; +#else +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#endif + +// ███████ ████████ ██████ ██ ██ ██████ ████████ ███████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██ ██████ ██ ██ ██ ██ ███████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██ ██ ██ ██████ ██████ ██ ███████ +// +// >>structs +typedef struct { + uint32_t id; + sg_resource_state state; +} _sdtx_slot_t; + +typedef struct { + int size; + int queue_top; + uint32_t* gen_ctrs; + int* free_queue; +} _sdtx_pool_t; + +typedef struct { + float x, y; +} _sdtx_float2_t; + +typedef struct { + float x, y; + uint16_t u, v; + uint32_t color; +} _sdtx_vertex_t; + +typedef struct { + int layer_id; + int first_vertex; + int num_vertices; +} _sdtx_command_t; + +typedef struct { + _sdtx_slot_t slot; + sdtx_context_desc_t desc; + uint32_t frame_id; + uint32_t update_frame_id; + struct { + int cap; + int next; + _sdtx_vertex_t* ptr; + } vertices; + struct { + int cap; + int next; + _sdtx_command_t* ptr; + } commands; + sg_buffer vbuf; + sg_pipeline pip; + int cur_font; + int cur_layer_id; + _sdtx_float2_t canvas_size; + _sdtx_float2_t glyph_size; + _sdtx_float2_t origin; + _sdtx_float2_t pos; + float tab_width; + uint32_t color; +} _sdtx_context_t; + +typedef struct { + _sdtx_pool_t pool; + _sdtx_context_t* contexts; +} _sdtx_context_pool_t; + +typedef struct { + uint32_t init_cookie; + sdtx_desc_t desc; + sg_image font_img; + sg_shader shader; + uint32_t fmt_buf_size; + char* fmt_buf; + sdtx_context def_ctx_id; + sdtx_context cur_ctx_id; + _sdtx_context_t* cur_ctx; // may be 0! + _sdtx_context_pool_t context_pool; + uint8_t font_pixels[SDTX_MAX_FONTS * 256 * 8 * 8]; +} _sdtx_t; +static _sdtx_t _sdtx; + +// ██ ██████ ██████ ██████ ██ ███ ██ ██████ +// ██ ██ ██ ██ ██ ██ ████ ██ ██ +// ██ ██ ██ ██ ███ ██ ███ ██ ██ ██ ██ ██ ███ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██████ ██████ ██████ ██ ██ ████ ██████ +// +// >>logging +#if defined(SOKOL_DEBUG) +#define _SDTX_LOGITEM_XMACRO(item,msg) #item ": " msg, +static const char* _sdtx_log_messages[] = { + _SDTX_LOG_ITEMS +}; +#undef _SDTX_LOGITEM_XMACRO +#endif // SOKOL_DEBUG + +#define _SDTX_PANIC(code) _sdtx_log(SDTX_LOGITEM_ ##code, 0, __LINE__) +#define _SDTX_ERROR(code) _sdtx_log(SDTX_LOGITEM_ ##code, 1, __LINE__) +#define _SDTX_WARN(code) _sdtx_log(SDTX_LOGITEM_ ##code, 2, __LINE__) +#define _SDTX_INFO(code) _sdtx_log(SDTX_LOGITEM_ ##code, 3, __LINE__) + +static void _sdtx_log(sdtx_log_item_t log_item, uint32_t log_level, uint32_t line_nr) { + if (_sdtx.desc.logger.func) { + #if defined(SOKOL_DEBUG) + const char* filename = __FILE__; + const char* message = _sdtx_log_messages[log_item]; + #else + const char* filename = 0; + const char* message = 0; + #endif + _sdtx.desc.logger.func("sdtx", log_level, log_item, message, line_nr, filename, _sdtx.desc.logger.user_data); + } + else { + // for log level PANIC it would be 'undefined behaviour' to continue + if (log_level == 0) { + abort(); + } + } +} + +// ███ ███ ███████ ███ ███ ██████ ██████ ██ ██ +// ████ ████ ██ ████ ████ ██ ██ ██ ██ ██ ██ +// ██ ████ ██ █████ ██ ████ ██ ██ ██ ██████ ████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ███████ ██ ██ ██████ ██ ██ ██ +// +// >>memory +static void _sdtx_clear(void* ptr, size_t size) { + SOKOL_ASSERT(ptr && (size > 0)); + memset(ptr, 0, size); +} + +static void* _sdtx_malloc(size_t size) { + SOKOL_ASSERT(size > 0); + void* ptr; + if (_sdtx.desc.allocator.alloc) { + ptr = _sdtx.desc.allocator.alloc(size, _sdtx.desc.allocator.user_data); + } + else { + ptr = malloc(size); + } + if (0 == ptr) { + _SDTX_PANIC(MALLOC_FAILED); + } + return ptr; +} + +static void* _sdtx_malloc_clear(size_t size) { + void* ptr = _sdtx_malloc(size); + _sdtx_clear(ptr, size); + return ptr; +} + +static void _sdtx_free(void* ptr) { + if (_sdtx.desc.allocator.free) { + _sdtx.desc.allocator.free(ptr, _sdtx.desc.allocator.user_data); + } + else { + free(ptr); + } +} + +// ██████ ██████ ███ ██ ████████ ███████ ██ ██ ████████ ██████ ██████ ██████ ██ +// ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ █████ ███ ██ ██████ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██████ ██████ ██ ████ ██ ███████ ██ ██ ██ ██ ██████ ██████ ███████ +// +// >>context pool +static void _sdtx_init_pool(_sdtx_pool_t* pool, int num) { + SOKOL_ASSERT(pool && (num >= 1)); + /* slot 0 is reserved for the 'invalid id', so bump the pool size by 1 */ + pool->size = num + 1; + pool->queue_top = 0; + /* generation counters indexable by pool slot index, slot 0 is reserved */ + size_t gen_ctrs_size = sizeof(uint32_t) * (size_t)pool->size; + pool->gen_ctrs = (uint32_t*) _sdtx_malloc_clear(gen_ctrs_size); + /* it's not a bug to only reserve 'num' here */ + pool->free_queue = (int*) _sdtx_malloc_clear(sizeof(int) * (size_t)num); + /* never allocate the zero-th pool item since the invalid id is 0 */ + for (int i = pool->size-1; i >= 1; i--) { + pool->free_queue[pool->queue_top++] = i; + } +} + +static void _sdtx_discard_pool(_sdtx_pool_t* pool) { + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + _sdtx_free(pool->free_queue); + pool->free_queue = 0; + SOKOL_ASSERT(pool->gen_ctrs); + _sdtx_free(pool->gen_ctrs); + pool->gen_ctrs = 0; + pool->size = 0; + pool->queue_top = 0; +} + +static int _sdtx_pool_alloc_index(_sdtx_pool_t* pool) { + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + if (pool->queue_top > 0) { + int slot_index = pool->free_queue[--pool->queue_top]; + SOKOL_ASSERT((slot_index > 0) && (slot_index < pool->size)); + return slot_index; + } + else { + /* pool exhausted */ + return _SDTX_INVALID_SLOT_INDEX; + } +} + +static void _sdtx_pool_free_index(_sdtx_pool_t* pool, int slot_index) { + SOKOL_ASSERT((slot_index > _SDTX_INVALID_SLOT_INDEX) && (slot_index < pool->size)); + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + SOKOL_ASSERT(pool->queue_top < pool->size); + #ifdef SOKOL_DEBUG + /* debug check against double-free */ + for (int i = 0; i < pool->queue_top; i++) { + SOKOL_ASSERT(pool->free_queue[i] != slot_index); + } + #endif + pool->free_queue[pool->queue_top++] = slot_index; + SOKOL_ASSERT(pool->queue_top <= (pool->size-1)); +} + +static void _sdtx_setup_context_pool(const sdtx_desc_t* desc) { + SOKOL_ASSERT(desc); + /* note: the pool will have an additional item, since slot 0 is reserved */ + SOKOL_ASSERT((desc->context_pool_size > 0) && (desc->context_pool_size < _SDTX_MAX_POOL_SIZE)); + _sdtx_init_pool(&_sdtx.context_pool.pool, desc->context_pool_size); + size_t pool_byte_size = sizeof(_sdtx_context_t) * (size_t)_sdtx.context_pool.pool.size; + _sdtx.context_pool.contexts = (_sdtx_context_t*) _sdtx_malloc_clear(pool_byte_size); +} + +static void _sdtx_discard_context_pool(void) { + SOKOL_ASSERT(_sdtx.context_pool.contexts); + _sdtx_free(_sdtx.context_pool.contexts); + _sdtx.context_pool.contexts = 0; + _sdtx_discard_pool(&_sdtx.context_pool.pool); +} + +/* allocate the slot at slot_index: + - bump the slot's generation counter + - create a resource id from the generation counter and slot index + - set the slot's id to this id + - set the slot's state to ALLOC + - return the resource id +*/ +static uint32_t _sdtx_slot_alloc(_sdtx_pool_t* pool, _sdtx_slot_t* slot, int slot_index) { + /* FIXME: add handling for an overflowing generation counter, + for now, just overflow (another option is to disable + the slot) + */ + SOKOL_ASSERT(pool && pool->gen_ctrs); + SOKOL_ASSERT((slot_index > _SDTX_INVALID_SLOT_INDEX) && (slot_index < pool->size)); + SOKOL_ASSERT((slot->state == SG_RESOURCESTATE_INITIAL) && (slot->id == SG_INVALID_ID)); + uint32_t ctr = ++pool->gen_ctrs[slot_index]; + slot->id = (ctr<<_SDTX_SLOT_SHIFT)|(slot_index & _SDTX_SLOT_MASK); + slot->state = SG_RESOURCESTATE_ALLOC; + return slot->id; +} + +/* extract slot index from id */ +static int _sdtx_slot_index(uint32_t id) { + int slot_index = (int) (id & _SDTX_SLOT_MASK); + SOKOL_ASSERT(_SDTX_INVALID_SLOT_INDEX != slot_index); + return slot_index; +} + +/* get context pointer without id-check */ +static _sdtx_context_t* _sdtx_context_at(uint32_t ctx_id) { + SOKOL_ASSERT(SG_INVALID_ID != ctx_id); + int slot_index = _sdtx_slot_index(ctx_id); + SOKOL_ASSERT((slot_index > _SDTX_INVALID_SLOT_INDEX) && (slot_index < _sdtx.context_pool.pool.size)); + return &_sdtx.context_pool.contexts[slot_index]; +} + +/* get context pointer with id-check, returns 0 if no match */ +static _sdtx_context_t* _sdtx_lookup_context(uint32_t ctx_id) { + if (SG_INVALID_ID != ctx_id) { + _sdtx_context_t* ctx = _sdtx_context_at(ctx_id); + if (ctx->slot.id == ctx_id) { + return ctx; + } + } + return 0; +} + +/* make context handle from raw uint32_t id */ +static sdtx_context _sdtx_make_ctx_id(uint32_t ctx_id) { + sdtx_context ctx; + ctx.id = ctx_id; + return ctx; +} + +static sdtx_context _sdtx_alloc_context(void) { + sdtx_context ctx_id; + int slot_index = _sdtx_pool_alloc_index(&_sdtx.context_pool.pool); + if (_SDTX_INVALID_SLOT_INDEX != slot_index) { + ctx_id = _sdtx_make_ctx_id(_sdtx_slot_alloc(&_sdtx.context_pool.pool, &_sdtx.context_pool.contexts[slot_index].slot, slot_index)); + } + else { + /* pool is exhausted */ + ctx_id = _sdtx_make_ctx_id(SG_INVALID_ID); + } + return ctx_id; +} + +static sdtx_context_desc_t _sdtx_context_desc_defaults(const sdtx_context_desc_t* desc) { + sdtx_context_desc_t res = *desc; + res.max_commands = _sdtx_def(res.max_commands, _SDTX_DEFAULT_MAX_COMMANDS); + res.char_buf_size = _sdtx_def(res.char_buf_size, _SDTX_DEFAULT_CHAR_BUF_SIZE); + res.canvas_width = _sdtx_def(res.canvas_width, _SDTX_DEFAULT_CANVAS_WIDTH); + res.canvas_height = _sdtx_def(res.canvas_height, _SDTX_DEFAULT_CANVAS_HEIGHT); + res.tab_width = _sdtx_def(res.tab_width, _SDTX_DEFAULT_TAB_WIDTH); + /* keep pixel format attrs are passed as is into pipeline creation */ + SOKOL_ASSERT(res.char_buf_size > 0); + SOKOL_ASSERT(res.canvas_width > 0.0f); + SOKOL_ASSERT(res.canvas_height > 0.0f); + return res; +} + +static void _sdtx_set_layer(_sdtx_context_t* ctx, int layer_id); +static void _sdtx_rewind(_sdtx_context_t* ctx) { + SOKOL_ASSERT(ctx); + ctx->frame_id++; + ctx->vertices.next = 0; + ctx->commands.next = 0; + _sdtx_set_layer(ctx, 0); + ctx->cur_font = 0; + ctx->pos.x = 0.0f; + ctx->pos.y = 0.0f; +} + +static void _sdtx_commit_listener(void* userdata) { + _sdtx_context_t* ctx = _sdtx_lookup_context((uint32_t)(uintptr_t)userdata); + if (ctx) { + _sdtx_rewind(ctx); + } +} + +static sg_commit_listener _sdtx_make_commit_listener(_sdtx_context_t* ctx) { + sg_commit_listener listener = { _sdtx_commit_listener, (void*)(uintptr_t)(ctx->slot.id) }; + return listener; +} + +static void _sdtx_init_context(sdtx_context ctx_id, const sdtx_context_desc_t* in_desc) { + sg_push_debug_group("sokol-debugtext"); + + SOKOL_ASSERT((ctx_id.id != SG_INVALID_ID) && in_desc); + _sdtx_context_t* ctx = _sdtx_lookup_context(ctx_id.id); + SOKOL_ASSERT(ctx); + ctx->desc = _sdtx_context_desc_defaults(in_desc); + // NOTE: frame_id must be non-zero, so that updates trigger in first frame + ctx->frame_id = 1; + + ctx->vertices.cap = 6 * ctx->desc.char_buf_size; + const size_t vbuf_size = (size_t)ctx->vertices.cap * sizeof(_sdtx_vertex_t); + ctx->vertices.ptr = (_sdtx_vertex_t*) _sdtx_malloc(vbuf_size); + + ctx->commands.cap = ctx->desc.max_commands; + ctx->commands.ptr = (_sdtx_command_t*) _sdtx_malloc((size_t)ctx->commands.cap * sizeof(_sdtx_command_t)); + _sdtx_set_layer(ctx, 0); + + sg_buffer_desc vbuf_desc; + _sdtx_clear(&vbuf_desc, sizeof(vbuf_desc)); + vbuf_desc.size = vbuf_size; + vbuf_desc.type = SG_BUFFERTYPE_VERTEXBUFFER; + vbuf_desc.usage = SG_USAGE_STREAM; + vbuf_desc.label = "sdtx-vbuf"; + ctx->vbuf = sg_make_buffer(&vbuf_desc); + SOKOL_ASSERT(SG_INVALID_ID != ctx->vbuf.id); + + sg_pipeline_desc pip_desc; + _sdtx_clear(&pip_desc, sizeof(pip_desc)); + pip_desc.layout.buffers[0].stride = sizeof(_sdtx_vertex_t); + pip_desc.layout.attrs[0].format = SG_VERTEXFORMAT_FLOAT2; + pip_desc.layout.attrs[1].format = SG_VERTEXFORMAT_USHORT2N; + pip_desc.layout.attrs[2].format = SG_VERTEXFORMAT_UBYTE4N; + pip_desc.shader = _sdtx.shader; + pip_desc.index_type = SG_INDEXTYPE_NONE; + pip_desc.sample_count = ctx->desc.sample_count; + pip_desc.depth.pixel_format = ctx->desc.depth_format; + pip_desc.colors[0].pixel_format = ctx->desc.color_format; + pip_desc.colors[0].blend.enabled = true; + pip_desc.colors[0].blend.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA; + pip_desc.colors[0].blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + pip_desc.colors[0].blend.src_factor_alpha = SG_BLENDFACTOR_ZERO; + pip_desc.colors[0].blend.dst_factor_alpha = SG_BLENDFACTOR_ONE; + pip_desc.label = "sdtx-pipeline"; + ctx->pip = sg_make_pipeline(&pip_desc); + SOKOL_ASSERT(SG_INVALID_ID != ctx->pip.id); + + ctx->canvas_size.x = ctx->desc.canvas_width; + ctx->canvas_size.y = ctx->desc.canvas_height; + ctx->glyph_size.x = 8.0f / ctx->canvas_size.x; + ctx->glyph_size.y = 8.0f / ctx->canvas_size.y; + ctx->tab_width = (float) ctx->desc.tab_width; + ctx->color = _SDTX_DEFAULT_COLOR; + + if (!sg_add_commit_listener(_sdtx_make_commit_listener(ctx))) { + _SDTX_ERROR(ADD_COMMIT_LISTENER_FAILED); + } + sg_pop_debug_group(); +} + +static void _sdtx_destroy_context(sdtx_context ctx_id) { + _sdtx_context_t* ctx = _sdtx_lookup_context(ctx_id.id); + if (ctx) { + if (ctx->vertices.ptr) { + _sdtx_free(ctx->vertices.ptr); + ctx->vertices.ptr = 0; + ctx->vertices.cap = 0; + ctx->vertices.next = 0; + } + if (ctx->commands.ptr) { + _sdtx_free(ctx->commands.ptr); + ctx->commands.ptr = 0; + ctx->commands.cap = 0; + ctx->commands.next = 0; + } + sg_push_debug_group("sokol_debugtext"); + sg_destroy_buffer(ctx->vbuf); + sg_destroy_pipeline(ctx->pip); + sg_remove_commit_listener(_sdtx_make_commit_listener(ctx)); + sg_pop_debug_group(); + _sdtx_clear(ctx, sizeof(*ctx)); + _sdtx_pool_free_index(&_sdtx.context_pool.pool, _sdtx_slot_index(ctx_id.id)); + } +} + +static bool _sdtx_is_default_context(sdtx_context ctx_id) { + return ctx_id.id == SDTX_DEFAULT_CONTEXT.id; +} + +// ███ ███ ██ ███████ ██████ +// ████ ████ ██ ██ ██ +// ██ ████ ██ ██ ███████ ██ +// ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ███████ ██████ +// +// >>misc + +/* unpack linear 8x8 bits-per-pixel font data into 2D byte-per-pixel texture data */ +static void _sdtx_unpack_font(const sdtx_font_desc_t* font_desc, uint8_t* out_pixels) { + SOKOL_ASSERT(font_desc->data.ptr); + SOKOL_ASSERT((font_desc->data.size > 0) && ((font_desc->data.size % 8) == 0)); + SOKOL_ASSERT(font_desc->first_char <= font_desc->last_char); + SOKOL_ASSERT((size_t)(((font_desc->last_char - font_desc->first_char) + 1) * 8) == font_desc->data.size); + const uint8_t* ptr = (const uint8_t*) font_desc->data.ptr; + for (int chr = font_desc->first_char; chr <= font_desc->last_char; chr++) { + for (int line = 0; line < 8; line++) { + uint8_t bits = *ptr++; + for (int x = 0; x < 8; x++) { + out_pixels[line*256*8 + chr*8 + x] = ((bits>>(7-x)) & 1) ? 0xFF : 0x00; + } + } + } +} + +static void _sdtx_setup_common(void) { + + /* common printf formatting buffer */ + _sdtx.fmt_buf_size = (uint32_t) _sdtx.desc.printf_buf_size + 1; + _sdtx.fmt_buf = (char*) _sdtx_malloc_clear(_sdtx.fmt_buf_size); + + sg_push_debug_group("sokol-debugtext"); + + /* common shader for all contexts */ + sg_shader_desc shd_desc; + _sdtx_clear(&shd_desc, sizeof(shd_desc)); + shd_desc.label = "sokol-debugtext-shader"; + shd_desc.attrs[0].name = "position"; + shd_desc.attrs[1].name = "texcoord0"; + shd_desc.attrs[2].name = "color0"; + shd_desc.attrs[0].sem_name = "TEXCOORD"; + shd_desc.attrs[0].sem_index = 0; + shd_desc.attrs[1].sem_name = "TEXCOORD"; + shd_desc.attrs[1].sem_index = 1; + shd_desc.attrs[2].sem_name = "TEXCOORD"; + shd_desc.attrs[2].sem_index = 2; + shd_desc.fs.images[0].name = "tex"; + shd_desc.fs.images[0].image_type = SG_IMAGETYPE_2D; + shd_desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; + #if defined(SOKOL_GLCORE33) + shd_desc.vs.source = _sdtx_vs_src_glsl330; + shd_desc.fs.source = _sdtx_fs_src_glsl330; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _sdtx_vs_src_glsl300es; + shd_desc.fs.source = _sdtx_fs_src_glsl300es; + #elif defined(SOKOL_METAL) + shd_desc.vs.entry = "main0"; + shd_desc.fs.entry = "main0"; + switch (sg_query_backend()) { + case SG_BACKEND_METAL_MACOS: + shd_desc.vs.bytecode = SG_RANGE(_sdtx_vs_bytecode_metal_macos); + shd_desc.fs.bytecode = SG_RANGE(_sdtx_fs_bytecode_metal_macos); + break; + case SG_BACKEND_METAL_IOS: + shd_desc.vs.bytecode = SG_RANGE(_sdtx_vs_bytecode_metal_ios); + shd_desc.fs.bytecode = SG_RANGE(_sdtx_fs_bytecode_metal_ios); + break; + default: + shd_desc.vs.source = _sdtx_vs_src_metal_sim; + shd_desc.fs.source = _sdtx_fs_src_metal_sim; + break; + } + #elif defined(SOKOL_D3D11) + shd_desc.vs.bytecode = SG_RANGE(_sdtx_vs_bytecode_d3d11); + shd_desc.fs.bytecode = SG_RANGE(_sdtx_fs_bytecode_d3d11); + #elif defined(SOKOL_WGPU) + shd_desc.vs.bytecode = SG_RANGE(_sdtx_vs_bytecode_wgpu); + shd_desc.fs.bytecode = SG_RANGE(_sdtx_fs_bytecode_wgpu); + #else + shd_desc.vs.source = _sdtx_vs_src_dummy; + shd_desc.fs.source = _sdtx_fs_src_dummy; + #endif + _sdtx.shader = sg_make_shader(&shd_desc); + SOKOL_ASSERT(SG_INVALID_ID != _sdtx.shader.id); + + /* unpack font data */ + memset(_sdtx.font_pixels, 0xFF, sizeof(_sdtx.font_pixels)); + const int unpacked_font_size = (int) (sizeof(_sdtx.font_pixels) / SDTX_MAX_FONTS); + for (int i = 0; i < SDTX_MAX_FONTS; i++) { + if (_sdtx.desc.fonts[i].data.ptr) { + _sdtx_unpack_font(&_sdtx.desc.fonts[i], &_sdtx.font_pixels[i * unpacked_font_size]); + } + } + + /* create font texture */ + sg_image_desc img_desc; + _sdtx_clear(&img_desc, sizeof(img_desc)); + img_desc.width = 256 * 8; + img_desc.height = SDTX_MAX_FONTS * 8; + img_desc.pixel_format = SG_PIXELFORMAT_R8; + img_desc.min_filter = SG_FILTER_NEAREST; + img_desc.mag_filter = SG_FILTER_NEAREST; + img_desc.wrap_u = SG_WRAP_CLAMP_TO_EDGE; + img_desc.wrap_v = SG_WRAP_CLAMP_TO_EDGE; + img_desc.data.subimage[0][0] = SG_RANGE(_sdtx.font_pixels); + img_desc.label = "sdtx-font-texture"; + _sdtx.font_img = sg_make_image(&img_desc); + SOKOL_ASSERT(SG_INVALID_ID != _sdtx.font_img.id); + + sg_pop_debug_group(); +} + +static void _sdtx_discard_common(void) { + sg_push_debug_group("sokol-debugtext"); + sg_destroy_image(_sdtx.font_img); + sg_destroy_shader(_sdtx.shader); + if (_sdtx.fmt_buf) { + _sdtx_free(_sdtx.fmt_buf); + _sdtx.fmt_buf = 0; + } + sg_pop_debug_group(); +} + +static uint32_t _sdtx_pack_rgbab(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + return (uint32_t)(((uint32_t)a<<24)|((uint32_t)b<<16)|((uint32_t)g<<8)|r); +} + +static float _sdtx_clamp(float v, float lo, float hi) { + if (v < lo) return lo; + else if (v > hi) return hi; + else return v; +} + +static uint32_t _sdtx_pack_rgbaf(float r, float g, float b, float a) { + uint8_t r_u8 = (uint8_t) (_sdtx_clamp(r, 0.0f, 1.0f) * 255.0f); + uint8_t g_u8 = (uint8_t) (_sdtx_clamp(g, 0.0f, 1.0f) * 255.0f); + uint8_t b_u8 = (uint8_t) (_sdtx_clamp(b, 0.0f, 1.0f) * 255.0f); + uint8_t a_u8 = (uint8_t) (_sdtx_clamp(a, 0.0f, 1.0f) * 255.0f); + return _sdtx_pack_rgbab(r_u8, g_u8, b_u8, a_u8); +} + +static void _sdtx_ctrl_char(_sdtx_context_t* ctx, uint8_t c) { + switch (c) { + case '\r': + ctx->pos.x = 0.0f; + break; + case '\n': + ctx->pos.x = 0.0f; + ctx->pos.y += 1.0f; + break; + case '\t': + ctx->pos.x = (ctx->pos.x - fmodf(ctx->pos.x, ctx->tab_width)) + ctx->tab_width; + break; + case ' ': + ctx->pos.x += 1.0f; + break; + } +} + +static _sdtx_vertex_t* _sdtx_next_vertex(_sdtx_context_t* ctx) { + if ((ctx->vertices.next + 6) <= ctx->vertices.cap) { + _sdtx_vertex_t* vx = &ctx->vertices.ptr[ctx->vertices.next]; + ctx->vertices.next += 6; + return vx; + } + else { + return 0; + } +} + +static _sdtx_command_t* _sdtx_cur_command(_sdtx_context_t* ctx) { + if (ctx->commands.next > 0) { + return &ctx->commands.ptr[ctx->commands.next - 1]; + } + else { + return 0; + } +} + +static _sdtx_command_t* _sdtx_next_command(_sdtx_context_t* ctx) { + if (ctx->commands.next < ctx->commands.cap) { + return &ctx->commands.ptr[ctx->commands.next++]; + } + else { + _SDTX_ERROR(COMMAND_BUFFER_FULL); + return 0; + } +} + +static void _sdtx_set_layer(_sdtx_context_t* ctx, int layer_id) { + ctx->cur_layer_id = layer_id; + _sdtx_command_t* cur_cmd = _sdtx_cur_command(ctx); + if (cur_cmd) { + if ((cur_cmd->num_vertices == 0) || (cur_cmd->layer_id == layer_id)) { + // no vertices recorded in current draw command, or layer hasn't changed, can just reuse this + cur_cmd->layer_id = layer_id; + } + else { + // layer has changed, need to start a new draw command + _sdtx_command_t* next_cmd = _sdtx_next_command(ctx); + if (next_cmd) { + next_cmd->layer_id = layer_id; + next_cmd->first_vertex = cur_cmd->first_vertex + cur_cmd->num_vertices; + next_cmd->num_vertices = 0; + } + } + } + else { + // first draw command in frame + _sdtx_command_t* next_cmd = _sdtx_next_command(ctx); + if (next_cmd) { + next_cmd->layer_id = layer_id; + next_cmd->first_vertex = 0; + next_cmd->num_vertices = 0; + } + } +} + +static void _sdtx_render_char(_sdtx_context_t* ctx, uint8_t c) { + _sdtx_vertex_t* vx = _sdtx_next_vertex(ctx); + _sdtx_command_t* cmd = _sdtx_cur_command(ctx); + if (vx && cmd) { + // update vertex count in current draw command + cmd->num_vertices += 6; + + const float x0 = (ctx->origin.x + ctx->pos.x) * ctx->glyph_size.x; + const float y0 = (ctx->origin.y + ctx->pos.y) * ctx->glyph_size.y; + const float x1 = x0 + ctx->glyph_size.x; + const float y1 = y0 + ctx->glyph_size.y; + + // glyph width and heigth in font texture space + // NOTE: the '+1' and '-2' fixes texture bleeding into the neighboring font texture cell + const uint16_t uvw = 0x10000 / 0x100; + const uint16_t uvh = 0x10000 / SDTX_MAX_FONTS; + const uint16_t u0 = (((uint16_t)c) * uvw) + 1; + const uint16_t v0 = (((uint16_t)ctx->cur_font) * uvh) + 1; + uint16_t u1 = (u0 + uvw) - 2; + uint16_t v1 = (v0 + uvh) - 2; + const uint32_t color = ctx->color; + + // write 6 vertices + vx->x=x0; vx->y=y0; vx->u = u0; vx->v = v0; vx->color = color; vx++; + vx->x=x1; vx->y=y0; vx->u = u1; vx->v = v0; vx->color = color; vx++; + vx->x=x1; vx->y=y1; vx->u = u1; vx->v = v1; vx->color = color; vx++; + + vx->x=x0; vx->y=y0; vx->u = u0; vx->v = v0; vx->color = color; vx++; + vx->x=x1; vx->y=y1; vx->u = u1; vx->v = v1; vx->color = color; vx++; + vx->x=x0; vx->y=y1; vx->u = u0; vx->v = v1; vx->color = color; vx++; + } + ctx->pos.x += 1.0f; +} + +static void _sdtx_put_char(_sdtx_context_t* ctx, char c) { + uint8_t c_u8 = (uint8_t)c; + if (c_u8 <= 32) { + _sdtx_ctrl_char(ctx, c_u8); + } + else { + _sdtx_render_char(ctx, c_u8); + } +} + +SOKOL_API_IMPL void _sdtx_draw_layer(_sdtx_context_t* ctx, int layer_id) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + SOKOL_ASSERT(ctx); + if ((ctx->vertices.next > 0) && (ctx->commands.next > 0)) { + sg_push_debug_group("sokol-debugtext"); + + if (ctx->update_frame_id != ctx->frame_id) { + ctx->update_frame_id = ctx->frame_id; + const sg_range range = { ctx->vertices.ptr, (size_t)ctx->vertices.next * sizeof(_sdtx_vertex_t) }; + sg_update_buffer(ctx->vbuf, &range); + } + + sg_apply_pipeline(ctx->pip); + sg_bindings bindings; + _sdtx_clear(&bindings, sizeof(bindings)); + bindings.vertex_buffers[0] = ctx->vbuf; + bindings.fs_images[0] = _sdtx.font_img; + sg_apply_bindings(&bindings); + for (int cmd_index = 0; cmd_index < ctx->commands.next; cmd_index++) { + const _sdtx_command_t* cmd = &ctx->commands.ptr[cmd_index]; + if (cmd->layer_id != layer_id) { + continue; + } + SOKOL_ASSERT((cmd->num_vertices % 6) == 0); + sg_draw(cmd->first_vertex, cmd->num_vertices, 1); + } + sg_pop_debug_group(); + } +} + + +static sdtx_desc_t _sdtx_desc_defaults(const sdtx_desc_t* desc) { + SOKOL_ASSERT((desc->allocator.alloc && desc->allocator.free) || (!desc->allocator.alloc && !desc->allocator.free)); + sdtx_desc_t res = *desc; + res.context_pool_size = _sdtx_def(res.context_pool_size, _SDTX_DEFAULT_CONTEXT_POOL_SIZE); + res.printf_buf_size = _sdtx_def(res.printf_buf_size, _SDTX_DEFAULT_PRINTF_BUF_SIZE); + for (int i = 0; i < SDTX_MAX_FONTS; i++) { + if (res.fonts[i].data.ptr) { + res.fonts[i].last_char = _sdtx_def(res.fonts[i].last_char, 255); + } + } + res.context = _sdtx_context_desc_defaults(&res.context); + SOKOL_ASSERT(res.context_pool_size > 0); + SOKOL_ASSERT(res.printf_buf_size > 0); + SOKOL_ASSERT(res.context.char_buf_size > 0); + return res; +} + +// ██████ ██ ██ ██████ ██ ██ ██████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██████ ██ ██ ██████ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██████ ██████ ███████ ██ ██████ +// +// >>public +SOKOL_API_IMPL void sdtx_setup(const sdtx_desc_t* desc) { + SOKOL_ASSERT(desc); + _sdtx_clear(&_sdtx, sizeof(_sdtx)); + _sdtx.init_cookie = _SDTX_INIT_COOKIE; + _sdtx.desc = _sdtx_desc_defaults(desc); + _sdtx_setup_context_pool(&_sdtx.desc); + _sdtx_setup_common(); + _sdtx.def_ctx_id = sdtx_make_context(&_sdtx.desc.context); + SOKOL_ASSERT(SDTX_DEFAULT_CONTEXT.id == _sdtx.def_ctx_id.id); + sdtx_set_context(_sdtx.def_ctx_id); +} + +SOKOL_API_IMPL void sdtx_shutdown(void) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + for (int i = 0; i < _sdtx.context_pool.pool.size; i++) { + _sdtx_context_t* ctx = &_sdtx.context_pool.contexts[i]; + _sdtx_destroy_context(_sdtx_make_ctx_id(ctx->slot.id)); + } + _sdtx_discard_common(); + _sdtx_discard_context_pool(); + _sdtx.init_cookie = 0; +} + +SOKOL_API_IMPL sdtx_font_desc_t sdtx_font_kc853(void) { + sdtx_font_desc_t desc = { { _sdtx_font_kc853, sizeof(_sdtx_font_kc853) }, 0, 255 }; + return desc; +} + +SOKOL_API_IMPL sdtx_font_desc_t sdtx_font_kc854(void) { + sdtx_font_desc_t desc = { { _sdtx_font_kc854, sizeof(_sdtx_font_kc854) }, 0, 255 }; + return desc; +} + +SOKOL_API_IMPL sdtx_font_desc_t sdtx_font_z1013(void) { + sdtx_font_desc_t desc = { { _sdtx_font_z1013, sizeof(_sdtx_font_z1013) }, 0, 255 }; + return desc; +} + +SOKOL_API_IMPL sdtx_font_desc_t sdtx_font_cpc(void) { + sdtx_font_desc_t desc = { { _sdtx_font_cpc, sizeof(_sdtx_font_cpc) }, 0, 255 }; + return desc; +} + +SOKOL_API_IMPL sdtx_font_desc_t sdtx_font_c64(void) { + sdtx_font_desc_t desc = { { _sdtx_font_c64, sizeof(_sdtx_font_c64) }, 0, 255 }; + return desc; +} + +SOKOL_API_IMPL sdtx_font_desc_t sdtx_font_oric(void) { + sdtx_font_desc_t desc = { { _sdtx_font_oric, sizeof(_sdtx_font_oric) }, 0, 255 }; + return desc; +} + +SOKOL_API_IMPL sdtx_context sdtx_make_context(const sdtx_context_desc_t* desc) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + SOKOL_ASSERT(desc); + sdtx_context ctx_id = _sdtx_alloc_context(); + if (ctx_id.id != SG_INVALID_ID) { + _sdtx_init_context(ctx_id, desc); + } + else { + _SDTX_ERROR(CONTEXT_POOL_EXHAUSTED); + } + return ctx_id; +} + +SOKOL_API_IMPL void sdtx_destroy_context(sdtx_context ctx_id) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + if (_sdtx_is_default_context(ctx_id)) { + _SDTX_ERROR(CANNOT_DESTROY_DEFAULT_CONTEXT); + return; + } + _sdtx_destroy_context(ctx_id); + // re-validate the current context pointer (this will return a nullptr + // if we just destroyed the current context) + _sdtx.cur_ctx = _sdtx_lookup_context(_sdtx.cur_ctx_id.id); +} + +SOKOL_API_IMPL void sdtx_set_context(sdtx_context ctx_id) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + if (_sdtx_is_default_context(ctx_id)) { + _sdtx.cur_ctx_id = _sdtx.def_ctx_id; + } + else { + _sdtx.cur_ctx_id = ctx_id; + } + // this may return a nullptr if the ctx_id handle is invalid + _sdtx.cur_ctx = _sdtx_lookup_context(_sdtx.cur_ctx_id.id); +} + +SOKOL_API_IMPL sdtx_context sdtx_get_context(void) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + return _sdtx.cur_ctx_id; +} + +SOKOL_API_IMPL sdtx_context sdtx_default_context(void) { + return SDTX_DEFAULT_CONTEXT; +} + +SOKOL_API_IMPL void sdtx_layer(int layer_id) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + _sdtx_set_layer(ctx, layer_id); + } +} + +SOKOL_API_IMPL void sdtx_font(int font_index) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + SOKOL_ASSERT((font_index >= 0) && (font_index < SDTX_MAX_FONTS)); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->cur_font = font_index; + } +} + +SOKOL_API_IMPL void sdtx_canvas(float w, float h) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + SOKOL_ASSERT((w > 0.0f) && (h > 0.0f)); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->canvas_size.x = w; + ctx->canvas_size.y = h; + ctx->glyph_size.x = (8.0f / ctx->canvas_size.x); + ctx->glyph_size.y = (8.0f / ctx->canvas_size.y); + ctx->origin.x = 0.0f; + ctx->origin.y = 0.0f; + ctx->pos.x = 0.0f; + ctx->pos.y = 0.0f; + } +} + +SOKOL_API_IMPL void sdtx_origin(float x, float y) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->origin.x = x; + ctx->origin.y = y; + } +} + +SOKOL_API_IMPL void sdtx_home(void) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->pos.x = 0.0f; + ctx->pos.y = 0.0f; + } +} + +SOKOL_API_IMPL void sdtx_pos(float x, float y) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->pos.x = x; + ctx->pos.y = y; + } +} + +SOKOL_API_IMPL void sdtx_pos_x(float x) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->pos.x = x; + } +} + +SOKOL_API_IMPL void sdtx_pos_y(float y) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->pos.y = y; + } +} + +SOKOL_API_IMPL void sdtx_move(float dx, float dy) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->pos.x += dx; + ctx->pos.y += dy; + } +} + +SOKOL_API_IMPL void sdtx_move_x(float dx) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->pos.x += dx; + } +} + +SOKOL_API_IMPL void sdtx_move_y(float dy) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->pos.y += dy; + } +} + +SOKOL_API_IMPL void sdtx_crlf(void) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->pos.x = 0.0f; + ctx->pos.y += 1.0f; + } +} + +SOKOL_API_IMPL void sdtx_color3b(uint8_t r, uint8_t g, uint8_t b) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->color = _sdtx_pack_rgbab(r, g, b, 255); + } +} + +SOKOL_API_IMPL void sdtx_color3f(float r, float g, float b) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->color = _sdtx_pack_rgbaf(r, g, b, 1.0f); + } +} + +SOKOL_API_IMPL void sdtx_color4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->color = _sdtx_pack_rgbab(r, g, b, a); + } +} + +SOKOL_API_IMPL void sdtx_color4f(float r, float g, float b, float a) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->color = _sdtx_pack_rgbaf(r, g, b, a); + } +} + +SOKOL_API_IMPL void sdtx_color1i(uint32_t rgba) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + ctx->color = rgba; + } +} + +SOKOL_DEBUGTEXT_API_DECL void sdtx_putc(char chr) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + _sdtx_put_char(ctx, chr); + } +} + +SOKOL_DEBUGTEXT_API_DECL void sdtx_puts(const char* str) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + char chr; + while (0 != (chr = *str++)) { + _sdtx_put_char(ctx, chr); + } + } +} + +SOKOL_DEBUGTEXT_API_DECL void sdtx_putr(const char* str, int len) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + for (int i = 0; i < len; i++) { + char chr = str[i]; + if (0 == chr) { + break; + } + _sdtx_put_char(ctx, chr); + } + } +} + +SOKOL_DEBUGTEXT_API_DECL int sdtx_vprintf(const char* fmt, va_list args) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + SOKOL_ASSERT(_sdtx.fmt_buf && (_sdtx.fmt_buf_size >= 2)); + int res = SOKOL_VSNPRINTF(_sdtx.fmt_buf, _sdtx.fmt_buf_size, fmt, args); + // make sure we're 0-terminated in case we're on an old MSVC + _sdtx.fmt_buf[_sdtx.fmt_buf_size-1] = 0; + sdtx_puts(_sdtx.fmt_buf); + return res; +} + +SOKOL_DEBUGTEXT_API_DECL int sdtx_printf(const char* fmt, ...) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + SOKOL_ASSERT(_sdtx.fmt_buf && (_sdtx.fmt_buf_size >= 2)); + va_list args; + va_start(args, fmt); + int res = SOKOL_VSNPRINTF(_sdtx.fmt_buf, _sdtx.fmt_buf_size, fmt, args); + va_end(args); + // make sure we're 0-terminated in case we're on an old MSVC + _sdtx.fmt_buf[_sdtx.fmt_buf_size-1] = 0; + sdtx_puts(_sdtx.fmt_buf); + return res; +} + +SOKOL_API_IMPL void sdtx_draw(void) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + _sdtx_draw_layer(ctx, 0); + } +} + +SOKOL_API_IMPL void sdtx_context_draw(sdtx_context ctx_id) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx_lookup_context(ctx_id.id); + if (ctx) { + _sdtx_draw_layer(ctx, 0); + } +} + +SOKOL_API_IMPL void sdtx_draw_layer(int layer_id) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx.cur_ctx; + if (ctx) { + _sdtx_draw_layer(ctx, layer_id); + } +} + +SOKOL_API_IMPL void sdtx_context_draw_layer(sdtx_context ctx_id, int layer_id) { + SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + _sdtx_context_t* ctx = _sdtx_lookup_context(ctx_id.id); + if (ctx) { + _sdtx_draw_layer(ctx, layer_id); + } +} +#endif /* SOKOL_DEBUGTEXT_IMPL */ diff --git a/source/engine/thirdparty/sokol/sokol_fontstash.h b/source/engine/thirdparty/sokol/sokol_fontstash.h new file mode 100644 index 0000000..9bf406f --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_fontstash.h @@ -0,0 +1,1904 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_FONTSTASH_IMPL) +#define SOKOL_FONTSTASH_IMPL +#endif +#ifndef SOKOL_FONTSTASH_INCLUDED +/* + sokol_fontstash.h -- renderer for https://github.com/memononen/fontstash + on top of sokol_gl.h + + Project URL: https://github.com/floooh/sokol + + Do this: + #define SOKOL_IMPL or + #define SOKOL_FONTSTASH_IMPL + + before you include this file in *one* C or C++ file to create the + implementation. + + The following defines are used by the implementation to select the + platform-specific embedded shader code (these are the same defines as + used by sokol_gfx.h and sokol_app.h): + + SOKOL_GLCORE33 + SOKOL_GLES3 + SOKOL_D3D11 + SOKOL_METAL + + ...optionally provide the following macros to override defaults: + + SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) + SOKOL_FONTSTASH_API_DECL - public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_FONTSTASH_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) + + Include the following headers before including sokol_fontstash.h: + + sokol_gfx.h + + Additionally include the following headers for including the sokol_fontstash.h + implementation: + + sokol_gl.h + + HOW TO + ====== + --- First initialize sokol-gfx and sokol-gl as usual: + + sg_setup(&(sg_desc){...}); + sgl_setup(&(sgl_desc){...}); + + --- Create at least one fontstash context with sfons_create() (this replaces + glfonsCreate() from fontstash.h's example GL renderer: + + FONScontext* ctx = sfons_create(&(sfons_desc_t){ + .width = atlas_width, + .height = atlas_height, + }); + + Each FONScontext manages one font atlas texture which can hold rasterized + glyphs for multiple fonts. + + --- From here on, use fontstash.h's functions "as usual" to add TTF + font data and draw text. Note that (just like with sokol-gl), text + rendering can happen anywhere in the frame, not only inside + a sokol-gfx rendering pass. + + --- You can use the helper function + + uint32_t sfons_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a) + + To convert a 0..255 RGBA color into a packed uint32_t color value + expected by fontstash.h. + + --- Once per frame before calling sgl_draw(), call: + + sfons_flush(FONScontext* ctx) + + ...this will update the dynamic sokol-gfx texture with the latest font + atlas content. + + --- To actually render the text (and any other sokol-gl draw commands), + call sgl_draw() inside a sokol-gfx frame. + + --- NOTE that you can mix fontstash.h calls with sokol-gl calls to mix + text rendering with sokol-gl rendering. You can also use + sokol-gl's matrix stack to position fontstash.h text in 3D. + + --- finally on application shutdown, call: + + sfons_destroy(FONScontext* ctx) + + before sgl_shutdown() and sg_shutdown() + + + WHAT HAPPENS UNDER THE HOOD: + ============================ + + FONScontext* sfons_create(const sfons_desc_t* desc) + - creates a sokol-gfx shader compatible with sokol-gl + - creates an sgl_pipeline object with alpha-blending using + this shader + - creates a 1-byte-per-pixel font atlas texture via sokol-gfx + (pixel format SG_PIXELFORMAT_R8) + + fonsDrawText(): + - this will call the following sequence of sokol-gl functions: + + sgl_enable_texture(); + sgl_texture(...); + sgl_push_pipeline(); + sgl_load_pipeline(...); + sgl_begin_triangles(); + for each vertex: + sgl_v2f_t2f_c1i(...); + sgl_end(); + sgl_pop_pipeline(); + sgl_disable_texture(); + + - note that sokol-gl will merge several sgl_*_begin/sgl_end pairs + into a single draw call if no relevant state has changed, typically + all calls to fonsDrawText() will be merged into a single draw call + as long as all calls use the same FONScontext + + sfons_flush(FONScontext* ctx): + - this will call sg_update_image() on the font atlas texture + if fontstash.h has added any rasterized glyphs since the last + frame + + sfons_destroy(FONScontext* ctx): + - destroy the font atlas texture, sgl_pipeline and sg_shader objects + + + MEMORY ALLOCATION OVERRIDE + ========================== + You can override the memory allocation functions at initialization time + like this: + + void* my_alloc(size_t size, void* user_data) { + return malloc(size); + } + + void my_free(void* ptr, void* user_data) { + free(ptr); + } + + ... + FONScontext* fons_context = sfons_create(&(sfons_desc_t){ + ... + .allocator = { + .alloc = my_alloc, + .free = my_free, + .user_data = ..., + } + }); + ... + + If no overrides are provided, malloc and free will be used. Please + note that this doesn't affect any memory allocation performed + in fontstash.h (unfortunately those are hardwired to malloc/free). + + LICENSE + ======= + zlib/libpng license + + Copyright (c) 2018 Andre Weissflog + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_FONTSTASH_INCLUDED (1) +#include +#include +#include // size_t + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_fontstash.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_FONTSTASH_API_DECL) +#define SOKOL_FONTSTASH_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_FONTSTASH_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_FONTSTASH_IMPL) +#define SOKOL_FONTSTASH_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_FONTSTASH_API_DECL __declspec(dllimport) +#else +#define SOKOL_FONTSTASH_API_DECL extern +#endif +#endif +#ifdef __cplusplus +extern "C" { +#endif + +/* + sfonst_allocator_t + + Used in sfons_desc_t to provide custom memory-alloc and -free functions + to sokol_fontstash.h. If memory management should be overridden, both the + alloc and free function must be provided (e.g. it's not valid to + override one function but not the other). + + NOTE that this does not affect memory allocation calls inside + fontstash.h +*/ +typedef struct sfons_allocator_t { + void* (*alloc)(size_t size, void* user_data); + void (*free)(void* ptr, void* user_data); + void* user_data; +} sfons_allocator_t; + +typedef struct sfons_desc_t { + int width; // initial width of font atlas texture (default: 512, must be power of 2) + int height; // initial height of font atlas texture (default: 512, must be power of 2) + sfons_allocator_t allocator; // optional memory allocation overrides +} sfons_desc_t; + +SOKOL_FONTSTASH_API_DECL FONScontext* sfons_create(const sfons_desc_t* desc); +SOKOL_FONTSTASH_API_DECL void sfons_destroy(FONScontext* ctx); +SOKOL_FONTSTASH_API_DECL void sfons_flush(FONScontext* ctx); +SOKOL_FONTSTASH_API_DECL uint32_t sfons_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* SOKOL_FONTSTASH_INCLUDED */ + +/*-- IMPLEMENTATION ----------------------------------------------------------*/ +#ifdef SOKOL_FONTSTASH_IMPL +#define SOKOL_FONTSTASH_IMPL_INCLUDED (1) + +#if defined(SOKOL_MALLOC) || defined(SOKOL_CALLOC) || defined(SOKOL_FREE) +#error "SOKOL_MALLOC/CALLOC/FREE macros are no longer supported, please use sfons_desc_t.allocator to override memory allocation functions" +#endif + +#include // memset, memcpy +#include // malloc, free + +#if !defined(SOKOL_GL_INCLUDED) +#error "Please include sokol_gl.h before sokol_fontstash.h" +#endif +#if !defined(FONS_H) +#error "Please include fontstash.h before sokol_fontstash.h" +#endif + +#ifndef SOKOL_API_IMPL + #define SOKOL_API_IMPL +#endif +#ifndef SOKOL_DEBUG + #ifndef NDEBUG + #define SOKOL_DEBUG + #endif +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif +#ifndef SOKOL_UNREACHABLE + #define SOKOL_UNREACHABLE SOKOL_ASSERT(false) +#endif +#ifndef _SOKOL_UNUSED + #define _SOKOL_UNUSED(x) (void)(x) +#endif + +#if defined(SOKOL_GLCORE33) +/* + Embedded source code compiled with: + + sokol-shdc -i sfons.glsl -o sfons.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + + (not that for Metal and D3D11 byte code, sokol-shdc must be run + on macOS and Windows) + + @vs vs + uniform vs_params { + uniform mat4 mvp; + uniform mat4 tm; + }; + in vec4 position; + in vec2 texcoord0; + in vec4 color0; + in float psize; + out vec4 uv; + out vec4 color; + void main() { + gl_Position = mvp * position; + gl_PointSize = psize; + uv = tm * vec4(texcoord0, 0.0, 1.0); + color = color0; + } + @end + + @fs fs + uniform sampler2D tex; + in vec4 uv; + in vec4 color; + out vec4 frag_color; + void main() { + frag_color = vec4(1.0, 1.0, 1.0, texture(tex, uv.xy).r) * color; + } + @end + + @program sfontstash vs fs +*/ +static const char _sfons_vs_source_glsl330[478] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e, + 0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x73, + 0x69,0x7a,0x65,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76, + 0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f, + 0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74, + 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65, + 0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74, + 0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69, + 0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a, + 0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30, + 0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c, + 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f, + 0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70,0x73,0x69,0x7a, + 0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34, + 0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x76,0x73,0x5f, + 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28, + 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20, + 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20, + 0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _sfons_fs_source_glsl330[195] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20, + 0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63, + 0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76, + 0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x69,0x6e,0x20,0x76, + 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, + 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28, + 0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x74, + 0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x2e,0x78, + 0x79,0x29,0x2e,0x78,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_GLES3) +static const char _sfons_vs_source_glsl300es[481] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74, + 0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30, + 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20, + 0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70, + 0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d, + 0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65, + 0x63,0x34,0x28,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e, + 0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a, + 0x00, +}; +static const char _sfons_fs_source_glsl300es[268] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e, + 0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28, + 0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x2e,0x78,0x79,0x29,0x2e,0x78,0x29,0x20,0x2a, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_METAL) +static const uint8_t _sfons_vs_bytecode_metal_macos[3417] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x59,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0x0a,0x16,0x9b,0x1c,0x17,0xd6,0x38, + 0xd5,0x49,0x10,0x98,0x04,0x66,0x15,0xf9,0x7e,0x49,0x87,0x6c,0x57,0x88,0x31,0x1d, + 0xab,0xb6,0x09,0x92,0x56,0xe2,0x6f,0x4d,0x48,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x40,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x2a,0x00,0x04,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x70,0x73,0x69,0x7a,0x65,0x00,0x03, + 0x80,0x56,0x41,0x54,0x59,0x06,0x00,0x04,0x00,0x06,0x04,0x06,0x03,0x45,0x4e,0x44, + 0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00, + 0x00,0x14,0x00,0x00,0x00,0x24,0x0c,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0, + 0xde,0x21,0x0c,0x00,0x00,0x06,0x03,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00, + 0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32, + 0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45, + 0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44, + 0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8, + 0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00, + 0x00,0x89,0x00,0x00,0x00,0x1b,0xf6,0x25,0xf8,0xff,0xff,0xff,0xff,0x01,0x90,0x80, + 0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87,0x71,0xa0,0x07,0x76,0xc8,0x87,0x36, + 0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72,0x20,0x87,0x36,0x20,0x87,0x74,0xb0, + 0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88,0x07,0x79,0xa0,0x87,0x36,0x30,0x07, + 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1, + 0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e, + 0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c,0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87,0x72,0x98,0x87,0x79,0x68,0x03,0x78, + 0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x76,0x08, + 0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda, + 0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda,0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81, + 0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21,0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8, + 0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30,0x07,0x79,0x08,0x87,0x76,0x28,0x87, + 0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87,0x72,0x90,0x87,0x36,0x28,0x07,0x76, + 0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77,0x68,0x03,0x76,0x28,0x87,0x70,0x30, + 0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70,0x07,0x73,0x98,0x87,0x36,0x30,0x07, + 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01, + 0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1,0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c, + 0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08, + 0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36, + 0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d, + 0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d,0xca,0x81,0x1c,0xda,0x40,0x1f,0xca, + 0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x7a,0x90, + 0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38,0x87,0x36,0x68,0x87,0x70,0xa0,0x07, + 0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61, + 0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1,0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e, + 0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4, + 0xa1,0x1c,0x00,0x3c,0x00,0x08,0x7a,0x08,0x07,0x79,0x38,0x87,0x72,0xa0,0x87,0x36, + 0x30,0x87,0x72,0x08,0x07,0x7a,0xa8,0x07,0x79,0x28,0x87,0x79,0x00,0xda,0xc0,0x1c, + 0xe0,0x21,0x0e,0xec,0x00,0x20,0xea,0xc1,0x1d,0xe6,0x21,0x1c,0xcc,0xa1,0x1c,0xda, + 0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a, + 0x28,0x07,0x80,0xa8,0x87,0x79,0x28,0x87,0x36,0x98,0x87,0x77,0x30,0x07,0x7a,0x68, + 0x03,0x73,0x60,0x87,0x77,0x08,0x07,0x7a,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e,0xca, + 0x01,0xd8,0x60,0x08,0x05,0xb0,0x00,0x15,0x00,0x49,0x18,0x00,0x00,0x01,0x00,0x00, + 0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,0x00,0x24,0x00,0x00,0x00,0x32,0x22,0x48, + 0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90, + 0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x40,0x33,0x00,0xc3,0x08,0x04, + 0x70,0x97,0x34,0x45,0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x93,0xff,0x00, + 0x82,0x42,0x0c,0x98,0x08,0x21,0x80,0x61,0x04,0x01,0x48,0x82,0x30,0x13,0x35,0x0f, + 0xf4,0x20,0x0f,0xf5,0x30,0x0e,0xf4,0xe0,0x06,0xed,0x50,0x0e,0xf4,0x10,0x0e,0xec, + 0xa0,0x07,0x7a,0xd0,0x0e,0xe1,0x40,0x0f,0xf2,0x90,0x0e,0xf8,0x80,0x02,0x72,0x90, + 0x34,0x45,0x94,0x30,0xf9,0x95,0xf4,0x3f,0x40,0x04,0x30,0x12,0x12,0x4a,0x19,0x44, + 0x30,0x84,0x62,0x88,0x30,0x02,0x38,0x84,0x06,0x02,0xe6,0x08,0xc0,0x60,0x8e,0x00, + 0x14,0x06,0x11,0x02,0x61,0x18,0x81,0x58,0x46,0x00,0x00,0x00,0x00,0x13,0xb2,0x70, + 0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68, + 0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83, + 0x38,0x70,0x03,0x38,0xd8,0xf0,0x1e,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78, + 0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90, + 0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e, + 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76, + 0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x78,0x00,0x07,0x7a, + 0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x60, + 0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07, + 0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a, + 0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60, + 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72, + 0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0, + 0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07, + 0x79,0x20,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d, + 0x60,0x0f,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50, + 0x07,0x76,0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07, + 0x7a,0x50,0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a, + 0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0x60, + 0x0e,0x78,0x00,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07, + 0x6d,0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x49, + 0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xc8,0x02,0x01,0x00,0x00,0x09,0x00,0x00, + 0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43, + 0x5a,0x25,0x30,0x02,0x50,0x80,0x01,0x85,0x50,0x04,0x65,0x50,0x80,0x02,0x05,0x51, + 0x20,0xc4,0x46,0x00,0x00,0x79,0x18,0x00,0x00,0x15,0x01,0x00,0x00,0x1a,0x03,0x4c, + 0x10,0x95,0xbb,0x31,0xb4,0x30,0xb9,0xaf,0xb9,0x34,0xbd,0xb2,0x21,0xc6,0x12,0x28, + 0xc0,0x42,0x70,0x0d,0x82,0xe0,0xe0,0xd8,0xca,0x40,0x98,0x98,0xac,0x9a,0x40,0xec, + 0xca,0xe4,0xe6,0xd2,0xde,0xdc,0x40,0x72,0x60,0x64,0x5c,0x62,0x40,0x50,0xda,0xca, + 0xe8,0xc2,0xd8,0xcc,0xca,0x5a,0x72,0x60,0x64,0x5c,0x62,0x5c,0x68,0x72,0x52,0x86, + 0x08,0x8a,0x30,0xc4,0x58,0x82,0x05,0x59,0x04,0x16,0x4d,0x65,0x74,0x61,0x6c,0x43, + 0x10,0xa5,0x58,0x82,0x25,0x58,0x04,0x6e,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70, + 0x69,0x6c,0x65,0x2e,0x64,0x65,0x6e,0x6f,0x72,0x6d,0x73,0x5f,0x64,0x69,0x73,0x61, + 0x62,0x6c,0x65,0x43,0x04,0xe5,0x20,0x17,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97, + 0xc6,0x56,0xe6,0x62,0x16,0x36,0x47,0xf7,0xd5,0x16,0x46,0x87,0xf6,0x55,0xe6,0x16, + 0x26,0xc6,0x56,0x36,0x44,0x50,0x12,0x96,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b, + 0x5c,0x1a,0x5b,0x99,0x8b,0x99,0x5c,0x58,0x5b,0x99,0x58,0x9d,0x99,0x59,0x99,0xdc, + 0x97,0x59,0x19,0xdd,0x18,0xda,0x17,0x59,0xda,0x5c,0x98,0x18,0x5b,0xd9,0x10,0x41, + 0x59,0x18,0x06,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e, + 0x61,0x74,0x69,0x76,0x65,0x5f,0x64,0x6f,0x75,0x62,0x6c,0x65,0x5f,0x64,0x69,0x73, + 0x61,0x62,0x6c,0x65,0x43,0x04,0xa5,0x61,0x14,0x96,0x26,0xe7,0x62,0x57,0x26,0x47, + 0x57,0x86,0xf7,0xf5,0x56,0x47,0x07,0x57,0x47,0xc7,0xa5,0x6e,0xae,0x4c,0x0e,0x85, + 0xed,0x6d,0xcc,0x0d,0x26,0x85,0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d, + 0x1e,0x5c,0xd9,0x97,0x5b,0x58,0x5b,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x1a,0x32, + 0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x6e,0x61,0x6d,0x65,0x14,0xea,0xec,0x86, + 0x30,0xca,0xa3,0x40,0x4a,0xa4,0x48,0xca,0xa4,0x50,0x5c,0xea,0xe6,0xca,0xe4,0x50, + 0xd8,0xde,0xc6,0xdc,0x62,0x52,0x58,0x8c,0xbd,0xb1,0xbd,0xc9,0x0d,0x61,0x94,0x47, + 0xb1,0x94,0x48,0x91,0x94,0x49,0xb9,0xc8,0x84,0xa5,0xc9,0xb9,0xc0,0xbd,0xcd,0xa5, + 0xd1,0xa5,0xbd,0xb9,0x71,0x39,0x63,0xfb,0x82,0x7a,0x9b,0x4b,0xa3,0x4b,0x7b,0x73, + 0x1b,0xa2,0x28,0x99,0x12,0x29,0x92,0x32,0x29,0x1a,0x9d,0xb0,0x34,0x39,0x17,0xb8, + 0xb7,0x34,0x37,0xba,0xaf,0xb9,0x34,0xbd,0x32,0x16,0x66,0x6c,0x6f,0x61,0x74,0x64, + 0xce,0xd8,0xbe,0xa0,0xde,0xd2,0xdc,0xe8,0xa6,0xd2,0xf4,0xca,0x86,0x28,0x0a,0xa7, + 0x44,0x4a,0xa7,0x4c,0x8a,0x37,0x04,0x51,0x2a,0x05,0x53,0x36,0xe5,0x23,0x14,0x96, + 0x26,0xe7,0x62,0x57,0x26,0x47,0x57,0x86,0xf7,0x95,0xe6,0x06,0x57,0x47,0x47,0x29, + 0x2c,0x4d,0xce,0x85,0xed,0x6d,0x2c,0x8c,0x2e,0xed,0xcd,0xed,0x2b,0xcd,0x8d,0xac, + 0x0c,0x8f,0xd9,0x59,0x99,0x5b,0x99,0x5c,0x18,0x5d,0x19,0x19,0x0a,0x0e,0xdc,0xdb, + 0x5c,0x1a,0x5d,0xda,0x9b,0x1b,0x91,0x1d,0xcd,0x97,0x59,0x0a,0x11,0xb8,0xb7,0xb9, + 0x34,0xba,0xb4,0x37,0xb7,0x21,0xd4,0x22,0x28,0x61,0xa0,0x88,0xc1,0x22,0x2c,0x81, + 0x32,0x06,0x4a,0xa4,0x48,0xca,0xa4,0x90,0x01,0xb5,0xb3,0x32,0xb7,0x32,0xb9,0x30, + 0xba,0x32,0x32,0x94,0x1c,0xba,0x32,0xbc,0xb1,0xb7,0x37,0x39,0x32,0x18,0x22,0x3b, + 0x99,0x2f,0xb3,0x14,0x1a,0x66,0x6c,0x6f,0x61,0x74,0x32,0x4c,0xe8,0xca,0xf0,0xc6, + 0xde,0xde,0xe4,0xc8,0x60,0x86,0x50,0x4b,0xa0,0x84,0x81,0x22,0x06,0x4b,0xb0,0x04, + 0x8a,0x19,0x28,0x91,0x72,0x06,0xca,0xa4,0xa0,0x01,0xaf,0xb3,0x32,0xb7,0x32,0xb9, + 0x30,0xba,0x32,0x32,0x14,0x9b,0xb1,0x37,0xb6,0x37,0x39,0x18,0x22,0x3b,0x9a,0x2f, + 0xb3,0x14,0x1a,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x43,0xa8,0xa5,0x50,0xc2,0x40,0x11, + 0x83,0xa5,0x58,0x02,0x45,0x0d,0x94,0x48,0x91,0x94,0x49,0x59,0x03,0x4a,0x67,0x65, + 0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x28,0x35,0x70,0x73,0x69,0x7a,0x65,0x66,0x29, + 0x2c,0xe0,0xe6,0xd2,0xf4,0xca,0x86,0x50,0x8b,0xa1,0x84,0x81,0x22,0x06,0x8b,0xb1, + 0x04,0x4a,0x1b,0x28,0x91,0xd2,0x29,0x93,0xe2,0x06,0x54,0xc2,0xd2,0xe4,0x5c,0xc4, + 0xea,0xcc,0xcc,0xca,0xe4,0xf8,0x84,0xa5,0xc9,0xb9,0x88,0xd5,0x99,0x99,0x95,0xc9, + 0x7d,0xcd,0xa5,0xe9,0x95,0x11,0x09,0x4b,0x93,0x73,0x91,0x2b,0x0b,0x23,0x23,0x15, + 0x96,0x26,0xe7,0x32,0x47,0x27,0x57,0x37,0x46,0xf7,0x45,0x97,0x07,0x57,0xf6,0x95, + 0xe6,0x66,0xf6,0x46,0xc4,0x8c,0xed,0x2d,0x8c,0x8e,0x06,0x8f,0x86,0x43,0x9b,0x1d, + 0x1c,0x05,0xba,0xb6,0x21,0xd4,0x22,0x2c,0xc3,0x22,0x28,0x74,0xa0,0xd4,0xc1,0x32, + 0x2c,0xc3,0x22,0x28,0x74,0xa0,0xd8,0x01,0xa3,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3, + 0x2f,0xba,0x3c,0xb8,0xb2,0xaf,0xb9,0x34,0xbd,0x32,0x5e,0x61,0x69,0x72,0x2e,0x61, + 0x72,0x67,0x5f,0x74,0x79,0x70,0x65,0x5f,0x61,0x6c,0x69,0x67,0x6e,0x5f,0x73,0x69, + 0x7a,0x65,0x4c,0xec,0xe6,0xbe,0xe0,0xc2,0xe4,0xc2,0xda,0xe6,0x38,0x7c,0xc9,0xc4, + 0x0c,0x21,0x83,0x85,0x50,0xe0,0x40,0x89,0x83,0xe5,0x50,0xc4,0x60,0x11,0x96,0x40, + 0x91,0x03,0x65,0x0e,0x94,0x3b,0x50,0xf0,0x60,0x39,0x94,0x3c,0x58,0x12,0x25,0x52, + 0xf4,0x40,0x99,0x94,0x3d,0x18,0xa2,0x28,0x65,0xa0,0xa4,0x81,0xc2,0x06,0xca,0x1b, + 0x28,0x7c,0x30,0xc4,0x48,0x00,0x05,0x0c,0x94,0x3e,0xe0,0xf3,0xd6,0xe6,0x96,0x06, + 0xf7,0x46,0x57,0xe6,0x46,0x07,0x32,0x86,0x16,0x26,0xc7,0x67,0x2a,0xad,0x0d,0x8e, + 0xad,0x0c,0x64,0x68,0x65,0x05,0x84,0x4a,0x28,0x28,0x68,0x88,0xa0,0x80,0xc2,0x10, + 0x43,0xf9,0x03,0x25,0x14,0x18,0x65,0x88,0xa1,0x88,0x82,0x22,0x0a,0x8c,0x32,0x22, + 0x62,0x07,0x76,0xb0,0x87,0x76,0x70,0x83,0x76,0x78,0x07,0x72,0xa8,0x07,0x76,0x28, + 0x07,0x37,0x30,0x07,0x76,0x08,0x87,0x73,0x98,0x87,0x29,0x41,0x30,0x42,0x61,0x07, + 0x76,0xb0,0x87,0x76,0x70,0x83,0x74,0x20,0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0x0c, + 0x23,0x96,0x70,0x48,0x07,0x79,0x70,0x03,0x7b,0x28,0x07,0x79,0x98,0x87,0x74,0x78, + 0x07,0x77,0x98,0x12,0x10,0x23,0xa8,0x70,0x48,0x07,0x79,0x70,0x03,0x76,0x08,0x07, + 0x77,0x38,0x87,0x7a,0x08,0x87,0x73,0x28,0x87,0x5f,0xb0,0x87,0x72,0x90,0x87,0x79, + 0x48,0x87,0x77,0x70,0x87,0x29,0x81,0x31,0x62,0x0a,0x87,0x74,0x90,0x07,0x37,0x18, + 0x87,0x77,0x68,0x07,0x78,0x48,0x07,0x76,0x28,0x87,0x5f,0x78,0x07,0x78,0xa0,0x87, + 0x74,0x78,0x07,0x77,0x98,0x87,0x29,0x04,0xa2,0x30,0xce,0x08,0x25,0x1c,0xd2,0x41, + 0x1e,0xdc,0xc0,0x1e,0xca,0x41,0x1e,0xe8,0xa1,0x1c,0xf0,0x61,0x4a,0xe0,0x07,0x00, + 0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c, + 0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07, + 0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42, + 0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83, + 0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07, + 0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70, + 0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3, + 0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2, + 0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc, + 0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68, + 0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07, + 0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72, + 0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec, + 0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc, + 0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8, + 0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03, + 0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c, + 0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74, + 0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4, + 0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc, + 0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1, + 0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50, + 0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51, + 0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21, + 0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06, + 0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c, + 0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77, + 0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00, + 0x00,0x02,0x00,0x00,0x00,0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00, + 0x00,0x3e,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x09,0x00,0x00, + 0x00,0xe4,0xc6,0x22,0x86,0x61,0x18,0xc6,0x22,0x04,0x41,0x10,0xc6,0x22,0x82,0x20, + 0x08,0x88,0x95,0x40,0x19,0x14,0x01,0xb9,0x11,0x00,0x1a,0x33,0x00,0x24,0x66,0x00, + 0x28,0xcc,0x00,0x00,0x00,0xe3,0x15,0x0b,0x84,0x61,0x10,0x05,0x65,0x90,0x21,0x1a, + 0x0c,0x13,0x02,0xf9,0x8c,0x57,0x3c,0x14,0xc7,0x2d,0x14,0x94,0x41,0x86,0xea,0x70, + 0x4c,0x08,0xe4,0x63,0x41,0x01,0x9f,0xf1,0x0a,0x2a,0x0b,0x83,0x30,0x70,0x28,0x28, + 0x83,0x0c,0x1a,0x43,0x99,0x10,0xc8,0xc7,0x8a,0x00,0x3e,0xe3,0x15,0x99,0x67,0x06, + 0x66,0x40,0x51,0x50,0x06,0x19,0xbe,0x48,0x33,0x21,0x90,0x8f,0x15,0x01,0x7c,0xc6, + 0x2b,0xbc,0x31,0x60,0x83,0x35,0x18,0x03,0x0a,0xca,0x20,0xc3,0x18,0x60,0x99,0x09, + 0x81,0x7c,0xc6,0x2b,0xc4,0xe0,0x0c,0xe0,0xe0,0x0d,0x3c,0x0a,0xca,0x20,0xc3,0x19, + 0x70,0x61,0x60,0x42,0x20,0x1f,0x0b,0x0a,0xf8,0x8c,0x57,0x9c,0x01,0x1b,0xd4,0x01, + 0x1d,0x88,0x01,0x05,0xc5,0x86,0x00,0x3e,0xb3,0x0d,0x61,0x10,0x00,0xb3,0x0d,0x41, + 0x1b,0x04,0xb3,0x0d,0xc1,0x23,0xcc,0x36,0x04,0x6e,0x30,0x64,0x10,0x10,0x03,0x00, + 0x00,0x09,0x00,0x00,0x00,0x5b,0x86,0x20,0x18,0x85,0x2d,0x43,0x11,0x8c,0xc2,0x96, + 0x41,0x09,0x46,0x61,0xcb,0xf0,0x04,0xa3,0xb0,0x65,0xa0,0x82,0x51,0xd8,0x32,0x60, + 0xc1,0x28,0x6c,0x19,0xba,0x60,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sfons_fs_bytecode_metal_macos[2893] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x4d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x70,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0xb6,0x8b,0xa9,0x7e,0x5a,0xee,0x89, + 0x6e,0x6c,0x22,0x2c,0x4b,0xad,0x03,0xda,0xe6,0xd7,0x2e,0x88,0x05,0x1f,0x44,0x92, + 0x88,0x08,0xa6,0x2c,0x57,0xb7,0x10,0x8a,0x6e,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x54,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x92,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x92,0x00,0x00,0x00,0x1b,0xfa,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa0,0x87,0x70,0x90,0x87, + 0x73,0x28,0x07,0x7a,0x68,0x03,0x73,0x28,0x87,0x70,0xa0,0x87,0x7a,0x90,0x87,0x72, + 0x98,0x07,0xa0,0x0d,0xcc,0x01,0x1e,0xe2,0xc0,0x0e,0x00,0xa2,0x1e,0xdc,0x61,0x1e, + 0xc2,0xc1,0x1c,0xca,0xa1,0x0d,0xcc,0x01,0x1e,0xda,0xa0,0x1d,0xc2,0x81,0x1e,0xd0, + 0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x88,0x7a,0x98,0x87,0x72,0x68,0x83,0x79, + 0x78,0x07,0x73,0xa0,0x87,0x36,0x30,0x07,0x76,0x78,0x87,0x70,0xa0,0x07,0xc0,0x1c, + 0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x80,0x0d,0x86,0x30,0x00,0x0b,0x50,0x6d,0x30,0x06, + 0x02,0x58,0x80,0x6a,0x03,0x42,0xfc,0xff,0xff,0xff,0xff,0x00,0x30,0x80,0x04,0x54, + 0x1b,0x8c,0x22,0x00,0x16,0xa0,0xda,0x60,0x18,0x02,0xb0,0x00,0x15,0x00,0x00,0x00, + 0x00,0x49,0x18,0x00,0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44, + 0x61,0x00,0x00,0x00,0x00,0x89,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48, + 0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90, + 0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04, + 0x70,0x90,0x34,0x45,0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x13,0x0a,0xc2, + 0x51,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x13,0x71,0x4d,0x54,0x44,0xfc,0xf6,0xf0,0x4f, + 0x63,0x04,0xc0,0x20,0xc2,0x10,0x5c,0x24,0x4d,0x11,0x25,0x4c,0xfe,0x2f,0x01,0xcc, + 0xb3,0x10,0xd1,0x3f,0x8d,0x11,0x00,0x83,0x08,0x85,0x50,0x0a,0x11,0x02,0x31,0x74, + 0x86,0x11,0x04,0x60,0x8e,0x20,0x98,0x23,0x00,0x83,0x61,0x04,0x61,0x29,0x48,0x20, + 0x26,0x29,0xa6,0x00,0xb5,0x81,0x80,0x61,0x04,0x62,0x19,0x01,0x00,0x13,0xb2,0x70, + 0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68, + 0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83, + 0x38,0x70,0x03,0x38,0xd8,0xf0,0x1e,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78, + 0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90, + 0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e, + 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76, + 0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x78,0x00,0x07,0x7a, + 0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x60, + 0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07, + 0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a, + 0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60, + 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72, + 0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0, + 0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07, + 0x79,0x20,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d, + 0x60,0x0f,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50, + 0x07,0x76,0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07, + 0x7a,0x50,0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a, + 0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0x60, + 0x0e,0x78,0x00,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07, + 0x6d,0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x41, + 0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x18,0xc2,0x38,0x40,0x00,0x08,0x00,0x00, + 0x00,0x00,0x00,0x64,0x81,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x32,0x1e,0x98, + 0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02, + 0x50,0x08,0x05,0x51,0x04,0x65,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0xbb,0x00,0x00, + 0x00,0x1a,0x03,0x4c,0x10,0x95,0xbb,0x31,0xb4,0x30,0xb9,0xaf,0xb9,0x34,0xbd,0xb2, + 0x21,0xc6,0x22,0x3c,0xc0,0x42,0x70,0x0d,0x82,0xe0,0xe0,0xd8,0xca,0x40,0x98,0x98, + 0xac,0x9a,0x40,0xec,0xca,0xe4,0xe6,0xd2,0xde,0xdc,0x40,0x72,0x60,0x64,0x5c,0x62, + 0x40,0x50,0xda,0xca,0xe8,0xc2,0xd8,0xcc,0xca,0x5a,0x72,0x60,0x64,0x5c,0x62,0x5c, + 0x68,0x72,0x52,0x86,0x08,0x8f,0x30,0xc4,0x58,0x84,0xa5,0x58,0x06,0x16,0x4d,0x65, + 0x74,0x61,0x6c,0x43,0x90,0xa7,0x58,0x84,0x45,0x58,0x06,0x6e,0x61,0x69,0x72,0x2e, + 0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x64,0x65,0x6e,0x6f,0x72,0x6d,0x73,0x5f, + 0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43,0x84,0xe7,0x20,0x17,0x96,0x26,0xe7,0x32, + 0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x62,0x16,0x36,0x47,0xf7,0xd5,0x16,0x46,0x87, + 0xf6,0x55,0xe6,0x16,0x26,0xc6,0x56,0x36,0x44,0x78,0x12,0x96,0x41,0x58,0x9a,0x9c, + 0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b,0x99,0x5c,0x58,0x5b,0x99,0x58,0x9d, + 0x99,0x59,0x99,0xdc,0x97,0x59,0x19,0xdd,0x18,0xda,0x17,0x59,0xda,0x5c,0x98,0x18, + 0x5b,0xd9,0x10,0xe1,0x59,0x18,0x06,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69, + 0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f,0x64,0x6f,0x75,0x62,0x6c,0x65, + 0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43,0x84,0xa7,0x61,0x14,0x96,0x26,0xe7, + 0x22,0x57,0xe6,0x46,0x56,0x26,0xf7,0x45,0x17,0x26,0x77,0x56,0x46,0xc7,0x28,0x2c, + 0x4d,0xce,0x25,0x4c,0xee,0xec,0x8b,0x2e,0x0f,0xae,0xec,0xcb,0x2d,0xac,0xad,0x8c, + 0x86,0x19,0xdb,0x5b,0x18,0x1d,0x0d,0x99,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f, + 0xb7,0xb0,0xb6,0x32,0x2a,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x43, + 0x98,0xe7,0x59,0x86,0x07,0x7a,0xa2,0x47,0x7a,0xa6,0x21,0xc2,0x43,0x51,0x0a,0x4b, + 0x93,0x73,0x31,0x93,0x0b,0x3b,0x6b,0x2b,0x73,0xa3,0xfb,0x4a,0x73,0x83,0xab,0xa3, + 0xe3,0x52,0x37,0x57,0x26,0x87,0xc2,0xf6,0x36,0xe6,0x06,0x93,0x42,0x25,0x2c,0x4d, + 0xce,0x65,0xac,0xcc,0x8d,0xae,0x4c,0x8e,0x4f,0x58,0x9a,0x9c,0x0b,0x5c,0x99,0xdc, + 0x1c,0x5c,0xd9,0x18,0x5d,0x9a,0x5d,0x19,0x85,0x3a,0xbb,0x21,0xd2,0x32,0x3c,0xd6, + 0x73,0x3d,0xd8,0x93,0x3d,0xd0,0x13,0x3d,0xd2,0xa3,0x71,0xa9,0x9b,0x2b,0x93,0x43, + 0x61,0x7b,0x1b,0x73,0x8b,0x49,0x61,0x31,0xf6,0xc6,0xf6,0x26,0x37,0x44,0x5a,0x84, + 0xc7,0x7a,0xb8,0x07,0x7b,0xb2,0x07,0x7a,0xa2,0x47,0x7a,0x3a,0x2e,0x61,0x69,0x72, + 0x2e,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x94,0xc2,0xd2,0xe4,0x5c,0xd8,0xde,0xc6, + 0xc2,0xe8,0xd2,0xde,0xdc,0xbe,0xd2,0xdc,0xc8,0xca,0xf0,0xa8,0x84,0xa5,0xc9,0xb9, + 0xcc,0x85,0xb5,0xc1,0xb1,0x95,0x11,0xa3,0x2b,0xc3,0xa3,0xab,0x93,0x2b,0x93,0x21, + 0xe3,0x31,0x63,0x7b,0x0b,0xa3,0x63,0x01,0x99,0x0b,0x6b,0x83,0x63,0x2b,0xf3,0xe1, + 0x40,0x57,0x86,0x37,0x84,0x5a,0x8c,0xe7,0x7b,0xc0,0x60,0x19,0x16,0xe1,0x09,0x83, + 0x07,0x7a,0xc4,0xe0,0x91,0x9e,0x31,0xe0,0x12,0x96,0x26,0xe7,0x32,0x17,0xd6,0x06, + 0xc7,0x56,0x26,0xc7,0x63,0x2e,0xac,0x0d,0x8e,0xad,0x4c,0x8e,0x08,0x5d,0x19,0xde, + 0x54,0x1b,0x1c,0x9b,0xdc,0x10,0x69,0x39,0x9e,0x32,0x78,0xc0,0x60,0x19,0x16,0xe1, + 0x81,0x1e,0x33,0x78,0xa4,0xe7,0x0c,0x86,0x20,0xcf,0xf6,0x78,0x0f,0x19,0x3c,0x68, + 0x30,0xc4,0x40,0x80,0xa7,0x7a,0xd2,0x60,0x44,0xc4,0x0e,0xec,0x60,0x0f,0xed,0xe0, + 0x06,0xed,0xf0,0x0e,0xe4,0x50,0x0f,0xec,0x50,0x0e,0x6e,0x60,0x0e,0xec,0x10,0x0e, + 0xe7,0x30,0x0f,0x53,0x82,0x60,0x84,0xc2,0x0e,0xec,0x60,0x0f,0xed,0xe0,0x06,0xe9, + 0x40,0x0e,0xe5,0xe0,0x0e,0xf4,0x30,0x25,0x18,0x46,0x2c,0xe1,0x90,0x0e,0xf2,0xe0, + 0x06,0xf6,0x50,0x0e,0xf2,0x30,0x0f,0xe9,0xf0,0x0e,0xee,0x30,0x25,0x20,0x46,0x50, + 0xe1,0x90,0x0e,0xf2,0xe0,0x06,0xec,0x10,0x0e,0xee,0x70,0x0e,0xf5,0x10,0x0e,0xe7, + 0x50,0x0e,0xbf,0x60,0x0f,0xe5,0x20,0x0f,0xf3,0x90,0x0e,0xef,0xe0,0x0e,0x53,0x02, + 0x63,0xc4,0x14,0x0e,0xe9,0x20,0x0f,0x6e,0x30,0x0e,0xef,0xd0,0x0e,0xf0,0x90,0x0e, + 0xec,0x50,0x0e,0xbf,0xf0,0x0e,0xf0,0x40,0x0f,0xe9,0xf0,0x0e,0xee,0x30,0x0f,0x53, + 0x08,0x44,0x61,0x9c,0x11,0x4c,0x38,0xa4,0x83,0x3c,0xb8,0x81,0x39,0xc8,0x43,0x38, + 0x9c,0x43,0x3b,0x94,0x83,0x3b,0xd0,0xc3,0x94,0x40,0x0d,0x00,0x00,0x79,0x18,0x00, + 0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d, + 0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c, + 0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d, + 0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d, + 0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79, + 0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc, + 0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50, + 0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30, + 0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03, + 0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07, + 0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76, + 0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98, + 0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8, + 0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21, + 0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43, + 0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f, + 0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70, + 0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0, + 0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40, + 0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41, + 0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e, + 0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07, + 0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f, + 0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d, + 0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38, + 0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88, + 0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08, + 0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00, + 0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45, + 0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00, + 0x00,0x61,0x20,0x00,0x00,0x16,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00, + 0x00,0x0b,0x00,0x00,0x00,0x04,0xc7,0x22,0x80,0x40,0x20,0x88,0x8d,0x00,0x8c,0x25, + 0x00,0x01,0xa9,0x11,0x80,0x1a,0x20,0x31,0x03,0x40,0x61,0x0e,0xc2,0xb2,0x2c,0x6a, + 0x06,0x80,0xc0,0x0c,0xc0,0x08,0xc0,0x18,0x01,0x08,0x82,0x20,0xfe,0x01,0x00,0x00, + 0x00,0x83,0x0c,0x0f,0x91,0x8c,0x18,0x28,0x42,0x70,0x39,0x4d,0x80,0x2c,0xc9,0x30, + 0xc8,0x70,0x04,0x8d,0x05,0x91,0x7c,0x66,0x1b,0x94,0x00,0xc8,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sfons_vs_bytecode_metal_ios[3417] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x59,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0x53,0xd2,0x06,0xf6,0xae,0x63,0x48, + 0x79,0x19,0x71,0xbe,0x11,0x2a,0xc0,0x72,0x90,0x9c,0xd4,0x1c,0xf2,0xfa,0xd7,0x02, + 0x09,0x76,0xb9,0xee,0x24,0x42,0xd7,0xbd,0x99,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x40,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x2a,0x00,0x04,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x70,0x73,0x69,0x7a,0x65,0x00,0x03, + 0x80,0x56,0x41,0x54,0x59,0x06,0x00,0x04,0x00,0x06,0x04,0x06,0x03,0x45,0x4e,0x44, + 0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00, + 0x00,0x14,0x00,0x00,0x00,0x20,0x0c,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0, + 0xde,0x21,0x0c,0x00,0x00,0x05,0x03,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00, + 0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32, + 0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45, + 0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44, + 0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8, + 0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00, + 0x00,0x8a,0x00,0x00,0x00,0x1b,0xf6,0x25,0xf8,0xff,0xff,0xff,0xff,0x01,0x90,0x80, + 0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87,0x71,0xa0,0x07,0x76,0xc8,0x87,0x36, + 0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72,0x20,0x87,0x36,0x20,0x87,0x74,0xb0, + 0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88,0x07,0x79,0xa0,0x87,0x36,0x30,0x07, + 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1, + 0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e, + 0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c,0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87,0x72,0x98,0x87,0x79,0x68,0x03,0x78, + 0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x76,0x08, + 0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda, + 0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda,0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81, + 0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21,0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8, + 0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30,0x07,0x79,0x08,0x87,0x76,0x28,0x87, + 0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87,0x72,0x90,0x87,0x36,0x28,0x07,0x76, + 0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77,0x68,0x03,0x76,0x28,0x87,0x70,0x30, + 0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70,0x07,0x73,0x98,0x87,0x36,0x30,0x07, + 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01, + 0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1,0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c, + 0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08, + 0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36, + 0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d, + 0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d,0xca,0x81,0x1c,0xda,0x40,0x1f,0xca, + 0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x7a,0x90, + 0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38,0x87,0x36,0x68,0x87,0x70,0xa0,0x07, + 0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61, + 0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1,0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e, + 0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4, + 0xa1,0x1c,0x00,0x3c,0x00,0x08,0x7a,0x08,0x07,0x79,0x38,0x87,0x72,0xa0,0x87,0x36, + 0x30,0x87,0x72,0x08,0x07,0x7a,0xa8,0x07,0x79,0x28,0x87,0x79,0x00,0xda,0xc0,0x1c, + 0xe0,0x21,0x0e,0xec,0x00,0x20,0xea,0xc1,0x1d,0xe6,0x21,0x1c,0xcc,0xa1,0x1c,0xda, + 0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a, + 0x28,0x07,0x80,0xa8,0x87,0x79,0x28,0x87,0x36,0x98,0x87,0x77,0x30,0x07,0x7a,0x68, + 0x03,0x73,0x60,0x87,0x77,0x08,0x07,0x7a,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e,0xca, + 0x01,0xd8,0x80,0x08,0x05,0x90,0x00,0x0b,0x50,0x01,0x00,0x00,0x00,0x49,0x18,0x00, + 0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,0x00,0x24,0x00,0x00, + 0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22, + 0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x40,0x33, + 0x00,0xc3,0x08,0x04,0x70,0x97,0x34,0x45,0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef, + 0x50,0x93,0xff,0x00,0x82,0x42,0x0c,0x98,0x08,0x21,0x80,0x61,0x04,0x01,0x48,0x82, + 0x30,0x13,0x35,0x0f,0xf4,0x20,0x0f,0xf5,0x30,0x0e,0xf4,0xe0,0x06,0xed,0x50,0x0e, + 0xf4,0x10,0x0e,0xec,0xa0,0x07,0x7a,0xd0,0x0e,0xe1,0x40,0x0f,0xf2,0x90,0x0e,0xf8, + 0x80,0x02,0x72,0x90,0x34,0x45,0x94,0x30,0xf9,0x95,0xf4,0x3f,0x40,0x04,0x30,0x12, + 0x12,0x4a,0x19,0x44,0x30,0x84,0x62,0x88,0x30,0x02,0x38,0x84,0x06,0x02,0xe6,0x08, + 0xc0,0x60,0x8e,0x00,0x14,0x06,0x11,0x02,0x61,0x18,0x81,0x58,0x46,0x00,0x00,0x00, + 0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78, + 0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80, + 0x83,0x0d,0xef,0x51,0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40, + 0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07, + 0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76, + 0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0, + 0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73, + 0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40, + 0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x80,0x07,0x70,0xa0,0x07,0x71,0x20,0x07, + 0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07,0x71, + 0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07, + 0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07,0x7a, + 0x60,0x07,0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60, + 0x07,0x74,0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07, + 0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72, + 0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72,0xa0, + 0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07, + 0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d, + 0x60,0x0f,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10, + 0x07,0x72,0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07, + 0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xe6,0x80,0x07,0x70, + 0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xee,0x80, + 0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x98,0x04,0x00,0x80,0x00, + 0x00,0x00,0x00,0x00,0x80,0x2c,0x10,0x00,0x00,0x09,0x00,0x00,0x00,0x32,0x1e,0x98, + 0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02, + 0x50,0x80,0x01,0x85,0x50,0x04,0x65,0x50,0x80,0x02,0x05,0x51,0x20,0xc4,0x46,0x00, + 0x00,0x79,0x18,0x00,0x00,0x15,0x01,0x00,0x00,0x1a,0x03,0x4c,0x10,0x95,0xbb,0x31, + 0xb4,0x30,0xb9,0xaf,0xb9,0x34,0xbd,0xb2,0x21,0xc6,0x12,0x28,0xc0,0x42,0x70,0x0d, + 0x82,0xe0,0xe0,0xd8,0xca,0x40,0x98,0x98,0xac,0x9a,0x40,0xec,0xca,0xe4,0xe6,0xd2, + 0xde,0xdc,0x40,0x72,0x60,0x64,0x5c,0x62,0x40,0x50,0xda,0xca,0xe8,0xc2,0xd8,0xcc, + 0xca,0x5a,0x72,0x60,0x64,0x5c,0x62,0x5c,0x6a,0x60,0x52,0x86,0x08,0x8a,0x30,0xc4, + 0x58,0x82,0x05,0x59,0x04,0x16,0x4d,0x65,0x74,0x61,0x6c,0x43,0x10,0xa5,0x58,0x82, + 0x45,0x58,0x04,0x6e,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e, + 0x64,0x65,0x6e,0x6f,0x72,0x6d,0x73,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43, + 0x04,0xe5,0x20,0x17,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x62, + 0x16,0x36,0x47,0xf7,0xd5,0x16,0x46,0x87,0xf6,0x55,0xe6,0x16,0x26,0xc6,0x56,0x36, + 0x44,0x50,0x12,0x92,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99, + 0x8b,0x99,0x5c,0x58,0x5b,0x99,0x58,0x9d,0x99,0x59,0x99,0xdc,0x97,0x59,0x19,0xdd, + 0x18,0xda,0x57,0x99,0x5b,0x98,0x18,0x5b,0xd9,0x10,0x41,0x59,0x18,0x06,0x61,0x69, + 0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65, + 0x5f,0x64,0x6f,0x75,0x62,0x6c,0x65,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43, + 0x04,0xa5,0x61,0x14,0x96,0x26,0xe7,0x62,0x57,0x26,0x47,0x57,0x86,0xf7,0xf5,0x56, + 0x47,0x07,0x57,0x47,0xc7,0xa5,0x6e,0xae,0x4c,0x0e,0x85,0xed,0x6d,0xcc,0x0d,0x26, + 0x85,0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d,0x1e,0x5c,0xd9,0x97,0x5b, + 0x58,0x5b,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x1a,0x32,0x61,0x69,0x72,0x2e,0x61, + 0x72,0x67,0x5f,0x6e,0x61,0x6d,0x65,0x14,0xea,0xec,0x86,0x30,0xca,0xa3,0x40,0x4a, + 0xa4,0x48,0xca,0xa4,0x50,0x5c,0xea,0xe6,0xca,0xe4,0x50,0xd8,0xde,0xc6,0xdc,0x62, + 0x52,0x58,0x8c,0xbd,0xb1,0xbd,0xc9,0x0d,0x61,0x94,0x47,0xb1,0x94,0x48,0x91,0x94, + 0x49,0xb9,0xc8,0x84,0xa5,0xc9,0xb9,0xc0,0xbd,0xcd,0xa5,0xd1,0xa5,0xbd,0xb9,0x71, + 0x39,0x63,0xfb,0x82,0x7a,0x9b,0x4b,0xa3,0x4b,0x7b,0x73,0x1b,0xa2,0x28,0x99,0x12, + 0x29,0x92,0x32,0x29,0x1a,0x9d,0xb0,0x34,0x39,0x17,0xb8,0xb7,0x34,0x37,0xba,0xaf, + 0xb9,0x34,0xbd,0x32,0x16,0x66,0x6c,0x6f,0x61,0x74,0x64,0xce,0xd8,0xbe,0xa0,0xde, + 0xd2,0xdc,0xe8,0xa6,0xd2,0xf4,0xca,0x86,0x28,0x0a,0xa7,0x44,0x4a,0xa7,0x4c,0x8a, + 0x37,0x04,0x51,0x2a,0x05,0x53,0x36,0xe5,0x23,0x14,0x96,0x26,0xe7,0x62,0x57,0x26, + 0x47,0x57,0x86,0xf7,0x95,0xe6,0x06,0x57,0x47,0x47,0x29,0x2c,0x4d,0xce,0x85,0xed, + 0x6d,0x2c,0x8c,0x2e,0xed,0xcd,0xed,0x2b,0xcd,0x8d,0xac,0x0c,0x8f,0xd9,0x59,0x99, + 0x5b,0x99,0x5c,0x18,0x5d,0x19,0x19,0x0a,0x0e,0xdc,0xdb,0x5c,0x1a,0x5d,0xda,0x9b, + 0x1b,0x91,0x1d,0xcd,0x97,0x59,0x0a,0x11,0xb8,0xb7,0xb9,0x34,0xba,0xb4,0x37,0xb7, + 0x21,0xd4,0x22,0x28,0x61,0xa0,0x88,0xc1,0x22,0x2c,0x81,0x32,0x06,0x4a,0xa4,0x48, + 0xca,0xa4,0x90,0x01,0xb5,0xb3,0x32,0xb7,0x32,0xb9,0x30,0xba,0x32,0x32,0x94,0x1c, + 0xba,0x32,0xbc,0xb1,0xb7,0x37,0x39,0x32,0x18,0x22,0x3b,0x99,0x2f,0xb3,0x14,0x1a, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x4c,0xe8,0xca,0xf0,0xc6,0xde,0xde,0xe4,0xc8,0x60, + 0x86,0x50,0x4b,0xa0,0x84,0x81,0x22,0x06,0x4b,0xb0,0x04,0x8a,0x19,0x28,0x91,0x72, + 0x06,0xca,0xa4,0xa0,0x01,0xaf,0xb3,0x32,0xb7,0x32,0xb9,0x30,0xba,0x32,0x32,0x14, + 0x9b,0xb1,0x37,0xb6,0x37,0x39,0x18,0x22,0x3b,0x9a,0x2f,0xb3,0x14,0x1a,0x63,0x6f, + 0x6c,0x6f,0x72,0x30,0x43,0xa8,0xa5,0x50,0xc2,0x40,0x11,0x83,0xa5,0x58,0x02,0x45, + 0x0d,0x94,0x48,0x91,0x94,0x49,0x59,0x03,0x4a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74, + 0x65,0x64,0x28,0x35,0x70,0x73,0x69,0x7a,0x65,0x66,0x29,0x2c,0xe0,0xe6,0xd2,0xf4, + 0xca,0x86,0x50,0x8b,0xa1,0x84,0x81,0x22,0x06,0x8b,0xb1,0x04,0x4a,0x1b,0x28,0x91, + 0xd2,0x29,0x93,0xe2,0x06,0x54,0xc2,0xd2,0xe4,0x5c,0xc4,0xea,0xcc,0xcc,0xca,0xe4, + 0xf8,0x84,0xa5,0xc9,0xb9,0x88,0xd5,0x99,0x99,0x95,0xc9,0x7d,0xcd,0xa5,0xe9,0x95, + 0x11,0x09,0x4b,0x93,0x73,0x91,0x2b,0x0b,0x23,0x23,0x15,0x96,0x26,0xe7,0x32,0x47, + 0x27,0x57,0x37,0x46,0xf7,0x45,0x97,0x07,0x57,0xf6,0x95,0xe6,0x66,0xf6,0x46,0xc4, + 0x8c,0xed,0x2d,0x8c,0x8e,0x06,0x8f,0x86,0x43,0x9b,0x1d,0x1c,0x05,0xba,0xb6,0x21, + 0xd4,0x22,0x2c,0xc3,0x22,0x28,0x74,0xa0,0xd4,0xc1,0x32,0x2c,0xc3,0x22,0x28,0x74, + 0xa0,0xd8,0x01,0xa3,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xba,0x3c,0xb8,0xb2, + 0xaf,0xb9,0x34,0xbd,0x32,0x5e,0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x74,0x79, + 0x70,0x65,0x5f,0x61,0x6c,0x69,0x67,0x6e,0x5f,0x73,0x69,0x7a,0x65,0x4c,0xec,0xe6, + 0xbe,0xe0,0xc2,0xe4,0xc2,0xda,0xe6,0x38,0x7c,0xc9,0xc4,0x0c,0x21,0x83,0x85,0x50, + 0xe0,0x40,0x89,0x83,0xe5,0x50,0xc4,0x60,0x11,0x96,0x40,0x91,0x03,0x65,0x0e,0x94, + 0x3b,0x50,0xf0,0x60,0x39,0x94,0x3c,0x58,0x12,0x25,0x52,0xf4,0x40,0x99,0x94,0x3d, + 0x18,0xa2,0x28,0x65,0xa0,0xa4,0x81,0xc2,0x06,0xca,0x1b,0x28,0x7c,0x30,0xc4,0x48, + 0x00,0x05,0x0c,0x94,0x3e,0xe0,0xf3,0xd6,0xe6,0x96,0x06,0xf7,0x46,0x57,0xe6,0x46, + 0x07,0x32,0x86,0x16,0x26,0xc7,0x67,0x2a,0xad,0x0d,0x8e,0xad,0x0c,0x64,0x68,0x65, + 0x05,0x84,0x4a,0x28,0x28,0x68,0x88,0xa0,0x80,0xc2,0x10,0x43,0xf9,0x03,0x25,0x14, + 0x18,0x65,0x88,0xa1,0x88,0x82,0x22,0x0a,0x8c,0x32,0x22,0x62,0x07,0x76,0xb0,0x87, + 0x76,0x70,0x83,0x76,0x78,0x07,0x72,0xa8,0x07,0x76,0x28,0x07,0x37,0x30,0x07,0x76, + 0x08,0x87,0x73,0x98,0x87,0x29,0x41,0x30,0x42,0x61,0x07,0x76,0xb0,0x87,0x76,0x70, + 0x83,0x74,0x20,0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0x0c,0x23,0x96,0x70,0x48,0x07, + 0x79,0x70,0x03,0x7b,0x28,0x07,0x79,0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12,0x10, + 0x23,0xa8,0x70,0x48,0x07,0x79,0x70,0x03,0x76,0x08,0x07,0x77,0x38,0x87,0x7a,0x08, + 0x87,0x73,0x28,0x87,0x5f,0xb0,0x87,0x72,0x90,0x87,0x79,0x48,0x87,0x77,0x70,0x87, + 0x29,0x81,0x31,0x62,0x0a,0x87,0x74,0x90,0x07,0x37,0x18,0x87,0x77,0x68,0x07,0x78, + 0x48,0x07,0x76,0x28,0x87,0x5f,0x78,0x07,0x78,0xa0,0x87,0x74,0x78,0x07,0x77,0x98, + 0x87,0x29,0x04,0xa2,0x30,0xce,0x08,0x25,0x1c,0xd2,0x41,0x1e,0xdc,0xc0,0x1e,0xca, + 0x41,0x1e,0xe8,0xa1,0x1c,0xf0,0x61,0x4a,0xe0,0x07,0x00,0x00,0x00,0x79,0x18,0x00, + 0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d, + 0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c, + 0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d, + 0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d, + 0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79, + 0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc, + 0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50, + 0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30, + 0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03, + 0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07, + 0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76, + 0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98, + 0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8, + 0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21, + 0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43, + 0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f, + 0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70, + 0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0, + 0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40, + 0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41, + 0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e, + 0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07, + 0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f, + 0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d, + 0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38, + 0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88, + 0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08, + 0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00, + 0x00,0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x3e,0x00,0x00, + 0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xe4,0xc6,0x22, + 0x86,0x61,0x18,0xc6,0x22,0x04,0x41,0x10,0xc6,0x22,0x82,0x20,0x08,0x88,0x95,0x40, + 0x19,0x14,0x01,0xb9,0x11,0x00,0x1a,0x33,0x00,0x24,0x66,0x00,0x28,0xcc,0x00,0x00, + 0x00,0xe3,0x15,0x0b,0x84,0x61,0x10,0x05,0x65,0x90,0x21,0x1a,0x0c,0x13,0x02,0xf9, + 0x8c,0x57,0x3c,0x14,0xc7,0x2d,0x14,0x94,0x41,0x86,0xea,0x70,0x4c,0x08,0xe4,0x63, + 0x41,0x01,0x9f,0xf1,0x0a,0x2a,0x0b,0x83,0x30,0x70,0x28,0x28,0x83,0x0c,0x1a,0x43, + 0x99,0x10,0xc8,0xc7,0x8a,0x00,0x3e,0xe3,0x15,0x99,0x67,0x06,0x66,0x40,0x51,0x50, + 0x06,0x19,0xbe,0x48,0x33,0x21,0x90,0x8f,0x15,0x01,0x7c,0xc6,0x2b,0xbc,0x31,0x60, + 0x83,0x35,0x18,0x03,0x0a,0xca,0x20,0xc3,0x18,0x60,0x99,0x09,0x81,0x7c,0xc6,0x2b, + 0xc4,0xe0,0x0c,0xe0,0xe0,0x0d,0x3c,0x0a,0xca,0x20,0xc3,0x19,0x70,0x61,0x60,0x42, + 0x20,0x1f,0x0b,0x0a,0xf8,0x8c,0x57,0x9c,0x01,0x1b,0xd4,0x01,0x1d,0x88,0x01,0x05, + 0xc5,0x86,0x00,0x3e,0xb3,0x0d,0x61,0x10,0x00,0xb3,0x0d,0x41,0x1b,0x04,0xb3,0x0d, + 0xc1,0x23,0xcc,0x36,0x04,0x6e,0x30,0x64,0x10,0x10,0x03,0x00,0x00,0x09,0x00,0x00, + 0x00,0x5b,0x86,0x20,0x18,0x85,0x2d,0x43,0x11,0x8c,0xc2,0x96,0x41,0x09,0x46,0x61, + 0xcb,0xf0,0x04,0xa3,0xb0,0x65,0xa0,0x82,0x51,0xd8,0x32,0x60,0xc1,0x28,0x6c,0x19, + 0xba,0x60,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sfons_fs_bytecode_metal_ios[2877] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x60,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0x54,0xcb,0x23,0xc1,0x79,0xec,0x33, + 0x7a,0x1d,0x12,0x8c,0x7c,0xe5,0x11,0xa5,0xdb,0xc5,0x1c,0x52,0xd5,0x69,0x04,0xe6, + 0x72,0x3d,0xdb,0xf1,0xf1,0xf4,0x44,0xa4,0xb5,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x4c,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x90,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x92,0x00,0x00,0x00,0x1b,0xfa,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa0,0x87,0x70,0x90,0x87, + 0x73,0x28,0x07,0x7a,0x68,0x03,0x73,0x28,0x87,0x70,0xa0,0x87,0x7a,0x90,0x87,0x72, + 0x98,0x07,0xa0,0x0d,0xcc,0x01,0x1e,0xe2,0xc0,0x0e,0x00,0xa2,0x1e,0xdc,0x61,0x1e, + 0xc2,0xc1,0x1c,0xca,0xa1,0x0d,0xcc,0x01,0x1e,0xda,0xa0,0x1d,0xc2,0x81,0x1e,0xd0, + 0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x88,0x7a,0x98,0x87,0x72,0x68,0x83,0x79, + 0x78,0x07,0x73,0xa0,0x87,0x36,0x30,0x07,0x76,0x78,0x87,0x70,0xa0,0x07,0xc0,0x1c, + 0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x80,0x0d,0x86,0x30,0x00,0x0b,0x50,0x6d,0x30,0x06, + 0x02,0x58,0x80,0x6a,0x03,0x42,0xfc,0xff,0xff,0xff,0xff,0x00,0x30,0x80,0x04,0x54, + 0x1b,0x8c,0x22,0x00,0x16,0xa0,0xda,0x60,0x18,0x02,0xb0,0x00,0x15,0x00,0x00,0x00, + 0x00,0x49,0x18,0x00,0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44, + 0x61,0x00,0x00,0x00,0x00,0x89,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48, + 0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90, + 0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04, + 0x70,0x90,0x34,0x45,0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x13,0x0a,0xc2, + 0x51,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x13,0x71,0x4d,0x54,0x44,0xfc,0xf6,0xf0,0x4f, + 0x63,0x04,0xc0,0x20,0xc2,0x10,0x5c,0x24,0x4d,0x11,0x25,0x4c,0xfe,0x2f,0x01,0xcc, + 0xb3,0x10,0xd1,0x3f,0x8d,0x11,0x00,0x83,0x08,0x85,0x50,0x0a,0x11,0x02,0x31,0x74, + 0x86,0x11,0x04,0x60,0x8e,0x20,0x98,0x23,0x00,0x83,0x61,0x04,0x61,0x29,0x48,0x20, + 0x26,0x29,0xa6,0x00,0xb5,0x81,0x80,0x61,0x04,0x62,0x19,0x01,0x00,0x13,0xa8,0x70, + 0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68, + 0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80,0x83,0x0d,0xef,0x51, + 0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78, + 0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60, + 0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07, + 0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a, + 0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30, + 0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xd0,0x06,0xe6,0x80,0x07,0x70,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71, + 0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10, + 0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07, + 0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72, + 0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0, + 0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06, + 0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78, + 0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10, + 0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72,0x50,0x07, + 0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60,0x07,0x7a, + 0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x75,0x10, + 0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xd0,0x06, + 0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x7a, + 0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xe6,0x80,0x07,0x70,0xa0,0x07,0x71,0x20, + 0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07, + 0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x18,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x00, + 0x80,0x21,0x8c,0x03,0x04,0x80,0x00,0x00,0x00,0x00,0x00,0x40,0x16,0x08,0x00,0x00, + 0x00,0x07,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26, + 0x47,0xc6,0x04,0x43,0x5a,0x23,0x00,0x25,0x50,0x08,0x05,0x51,0x04,0x65,0x00,0x00, + 0x00,0x79,0x18,0x00,0x00,0xbb,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x95,0xbb,0x31, + 0xb4,0x30,0xb9,0xaf,0xb9,0x34,0xbd,0xb2,0x21,0xc6,0x32,0x3c,0xc0,0x42,0x70,0x0d, + 0x82,0xe0,0xe0,0xd8,0xca,0x40,0x98,0x98,0xac,0x9a,0x40,0xec,0xca,0xe4,0xe6,0xd2, + 0xde,0xdc,0x40,0x72,0x60,0x64,0x5c,0x62,0x40,0x50,0xda,0xca,0xe8,0xc2,0xd8,0xcc, + 0xca,0x5a,0x72,0x60,0x64,0x5c,0x62,0x5c,0x6a,0x60,0x52,0x86,0x08,0x8f,0x30,0xc4, + 0x58,0x86,0xa5,0x58,0x04,0x16,0x4d,0x65,0x74,0x61,0x6c,0x43,0x90,0xa7,0x58,0x86, + 0x45,0x58,0x04,0x6e,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e, + 0x64,0x65,0x6e,0x6f,0x72,0x6d,0x73,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43, + 0x84,0xe7,0x20,0x17,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x62, + 0x16,0x36,0x47,0xf7,0xd5,0x16,0x46,0x87,0xf6,0x55,0xe6,0x16,0x26,0xc6,0x56,0x36, + 0x44,0x78,0x12,0x92,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99, + 0x8b,0x99,0x5c,0x58,0x5b,0x99,0x58,0x9d,0x99,0x59,0x99,0xdc,0x97,0x59,0x19,0xdd, + 0x18,0xda,0x57,0x99,0x5b,0x98,0x18,0x5b,0xd9,0x10,0xe1,0x59,0x18,0x06,0x61,0x69, + 0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65, + 0x5f,0x64,0x6f,0x75,0x62,0x6c,0x65,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43, + 0x84,0xa7,0x61,0x14,0x96,0x26,0xe7,0x22,0x57,0xe6,0x46,0x56,0x26,0xf7,0x45,0x17, + 0x26,0x77,0x56,0x46,0xc7,0x28,0x2c,0x4d,0xce,0x25,0x4c,0xee,0xec,0x8b,0x2e,0x0f, + 0xae,0xec,0xcb,0x2d,0xac,0xad,0x8c,0x86,0x19,0xdb,0x5b,0x18,0x1d,0x0d,0x99,0xb0, + 0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xb7,0xb0,0xb6,0x32,0x2a,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x43,0x98,0xe7,0x59,0x84,0x07,0x7a,0xa2,0x47,0x7a, + 0xa6,0x21,0xc2,0x43,0x51,0x0a,0x4b,0x93,0x73,0x31,0x93,0x0b,0x3b,0x6b,0x2b,0x73, + 0xa3,0xfb,0x4a,0x73,0x83,0xab,0xa3,0xe3,0x52,0x37,0x57,0x26,0x87,0xc2,0xf6,0x36, + 0xe6,0x06,0x93,0x42,0x25,0x2c,0x4d,0xce,0x65,0xac,0xcc,0x8d,0xae,0x4c,0x8e,0x4f, + 0x58,0x9a,0x9c,0x0b,0x5c,0x99,0xdc,0x1c,0x5c,0xd9,0x18,0x5d,0x9a,0x5d,0x19,0x85, + 0x3a,0xbb,0x21,0xd2,0x22,0x3c,0xd6,0x73,0x3d,0xd8,0x93,0x3d,0xd0,0x13,0x3d,0xd2, + 0xa3,0x71,0xa9,0x9b,0x2b,0x93,0x43,0x61,0x7b,0x1b,0x73,0x8b,0x49,0x61,0x31,0xf6, + 0xc6,0xf6,0x26,0x37,0x44,0x5a,0x86,0xc7,0x7a,0xb8,0x07,0x7b,0xb2,0x07,0x7a,0xa2, + 0x47,0x7a,0x3a,0x2e,0x61,0x69,0x72,0x2e,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x94, + 0xc2,0xd2,0xe4,0x5c,0xd8,0xde,0xc6,0xc2,0xe8,0xd2,0xde,0xdc,0xbe,0xd2,0xdc,0xc8, + 0xca,0xf0,0xa8,0x84,0xa5,0xc9,0xb9,0xcc,0x85,0xb5,0xc1,0xb1,0x95,0x11,0xa3,0x2b, + 0xc3,0xa3,0xab,0x93,0x2b,0x93,0x21,0xe3,0x31,0x63,0x7b,0x0b,0xa3,0x63,0x01,0x99, + 0x0b,0x6b,0x83,0x63,0x2b,0xf3,0xe1,0x40,0x57,0x86,0x37,0x84,0x5a,0x8c,0xe7,0x7b, + 0xc0,0x60,0x11,0x96,0xe1,0x09,0x83,0x07,0x7a,0xc4,0xe0,0x91,0x9e,0x31,0xe0,0x12, + 0x96,0x26,0xe7,0x32,0x17,0xd6,0x06,0xc7,0x56,0x26,0xc7,0x63,0x2e,0xac,0x0d,0x8e, + 0xad,0x4c,0x8e,0x08,0x5d,0x19,0xde,0x54,0x1b,0x1c,0x9b,0xdc,0x10,0x69,0x39,0x9e, + 0x32,0x78,0xc0,0x60,0x11,0x96,0xe1,0x81,0x1e,0x33,0x78,0xa4,0xe7,0x0c,0x86,0x20, + 0xcf,0xf6,0x78,0x0f,0x19,0x3c,0x68,0x30,0xc4,0x40,0x80,0xa7,0x7a,0xd2,0x60,0x44, + 0xc4,0x0e,0xec,0x60,0x0f,0xed,0xe0,0x06,0xed,0xf0,0x0e,0xe4,0x50,0x0f,0xec,0x50, + 0x0e,0x6e,0x60,0x0e,0xec,0x10,0x0e,0xe7,0x30,0x0f,0x53,0x82,0x60,0x84,0xc2,0x0e, + 0xec,0x60,0x0f,0xed,0xe0,0x06,0xe9,0x40,0x0e,0xe5,0xe0,0x0e,0xf4,0x30,0x25,0x18, + 0x46,0x2c,0xe1,0x90,0x0e,0xf2,0xe0,0x06,0xf6,0x50,0x0e,0xf2,0x30,0x0f,0xe9,0xf0, + 0x0e,0xee,0x30,0x25,0x20,0x46,0x50,0xe1,0x90,0x0e,0xf2,0xe0,0x06,0xec,0x10,0x0e, + 0xee,0x70,0x0e,0xf5,0x10,0x0e,0xe7,0x50,0x0e,0xbf,0x60,0x0f,0xe5,0x20,0x0f,0xf3, + 0x90,0x0e,0xef,0xe0,0x0e,0x53,0x02,0x63,0xc4,0x14,0x0e,0xe9,0x20,0x0f,0x6e,0x30, + 0x0e,0xef,0xd0,0x0e,0xf0,0x90,0x0e,0xec,0x50,0x0e,0xbf,0xf0,0x0e,0xf0,0x40,0x0f, + 0xe9,0xf0,0x0e,0xee,0x30,0x0f,0x53,0x08,0x44,0x61,0x9c,0x11,0x4c,0x38,0xa4,0x83, + 0x3c,0xb8,0x81,0x39,0xc8,0x43,0x38,0x9c,0x43,0x3b,0x94,0x83,0x3b,0xd0,0xc3,0x94, + 0x40,0x0d,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80, + 0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80, + 0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80, + 0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88, + 0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78, + 0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03, + 0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f, + 0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c, + 0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39, + 0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b, + 0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60, + 0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87, + 0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e, + 0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6, + 0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94, + 0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03, + 0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07, + 0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f, + 0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33, + 0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc, + 0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c, + 0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78, + 0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca, + 0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21, + 0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43, + 0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87, + 0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00, + 0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00, + 0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d, + 0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00,0x00,0x16,0x00,0x00, + 0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x04,0xc7,0x22, + 0x80,0x40,0x20,0x88,0x8d,0x00,0x8c,0x25,0x00,0x01,0xa9,0x11,0x80,0x1a,0x20,0x31, + 0x03,0x40,0x61,0x0e,0xc2,0xb2,0x2c,0x6a,0x06,0x80,0xc0,0x0c,0xc0,0x08,0xc0,0x18, + 0x01,0x08,0x82,0x20,0xfe,0x01,0x00,0x00,0x00,0x83,0x0c,0x0f,0x91,0x8c,0x18,0x28, + 0x42,0x70,0x39,0x4d,0x80,0x2c,0xc9,0x30,0xc8,0x70,0x04,0x8d,0x05,0x91,0x7c,0x66, + 0x1b,0x94,0x00,0xc8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const char _sfons_vs_source_metal_sim[866] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x74,0x6d,0x3b,0x0a,0x7d,0x3b, + 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f, + 0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, + 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a, + 0x65,0x20,0x5b,0x5b,0x70,0x6f,0x69,0x6e,0x74,0x5f,0x73,0x69,0x7a,0x65,0x5d,0x5d, + 0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69, + 0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74, + 0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72, + 0x64,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31, + 0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75, + 0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x70,0x73,0x69,0x7a,0x65,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69, + 0x62,0x75,0x74,0x65,0x28,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23, + 0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22,0x73,0x66,0x6f,0x6e,0x73,0x2e,0x67, + 0x6c,0x73,0x6c,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f, + 0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x31,0x20,0x5b,0x5b, + 0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74, + 0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20, + 0x22,0x73,0x66,0x6f,0x6e,0x73,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20, + 0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x5f,0x32,0x31,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x69,0x6e,0x2e, + 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20, + 0x31,0x38,0x20,0x22,0x73,0x66,0x6f,0x6e,0x73,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a, + 0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74, + 0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,0x73,0x69,0x7a,0x65,0x3b, + 0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x39,0x20,0x22,0x73,0x66,0x6f,0x6e,0x73, + 0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75, + 0x76,0x20,0x3d,0x20,0x5f,0x32,0x31,0x2e,0x74,0x6d,0x20,0x2a,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30, + 0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x23,0x6c,0x69, + 0x6e,0x65,0x20,0x32,0x30,0x20,0x22,0x73,0x66,0x6f,0x6e,0x73,0x2e,0x67,0x6c,0x73, + 0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a, + 0x0a,0x00, +}; +static const char _sfons_fs_source_metal_sim[518] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d, + 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, + 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20, + 0x31,0x31,0x20,0x22,0x73,0x66,0x6f,0x6e,0x73,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a, + 0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f, + 0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69, + 0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d, + 0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f, + 0x61,0x74,0x3e,0x20,0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72, + 0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20, + 0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c, + 0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b, + 0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x31,0x20,0x22,0x73,0x66,0x6f, + 0x6e,0x73,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, + 0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x34,0x28,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x31, + 0x2e,0x30,0x2c,0x20,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x74, + 0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x69,0x6e,0x2e,0x75,0x76,0x2e,0x78, + 0x79,0x29,0x2e,0x78,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74, + 0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_D3D11) +static const uint8_t _sfons_vs_bytecode_hlsl4[1032] = { + 0x44,0x58,0x42,0x43,0x09,0x96,0xbb,0xbb,0xfc,0x44,0x44,0xa8,0xa4,0x1c,0x9e,0x45, + 0x50,0x97,0xf1,0xde,0x01,0x00,0x00,0x00,0x08,0x04,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0x14,0x01,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x02,0x00,0x00, + 0x8c,0x03,0x00,0x00,0x52,0x44,0x45,0x46,0xd8,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xfe,0xff, + 0x10,0x81,0x00,0x00,0xaf,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x00,0xab,0xab,0x3c,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x60,0x00,0x00,0x00, + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x98,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5f,0x32,0x31,0x5f, + 0x6d,0x76,0x70,0x00,0x02,0x00,0x03,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x5f,0x32,0x31,0x5f,0x74,0x6d,0x00,0x4d,0x69,0x63,0x72,0x6f, + 0x73,0x6f,0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68, + 0x61,0x64,0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30, + 0x2e,0x31,0x00,0xab,0x49,0x53,0x47,0x4e,0x74,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x68,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x03,0x03,0x00,0x00,0x68,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x68,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x68,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, + 0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44, + 0x00,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0xab,0xab,0xab, + 0x53,0x48,0x44,0x52,0x84,0x01,0x00,0x00,0x40,0x00,0x01,0x00,0x61,0x00,0x00,0x00, + 0x59,0x00,0x00,0x04,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x03, + 0x32,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00, + 0x02,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00, + 0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x67,0x00,0x00,0x04, + 0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x68,0x00,0x00,0x02, + 0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x08,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00, + 0x56,0x15,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00, + 0x06,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08, + 0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x36,0x00,0x00,0x05, + 0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x02,0x00,0x00,0x00, + 0x38,0x00,0x00,0x08,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x56,0x15,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x06,0x10,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00, + 0x00,0x00,0x00,0x00,0xa6,0x1a,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00, + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00, + 0x32,0x00,0x00,0x0a,0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0xf6,0x1f,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x01,0x53,0x54,0x41,0x54, + 0x74,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x06,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sfons_fs_bytecode_hlsl4[640] = { + 0x44,0x58,0x42,0x43,0x5e,0xbc,0x77,0xd9,0xc9,0xdf,0x7d,0x8e,0x0c,0x24,0x18,0x66, + 0x36,0xd3,0xf4,0x78,0x01,0x00,0x00,0x00,0x80,0x02,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0x20,0x01,0x00,0x00,0x54,0x01,0x00,0x00, + 0x04,0x02,0x00,0x00,0x52,0x44,0x45,0x46,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xff,0xff, + 0x10,0x81,0x00,0x00,0x6d,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x69,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x00,0x74,0x65,0x78,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f, + 0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64, + 0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31, + 0x00,0xab,0xab,0xab,0x49,0x53,0x47,0x4e,0x44,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x03,0x00,0x00,0x38,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x2c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65, + 0x74,0x00,0xab,0xab,0x53,0x48,0x44,0x52,0xa8,0x00,0x00,0x00,0x40,0x00,0x00,0x00, + 0x2a,0x00,0x00,0x00,0x5a,0x00,0x00,0x03,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x58,0x18,0x00,0x04,0x00,0x70,0x10,0x00,0x00,0x00,0x00,0x00,0x55,0x55,0x00,0x00, + 0x62,0x10,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x00,0x03, + 0xf2,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00, + 0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x02,0x01,0x00,0x00,0x00,0x45,0x00,0x00,0x09, + 0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x96,0x73,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x36,0x00,0x00,0x05,0x12,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x00, + 0x00,0x00,0x80,0x3f,0x38,0x00,0x00,0x07,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00, + 0x06,0x0c,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x01,0x00,0x00,0x00, + 0x3e,0x00,0x00,0x01,0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +#elif defined(SOKOL_WGPU) +/* + WebGPU shader blobs: + + Vertex shader source: + + #version 450 + + layout(set = 0, binding = 0, std140) uniform vs_params + { + mat4 mvp; + mat4 tm; + } _21; + + layout(location = 0) in vec4 position; + layout(location = 3) in float psize; + layout(location = 0) out vec4 uv; + layout(location = 1) in vec2 texcoord0; + layout(location = 1) out vec4 color; + layout(location = 2) in vec4 color0; + + void main() + { + gl_Position = _21.mvp * position; + gl_PointSize = psize; + uv = _21.tm * vec4(texcoord0, 0.0, 1.0); + color = color0; + } + + Fragment shader source: + + #version 450 + + layout(location = 0, set = 2, binding = 0) uniform sampler2D tex; + + layout(location = 0) out vec4 frag_color; + layout(location = 0) in vec4 uv; + layout(location = 1) in vec4 color; + + void main() + { + frag_color = vec4(1.0, 1.0, 1.0, texture(tex, uv.xy).x) * color; + } +*/ +static const uint8_t _sfons_vs_bytecode_wgpu[1968] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x35,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x21,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x33,0x00,0x00,0x00, + 0x07,0x00,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x05,0x00, + 0x07,0x00,0x00,0x00,0x73,0x66,0x6f,0x6e,0x73,0x2e,0x67,0x6c,0x73,0x6c,0x00,0x00, + 0x03,0x00,0x37,0x00,0x02,0x00,0x00,0x00,0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65, + 0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e, + 0x74,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f, + 0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64, + 0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x2e,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65, + 0x74,0x2d,0x65,0x6e,0x76,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20, + 0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65, + 0x64,0x20,0x65,0x6e,0x74,0x72,0x79,0x2d,0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61, + 0x69,0x6e,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00, + 0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,0x05,0x00,0x06,0x00, + 0x0d,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x65,0x72,0x56,0x65,0x72,0x74,0x65,0x78, + 0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x06,0x00,0x07,0x00, + 0x0d,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74, + 0x53,0x69,0x7a,0x65,0x00,0x00,0x00,0x00,0x06,0x00,0x07,0x00,0x0d,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x67,0x6c,0x5f,0x43,0x6c,0x69,0x70,0x44,0x69,0x73,0x74,0x61, + 0x6e,0x63,0x65,0x00,0x06,0x00,0x07,0x00,0x0d,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x43,0x75,0x6c,0x6c,0x44,0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x00, + 0x05,0x00,0x03,0x00,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00, + 0x13,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x00,0x00,0x00, + 0x06,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6d,0x76,0x70,0x00, + 0x06,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x74,0x6d,0x00,0x00, + 0x05,0x00,0x03,0x00,0x15,0x00,0x00,0x00,0x5f,0x32,0x31,0x00,0x05,0x00,0x05,0x00, + 0x1a,0x00,0x00,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x00,0x00, + 0x05,0x00,0x04,0x00,0x21,0x00,0x00,0x00,0x70,0x73,0x69,0x7a,0x65,0x00,0x00,0x00, + 0x05,0x00,0x03,0x00,0x25,0x00,0x00,0x00,0x75,0x76,0x00,0x00,0x05,0x00,0x05,0x00, + 0x2a,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x00,0x00, + 0x05,0x00,0x04,0x00,0x32,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00, + 0x05,0x00,0x04,0x00,0x33,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x00, + 0x48,0x00,0x05,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0d,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x48,0x00,0x05,0x00, + 0x0d,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x47,0x00,0x03,0x00,0x0d,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x48,0x00,0x04,0x00, + 0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x48,0x00,0x05,0x00, + 0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x48,0x00,0x05,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x48,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x23,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x13,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x47,0x00,0x03,0x00, + 0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x15,0x00,0x00,0x00, + 0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x15,0x00,0x00,0x00, + 0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x1a,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x21,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x25,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x2a,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x32,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x33,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00, + 0x21,0x00,0x03,0x00,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00, + 0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x09,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x15,0x00,0x04,0x00,0x0a,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x0a,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x04,0x00,0x0c,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x1e,0x00,0x06,0x00,0x0d,0x00,0x00,0x00, + 0x09,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x0c,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0d,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x15,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x18,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x1e,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x12,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x19,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x1d,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x20,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x23,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x1d,0x00,0x00,0x00,0x25,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x28,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x29,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x28,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x29,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,0x80,0x3f, + 0x3b,0x00,0x04,0x00,0x1d,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x19,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x36,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x07,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x05,0x00, + 0x16,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x11,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x1a,0x00,0x00,0x00, + 0x91,0x00,0x05,0x00,0x09,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x18,0x00,0x00,0x00, + 0x1b,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x1d,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x0f,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x1e,0x00,0x00,0x00, + 0x1c,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x22,0x00,0x00,0x00, + 0x21,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x23,0x00,0x00,0x00,0x24,0x00,0x00,0x00, + 0x0f,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x24,0x00,0x00,0x00, + 0x22,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x14,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x16,0x00,0x00,0x00,0x26,0x00,0x00,0x00, + 0x15,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x12,0x00,0x00,0x00, + 0x27,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x28,0x00,0x00,0x00, + 0x2b,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x51,0x00,0x05,0x00,0x08,0x00,0x00,0x00, + 0x2e,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0x00,0x05,0x00, + 0x08,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x50,0x00,0x07,0x00,0x09,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x2e,0x00,0x00,0x00, + 0x2f,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x91,0x00,0x05,0x00, + 0x09,0x00,0x00,0x00,0x31,0x00,0x00,0x00,0x27,0x00,0x00,0x00,0x30,0x00,0x00,0x00, + 0x3e,0x00,0x03,0x00,0x25,0x00,0x00,0x00,0x31,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x07,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x09,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x3e,0x00,0x03,0x00, + 0x32,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +static const uint8_t fs_bytecode_wgpu[1000] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x1f,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x08,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x1c,0x00,0x00,0x00, + 0x10,0x00,0x03,0x00,0x05,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x00,0x03,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x05,0x00,0x07,0x00,0x00,0x00, + 0x73,0x66,0x6f,0x6e,0x73,0x2e,0x67,0x6c,0x73,0x6c,0x00,0x00,0x03,0x00,0x37,0x00, + 0x02,0x00,0x00,0x00,0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x2f,0x2f,0x20,0x4f, + 0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64, + 0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x30, + 0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f, + 0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x6f,0x70, + 0x65,0x6e,0x67,0x6c,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64, + 0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72, + 0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x2e, + 0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f, + 0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e, + 0x76,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f, + 0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x65,0x6e, + 0x74,0x72,0x79,0x2d,0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x0a,0x23, + 0x6c,0x69,0x6e,0x65,0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00,0x05,0x00,0x00,0x00, + 0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00,0x0b,0x00,0x00,0x00, + 0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x05,0x00,0x03,0x00, + 0x10,0x00,0x00,0x00,0x74,0x65,0x78,0x00,0x05,0x00,0x03,0x00,0x13,0x00,0x00,0x00, + 0x75,0x76,0x00,0x00,0x05,0x00,0x04,0x00,0x1c,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f, + 0x72,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x0b,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x22,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x21,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x1c,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x21,0x00,0x03,0x00, + 0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00,0x08,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x09,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x0a,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x0c,0x00,0x00,0x00, + 0x00,0x00,0x80,0x3f,0x19,0x00,0x09,0x00,0x0d,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x03,0x00,0x0e,0x00,0x00,0x00, + 0x0d,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x0e,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x09,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x1c,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x36,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00, + 0x08,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x4f,0x00,0x07,0x00,0x14,0x00,0x00,0x00,0x16,0x00,0x00,0x00,0x15,0x00,0x00,0x00, + 0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x57,0x00,0x05,0x00, + 0x09,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x16,0x00,0x00,0x00, + 0x51,0x00,0x05,0x00,0x08,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x50,0x00,0x07,0x00,0x09,0x00,0x00,0x00,0x1b,0x00,0x00,0x00, + 0x0c,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x1a,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x1d,0x00,0x00,0x00,0x1c,0x00,0x00,0x00, + 0x85,0x00,0x05,0x00,0x09,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1b,0x00,0x00,0x00, + 0x1d,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x0b,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +#elif defined(SOKOL_DUMMY_BACKEND) +static const char* _sfons_vs_source_dummy = ""; +static const char* _sfons_fs_source_dummy = ""; +#else +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#endif + +typedef struct _sfons_t { + sfons_desc_t desc; + sg_shader shd; + sgl_pipeline pip; + sg_image img; + int cur_width, cur_height; + bool img_dirty; +} _sfons_t; + +static void _sfons_clear(void* ptr, size_t size) { + SOKOL_ASSERT(ptr && (size > 0)); + memset(ptr, 0, size); +} + +static void* _sfons_malloc(const sfons_allocator_t* allocator, size_t size) { + SOKOL_ASSERT(allocator && (size > 0)); + void* ptr; + if (allocator->alloc) { + ptr = allocator->alloc(size, allocator->user_data); + } + else { + ptr = malloc(size); + } + SOKOL_ASSERT(ptr); + return ptr; +} + +static void* _sfons_malloc_clear(const sfons_allocator_t* allocator, size_t size) { + void* ptr = _sfons_malloc(allocator, size); + _sfons_clear(ptr, size); + return ptr; +} + +static void _sfons_free(const sfons_allocator_t* allocator, void* ptr) { + SOKOL_ASSERT(allocator); + if (allocator->free) { + allocator->free(ptr, allocator->user_data); + } + else { + free(ptr); + } +} + +static int _sfons_render_create(void* user_ptr, int width, int height) { + SOKOL_ASSERT(user_ptr && (width > 8) && (height > 8)); + _sfons_t* sfons = (_sfons_t*) user_ptr; + + /* sokol-gl compatible shader which treats RED channel as alpha */ + if (sfons->shd.id == SG_INVALID_ID) { + sg_shader_desc shd_desc; + _sfons_clear(&shd_desc, sizeof(shd_desc)); + shd_desc.attrs[0].name = "position"; + shd_desc.attrs[1].name = "texcoord0"; + shd_desc.attrs[2].name = "color0"; + shd_desc.attrs[3].name = "psize"; + shd_desc.attrs[0].sem_name = "TEXCOORD"; + shd_desc.attrs[0].sem_index = 0; + shd_desc.attrs[1].sem_name = "TEXCOORD"; + shd_desc.attrs[1].sem_index = 1; + shd_desc.attrs[2].sem_name = "TEXCOORD"; + shd_desc.attrs[2].sem_index = 2; + shd_desc.attrs[3].sem_name = "TEXCOORD"; + shd_desc.attrs[3].sem_index = 3; + sg_shader_uniform_block_desc* ub = &shd_desc.vs.uniform_blocks[0]; + ub->size = 128; + ub->uniforms[0].name = "vs_params"; + ub->uniforms[0].type = SG_UNIFORMTYPE_FLOAT4; + ub->uniforms[0].array_count = 8; + shd_desc.fs.images[0].name = "tex"; + shd_desc.fs.images[0].image_type = SG_IMAGETYPE_2D; + shd_desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; + shd_desc.label = "sokol-fontstash-shader"; + #if defined(SOKOL_GLCORE33) + shd_desc.vs.source = _sfons_vs_source_glsl330; + shd_desc.fs.source = _sfons_fs_source_glsl330; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _sfons_vs_source_glsl300es; + shd_desc.fs.source = _sfons_fs_source_glsl300es; + #elif defined(SOKOL_METAL) + shd_desc.vs.entry = "main0"; + shd_desc.fs.entry = "main0"; + switch (sg_query_backend()) { + case SG_BACKEND_METAL_MACOS: + shd_desc.vs.bytecode = SG_RANGE(_sfons_vs_bytecode_metal_macos); + shd_desc.fs.bytecode = SG_RANGE(_sfons_fs_bytecode_metal_macos); + break; + case SG_BACKEND_METAL_IOS: + shd_desc.vs.bytecode = SG_RANGE(_sfons_vs_bytecode_metal_ios); + shd_desc.fs.bytecode = SG_RANGE(_sfons_fs_bytecode_metal_ios); + break; + default: + shd_desc.vs.source = _sfons_vs_source_metal_sim; + shd_desc.fs.source = _sfons_fs_source_metal_sim; + break; + } + #elif defined(SOKOL_D3D11) + shd_desc.vs.bytecode = SG_RANGE(_sfons_vs_bytecode_hlsl4); + shd_desc.fs.bytecode = SG_RANGE(_sfons_fs_bytecode_hlsl4); + #elif defined(SOKOL_WGPU) + shd_desc.vs.byte_code = _sfons_vs_bytecode_wgpu; + shd_desc.vs.byte_code_size = sizeof(_sfons_vs_bytecode_wgpu); + shd_desc.fs.byte_code = _sfons_fs_bytecode_wgpu; + shd_desc.fs.byte_code_size = sizeof(_sfons_fs_bytecode_wgpu); + #else + shd_desc.vs.source = _sfons_vs_source_dummy; + shd_desc.fs.source = _sfons_fs_source_dummy; + #endif + shd_desc.label = "sfons-shader"; + sfons->shd = sg_make_shader(&shd_desc); + } + + /* sokol-gl pipeline object */ + if (sfons->pip.id == SG_INVALID_ID) { + sg_pipeline_desc pip_desc; + _sfons_clear(&pip_desc, sizeof(pip_desc)); + pip_desc.shader = sfons->shd; + pip_desc.colors[0].blend.enabled = true; + pip_desc.colors[0].blend.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA; + pip_desc.colors[0].blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + sfons->pip = sgl_make_pipeline(&pip_desc); + } + + /* create or re-create font atlas texture */ + if (sfons->img.id != SG_INVALID_ID) { + sg_destroy_image(sfons->img); + sfons->img.id = SG_INVALID_ID; + } + sfons->cur_width = width; + sfons->cur_height = height; + + SOKOL_ASSERT(sfons->img.id == SG_INVALID_ID); + sg_image_desc img_desc; + _sfons_clear(&img_desc, sizeof(img_desc)); + img_desc.width = sfons->cur_width; + img_desc.height = sfons->cur_height; + img_desc.min_filter = SG_FILTER_LINEAR; + img_desc.mag_filter = SG_FILTER_LINEAR; + img_desc.usage = SG_USAGE_DYNAMIC; + img_desc.pixel_format = SG_PIXELFORMAT_R8; + sfons->img = sg_make_image(&img_desc); + return 1; +} + +static int _sfons_render_resize(void* user_ptr, int width, int height) { + return _sfons_render_create(user_ptr, width, height); +} + +static void _sfons_render_update(void* user_ptr, int* rect, const unsigned char* data) { + SOKOL_ASSERT(user_ptr && rect && data); + _SOKOL_UNUSED(rect); + _SOKOL_UNUSED(data); + _sfons_t* sfons = (_sfons_t*) user_ptr; + sfons->img_dirty = true; +} + +static void _sfons_render_draw(void* user_ptr, const float* verts, const float* tcoords, const unsigned int* colors, int nverts) { + SOKOL_ASSERT(user_ptr && verts && tcoords && colors && (nverts > 0)); + _sfons_t* sfons = (_sfons_t*) user_ptr; + sgl_enable_texture(); + sgl_texture(sfons->img); + sgl_push_pipeline(); + sgl_load_pipeline(sfons->pip); + sgl_begin_triangles(); + for (int i = 0; i < nverts; i++) { + sgl_v2f_t2f_c1i(verts[2*i+0], verts[2*i+1], tcoords[2*i+0], tcoords[2*i+1], colors[i]); + } + sgl_end(); + sgl_pop_pipeline(); + sgl_disable_texture(); +} + +static void _sfons_render_delete(void* user_ptr) { + SOKOL_ASSERT(user_ptr); + _sfons_t* sfons = (_sfons_t*) user_ptr; + if (sfons->img.id != SG_INVALID_ID) { + sg_destroy_image(sfons->img); + sfons->img.id = SG_INVALID_ID; + } + if (sfons->pip.id != SG_INVALID_ID) { + sgl_destroy_pipeline(sfons->pip); + sfons->pip.id = SG_INVALID_ID; + } + if (sfons->shd.id != SG_INVALID_ID) { + sg_destroy_shader(sfons->shd); + sfons->shd.id = SG_INVALID_ID; + } +} + +#define _sfons_def(val, def) (((val) == 0) ? (def) : (val)) + +static sfons_desc_t _sfons_desc_defaults(const sfons_desc_t* desc) { + SOKOL_ASSERT(desc); + sfons_desc_t res = *desc; + res.width = _sfons_def(res.width, 512); + res.height = _sfons_def(res.height, 512); + return res; +} + +SOKOL_API_IMPL FONScontext* sfons_create(const sfons_desc_t* desc) { + SOKOL_ASSERT(desc); + SOKOL_ASSERT((desc->allocator.alloc && desc->allocator.free) || (!desc->allocator.alloc && !desc->allocator.free)); + _sfons_t* sfons = (_sfons_t*) _sfons_malloc_clear(&desc->allocator, sizeof(_sfons_t)); + sfons->desc = _sfons_desc_defaults(desc); + FONSparams params; + _sfons_clear(¶ms, sizeof(params)); + params.width = sfons->desc.width; + params.height = sfons->desc.height; + params.flags = FONS_ZERO_TOPLEFT; + params.renderCreate = _sfons_render_create; + params.renderResize = _sfons_render_resize; + params.renderUpdate = _sfons_render_update; + params.renderDraw = _sfons_render_draw; + params.renderDelete = _sfons_render_delete; + params.userPtr = sfons; + return fonsCreateInternal(¶ms); +} + +SOKOL_API_IMPL void sfons_destroy(FONScontext* ctx) { + SOKOL_ASSERT(ctx); + _sfons_t* sfons = (_sfons_t*) ctx->params.userPtr; + fonsDeleteInternal(ctx); + const sfons_allocator_t allocator = sfons->desc.allocator; + _sfons_free(&allocator, sfons); +} + +SOKOL_API_IMPL void sfons_flush(FONScontext* ctx) { + SOKOL_ASSERT(ctx && ctx->params.userPtr); + _sfons_t* sfons = (_sfons_t*) ctx->params.userPtr; + if (sfons->img_dirty) { + sfons->img_dirty = false; + sg_image_data data; + _sfons_clear(&data, sizeof(data)); + data.subimage[0][0].ptr = ctx->texData; + data.subimage[0][0].size = (size_t) (sfons->cur_width * sfons->cur_height); + sg_update_image(sfons->img, &data); + } +} + +SOKOL_API_IMPL uint32_t sfons_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + return ((uint32_t)r) | ((uint32_t)g<<8) | ((uint32_t)b<<16) | ((uint32_t)a<<24); +} + +#endif /* SOKOL_FONTSTASH_IMPL */ diff --git a/source/engine/thirdparty/sokol/sokol_gfx_imgui.h b/source/engine/thirdparty/sokol/sokol_gfx_imgui.h new file mode 100644 index 0000000..4e7cbe1 --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_gfx_imgui.h @@ -0,0 +1,4226 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_GFX_IMGUI_IMPL) +#define SOKOL_GFX_IMGUI_IMPL +#endif +#ifndef SOKOL_GFX_IMGUI_INCLUDED +/* + sokol_gfx_imgui.h -- debug-inspection UI for sokol_gfx.h using Dear ImGui + + Project URL: https://github.com/floooh/sokol + + Do this: + #define SOKOL_IMPL or + #define SOKOL_GFX_IMGUI_IMPL + + before you include this file in *one* C or C++ file to create the + implementation. + + NOTE that the implementation can be compiled either as C++ or as C. + When compiled as C++, sokol_gfx_imgui.h will directly call into the + Dear ImGui C++ API. When compiled as C, sokol_gfx_imgui.h will call + cimgui.h functions instead. + + Include the following file(s) before including sokol_gfx_imgui.h: + + sokol_gfx.h + + Additionally, include the following headers before including the + implementation: + + If the implementation is compiled as C++: + imgui.h + + If the implementation is compiled as C: + cimgui.h + + The sokol_gfx.h implementation must be compiled with debug trace hooks + enabled by defining: + + SOKOL_TRACE_HOOKS + + ...before including the sokol_gfx.h implementation. + + Before including the sokol_gfx_imgui.h implementation, optionally + override the following macros: + + SOKOL_ASSERT(c) -- your own assert macro, default: assert(c) + SOKOL_UNREACHABLE -- your own macro to annotate unreachable code, + default: SOKOL_ASSERT(false) + SOKOL_GFX_IMGUI_API_DECL - public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_GFX_IMGUI_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + + If sokol_gfx_imgui.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + On Windows, SOKOL_DLL will define SOKOL_GFX_IMGUI_API_DECL as __declspec(dllexport) + or __declspec(dllimport) as needed. + + STEP BY STEP: + ============= + --- create an sg_imgui_t struct (which must be preserved between frames) + and initialize it with: + + sg_imgui_init(&sg_imgui, &(sg_imgui_desc_t){ 0 }); + + Note that from C++ you can't inline the desc structure initialization: + + const sg_imgui_desc_t desc = { }; + sg_imgui_init(&sg_imgui, &desc); + + Provide optional memory allocator override functions (compatible with malloc/free) like this: + + sg_imgui_init(&sg_imgui, &(sg_imgui_desc_t){ + .allocator = { + .alloc = my_malloc, + .free = my_free, + } + }); + + --- somewhere in the per-frame code call: + + sg_imgui_draw(&sg_imgui) + + this won't draw anything yet, since no windows are open. + + --- open and close windows directly by setting the following public + booleans in the sg_imgui_t struct: + + sg_imgui.buffers.open = true; + sg_imgui.images.open = true; + sg_imgui.shaders.open = true; + sg_imgui.pipelines.open = true; + sg_imgui.passes.open = true; + sg_imgui.capture.open = true; + + ...for instance, to control the window visibility through + menu items, the following code can be used: + + if (ImGui::BeginMainMenuBar()) { + if (ImGui::BeginMenu("sokol-gfx")) { + ImGui::MenuItem("Buffers", 0, &sg_imgui.buffers.open); + ImGui::MenuItem("Images", 0, &sg_imgui.images.open); + ImGui::MenuItem("Shaders", 0, &sg_imgui.shaders.open); + ImGui::MenuItem("Pipelines", 0, &sg_imgui.pipelines.open); + ImGui::MenuItem("Passes", 0, &sg_imgui.passes.open); + ImGui::MenuItem("Calls", 0, &sg_imgui.capture.open); + ImGui::EndMenu(); + } + ImGui::EndMainMenuBar(); + } + + --- before application shutdown, call: + + sg_imgui_discard(&sg_imgui); + + ...this is not strictly necessary because the application exits + anyway, but not doing this may trigger memory leak detection tools. + + --- finally, your application needs an ImGui renderer, you can either + provide your own, or drop in the sokol_imgui.h utility header + + ALTERNATIVE DRAWING FUNCTIONS: + ============================== + Instead of the convenient, but all-in-one sg_imgui_draw() function, + you can also use the following granular functions which might allow + better integration with your existing UI: + + The following functions only render the window *content* (so you + can integrate the UI into you own windows): + + void sg_imgui_draw_buffers_content(sg_imgui_t* ctx); + void sg_imgui_draw_images_content(sg_imgui_t* ctx); + void sg_imgui_draw_shaders_content(sg_imgui_t* ctx); + void sg_imgui_draw_pipelines_content(sg_imgui_t* ctx); + void sg_imgui_draw_passes_content(sg_imgui_t* ctx); + void sg_imgui_draw_capture_content(sg_imgui_t* ctx); + + And these are the 'full window' drawing functions: + + void sg_imgui_draw_buffers_window(sg_imgui_t* ctx); + void sg_imgui_draw_images_window(sg_imgui_t* ctx); + void sg_imgui_draw_shaders_window(sg_imgui_t* ctx); + void sg_imgui_draw_pipelines_window(sg_imgui_t* ctx); + void sg_imgui_draw_passes_window(sg_imgui_t* ctx); + void sg_imgui_draw_capture_window(sg_imgui_t* ctx); + + Finer-grained drawing functions may be moved to the public API + in the future as needed. + + MEMORY ALLOCATION OVERRIDE + ========================== + You can override the memory allocation functions at initialization time + like this: + + void* my_alloc(size_t size, void* user_data) { + return malloc(size); + } + + void my_free(void* ptr, void* user_data) { + free(ptr); + } + + ... + sg_imgui_init(&(&ctx, &(sg_imgui_desc_t){ + // ... + .allocator = { + .alloc = my_alloc, + .free = my_free, + .user_data = ...; + } + }); + ... + + This only affects memory allocation calls done by sokol_gfx_imgui.h + itself though, not any allocations in OS libraries. + + + LICENSE + ======= + zlib/libpng license + + Copyright (c) 2018 Andre Weissflog + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_GFX_IMGUI_INCLUDED (1) +#include +#include +#include // size_t + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_gfx_imgui.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_GFX_IMGUI_API_DECL) +#define SOKOL_GFX_IMGUI_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_GFX_IMGUI_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_GFX_IMGUI_IMPL) +#define SOKOL_GFX_IMGUI_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_GFX_IMGUI_API_DECL __declspec(dllimport) +#else +#define SOKOL_GFX_IMGUI_API_DECL extern +#endif +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +#define SG_IMGUI_STRBUF_LEN (96) +/* max number of captured calls per frame */ +#define SG_IMGUI_MAX_FRAMECAPTURE_ITEMS (4096) + +typedef struct sg_imgui_str_t { + char buf[SG_IMGUI_STRBUF_LEN]; +} sg_imgui_str_t; + +typedef struct sg_imgui_buffer_t { + sg_buffer res_id; + sg_imgui_str_t label; + sg_buffer_desc desc; +} sg_imgui_buffer_t; + +typedef struct sg_imgui_image_t { + sg_image res_id; + float ui_scale; + sg_imgui_str_t label; + sg_image_desc desc; +} sg_imgui_image_t; + +typedef struct sg_imgui_shader_t { + sg_shader res_id; + sg_imgui_str_t label; + sg_imgui_str_t vs_entry; + sg_imgui_str_t vs_d3d11_target; + sg_imgui_str_t vs_image_name[SG_MAX_SHADERSTAGE_IMAGES]; + sg_imgui_str_t vs_uniform_name[SG_MAX_SHADERSTAGE_UBS][SG_MAX_UB_MEMBERS]; + sg_imgui_str_t fs_entry; + sg_imgui_str_t fs_d3d11_target; + sg_imgui_str_t fs_image_name[SG_MAX_SHADERSTAGE_IMAGES]; + sg_imgui_str_t fs_uniform_name[SG_MAX_SHADERSTAGE_UBS][SG_MAX_UB_MEMBERS]; + sg_imgui_str_t attr_name[SG_MAX_VERTEX_ATTRIBUTES]; + sg_imgui_str_t attr_sem_name[SG_MAX_VERTEX_ATTRIBUTES]; + sg_shader_desc desc; +} sg_imgui_shader_t; + +typedef struct sg_imgui_pipeline_t { + sg_pipeline res_id; + sg_imgui_str_t label; + sg_pipeline_desc desc; +} sg_imgui_pipeline_t; + +typedef struct sg_imgui_pass_t { + sg_pass res_id; + sg_imgui_str_t label; + float color_image_scale[SG_MAX_COLOR_ATTACHMENTS]; + float ds_image_scale; + sg_pass_desc desc; +} sg_imgui_pass_t; + +typedef struct sg_imgui_buffers_t { + bool open; + int num_slots; + sg_buffer sel_buf; + sg_imgui_buffer_t* slots; +} sg_imgui_buffers_t; + +typedef struct sg_imgui_images_t { + bool open; + int num_slots; + sg_image sel_img; + sg_imgui_image_t* slots; +} sg_imgui_images_t; + +typedef struct sg_imgui_shaders_t { + bool open; + int num_slots; + sg_shader sel_shd; + sg_imgui_shader_t* slots; +} sg_imgui_shaders_t; + +typedef struct sg_imgui_pipelines_t { + bool open; + int num_slots; + sg_pipeline sel_pip; + sg_imgui_pipeline_t* slots; +} sg_imgui_pipelines_t; + +typedef struct sg_imgui_passes_t { + bool open; + int num_slots; + sg_pass sel_pass; + sg_imgui_pass_t* slots; +} sg_imgui_passes_t; + +typedef enum sg_imgui_cmd_t { + SG_IMGUI_CMD_INVALID, + SG_IMGUI_CMD_RESET_STATE_CACHE, + SG_IMGUI_CMD_MAKE_BUFFER, + SG_IMGUI_CMD_MAKE_IMAGE, + SG_IMGUI_CMD_MAKE_SHADER, + SG_IMGUI_CMD_MAKE_PIPELINE, + SG_IMGUI_CMD_MAKE_PASS, + SG_IMGUI_CMD_DESTROY_BUFFER, + SG_IMGUI_CMD_DESTROY_IMAGE, + SG_IMGUI_CMD_DESTROY_SHADER, + SG_IMGUI_CMD_DESTROY_PIPELINE, + SG_IMGUI_CMD_DESTROY_PASS, + SG_IMGUI_CMD_UPDATE_BUFFER, + SG_IMGUI_CMD_UPDATE_IMAGE, + SG_IMGUI_CMD_APPEND_BUFFER, + SG_IMGUI_CMD_BEGIN_DEFAULT_PASS, + SG_IMGUI_CMD_BEGIN_PASS, + SG_IMGUI_CMD_APPLY_VIEWPORT, + SG_IMGUI_CMD_APPLY_SCISSOR_RECT, + SG_IMGUI_CMD_APPLY_PIPELINE, + SG_IMGUI_CMD_APPLY_BINDINGS, + SG_IMGUI_CMD_APPLY_UNIFORMS, + SG_IMGUI_CMD_DRAW, + SG_IMGUI_CMD_END_PASS, + SG_IMGUI_CMD_COMMIT, + SG_IMGUI_CMD_ALLOC_BUFFER, + SG_IMGUI_CMD_ALLOC_IMAGE, + SG_IMGUI_CMD_ALLOC_SHADER, + SG_IMGUI_CMD_ALLOC_PIPELINE, + SG_IMGUI_CMD_ALLOC_PASS, + SG_IMGUI_CMD_DEALLOC_BUFFER, + SG_IMGUI_CMD_DEALLOC_IMAGE, + SG_IMGUI_CMD_DEALLOC_SHADER, + SG_IMGUI_CMD_DEALLOC_PIPELINE, + SG_IMGUI_CMD_DEALLOC_PASS, + SG_IMGUI_CMD_INIT_BUFFER, + SG_IMGUI_CMD_INIT_IMAGE, + SG_IMGUI_CMD_INIT_SHADER, + SG_IMGUI_CMD_INIT_PIPELINE, + SG_IMGUI_CMD_INIT_PASS, + SG_IMGUI_CMD_UNINIT_BUFFER, + SG_IMGUI_CMD_UNINIT_IMAGE, + SG_IMGUI_CMD_UNINIT_SHADER, + SG_IMGUI_CMD_UNINIT_PIPELINE, + SG_IMGUI_CMD_UNINIT_PASS, + SG_IMGUI_CMD_FAIL_BUFFER, + SG_IMGUI_CMD_FAIL_IMAGE, + SG_IMGUI_CMD_FAIL_SHADER, + SG_IMGUI_CMD_FAIL_PIPELINE, + SG_IMGUI_CMD_FAIL_PASS, + SG_IMGUI_CMD_PUSH_DEBUG_GROUP, + SG_IMGUI_CMD_POP_DEBUG_GROUP, + SG_IMGUI_CMD_ERR_BUFFER_POOL_EXHAUSTED, + SG_IMGUI_CMD_ERR_IMAGE_POOL_EXHAUSTED, + SG_IMGUI_CMD_ERR_SHADER_POOL_EXHAUSTED, + SG_IMGUI_CMD_ERR_PIPELINE_POOL_EXHAUSTED, + SG_IMGUI_CMD_ERR_PASS_POOL_EXHAUSTED, + SG_IMGUI_CMD_ERR_CONTEXT_MISMATCH, + SG_IMGUI_CMD_ERR_PASS_INVALID, + SG_IMGUI_CMD_ERR_DRAW_INVALID, + SG_IMGUI_CMD_ERR_BINDINGS_INVALID, +} sg_imgui_cmd_t; + +typedef struct sg_imgui_args_make_buffer_t { + sg_buffer result; +} sg_imgui_args_make_buffer_t; + +typedef struct sg_imgui_args_make_image_t { + sg_image result; +} sg_imgui_args_make_image_t; + +typedef struct sg_imgui_args_make_shader_t { + sg_shader result; +} sg_imgui_args_make_shader_t; + +typedef struct sg_imgui_args_make_pipeline_t { + sg_pipeline result; +} sg_imgui_args_make_pipeline_t; + +typedef struct sg_imgui_args_make_pass_t { + sg_pass result; +} sg_imgui_args_make_pass_t; + +typedef struct sg_imgui_args_destroy_buffer_t { + sg_buffer buffer; +} sg_imgui_args_destroy_buffer_t; + +typedef struct sg_imgui_args_destroy_image_t { + sg_image image; +} sg_imgui_args_destroy_image_t; + +typedef struct sg_imgui_args_destroy_shader_t { + sg_shader shader; +} sg_imgui_args_destroy_shader_t; + +typedef struct sg_imgui_args_destroy_pipeline_t { + sg_pipeline pipeline; +} sg_imgui_args_destroy_pipeline_t; + +typedef struct sg_imgui_args_destroy_pass_t { + sg_pass pass; +} sg_imgui_args_destroy_pass_t; + +typedef struct sg_imgui_args_update_buffer_t { + sg_buffer buffer; + size_t data_size; +} sg_imgui_args_update_buffer_t; + +typedef struct sg_imgui_args_update_image_t { + sg_image image; +} sg_imgui_args_update_image_t; + +typedef struct sg_imgui_args_append_buffer_t { + sg_buffer buffer; + size_t data_size; + int result; +} sg_imgui_args_append_buffer_t; + +typedef struct sg_imgui_args_begin_default_pass_t { + sg_pass_action action; + int width; + int height; +} sg_imgui_args_begin_default_pass_t; + +typedef struct sg_imgui_args_begin_pass_t { + sg_pass pass; + sg_pass_action action; +} sg_imgui_args_begin_pass_t; + +typedef struct sg_imgui_args_apply_viewport_t { + int x, y, width, height; + bool origin_top_left; +} sg_imgui_args_apply_viewport_t; + +typedef struct sg_imgui_args_apply_scissor_rect_t { + int x, y, width, height; + bool origin_top_left; +} sg_imgui_args_apply_scissor_rect_t; + +typedef struct sg_imgui_args_apply_pipeline_t { + sg_pipeline pipeline; +} sg_imgui_args_apply_pipeline_t; + +typedef struct sg_imgui_args_apply_bindings_t { + sg_bindings bindings; +} sg_imgui_args_apply_bindings_t; + +typedef struct sg_imgui_args_apply_uniforms_t { + sg_shader_stage stage; + int ub_index; + size_t data_size; + sg_pipeline pipeline; /* the pipeline which was active at this call */ + size_t ubuf_pos; /* start of copied data in capture buffer */ +} sg_imgui_args_apply_uniforms_t; + +typedef struct sg_imgui_args_draw_t { + int base_element; + int num_elements; + int num_instances; +} sg_imgui_args_draw_t; + +typedef struct sg_imgui_args_alloc_buffer_t { + sg_buffer result; +} sg_imgui_args_alloc_buffer_t; + +typedef struct sg_imgui_args_alloc_image_t { + sg_image result; +} sg_imgui_args_alloc_image_t; + +typedef struct sg_imgui_args_alloc_shader_t { + sg_shader result; +} sg_imgui_args_alloc_shader_t; + +typedef struct sg_imgui_args_alloc_pipeline_t { + sg_pipeline result; +} sg_imgui_args_alloc_pipeline_t; + +typedef struct sg_imgui_args_alloc_pass_t { + sg_pass result; +} sg_imgui_args_alloc_pass_t; + +typedef struct sg_imgui_args_dealloc_buffer_t { + sg_buffer buffer; +} sg_imgui_args_dealloc_buffer_t; + +typedef struct sg_imgui_args_dealloc_image_t { + sg_image image; +} sg_imgui_args_dealloc_image_t; + +typedef struct sg_imgui_args_dealloc_shader_t { + sg_shader shader; +} sg_imgui_args_dealloc_shader_t; + +typedef struct sg_imgui_args_dealloc_pipeline_t { + sg_pipeline pipeline; +} sg_imgui_args_dealloc_pipeline_t; + +typedef struct sg_imgui_args_dealloc_pass_t { + sg_pass pass; +} sg_imgui_args_dealloc_pass_t; + +typedef struct sg_imgui_args_init_buffer_t { + sg_buffer buffer; +} sg_imgui_args_init_buffer_t; + +typedef struct sg_imgui_args_init_image_t { + sg_image image; +} sg_imgui_args_init_image_t; + +typedef struct sg_imgui_args_init_shader_t { + sg_shader shader; +} sg_imgui_args_init_shader_t; + +typedef struct sg_imgui_args_init_pipeline_t { + sg_pipeline pipeline; +} sg_imgui_args_init_pipeline_t; + +typedef struct sg_imgui_args_init_pass_t { + sg_pass pass; +} sg_imgui_args_init_pass_t; + +typedef struct sg_imgui_args_uninit_buffer_t { + sg_buffer buffer; +} sg_imgui_args_uninit_buffer_t; + +typedef struct sg_imgui_args_uninit_image_t { + sg_image image; +} sg_imgui_args_uninit_image_t; + +typedef struct sg_imgui_args_uninit_shader_t { + sg_shader shader; +} sg_imgui_args_uninit_shader_t; + +typedef struct sg_imgui_args_uninit_pipeline_t { + sg_pipeline pipeline; +} sg_imgui_args_uninit_pipeline_t; + +typedef struct sg_imgui_args_uninit_pass_t { + sg_pass pass; +} sg_imgui_args_uninit_pass_t; + +typedef struct sg_imgui_args_fail_buffer_t { + sg_buffer buffer; +} sg_imgui_args_fail_buffer_t; + +typedef struct sg_imgui_args_fail_image_t { + sg_image image; +} sg_imgui_args_fail_image_t; + +typedef struct sg_imgui_args_fail_shader_t { + sg_shader shader; +} sg_imgui_args_fail_shader_t; + +typedef struct sg_imgui_args_fail_pipeline_t { + sg_pipeline pipeline; +} sg_imgui_args_fail_pipeline_t; + +typedef struct sg_imgui_args_fail_pass_t { + sg_pass pass; +} sg_imgui_args_fail_pass_t; + +typedef struct sg_imgui_args_push_debug_group_t { + sg_imgui_str_t name; +} sg_imgui_args_push_debug_group_t; + +typedef union sg_imgui_args_t { + sg_imgui_args_make_buffer_t make_buffer; + sg_imgui_args_make_image_t make_image; + sg_imgui_args_make_shader_t make_shader; + sg_imgui_args_make_pipeline_t make_pipeline; + sg_imgui_args_make_pass_t make_pass; + sg_imgui_args_destroy_buffer_t destroy_buffer; + sg_imgui_args_destroy_image_t destroy_image; + sg_imgui_args_destroy_shader_t destroy_shader; + sg_imgui_args_destroy_pipeline_t destroy_pipeline; + sg_imgui_args_destroy_pass_t destroy_pass; + sg_imgui_args_update_buffer_t update_buffer; + sg_imgui_args_update_image_t update_image; + sg_imgui_args_append_buffer_t append_buffer; + sg_imgui_args_begin_default_pass_t begin_default_pass; + sg_imgui_args_begin_pass_t begin_pass; + sg_imgui_args_apply_viewport_t apply_viewport; + sg_imgui_args_apply_scissor_rect_t apply_scissor_rect; + sg_imgui_args_apply_pipeline_t apply_pipeline; + sg_imgui_args_apply_bindings_t apply_bindings; + sg_imgui_args_apply_uniforms_t apply_uniforms; + sg_imgui_args_draw_t draw; + sg_imgui_args_alloc_buffer_t alloc_buffer; + sg_imgui_args_alloc_image_t alloc_image; + sg_imgui_args_alloc_shader_t alloc_shader; + sg_imgui_args_alloc_pipeline_t alloc_pipeline; + sg_imgui_args_alloc_pass_t alloc_pass; + sg_imgui_args_dealloc_buffer_t dealloc_buffer; + sg_imgui_args_dealloc_image_t dealloc_image; + sg_imgui_args_dealloc_shader_t dealloc_shader; + sg_imgui_args_dealloc_pipeline_t dealloc_pipeline; + sg_imgui_args_dealloc_pass_t dealloc_pass; + sg_imgui_args_init_buffer_t init_buffer; + sg_imgui_args_init_image_t init_image; + sg_imgui_args_init_shader_t init_shader; + sg_imgui_args_init_pipeline_t init_pipeline; + sg_imgui_args_init_pass_t init_pass; + sg_imgui_args_uninit_buffer_t uninit_buffer; + sg_imgui_args_uninit_image_t uninit_image; + sg_imgui_args_uninit_shader_t uninit_shader; + sg_imgui_args_uninit_pipeline_t uninit_pipeline; + sg_imgui_args_uninit_pass_t uninit_pass; + sg_imgui_args_fail_buffer_t fail_buffer; + sg_imgui_args_fail_image_t fail_image; + sg_imgui_args_fail_shader_t fail_shader; + sg_imgui_args_fail_pipeline_t fail_pipeline; + sg_imgui_args_fail_pass_t fail_pass; + sg_imgui_args_push_debug_group_t push_debug_group; +} sg_imgui_args_t; + +typedef struct sg_imgui_capture_item_t { + sg_imgui_cmd_t cmd; + uint32_t color; + sg_imgui_args_t args; +} sg_imgui_capture_item_t; + +typedef struct sg_imgui_capture_bucket_t { + size_t ubuf_size; /* size of uniform capture buffer in bytes */ + size_t ubuf_pos; /* current uniform buffer pos */ + uint8_t* ubuf; /* buffer for capturing uniform updates */ + int num_items; + sg_imgui_capture_item_t items[SG_IMGUI_MAX_FRAMECAPTURE_ITEMS]; +} sg_imgui_capture_bucket_t; + +/* double-buffered call-capture buckets, one bucket is currently recorded, + the previous bucket is displayed +*/ +typedef struct sg_imgui_capture_t { + bool open; + int bucket_index; /* which bucket to record to, 0 or 1 */ + int sel_item; /* currently selected capture item by index */ + sg_imgui_capture_bucket_t bucket[2]; +} sg_imgui_capture_t; + +typedef struct sg_imgui_caps_t { + bool open; +} sg_imgui_caps_t; + +/* + sg_imgui_allocator_t + + Used in sg_imgui_desc_t to provide custom memory-alloc and -free functions + to sokol_gfx_imgui.h. If memory management should be overridden, both the + alloc and free function must be provided (e.g. it's not valid to + override one function but not the other). +*/ +typedef struct sg_imgui_allocator_t { + void* (*alloc)(size_t size, void* user_data); + void (*free)(void* ptr, void* user_data); + void* user_data; +} sg_imgui_allocator_t; + +/* + sg_imgui_desc_t + + Initialization options for sg_imgui_init(). +*/ +typedef struct sg_imgui_desc_t { + sg_imgui_allocator_t allocator; // optional memory allocation overrides (default: malloc/free) +} sg_imgui_desc_t; + +typedef struct sg_imgui_t { + uint32_t init_tag; + sg_imgui_desc_t desc; + sg_imgui_buffers_t buffers; + sg_imgui_images_t images; + sg_imgui_shaders_t shaders; + sg_imgui_pipelines_t pipelines; + sg_imgui_passes_t passes; + sg_imgui_capture_t capture; + sg_imgui_caps_t caps; + sg_pipeline cur_pipeline; + sg_trace_hooks hooks; +} sg_imgui_t; + +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_init(sg_imgui_t* ctx, const sg_imgui_desc_t* desc); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_discard(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw(sg_imgui_t* ctx); + +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_buffers_content(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_images_content(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_shaders_content(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_pipelines_content(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_passes_content(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_capture_content(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_capabilities_content(sg_imgui_t* ctx); + +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_buffers_window(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_images_window(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_shaders_window(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_pipelines_window(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_passes_window(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_capture_window(sg_imgui_t* ctx); +SOKOL_GFX_IMGUI_API_DECL void sg_imgui_draw_capabilities_window(sg_imgui_t* ctx); + +#if defined(__cplusplus) +} /* extern "C" */ +#endif +#endif /* SOKOL_GFX_IMGUI_INCLUDED */ + +/*=== IMPLEMENTATION =========================================================*/ +#ifdef SOKOL_GFX_IMGUI_IMPL +#define SOKOL_GFX_IMGUI_IMPL_INCLUDED (1) + +#if defined(SOKOL_MALLOC) || defined(SOKOL_CALLOC) || defined(SOKOL_FREE) +#error "SOKOL_MALLOC/CALLOC/FREE macros are no longer supported, please use sg_imgui_desc_t.allocator to override memory allocation functions" +#endif + +#if defined(__cplusplus) + #if !defined(IMGUI_VERSION) + #error "Please include imgui.h before the sokol_imgui.h implementation" + #endif +#else + #if !defined(CIMGUI_INCLUDED) + #error "Please include cimgui.h before the sokol_imgui.h implementation" + #endif +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif +#ifndef SOKOL_UNREACHABLE + #define SOKOL_UNREACHABLE SOKOL_ASSERT(false) +#endif +#ifndef _SOKOL_PRIVATE + #if defined(__GNUC__) || defined(__clang__) + #define _SOKOL_PRIVATE __attribute__((unused)) static + #else + #define _SOKOL_PRIVATE static + #endif +#endif +#ifndef _SOKOL_UNUSED +#define _SOKOL_UNUSED(x) (void)(x) +#endif +#ifndef SOKOL_API_IMPL +#define SOKOL_API_IMPL +#endif + +#include +#include // snprintf +#include // malloc, free + +#define _SG_IMGUI_SLOT_MASK (0xFFFF) +#define _SG_IMGUI_LIST_WIDTH (192) +#define _SG_IMGUI_COLOR_OTHER 0xFFCCCCCC +#define _SG_IMGUI_COLOR_RSRC 0xFF00FFFF +#define _SG_IMGUI_COLOR_DRAW 0xFF00FF00 +#define _SG_IMGUI_COLOR_ERR 0xFF8888FF + +/*--- C => C++ layer ---------------------------------------------------------*/ +#if defined(__cplusplus) +#define IMVEC2(x,y) ImVec2(x,y) +#define IMVEC4(x,y,z,w) ImVec4(x,y,z,w) +_SOKOL_PRIVATE void igText(const char* fmt,...) { + va_list args; + va_start(args, fmt); + ImGui::TextV(fmt, args); + va_end(args); +} +_SOKOL_PRIVATE void igSeparator() { + return ImGui::Separator(); +} +_SOKOL_PRIVATE void igSameLine(float offset_from_start_x, float spacing) { + return ImGui::SameLine(offset_from_start_x,spacing); +} +_SOKOL_PRIVATE void igPushID_Int(int int_id) { + return ImGui::PushID(int_id); +} +_SOKOL_PRIVATE void igPopID() { + return ImGui::PopID(); +} +_SOKOL_PRIVATE bool igSelectable_Bool(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2 size) { + return ImGui::Selectable(label,selected,flags,size); +} +_SOKOL_PRIVATE bool igSmallButton(const char* label) { + return ImGui::SmallButton(label); +} +_SOKOL_PRIVATE bool igBeginChild_Str(const char* str_id,const ImVec2 size,bool border,ImGuiWindowFlags flags) { + return ImGui::BeginChild(str_id,size,border,flags); +} +_SOKOL_PRIVATE void igEndChild() { + return ImGui::EndChild(); +} +_SOKOL_PRIVATE void igPushStyleColor_U32(ImGuiCol idx, ImU32 col) { + return ImGui::PushStyleColor(idx,col); +} +_SOKOL_PRIVATE void igPopStyleColor(int count) { + return ImGui::PopStyleColor(count); +} +_SOKOL_PRIVATE bool igTreeNode_StrStr(const char* str_id,const char* fmt,...) { + va_list args; + va_start(args, fmt); + bool ret = ImGui::TreeNodeV(str_id,fmt,args); + va_end(args); + return ret; +} +_SOKOL_PRIVATE bool igTreeNode_Str(const char* label) { + return ImGui::TreeNode(label); +} +_SOKOL_PRIVATE void igTreePop() { + return ImGui::TreePop(); +} +_SOKOL_PRIVATE bool igIsItemHovered(ImGuiHoveredFlags flags) { + return ImGui::IsItemHovered(flags); +} +_SOKOL_PRIVATE void igSetTooltip(const char* fmt,...) { + va_list args; + va_start(args, fmt); + ImGui::SetTooltipV(fmt,args); + va_end(args); +} +_SOKOL_PRIVATE bool igSliderFloat(const char* label,float* v,float v_min,float v_max,const char* format,ImGuiSliderFlags flags) { + return ImGui::SliderFloat(label,v,v_min,v_max,format,flags); +} +_SOKOL_PRIVATE void igImage(ImTextureID user_texture_id,const ImVec2 size,const ImVec2 uv0,const ImVec2 uv1,const ImVec4 tint_col,const ImVec4 border_col) { + return ImGui::Image(user_texture_id,size,uv0,uv1,tint_col,border_col); +} +_SOKOL_PRIVATE void igSetNextWindowSize(const ImVec2 size,ImGuiCond cond) { + return ImGui::SetNextWindowSize(size,cond); +} +_SOKOL_PRIVATE bool igBegin(const char* name,bool* p_open,ImGuiWindowFlags flags) { + return ImGui::Begin(name,p_open,flags); +} +_SOKOL_PRIVATE void igEnd() { + return ImGui::End(); +} +#else +#define IMVEC2(x,y) (ImVec2){x,y} +#define IMVEC4(x,y,z,w) (ImVec4){x,y,z,w} +#endif + +/*--- UTILS ------------------------------------------------------------------*/ +_SOKOL_PRIVATE void _sg_imgui_clear(void* ptr, size_t size) { + SOKOL_ASSERT(ptr && (size > 0)); + memset(ptr, 0, size); +} + +_SOKOL_PRIVATE void* _sg_imgui_malloc(const sg_imgui_allocator_t* allocator, size_t size) { + SOKOL_ASSERT(allocator && (size > 0)); + void* ptr; + if (allocator->alloc) { + ptr = allocator->alloc(size, allocator->user_data); + } + else { + ptr = malloc(size); + } + SOKOL_ASSERT(ptr); + return ptr; +} + +_SOKOL_PRIVATE void* _sg_imgui_malloc_clear(const sg_imgui_allocator_t* allocator, size_t size) { + void* ptr = _sg_imgui_malloc(allocator, size); + _sg_imgui_clear(ptr, size); + return ptr; +} + +_SOKOL_PRIVATE void _sg_imgui_free(const sg_imgui_allocator_t* allocator, void* ptr) { + SOKOL_ASSERT(allocator); + if (allocator->free) { + allocator->free(ptr, allocator->user_data); + } + else { + free(ptr); + } +} + + _SOKOL_PRIVATE void* _sg_imgui_realloc(const sg_imgui_allocator_t* allocator, void* old_ptr, size_t old_size, size_t new_size) { + SOKOL_ASSERT(allocator && (new_size > 0) && (new_size > old_size)); + void* new_ptr = _sg_imgui_malloc(allocator, new_size); + if (old_ptr) { + if (old_size > 0) { + memcpy(new_ptr, old_ptr, old_size); + } + _sg_imgui_free(allocator, old_ptr); + } + return new_ptr; +} + +_SOKOL_PRIVATE int _sg_imgui_slot_index(uint32_t id) { + int slot_index = (int) (id & _SG_IMGUI_SLOT_MASK); + SOKOL_ASSERT(0 != slot_index); + return slot_index; +} + +_SOKOL_PRIVATE uint32_t _sg_imgui_align_u32(uint32_t val, uint32_t align) { + SOKOL_ASSERT((align > 0) && ((align & (align - 1)) == 0)); + return (val + (align - 1)) & ~(align - 1); +} + +_SOKOL_PRIVATE uint32_t _sg_imgui_std140_uniform_alignment(sg_uniform_type type, int array_count) { + SOKOL_ASSERT(array_count > 0); + if (array_count == 1) { + switch (type) { + case SG_UNIFORMTYPE_FLOAT: + case SG_UNIFORMTYPE_INT: + return 4; + case SG_UNIFORMTYPE_FLOAT2: + case SG_UNIFORMTYPE_INT2: + return 8; + case SG_UNIFORMTYPE_FLOAT3: + case SG_UNIFORMTYPE_FLOAT4: + case SG_UNIFORMTYPE_INT3: + case SG_UNIFORMTYPE_INT4: + return 16; + case SG_UNIFORMTYPE_MAT4: + return 16; + default: + SOKOL_UNREACHABLE; + return 1; + } + } + else { + return 16; + } +} + +_SOKOL_PRIVATE uint32_t _sg_imgui_std140_uniform_size(sg_uniform_type type, int array_count) { + SOKOL_ASSERT(array_count > 0); + if (array_count == 1) { + switch (type) { + case SG_UNIFORMTYPE_FLOAT: + case SG_UNIFORMTYPE_INT: + return 4; + case SG_UNIFORMTYPE_FLOAT2: + case SG_UNIFORMTYPE_INT2: + return 8; + case SG_UNIFORMTYPE_FLOAT3: + case SG_UNIFORMTYPE_INT3: + return 12; + case SG_UNIFORMTYPE_FLOAT4: + case SG_UNIFORMTYPE_INT4: + return 16; + case SG_UNIFORMTYPE_MAT4: + return 64; + default: + SOKOL_UNREACHABLE; + return 0; + } + } + else { + switch (type) { + case SG_UNIFORMTYPE_FLOAT: + case SG_UNIFORMTYPE_FLOAT2: + case SG_UNIFORMTYPE_FLOAT3: + case SG_UNIFORMTYPE_FLOAT4: + case SG_UNIFORMTYPE_INT: + case SG_UNIFORMTYPE_INT2: + case SG_UNIFORMTYPE_INT3: + case SG_UNIFORMTYPE_INT4: + return 16 * (uint32_t)array_count; + case SG_UNIFORMTYPE_MAT4: + return 64 * (uint32_t)array_count; + default: + SOKOL_UNREACHABLE; + return 0; + } + } +} + +_SOKOL_PRIVATE void _sg_imgui_strcpy(sg_imgui_str_t* dst, const char* src) { + SOKOL_ASSERT(dst); + if (src) { + #if defined(_MSC_VER) + strncpy_s(dst->buf, SG_IMGUI_STRBUF_LEN, src, (SG_IMGUI_STRBUF_LEN-1)); + #else + strncpy(dst->buf, src, SG_IMGUI_STRBUF_LEN); + #endif + dst->buf[SG_IMGUI_STRBUF_LEN-1] = 0; + } + else { + _sg_imgui_clear(dst->buf, SG_IMGUI_STRBUF_LEN); + } +} + +_SOKOL_PRIVATE sg_imgui_str_t _sg_imgui_make_str(const char* str) { + sg_imgui_str_t res; + _sg_imgui_strcpy(&res, str); + return res; +} + +_SOKOL_PRIVATE const char* _sg_imgui_str_dup(const sg_imgui_allocator_t* allocator, const char* src) { + SOKOL_ASSERT(allocator && src); + size_t len = strlen(src) + 1; + char* dst = (char*) _sg_imgui_malloc(allocator, len); + memcpy(dst, src, len); + return (const char*) dst; +} + +_SOKOL_PRIVATE const void* _sg_imgui_bin_dup(const sg_imgui_allocator_t* allocator, const void* src, size_t num_bytes) { + SOKOL_ASSERT(allocator && src && (num_bytes > 0)); + void* dst = _sg_imgui_malloc(allocator, num_bytes); + memcpy(dst, src, num_bytes); + return (const void*) dst; +} + +_SOKOL_PRIVATE void _sg_imgui_snprintf(sg_imgui_str_t* dst, const char* fmt, ...) { + SOKOL_ASSERT(dst); + va_list args; + va_start(args, fmt); + vsnprintf(dst->buf, sizeof(dst->buf), fmt, args); + dst->buf[sizeof(dst->buf)-1] = 0; + va_end(args); +} + +/*--- STRING CONVERSION ------------------------------------------------------*/ +_SOKOL_PRIVATE const char* _sg_imgui_resourcestate_string(sg_resource_state s) { + switch (s) { + case SG_RESOURCESTATE_INITIAL: return "SG_RESOURCESTATE_INITIAL"; + case SG_RESOURCESTATE_ALLOC: return "SG_RESOURCESTATE_ALLOC"; + case SG_RESOURCESTATE_VALID: return "SG_RESOURCESTATE_VALID"; + case SG_RESOURCESTATE_FAILED: return "SG_RESOURCESTATE_FAILED"; + default: return "SG_RESOURCESTATE_INVALID"; + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_resource_slot(const sg_slot_info* slot) { + igText("ResId: %08X", slot->res_id); + igText("CtxId: %08X", slot->ctx_id); + igText("State: %s", _sg_imgui_resourcestate_string(slot->state)); +} + +_SOKOL_PRIVATE const char* _sg_imgui_backend_string(sg_backend b) { + switch (b) { + case SG_BACKEND_GLCORE33: return "SG_BACKEND_GLCORE33"; + case SG_BACKEND_GLES3: return "SG_BACKEND_GLES3"; + case SG_BACKEND_D3D11: return "SG_BACKEND_D3D11"; + case SG_BACKEND_METAL_IOS: return "SG_BACKEND_METAL_IOS"; + case SG_BACKEND_METAL_MACOS: return "SG_BACKEND_METAL_MACOS"; + case SG_BACKEND_METAL_SIMULATOR: return "SG_BACKEND_METAL_SIMULATOR"; + case SG_BACKEND_DUMMY: return "SG_BACKEND_DUMMY"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_buffertype_string(sg_buffer_type t) { + switch (t) { + case SG_BUFFERTYPE_VERTEXBUFFER: return "SG_BUFFERTYPE_VERTEXBUFFER"; + case SG_BUFFERTYPE_INDEXBUFFER: return "SG_BUFFERTYPE_INDEXBUFFER"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_usage_string(sg_usage u) { + switch (u) { + case SG_USAGE_IMMUTABLE: return "SG_USAGE_IMMUTABLE"; + case SG_USAGE_DYNAMIC: return "SG_USAGE_DYNAMIC"; + case SG_USAGE_STREAM: return "SG_USAGE_STREAM"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_imagetype_string(sg_image_type t) { + switch (t) { + case SG_IMAGETYPE_2D: return "SG_IMAGETYPE_2D"; + case SG_IMAGETYPE_CUBE: return "SG_IMAGETYPE_CUBE"; + case SG_IMAGETYPE_3D: return "SG_IMAGETYPE_3D"; + case SG_IMAGETYPE_ARRAY: return "SG_IMAGETYPE_ARRAY"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_samplertype_string(sg_sampler_type t) { + switch (t) { + case SG_SAMPLERTYPE_FLOAT: return "SG_SAMPLERTYPE_FLOAT"; + case SG_SAMPLERTYPE_SINT: return "SG_SAMPLERTYPE_SINT"; + case SG_SAMPLERTYPE_UINT: return "SG_SAMPLERTYPE_UINT"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_pixelformat_string(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_NONE: return "SG_PIXELFORMAT_NONE"; + case SG_PIXELFORMAT_R8: return "SG_PIXELFORMAT_R8"; + case SG_PIXELFORMAT_R8SN: return "SG_PIXELFORMAT_R8SN"; + case SG_PIXELFORMAT_R8UI: return "SG_PIXELFORMAT_R8UI"; + case SG_PIXELFORMAT_R8SI: return "SG_PIXELFORMAT_R8SI"; + case SG_PIXELFORMAT_R16: return "SG_PIXELFORMAT_R16"; + case SG_PIXELFORMAT_R16SN: return "SG_PIXELFORMAT_R16SN"; + case SG_PIXELFORMAT_R16UI: return "SG_PIXELFORMAT_R16UI"; + case SG_PIXELFORMAT_R16SI: return "SG_PIXELFORMAT_R16SI"; + case SG_PIXELFORMAT_R16F: return "SG_PIXELFORMAT_R16F"; + case SG_PIXELFORMAT_RG8: return "SG_PIXELFORMAT_RG8"; + case SG_PIXELFORMAT_RG8SN: return "SG_PIXELFORMAT_RG8SN"; + case SG_PIXELFORMAT_RG8UI: return "SG_PIXELFORMAT_RG8UI"; + case SG_PIXELFORMAT_RG8SI: return "SG_PIXELFORMAT_RG8SI"; + case SG_PIXELFORMAT_R32UI: return "SG_PIXELFORMAT_R32UI"; + case SG_PIXELFORMAT_R32SI: return "SG_PIXELFORMAT_R32SI"; + case SG_PIXELFORMAT_R32F: return "SG_PIXELFORMAT_R32F"; + case SG_PIXELFORMAT_RG16: return "SG_PIXELFORMAT_RG16"; + case SG_PIXELFORMAT_RG16SN: return "SG_PIXELFORMAT_RG16SN"; + case SG_PIXELFORMAT_RG16UI: return "SG_PIXELFORMAT_RG16UI"; + case SG_PIXELFORMAT_RG16SI: return "SG_PIXELFORMAT_RG16SI"; + case SG_PIXELFORMAT_RG16F: return "SG_PIXELFORMAT_RG16F"; + case SG_PIXELFORMAT_RGBA8: return "SG_PIXELFORMAT_RGBA8"; + case SG_PIXELFORMAT_SRGB8A8: return "SG_PIXELFORMAT_SRGB8A8"; + case SG_PIXELFORMAT_RGBA8SN: return "SG_PIXELFORMAT_RGBA8SN"; + case SG_PIXELFORMAT_RGBA8UI: return "SG_PIXELFORMAT_RGBA8UI"; + case SG_PIXELFORMAT_RGBA8SI: return "SG_PIXELFORMAT_RGBA8SI"; + case SG_PIXELFORMAT_BGRA8: return "SG_PIXELFORMAT_BGRA8"; + case SG_PIXELFORMAT_RGB10A2: return "SG_PIXELFORMAT_RGB10A2"; + case SG_PIXELFORMAT_RG11B10F: return "SG_PIXELFORMAT_RG11B10F"; + case SG_PIXELFORMAT_RG32UI: return "SG_PIXELFORMAT_RG32UI"; + case SG_PIXELFORMAT_RG32SI: return "SG_PIXELFORMAT_RG32SI"; + case SG_PIXELFORMAT_RG32F: return "SG_PIXELFORMAT_RG32F"; + case SG_PIXELFORMAT_RGBA16: return "SG_PIXELFORMAT_RGBA16"; + case SG_PIXELFORMAT_RGBA16SN: return "SG_PIXELFORMAT_RGBA16SN"; + case SG_PIXELFORMAT_RGBA16UI: return "SG_PIXELFORMAT_RGBA16UI"; + case SG_PIXELFORMAT_RGBA16SI: return "SG_PIXELFORMAT_RGBA16SI"; + case SG_PIXELFORMAT_RGBA16F: return "SG_PIXELFORMAT_RGBA16F"; + case SG_PIXELFORMAT_RGBA32UI: return "SG_PIXELFORMAT_RGBA32UI"; + case SG_PIXELFORMAT_RGBA32SI: return "SG_PIXELFORMAT_RGBA32SI"; + case SG_PIXELFORMAT_RGBA32F: return "SG_PIXELFORMAT_RGBA32F"; + case SG_PIXELFORMAT_DEPTH: return "SG_PIXELFORMAT_DEPTH"; + case SG_PIXELFORMAT_DEPTH_STENCIL: return "SG_PIXELFORMAT_DEPTH_STENCIL"; + case SG_PIXELFORMAT_BC1_RGBA: return "SG_PIXELFORMAT_BC1_RGBA"; + case SG_PIXELFORMAT_BC2_RGBA: return "SG_PIXELFORMAT_BC2_RGBA"; + case SG_PIXELFORMAT_BC3_RGBA: return "SG_PIXELFORMAT_BC3_RGBA"; + case SG_PIXELFORMAT_BC4_R: return "SG_PIXELFORMAT_BC4_R"; + case SG_PIXELFORMAT_BC4_RSN: return "SG_PIXELFORMAT_BC4_RSN"; + case SG_PIXELFORMAT_BC5_RG: return "SG_PIXELFORMAT_BC5_RG"; + case SG_PIXELFORMAT_BC5_RGSN: return "SG_PIXELFORMAT_BC5_RGSN"; + case SG_PIXELFORMAT_BC6H_RGBF: return "SG_PIXELFORMAT_BC6H_RGBF"; + case SG_PIXELFORMAT_BC6H_RGBUF: return "SG_PIXELFORMAT_BC6H_RGBUF"; + case SG_PIXELFORMAT_BC7_RGBA: return "SG_PIXELFORMAT_BC7_RGBA"; + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: return "SG_PIXELFORMAT_PVRTC_RGB_2BPP"; + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: return "SG_PIXELFORMAT_PVRTC_RGB_4BPP"; + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: return "SG_PIXELFORMAT_PVRTC_RGBA_2BPP"; + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: return "SG_PIXELFORMAT_PVRTC_RGBA_4BPP"; + case SG_PIXELFORMAT_ETC2_RGB8: return "SG_PIXELFORMAT_ETC2_RGB8"; + case SG_PIXELFORMAT_ETC2_RGB8A1: return "SG_PIXELFORMAT_ETC2_RGB8A1"; + case SG_PIXELFORMAT_ETC2_RGBA8: return "SG_PIXELFORMAT_ETC2_RGBA8"; + case SG_PIXELFORMAT_ETC2_RG11: return "SG_PIXELFORMAT_ETC2_RG11"; + case SG_PIXELFORMAT_ETC2_RG11SN: return "SG_PIXELFORMAT_ETC2_RG11SN"; + case SG_PIXELFORMAT_RGB9E5: return "SG_PIXELFORMAT_RGB9E5"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_filter_string(sg_filter f) { + switch (f) { + case SG_FILTER_NEAREST: return "SG_FILTER_NEAREST"; + case SG_FILTER_LINEAR: return "SG_FILTER_LINEAR"; + case SG_FILTER_NEAREST_MIPMAP_NEAREST: return "SG_FILTER_NEAREST_MIPMAP_NEAREST"; + case SG_FILTER_NEAREST_MIPMAP_LINEAR: return "SG_FILTER_NEAREST_MIPMAP_LINEAR"; + case SG_FILTER_LINEAR_MIPMAP_NEAREST: return "SG_FILTER_LINEAR_MIPMAP_NEAREST"; + case SG_FILTER_LINEAR_MIPMAP_LINEAR: return "SG_FILTER_LINEAR_MIPMAP_LINEAR"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_wrap_string(sg_wrap w) { + switch (w) { + case SG_WRAP_REPEAT: return "SG_WRAP_REPEAT"; + case SG_WRAP_CLAMP_TO_EDGE: return "SG_WRAP_CLAMP_TO_EDGE"; + case SG_WRAP_CLAMP_TO_BORDER: return "SG_WRAP_CLAMP_TO_BORDER"; + case SG_WRAP_MIRRORED_REPEAT: return "SG_WRAP_MIRRORED_REPEAT"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_bordercolor_string(sg_border_color bc) { + switch (bc) { + case SG_BORDERCOLOR_TRANSPARENT_BLACK: return "SG_BORDERCOLOR_TRANSPARENT_BLACK"; + case SG_BORDERCOLOR_OPAQUE_BLACK: return "SG_BORDERCOLOR_OPAQUE_BLACK"; + case SG_BORDERCOLOR_OPAQUE_WHITE: return "SG_BORDERCOLOR_OPAQUE_WHITE"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_uniformtype_string(sg_uniform_type t) { + switch (t) { + case SG_UNIFORMTYPE_FLOAT: return "SG_UNIFORMTYPE_FLOAT"; + case SG_UNIFORMTYPE_FLOAT2: return "SG_UNIFORMTYPE_FLOAT2"; + case SG_UNIFORMTYPE_FLOAT3: return "SG_UNIFORMTYPE_FLOAT3"; + case SG_UNIFORMTYPE_FLOAT4: return "SG_UNIFORMTYPE_FLOAT4"; + case SG_UNIFORMTYPE_INT: return "SG_UNIFORMTYPE_INT"; + case SG_UNIFORMTYPE_INT2: return "SG_UNIFORMTYPE_INT2"; + case SG_UNIFORMTYPE_INT3: return "SG_UNIFORMTYPE_INT3"; + case SG_UNIFORMTYPE_INT4: return "SG_UNIFORMTYPE_INT4"; + case SG_UNIFORMTYPE_MAT4: return "SG_UNIFORMTYPE_MAT4"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_vertexstep_string(sg_vertex_step s) { + switch (s) { + case SG_VERTEXSTEP_PER_VERTEX: return "SG_VERTEXSTEP_PER_VERTEX"; + case SG_VERTEXSTEP_PER_INSTANCE: return "SG_VERTEXSTEP_PER_INSTANCE"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_vertexformat_string(sg_vertex_format f) { + switch (f) { + case SG_VERTEXFORMAT_FLOAT: return "SG_VERTEXFORMAT_FLOAT"; + case SG_VERTEXFORMAT_FLOAT2: return "SG_VERTEXFORMAT_FLOAT2"; + case SG_VERTEXFORMAT_FLOAT3: return "SG_VERTEXFORMAT_FLOAT3"; + case SG_VERTEXFORMAT_FLOAT4: return "SG_VERTEXFORMAT_FLOAT4"; + case SG_VERTEXFORMAT_BYTE4: return "SG_VERTEXFORMAT_BYTE4"; + case SG_VERTEXFORMAT_BYTE4N: return "SG_VERTEXFORMAT_BYTE4N"; + case SG_VERTEXFORMAT_UBYTE4: return "SG_VERTEXFORMAT_UBYTE4"; + case SG_VERTEXFORMAT_UBYTE4N: return "SG_VERTEXFORMAT_UBYTE4N"; + case SG_VERTEXFORMAT_SHORT2: return "SG_VERTEXFORMAT_SHORT2"; + case SG_VERTEXFORMAT_SHORT2N: return "SG_VERTEXFORMAT_SHORT2N"; + case SG_VERTEXFORMAT_USHORT2N: return "SG_VERTEXFORMAT_USHORT2N"; + case SG_VERTEXFORMAT_SHORT4: return "SG_VERTEXFORMAT_SHORT4"; + case SG_VERTEXFORMAT_SHORT4N: return "SG_VERTEXFORMAT_SHORT4N"; + case SG_VERTEXFORMAT_USHORT4N: return "SG_VERTEXFORMAT_USHORT4N"; + case SG_VERTEXFORMAT_UINT10_N2: return "SG_VERTEXFORMAT_UINT10_N2"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_primitivetype_string(sg_primitive_type t) { + switch (t) { + case SG_PRIMITIVETYPE_POINTS: return "SG_PRIMITIVETYPE_POINTS"; + case SG_PRIMITIVETYPE_LINES: return "SG_PRIMITIVETYPE_LINES"; + case SG_PRIMITIVETYPE_LINE_STRIP: return "SG_PRIMITIVETYPE_LINE_STRIP"; + case SG_PRIMITIVETYPE_TRIANGLES: return "SG_PRIMITIVETYPE_TRIANGLES"; + case SG_PRIMITIVETYPE_TRIANGLE_STRIP: return "SG_PRIMITIVETYPE_TRIANGLE_STRIP"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_indextype_string(sg_index_type t) { + switch (t) { + case SG_INDEXTYPE_NONE: return "SG_INDEXTYPE_NONE"; + case SG_INDEXTYPE_UINT16: return "SG_INDEXTYPE_UINT16"; + case SG_INDEXTYPE_UINT32: return "SG_INDEXTYPE_UINT32"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_stencilop_string(sg_stencil_op op) { + switch (op) { + case SG_STENCILOP_KEEP: return "SG_STENCILOP_KEEP"; + case SG_STENCILOP_ZERO: return "SG_STENCILOP_ZERO"; + case SG_STENCILOP_REPLACE: return "SG_STENCILOP_REPLACE"; + case SG_STENCILOP_INCR_CLAMP: return "SG_STENCILOP_INCR_CLAMP"; + case SG_STENCILOP_DECR_CLAMP: return "SG_STENCILOP_DECR_CLAMP"; + case SG_STENCILOP_INVERT: return "SG_STENCILOP_INVERT"; + case SG_STENCILOP_INCR_WRAP: return "SG_STENCILOP_INCR_WRAP"; + case SG_STENCILOP_DECR_WRAP: return "SG_STENCILOP_DECR_WRAP"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_comparefunc_string(sg_compare_func f) { + switch (f) { + case SG_COMPAREFUNC_NEVER: return "SG_COMPAREFUNC_NEVER"; + case SG_COMPAREFUNC_LESS: return "SG_COMPAREFUNC_LESS"; + case SG_COMPAREFUNC_EQUAL: return "SG_COMPAREFUNC_EQUAL"; + case SG_COMPAREFUNC_LESS_EQUAL: return "SG_COMPAREFUNC_LESS_EQUAL"; + case SG_COMPAREFUNC_GREATER: return "SG_COMPAREFUNC_GREATER"; + case SG_COMPAREFUNC_NOT_EQUAL: return "SG_COMPAREFUNC_NOT_EQUAL"; + case SG_COMPAREFUNC_GREATER_EQUAL: return "SG_COMPAREFUNC_GREATER_EQUAL"; + case SG_COMPAREFUNC_ALWAYS: return "SG_COMPAREFUNC_ALWAYS"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_blendfactor_string(sg_blend_factor f) { + switch (f) { + case SG_BLENDFACTOR_ZERO: return "SG_BLENDFACTOR_ZERO"; + case SG_BLENDFACTOR_ONE: return "SG_BLENDFACTOR_ONE"; + case SG_BLENDFACTOR_SRC_COLOR: return "SG_BLENDFACTOR_SRC_COLOR"; + case SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return "SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR"; + case SG_BLENDFACTOR_SRC_ALPHA: return "SG_BLENDFACTOR_SRC_ALPHA"; + case SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return "SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA"; + case SG_BLENDFACTOR_DST_COLOR: return "SG_BLENDFACTOR_DST_COLOR"; + case SG_BLENDFACTOR_ONE_MINUS_DST_COLOR: return "SG_BLENDFACTOR_ONE_MINUS_DST_COLOR"; + case SG_BLENDFACTOR_DST_ALPHA: return "SG_BLENDFACTOR_DST_ALPHA"; + case SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return "SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA"; + case SG_BLENDFACTOR_SRC_ALPHA_SATURATED: return "SG_BLENDFACTOR_SRC_ALPHA_SATURATED"; + case SG_BLENDFACTOR_BLEND_COLOR: return "SG_BLENDFACTOR_BLEND_COLOR"; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR: return "SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR"; + case SG_BLENDFACTOR_BLEND_ALPHA: return "SG_BLENDFACTOR_BLEND_ALPHA"; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA: return "SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_blendop_string(sg_blend_op op) { + switch (op) { + case SG_BLENDOP_ADD: return "SG_BLENDOP_ADD"; + case SG_BLENDOP_SUBTRACT: return "SG_BLENDOP_SUBTRACT"; + case SG_BLENDOP_REVERSE_SUBTRACT: return "SG_BLENDOP_REVERSE_SUBTRACT"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_colormask_string(sg_color_mask m) { + static const char* str[] = { + "NONE", + "R", + "G", + "RG", + "B", + "RB", + "GB", + "RGB", + "A", + "RA", + "GA", + "RGA", + "BA", + "RBA", + "GBA", + "RGBA", + }; + return str[m & 0xF]; +} + +_SOKOL_PRIVATE const char* _sg_imgui_cullmode_string(sg_cull_mode cm) { + switch (cm) { + case SG_CULLMODE_NONE: return "SG_CULLMODE_NONE"; + case SG_CULLMODE_FRONT: return "SG_CULLMODE_FRONT"; + case SG_CULLMODE_BACK: return "SG_CULLMODE_BACK"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_facewinding_string(sg_face_winding fw) { + switch (fw) { + case SG_FACEWINDING_CCW: return "SG_FACEWINDING_CCW"; + case SG_FACEWINDING_CW: return "SG_FACEWINDING_CW"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_shaderstage_string(sg_shader_stage stage) { + switch (stage) { + case SG_SHADERSTAGE_VS: return "SG_SHADERSTAGE_VS"; + case SG_SHADERSTAGE_FS: return "SG_SHADERSTAGE_FS"; + default: return "???"; + } +} + +_SOKOL_PRIVATE const char* _sg_imgui_bool_string(bool b) { + return b ? "true" : "false"; +} + +_SOKOL_PRIVATE const char* _sg_imgui_color_string(sg_imgui_str_t* dst_str, sg_color color) { + _sg_imgui_snprintf(dst_str, "%.3f %.3f %.3f %.3f", color.r, color.g, color.b, color.a); + return dst_str->buf; +} + +_SOKOL_PRIVATE sg_imgui_str_t _sg_imgui_res_id_string(uint32_t res_id, const char* label) { + SOKOL_ASSERT(label); + sg_imgui_str_t res; + if (label[0]) { + _sg_imgui_snprintf(&res, "'%s'", label); + } + else { + _sg_imgui_snprintf(&res, "0x%08X", res_id); + } + return res; +} + +_SOKOL_PRIVATE sg_imgui_str_t _sg_imgui_buffer_id_string(sg_imgui_t* ctx, sg_buffer buf_id) { + if (buf_id.id != SG_INVALID_ID) { + const sg_imgui_buffer_t* buf_ui = &ctx->buffers.slots[_sg_imgui_slot_index(buf_id.id)]; + return _sg_imgui_res_id_string(buf_id.id, buf_ui->label.buf); + } + else { + return _sg_imgui_make_str(""); + } +} + +_SOKOL_PRIVATE sg_imgui_str_t _sg_imgui_image_id_string(sg_imgui_t* ctx, sg_image img_id) { + if (img_id.id != SG_INVALID_ID) { + const sg_imgui_image_t* img_ui = &ctx->images.slots[_sg_imgui_slot_index(img_id.id)]; + return _sg_imgui_res_id_string(img_id.id, img_ui->label.buf); + } + else { + return _sg_imgui_make_str(""); + } +} + +_SOKOL_PRIVATE sg_imgui_str_t _sg_imgui_shader_id_string(sg_imgui_t* ctx, sg_shader shd_id) { + if (shd_id.id != SG_INVALID_ID) { + const sg_imgui_shader_t* shd_ui = &ctx->shaders.slots[_sg_imgui_slot_index(shd_id.id)]; + return _sg_imgui_res_id_string(shd_id.id, shd_ui->label.buf); + } + else { + return _sg_imgui_make_str(""); + } +} + +_SOKOL_PRIVATE sg_imgui_str_t _sg_imgui_pipeline_id_string(sg_imgui_t* ctx, sg_pipeline pip_id) { + if (pip_id.id != SG_INVALID_ID) { + const sg_imgui_pipeline_t* pip_ui = &ctx->pipelines.slots[_sg_imgui_slot_index(pip_id.id)]; + return _sg_imgui_res_id_string(pip_id.id, pip_ui->label.buf); + } + else { + return _sg_imgui_make_str(""); + } +} + +_SOKOL_PRIVATE sg_imgui_str_t _sg_imgui_pass_id_string(sg_imgui_t* ctx, sg_pass pass_id) { + if (pass_id.id != SG_INVALID_ID) { + const sg_imgui_pass_t* pass_ui = &ctx->passes.slots[_sg_imgui_slot_index(pass_id.id)]; + return _sg_imgui_res_id_string(pass_id.id, pass_ui->label.buf); + } + else { + return _sg_imgui_make_str(""); + } +} + +/*--- RESOURCE HELPERS -------------------------------------------------------*/ +_SOKOL_PRIVATE void _sg_imgui_buffer_created(sg_imgui_t* ctx, sg_buffer res_id, int slot_index, const sg_buffer_desc* desc) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->buffers.num_slots)); + sg_imgui_buffer_t* buf = &ctx->buffers.slots[slot_index]; + buf->res_id = res_id; + buf->desc = *desc; + buf->label = _sg_imgui_make_str(desc->label); +} + +_SOKOL_PRIVATE void _sg_imgui_buffer_destroyed(sg_imgui_t* ctx, int slot_index) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->buffers.num_slots)); + sg_imgui_buffer_t* buf = &ctx->buffers.slots[slot_index]; + buf->res_id.id = SG_INVALID_ID; +} + +_SOKOL_PRIVATE void _sg_imgui_image_created(sg_imgui_t* ctx, sg_image res_id, int slot_index, const sg_image_desc* desc) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->images.num_slots)); + sg_imgui_image_t* img = &ctx->images.slots[slot_index]; + img->res_id = res_id; + img->desc = *desc; + img->ui_scale = 1.0f; + img->label = _sg_imgui_make_str(desc->label); +} + +_SOKOL_PRIVATE void _sg_imgui_image_destroyed(sg_imgui_t* ctx, int slot_index) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->images.num_slots)); + sg_imgui_image_t* img = &ctx->images.slots[slot_index]; + img->res_id.id = SG_INVALID_ID; +} + +_SOKOL_PRIVATE void _sg_imgui_shader_created(sg_imgui_t* ctx, sg_shader res_id, int slot_index, const sg_shader_desc* desc) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->shaders.num_slots)); + sg_imgui_shader_t* shd = &ctx->shaders.slots[slot_index]; + shd->res_id = res_id; + shd->desc = *desc; + shd->label = _sg_imgui_make_str(desc->label); + if (shd->desc.vs.entry) { + shd->vs_entry = _sg_imgui_make_str(shd->desc.vs.entry); + shd->desc.vs.entry = shd->vs_entry.buf; + } + if (shd->desc.fs.entry) { + shd->fs_entry = _sg_imgui_make_str(shd->desc.fs.entry); + shd->desc.fs.entry = shd->fs_entry.buf; + } + if (shd->desc.vs.d3d11_target) { + shd->vs_d3d11_target = _sg_imgui_make_str(shd->desc.vs.d3d11_target); + shd->desc.fs.d3d11_target = shd->vs_d3d11_target.buf; + } + if (shd->desc.fs.d3d11_target) { + shd->fs_d3d11_target = _sg_imgui_make_str(shd->desc.fs.d3d11_target); + shd->desc.fs.d3d11_target = shd->fs_d3d11_target.buf; + } + for (int i = 0; i < SG_MAX_SHADERSTAGE_UBS; i++) { + for (int j = 0; j < SG_MAX_UB_MEMBERS; j++) { + sg_shader_uniform_desc* ud = &shd->desc.vs.uniform_blocks[i].uniforms[j]; + if (ud->name) { + shd->vs_uniform_name[i][j] = _sg_imgui_make_str(ud->name); + ud->name = shd->vs_uniform_name[i][j].buf; + } + } + } + for (int i = 0; i < SG_MAX_SHADERSTAGE_UBS; i++) { + for (int j = 0; j < SG_MAX_UB_MEMBERS; j++) { + sg_shader_uniform_desc* ud = &shd->desc.fs.uniform_blocks[i].uniforms[j]; + if (ud->name) { + shd->fs_uniform_name[i][j] = _sg_imgui_make_str(ud->name); + ud->name = shd->fs_uniform_name[i][j].buf; + } + } + } + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + if (shd->desc.vs.images[i].name) { + shd->vs_image_name[i] = _sg_imgui_make_str(shd->desc.vs.images[i].name); + shd->desc.vs.images[i].name = shd->vs_image_name[i].buf; + } + } + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + if (shd->desc.fs.images[i].name) { + shd->fs_image_name[i] = _sg_imgui_make_str(shd->desc.fs.images[i].name); + shd->desc.fs.images[i].name = shd->fs_image_name[i].buf; + } + } + if (shd->desc.vs.source) { + shd->desc.vs.source = _sg_imgui_str_dup(&ctx->desc.allocator, shd->desc.vs.source); + } + if (shd->desc.vs.bytecode.ptr) { + shd->desc.vs.bytecode.ptr = _sg_imgui_bin_dup(&ctx->desc.allocator, shd->desc.vs.bytecode.ptr, shd->desc.vs.bytecode.size); + } + if (shd->desc.fs.source) { + shd->desc.fs.source = _sg_imgui_str_dup(&ctx->desc.allocator, shd->desc.fs.source); + } + if (shd->desc.fs.bytecode.ptr) { + shd->desc.fs.bytecode.ptr = _sg_imgui_bin_dup(&ctx->desc.allocator, shd->desc.fs.bytecode.ptr, shd->desc.fs.bytecode.size); + } + for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) { + sg_shader_attr_desc* ad = &shd->desc.attrs[i]; + if (ad->name) { + shd->attr_name[i] = _sg_imgui_make_str(ad->name); + ad->name = shd->attr_name[i].buf; + } + if (ad->sem_name) { + shd->attr_sem_name[i] = _sg_imgui_make_str(ad->sem_name); + ad->sem_name = shd->attr_sem_name[i].buf; + } + } +} + +_SOKOL_PRIVATE void _sg_imgui_shader_destroyed(sg_imgui_t* ctx, int slot_index) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->shaders.num_slots)); + sg_imgui_shader_t* shd = &ctx->shaders.slots[slot_index]; + shd->res_id.id = SG_INVALID_ID; + if (shd->desc.vs.source) { + _sg_imgui_free(&ctx->desc.allocator, (void*)shd->desc.vs.source); + shd->desc.vs.source = 0; + } + if (shd->desc.vs.bytecode.ptr) { + _sg_imgui_free(&ctx->desc.allocator, (void*)shd->desc.vs.bytecode.ptr); + shd->desc.vs.bytecode.ptr = 0; + } + if (shd->desc.fs.source) { + _sg_imgui_free(&ctx->desc.allocator, (void*)shd->desc.fs.source); + shd->desc.fs.source = 0; + } + if (shd->desc.fs.bytecode.ptr) { + _sg_imgui_free(&ctx->desc.allocator, (void*)shd->desc.fs.bytecode.ptr); + shd->desc.fs.bytecode.ptr = 0; + } +} + +_SOKOL_PRIVATE void _sg_imgui_pipeline_created(sg_imgui_t* ctx, sg_pipeline res_id, int slot_index, const sg_pipeline_desc* desc) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->pipelines.num_slots)); + sg_imgui_pipeline_t* pip = &ctx->pipelines.slots[slot_index]; + pip->res_id = res_id; + pip->label = _sg_imgui_make_str(desc->label); + pip->desc = *desc; + +} + +_SOKOL_PRIVATE void _sg_imgui_pipeline_destroyed(sg_imgui_t* ctx, int slot_index) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->pipelines.num_slots)); + sg_imgui_pipeline_t* pip = &ctx->pipelines.slots[slot_index]; + pip->res_id.id = SG_INVALID_ID; +} + +_SOKOL_PRIVATE void _sg_imgui_pass_created(sg_imgui_t* ctx, sg_pass res_id, int slot_index, const sg_pass_desc* desc) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->passes.num_slots)); + sg_imgui_pass_t* pass = &ctx->passes.slots[slot_index]; + pass->res_id = res_id; + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + pass->color_image_scale[i] = 0.25f; + } + pass->ds_image_scale = 0.25f; + pass->label = _sg_imgui_make_str(desc->label); + pass->desc = *desc; +} + +_SOKOL_PRIVATE void _sg_imgui_pass_destroyed(sg_imgui_t* ctx, int slot_index) { + SOKOL_ASSERT((slot_index > 0) && (slot_index < ctx->passes.num_slots)); + sg_imgui_pass_t* pass = &ctx->passes.slots[slot_index]; + pass->res_id.id = SG_INVALID_ID; +} + +/*--- COMMAND CAPTURING ------------------------------------------------------*/ +_SOKOL_PRIVATE void _sg_imgui_capture_init(sg_imgui_t* ctx) { + const size_t ubuf_initial_size = 256 * 1024; + for (int i = 0; i < 2; i++) { + sg_imgui_capture_bucket_t* bucket = &ctx->capture.bucket[i]; + bucket->ubuf_size = ubuf_initial_size; + bucket->ubuf = (uint8_t*) _sg_imgui_malloc(&ctx->desc.allocator, bucket->ubuf_size); + } +} + +_SOKOL_PRIVATE void _sg_imgui_capture_discard(sg_imgui_t* ctx) { + for (int i = 0; i < 2; i++) { + sg_imgui_capture_bucket_t* bucket = &ctx->capture.bucket[i]; + SOKOL_ASSERT(bucket->ubuf); + _sg_imgui_free(&ctx->desc.allocator, bucket->ubuf); + bucket->ubuf = 0; + } +} + +_SOKOL_PRIVATE sg_imgui_capture_bucket_t* _sg_imgui_capture_get_write_bucket(sg_imgui_t* ctx) { + return &ctx->capture.bucket[ctx->capture.bucket_index & 1]; +} + +_SOKOL_PRIVATE sg_imgui_capture_bucket_t* _sg_imgui_capture_get_read_bucket(sg_imgui_t* ctx) { + return &ctx->capture.bucket[(ctx->capture.bucket_index + 1) & 1]; +} + +_SOKOL_PRIVATE void _sg_imgui_capture_next_frame(sg_imgui_t* ctx) { + ctx->capture.bucket_index = (ctx->capture.bucket_index + 1) & 1; + sg_imgui_capture_bucket_t* bucket = &ctx->capture.bucket[ctx->capture.bucket_index]; + bucket->num_items = 0; + bucket->ubuf_pos = 0; +} + +_SOKOL_PRIVATE void _sg_imgui_capture_grow_ubuf(sg_imgui_t* ctx, size_t required_size) { + sg_imgui_capture_bucket_t* bucket = _sg_imgui_capture_get_write_bucket(ctx); + SOKOL_ASSERT(required_size > bucket->ubuf_size); + size_t old_size = bucket->ubuf_size; + size_t new_size = required_size + (required_size>>1); /* allocate a bit ahead */ + bucket->ubuf_size = new_size; + bucket->ubuf = (uint8_t*) _sg_imgui_realloc(&ctx->desc.allocator, bucket->ubuf, old_size, new_size); +} + +_SOKOL_PRIVATE sg_imgui_capture_item_t* _sg_imgui_capture_next_write_item(sg_imgui_t* ctx) { + sg_imgui_capture_bucket_t* bucket = _sg_imgui_capture_get_write_bucket(ctx); + if (bucket->num_items < SG_IMGUI_MAX_FRAMECAPTURE_ITEMS) { + sg_imgui_capture_item_t* item = &bucket->items[bucket->num_items++]; + return item; + } + else { + return 0; + } +} + +_SOKOL_PRIVATE int _sg_imgui_capture_num_read_items(sg_imgui_t* ctx) { + sg_imgui_capture_bucket_t* bucket = _sg_imgui_capture_get_read_bucket(ctx); + return bucket->num_items; +} + +_SOKOL_PRIVATE sg_imgui_capture_item_t* _sg_imgui_capture_read_item_at(sg_imgui_t* ctx, int index) { + sg_imgui_capture_bucket_t* bucket = _sg_imgui_capture_get_read_bucket(ctx); + SOKOL_ASSERT(index < bucket->num_items); + return &bucket->items[index]; +} + +_SOKOL_PRIVATE size_t _sg_imgui_capture_uniforms(sg_imgui_t* ctx, const sg_range* data) { + sg_imgui_capture_bucket_t* bucket = _sg_imgui_capture_get_write_bucket(ctx); + const size_t required_size = bucket->ubuf_pos + data->size; + if (required_size > bucket->ubuf_size) { + _sg_imgui_capture_grow_ubuf(ctx, required_size); + } + SOKOL_ASSERT(required_size <= bucket->ubuf_size); + memcpy(bucket->ubuf + bucket->ubuf_pos, data->ptr, data->size); + const size_t pos = bucket->ubuf_pos; + bucket->ubuf_pos += data->size; + SOKOL_ASSERT(bucket->ubuf_pos <= bucket->ubuf_size); + return pos; +} + +_SOKOL_PRIVATE sg_imgui_str_t _sg_imgui_capture_item_string(sg_imgui_t* ctx, int index, const sg_imgui_capture_item_t* item) { + sg_imgui_str_t str = _sg_imgui_make_str(0); + switch (item->cmd) { + case SG_IMGUI_CMD_RESET_STATE_CACHE: + _sg_imgui_snprintf(&str, "%d: sg_reset_state_cache()", index); + break; + + case SG_IMGUI_CMD_MAKE_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.make_buffer.result); + _sg_imgui_snprintf(&str, "%d: sg_make_buffer(desc=..) => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_MAKE_IMAGE: + { + sg_imgui_str_t res_id = _sg_imgui_image_id_string(ctx, item->args.make_image.result); + _sg_imgui_snprintf(&str, "%d: sg_make_image(desc=..) => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_MAKE_SHADER: + { + sg_imgui_str_t res_id = _sg_imgui_shader_id_string(ctx, item->args.make_shader.result); + _sg_imgui_snprintf(&str, "%d: sg_make_shader(desc=..) => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_MAKE_PIPELINE: + { + sg_imgui_str_t res_id = _sg_imgui_pipeline_id_string(ctx, item->args.make_pipeline.result); + _sg_imgui_snprintf(&str, "%d: sg_make_pipeline(desc=..) => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_MAKE_PASS: + { + sg_imgui_str_t res_id = _sg_imgui_pass_id_string(ctx, item->args.make_pass.result); + _sg_imgui_snprintf(&str, "%d: sg_make_pass(desc=..) => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DESTROY_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.destroy_buffer.buffer); + _sg_imgui_snprintf(&str, "%d: sg_destroy_buffer(buf=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DESTROY_IMAGE: + { + sg_imgui_str_t res_id = _sg_imgui_image_id_string(ctx, item->args.destroy_image.image); + _sg_imgui_snprintf(&str, "%d: sg_destroy_image(img=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DESTROY_SHADER: + { + sg_imgui_str_t res_id = _sg_imgui_shader_id_string(ctx, item->args.destroy_shader.shader); + _sg_imgui_snprintf(&str, "%d: sg_destroy_shader(shd=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DESTROY_PIPELINE: + { + sg_imgui_str_t res_id = _sg_imgui_pipeline_id_string(ctx, item->args.destroy_pipeline.pipeline); + _sg_imgui_snprintf(&str, "%d: sg_destroy_pipeline(pip=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DESTROY_PASS: + { + sg_imgui_str_t res_id = _sg_imgui_pass_id_string(ctx, item->args.destroy_pass.pass); + _sg_imgui_snprintf(&str, "%d: sg_destroy_pass(pass=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_UPDATE_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.update_buffer.buffer); + _sg_imgui_snprintf(&str, "%d: sg_update_buffer(buf=%s, data.size=%d)", + index, res_id.buf, + item->args.update_buffer.data_size); + } + break; + + case SG_IMGUI_CMD_UPDATE_IMAGE: + { + sg_imgui_str_t res_id = _sg_imgui_image_id_string(ctx, item->args.update_image.image); + _sg_imgui_snprintf(&str, "%d: sg_update_image(img=%s, data=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_APPEND_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.append_buffer.buffer); + _sg_imgui_snprintf(&str, "%d: sg_append_buffer(buf=%s, data.size=%d) => %d", + index, res_id.buf, + item->args.append_buffer.data_size, + item->args.append_buffer.result); + } + break; + + case SG_IMGUI_CMD_BEGIN_DEFAULT_PASS: + _sg_imgui_snprintf(&str, "%d: sg_begin_default_pass(pass_action=.., width=%d, height=%d)", + index, + item->args.begin_default_pass.width, + item->args.begin_default_pass.height); + break; + + case SG_IMGUI_CMD_BEGIN_PASS: + { + sg_imgui_str_t res_id = _sg_imgui_pass_id_string(ctx, item->args.begin_pass.pass); + _sg_imgui_snprintf(&str, "%d: sg_begin_pass(pass=%s, pass_action=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_APPLY_VIEWPORT: + _sg_imgui_snprintf(&str, "%d: sg_apply_viewport(x=%d, y=%d, width=%d, height=%d, origin_top_left=%s)", + index, + item->args.apply_viewport.x, + item->args.apply_viewport.y, + item->args.apply_viewport.width, + item->args.apply_viewport.height, + _sg_imgui_bool_string(item->args.apply_viewport.origin_top_left)); + break; + + case SG_IMGUI_CMD_APPLY_SCISSOR_RECT: + _sg_imgui_snprintf(&str, "%d: sg_apply_scissor_rect(x=%d, y=%d, width=%d, height=%d, origin_top_left=%s)", + index, + item->args.apply_scissor_rect.x, + item->args.apply_scissor_rect.y, + item->args.apply_scissor_rect.width, + item->args.apply_scissor_rect.height, + _sg_imgui_bool_string(item->args.apply_scissor_rect.origin_top_left)); + break; + + case SG_IMGUI_CMD_APPLY_PIPELINE: + { + sg_imgui_str_t res_id = _sg_imgui_pipeline_id_string(ctx, item->args.apply_pipeline.pipeline); + _sg_imgui_snprintf(&str, "%d: sg_apply_pipeline(pip=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_APPLY_BINDINGS: + _sg_imgui_snprintf(&str, "%d: sg_apply_bindings(bindings=..)", index); + break; + + case SG_IMGUI_CMD_APPLY_UNIFORMS: + _sg_imgui_snprintf(&str, "%d: sg_apply_uniforms(stage=%s, ub_index=%d, data.size=%d)", + index, + _sg_imgui_shaderstage_string(item->args.apply_uniforms.stage), + item->args.apply_uniforms.ub_index, + item->args.apply_uniforms.data_size); + break; + + case SG_IMGUI_CMD_DRAW: + _sg_imgui_snprintf(&str, "%d: sg_draw(base_element=%d, num_elements=%d, num_instances=%d)", + index, + item->args.draw.base_element, + item->args.draw.num_elements, + item->args.draw.num_instances); + break; + + case SG_IMGUI_CMD_END_PASS: + _sg_imgui_snprintf(&str, "%d: sg_end_pass()", index); + break; + + case SG_IMGUI_CMD_COMMIT: + _sg_imgui_snprintf(&str, "%d: sg_commit()", index); + break; + + case SG_IMGUI_CMD_ALLOC_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.alloc_buffer.result); + _sg_imgui_snprintf(&str, "%d: sg_alloc_buffer() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_ALLOC_IMAGE: + { + sg_imgui_str_t res_id = _sg_imgui_image_id_string(ctx, item->args.alloc_image.result); + _sg_imgui_snprintf(&str, "%d: sg_alloc_image() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_ALLOC_SHADER: + { + sg_imgui_str_t res_id = _sg_imgui_shader_id_string(ctx, item->args.alloc_shader.result); + _sg_imgui_snprintf(&str, "%d: sg_alloc_shader() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_ALLOC_PIPELINE: + { + sg_imgui_str_t res_id = _sg_imgui_pipeline_id_string(ctx, item->args.alloc_pipeline.result); + _sg_imgui_snprintf(&str, "%d: sg_alloc_pipeline() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_ALLOC_PASS: + { + sg_imgui_str_t res_id = _sg_imgui_pass_id_string(ctx, item->args.alloc_pass.result); + _sg_imgui_snprintf(&str, "%d: sg_alloc_pass() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DEALLOC_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.dealloc_buffer.buffer); + _sg_imgui_snprintf(&str, "%d: sg_dealloc_buffer() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DEALLOC_IMAGE: + { + sg_imgui_str_t res_id = _sg_imgui_image_id_string(ctx, item->args.dealloc_image.image); + _sg_imgui_snprintf(&str, "%d: sg_dealloc_image() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DEALLOC_SHADER: + { + sg_imgui_str_t res_id = _sg_imgui_shader_id_string(ctx, item->args.dealloc_shader.shader); + _sg_imgui_snprintf(&str, "%d: sg_dealloc_shader() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DEALLOC_PIPELINE: + { + sg_imgui_str_t res_id = _sg_imgui_pipeline_id_string(ctx, item->args.dealloc_pipeline.pipeline); + _sg_imgui_snprintf(&str, "%d: sg_dealloc_pipeline() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_DEALLOC_PASS: + { + sg_imgui_str_t res_id = _sg_imgui_pass_id_string(ctx, item->args.dealloc_pass.pass); + _sg_imgui_snprintf(&str, "%d: sg_dealloc_pass() => %s", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_INIT_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.init_buffer.buffer); + _sg_imgui_snprintf(&str, "%d: sg_init_buffer(buf=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_INIT_IMAGE: + { + sg_imgui_str_t res_id = _sg_imgui_image_id_string(ctx, item->args.init_image.image); + _sg_imgui_snprintf(&str, "%d: sg_init_image(img=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_INIT_SHADER: + { + sg_imgui_str_t res_id = _sg_imgui_shader_id_string(ctx, item->args.init_shader.shader); + _sg_imgui_snprintf(&str, "%d: sg_init_shader(shd=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_INIT_PIPELINE: + { + sg_imgui_str_t res_id = _sg_imgui_pipeline_id_string(ctx, item->args.init_pipeline.pipeline); + _sg_imgui_snprintf(&str, "%d: sg_init_pipeline(pip=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_INIT_PASS: + { + sg_imgui_str_t res_id = _sg_imgui_pass_id_string(ctx, item->args.init_pass.pass); + _sg_imgui_snprintf(&str, "%d: sg_init_pass(pass=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_UNINIT_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.uninit_buffer.buffer); + _sg_imgui_snprintf(&str, "%d: sg_uninit_buffer(buf=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_UNINIT_IMAGE: + { + sg_imgui_str_t res_id = _sg_imgui_image_id_string(ctx, item->args.uninit_image.image); + _sg_imgui_snprintf(&str, "%d: sg_uninit_image(img=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_UNINIT_SHADER: + { + sg_imgui_str_t res_id = _sg_imgui_shader_id_string(ctx, item->args.uninit_shader.shader); + _sg_imgui_snprintf(&str, "%d: sg_uninit_shader(shd=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_UNINIT_PIPELINE: + { + sg_imgui_str_t res_id = _sg_imgui_pipeline_id_string(ctx, item->args.uninit_pipeline.pipeline); + _sg_imgui_snprintf(&str, "%d: sg_uninit_pipeline(pip=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_UNINIT_PASS: + { + sg_imgui_str_t res_id = _sg_imgui_pass_id_string(ctx, item->args.uninit_pass.pass); + _sg_imgui_snprintf(&str, "%d: sg_uninit_pass(pass=%s, desc=..)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_FAIL_BUFFER: + { + sg_imgui_str_t res_id = _sg_imgui_buffer_id_string(ctx, item->args.fail_buffer.buffer); + _sg_imgui_snprintf(&str, "%d: sg_fail_buffer(buf=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_FAIL_IMAGE: + { + sg_imgui_str_t res_id = _sg_imgui_image_id_string(ctx, item->args.fail_image.image); + _sg_imgui_snprintf(&str, "%d: sg_fail_image(img=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_FAIL_SHADER: + { + sg_imgui_str_t res_id = _sg_imgui_shader_id_string(ctx, item->args.fail_shader.shader); + _sg_imgui_snprintf(&str, "%d: sg_fail_shader(shd=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_FAIL_PIPELINE: + { + sg_imgui_str_t res_id = _sg_imgui_pipeline_id_string(ctx, item->args.fail_pipeline.pipeline); + _sg_imgui_snprintf(&str, "%d: sg_fail_pipeline(shd=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_FAIL_PASS: + { + sg_imgui_str_t res_id = _sg_imgui_pass_id_string(ctx, item->args.fail_pass.pass); + _sg_imgui_snprintf(&str, "%d: sg_fail_pass(pass=%s)", index, res_id.buf); + } + break; + + case SG_IMGUI_CMD_PUSH_DEBUG_GROUP: + _sg_imgui_snprintf(&str, "%d: sg_push_debug_group(name=%s)", index, + item->args.push_debug_group.name.buf); + break; + + case SG_IMGUI_CMD_POP_DEBUG_GROUP: + _sg_imgui_snprintf(&str, "%d: sg_pop_debug_group()", index); + break; + + case SG_IMGUI_CMD_ERR_BUFFER_POOL_EXHAUSTED: + _sg_imgui_snprintf(&str, "%d: sg_err_buffer_pool_exhausted()", index); + break; + + case SG_IMGUI_CMD_ERR_IMAGE_POOL_EXHAUSTED: + _sg_imgui_snprintf(&str, "%d: sg_err_image_pool_exhausted()", index); + break; + + case SG_IMGUI_CMD_ERR_SHADER_POOL_EXHAUSTED: + _sg_imgui_snprintf(&str, "%d: sg_err_shader_pool_exhausted()", index); + break; + + case SG_IMGUI_CMD_ERR_PIPELINE_POOL_EXHAUSTED: + _sg_imgui_snprintf(&str, "%d: sg_err_pipeline_pool_exhausted()", index); + break; + + case SG_IMGUI_CMD_ERR_PASS_POOL_EXHAUSTED: + _sg_imgui_snprintf(&str, "%d: sg_err_pass_pool_exhausted()", index); + break; + + case SG_IMGUI_CMD_ERR_CONTEXT_MISMATCH: + _sg_imgui_snprintf(&str, "%d: sg_err_context_mismatch()", index); + break; + + case SG_IMGUI_CMD_ERR_PASS_INVALID: + _sg_imgui_snprintf(&str, "%d: sg_err_pass_invalid()", index); + break; + + case SG_IMGUI_CMD_ERR_DRAW_INVALID: + _sg_imgui_snprintf(&str, "%d: sg_err_draw_invalid()", index); + break; + + case SG_IMGUI_CMD_ERR_BINDINGS_INVALID: + _sg_imgui_snprintf(&str, "%d: sg_err_bindings_invalid()", index); + break; + + default: + _sg_imgui_snprintf(&str, "%d: ???", index); + break; + } + return str; +} + +/*--- CAPTURE CALLBACKS ------------------------------------------------------*/ +_SOKOL_PRIVATE void _sg_imgui_reset_state_cache(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_RESET_STATE_CACHE; + item->color = _SG_IMGUI_COLOR_OTHER; + } + if (ctx->hooks.reset_state_cache) { + ctx->hooks.reset_state_cache(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_make_buffer(const sg_buffer_desc* desc, sg_buffer buf_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_MAKE_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.make_buffer.result = buf_id; + } + if (ctx->hooks.make_buffer) { + ctx->hooks.make_buffer(desc, buf_id, ctx->hooks.user_data); + } + if (buf_id.id != SG_INVALID_ID) { + _sg_imgui_buffer_created(ctx, buf_id, _sg_imgui_slot_index(buf_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_make_image(const sg_image_desc* desc, sg_image img_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_MAKE_IMAGE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.make_image.result = img_id; + } + if (ctx->hooks.make_image) { + ctx->hooks.make_image(desc, img_id, ctx->hooks.user_data); + } + if (img_id.id != SG_INVALID_ID) { + _sg_imgui_image_created(ctx, img_id, _sg_imgui_slot_index(img_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_make_shader(const sg_shader_desc* desc, sg_shader shd_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_MAKE_SHADER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.make_shader.result = shd_id; + } + if (ctx->hooks.make_shader) { + ctx->hooks.make_shader(desc, shd_id, ctx->hooks.user_data); + } + if (shd_id.id != SG_INVALID_ID) { + _sg_imgui_shader_created(ctx, shd_id, _sg_imgui_slot_index(shd_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_make_pipeline(const sg_pipeline_desc* desc, sg_pipeline pip_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_MAKE_PIPELINE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.make_pipeline.result = pip_id; + } + if (ctx->hooks.make_pipeline) { + ctx->hooks.make_pipeline(desc, pip_id, ctx->hooks.user_data); + } + if (pip_id.id != SG_INVALID_ID) { + _sg_imgui_pipeline_created(ctx, pip_id, _sg_imgui_slot_index(pip_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_make_pass(const sg_pass_desc* desc, sg_pass pass_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_MAKE_PASS; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.make_pass.result = pass_id; + } + if (ctx->hooks.make_pass) { + ctx->hooks.make_pass(desc, pass_id, ctx->hooks.user_data); + } + if (pass_id.id != SG_INVALID_ID) { + _sg_imgui_pass_created(ctx, pass_id, _sg_imgui_slot_index(pass_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_destroy_buffer(sg_buffer buf, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DESTROY_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.destroy_buffer.buffer = buf; + } + if (ctx->hooks.destroy_buffer) { + ctx->hooks.destroy_buffer(buf, ctx->hooks.user_data); + } + if (buf.id != SG_INVALID_ID) { + _sg_imgui_buffer_destroyed(ctx, _sg_imgui_slot_index(buf.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_destroy_image(sg_image img, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DESTROY_IMAGE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.destroy_image.image = img; + } + if (ctx->hooks.destroy_image) { + ctx->hooks.destroy_image(img, ctx->hooks.user_data); + } + if (img.id != SG_INVALID_ID) { + _sg_imgui_image_destroyed(ctx, _sg_imgui_slot_index(img.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_destroy_shader(sg_shader shd, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DESTROY_SHADER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.destroy_shader.shader = shd; + } + if (ctx->hooks.destroy_shader) { + ctx->hooks.destroy_shader(shd, ctx->hooks.user_data); + } + if (shd.id != SG_INVALID_ID) { + _sg_imgui_shader_destroyed(ctx, _sg_imgui_slot_index(shd.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_destroy_pipeline(sg_pipeline pip, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DESTROY_PIPELINE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.destroy_pipeline.pipeline = pip; + } + if (ctx->hooks.destroy_pipeline) { + ctx->hooks.destroy_pipeline(pip, ctx->hooks.user_data); + } + if (pip.id != SG_INVALID_ID) { + _sg_imgui_pipeline_destroyed(ctx, _sg_imgui_slot_index(pip.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_destroy_pass(sg_pass pass, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DESTROY_PASS; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.destroy_pass.pass = pass; + } + if (ctx->hooks.destroy_pass) { + ctx->hooks.destroy_pass(pass, ctx->hooks.user_data); + } + if (pass.id != SG_INVALID_ID) { + _sg_imgui_pass_destroyed(ctx, _sg_imgui_slot_index(pass.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_update_buffer(sg_buffer buf, const sg_range* data, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_UPDATE_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.update_buffer.buffer = buf; + item->args.update_buffer.data_size = data->size; + } + if (ctx->hooks.update_buffer) { + ctx->hooks.update_buffer(buf, data, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_update_image(sg_image img, const sg_image_data* data, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_UPDATE_IMAGE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.update_image.image = img; + } + if (ctx->hooks.update_image) { + ctx->hooks.update_image(img, data, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_append_buffer(sg_buffer buf, const sg_range* data, int result, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_APPEND_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.append_buffer.buffer = buf; + item->args.append_buffer.data_size = data->size; + item->args.append_buffer.result = result; + } + if (ctx->hooks.append_buffer) { + ctx->hooks.append_buffer(buf, data, result, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_begin_default_pass(const sg_pass_action* pass_action, int width, int height, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + SOKOL_ASSERT(pass_action); + item->cmd = SG_IMGUI_CMD_BEGIN_DEFAULT_PASS; + item->color = _SG_IMGUI_COLOR_DRAW; + item->args.begin_default_pass.action = *pass_action; + item->args.begin_default_pass.width = width; + item->args.begin_default_pass.height = height; + } + if (ctx->hooks.begin_default_pass) { + ctx->hooks.begin_default_pass(pass_action, width, height, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_begin_pass(sg_pass pass, const sg_pass_action* pass_action, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + SOKOL_ASSERT(pass_action); + item->cmd = SG_IMGUI_CMD_BEGIN_PASS; + item->color = _SG_IMGUI_COLOR_DRAW; + item->args.begin_pass.pass = pass; + item->args.begin_pass.action = *pass_action; + } + if (ctx->hooks.begin_pass) { + ctx->hooks.begin_pass(pass, pass_action, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_apply_viewport(int x, int y, int width, int height, bool origin_top_left, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_APPLY_VIEWPORT; + item->color = _SG_IMGUI_COLOR_DRAW; + item->args.apply_viewport.x = x; + item->args.apply_viewport.y = y; + item->args.apply_viewport.width = width; + item->args.apply_viewport.height = height; + item->args.apply_viewport.origin_top_left = origin_top_left; + } + if (ctx->hooks.apply_viewport) { + ctx->hooks.apply_viewport(x, y, width, height, origin_top_left, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_apply_scissor_rect(int x, int y, int width, int height, bool origin_top_left, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_APPLY_SCISSOR_RECT; + item->color = _SG_IMGUI_COLOR_DRAW; + item->args.apply_scissor_rect.x = x; + item->args.apply_scissor_rect.y = y; + item->args.apply_scissor_rect.width = width; + item->args.apply_scissor_rect.height = height; + item->args.apply_scissor_rect.origin_top_left = origin_top_left; + } + if (ctx->hooks.apply_scissor_rect) { + ctx->hooks.apply_scissor_rect(x, y, width, height, origin_top_left, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_apply_pipeline(sg_pipeline pip, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + ctx->cur_pipeline = pip; /* stored for _sg_imgui_apply_uniforms */ + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_APPLY_PIPELINE; + item->color = _SG_IMGUI_COLOR_DRAW; + item->args.apply_pipeline.pipeline = pip; + } + if (ctx->hooks.apply_pipeline) { + ctx->hooks.apply_pipeline(pip, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_apply_bindings(const sg_bindings* bindings, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + SOKOL_ASSERT(bindings); + item->cmd = SG_IMGUI_CMD_APPLY_BINDINGS; + item->color = _SG_IMGUI_COLOR_DRAW; + item->args.apply_bindings.bindings = *bindings; + } + if (ctx->hooks.apply_bindings) { + ctx->hooks.apply_bindings(bindings, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_apply_uniforms(sg_shader_stage stage, int ub_index, const sg_range* data, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + SOKOL_ASSERT(data); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_APPLY_UNIFORMS; + item->color = _SG_IMGUI_COLOR_DRAW; + sg_imgui_args_apply_uniforms_t* args = &item->args.apply_uniforms; + args->stage = stage; + args->ub_index = ub_index; + args->data_size = data->size; + args->pipeline = ctx->cur_pipeline; + args->ubuf_pos = _sg_imgui_capture_uniforms(ctx, data); + } + if (ctx->hooks.apply_uniforms) { + ctx->hooks.apply_uniforms(stage, ub_index, data, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw(int base_element, int num_elements, int num_instances, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DRAW; + item->color = _SG_IMGUI_COLOR_DRAW; + item->args.draw.base_element = base_element; + item->args.draw.num_elements = num_elements; + item->args.draw.num_instances = num_instances; + } + if (ctx->hooks.draw) { + ctx->hooks.draw(base_element, num_elements, num_instances, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_end_pass(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + ctx->cur_pipeline.id = SG_INVALID_ID; + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_END_PASS; + item->color = _SG_IMGUI_COLOR_DRAW; + } + if (ctx->hooks.end_pass) { + ctx->hooks.end_pass(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_commit(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_COMMIT; + item->color = _SG_IMGUI_COLOR_DRAW; + } + _sg_imgui_capture_next_frame(ctx); + if (ctx->hooks.commit) { + ctx->hooks.commit(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_alloc_buffer(sg_buffer result, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ALLOC_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.alloc_buffer.result = result; + } + if (ctx->hooks.alloc_buffer) { + ctx->hooks.alloc_buffer(result, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_alloc_image(sg_image result, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ALLOC_IMAGE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.alloc_image.result = result; + } + if (ctx->hooks.alloc_image) { + ctx->hooks.alloc_image(result, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_alloc_shader(sg_shader result, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ALLOC_SHADER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.alloc_shader.result = result; + } + if (ctx->hooks.alloc_shader) { + ctx->hooks.alloc_shader(result, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_alloc_pipeline(sg_pipeline result, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ALLOC_PIPELINE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.alloc_pipeline.result = result; + } + if (ctx->hooks.alloc_pipeline) { + ctx->hooks.alloc_pipeline(result, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_alloc_pass(sg_pass result, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ALLOC_PASS; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.alloc_pass.result = result; + } + if (ctx->hooks.alloc_pass) { + ctx->hooks.alloc_pass(result, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_dealloc_buffer(sg_buffer buf_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DEALLOC_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.dealloc_buffer.buffer = buf_id; + } + if (ctx->hooks.dealloc_buffer) { + ctx->hooks.dealloc_buffer(buf_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_dealloc_image(sg_image img_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DEALLOC_IMAGE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.dealloc_image.image = img_id; + } + if (ctx->hooks.dealloc_image) { + ctx->hooks.dealloc_image(img_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_dealloc_shader(sg_shader shd_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DEALLOC_SHADER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.dealloc_shader.shader = shd_id; + } + if (ctx->hooks.dealloc_shader) { + ctx->hooks.dealloc_shader(shd_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_dealloc_pipeline(sg_pipeline pip_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DEALLOC_PIPELINE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.dealloc_pipeline.pipeline = pip_id; + } + if (ctx->hooks.dealloc_pipeline) { + ctx->hooks.dealloc_pipeline(pip_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_dealloc_pass(sg_pass pass_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_DEALLOC_PASS; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.dealloc_pass.pass = pass_id; + } + if (ctx->hooks.dealloc_pass) { + ctx->hooks.dealloc_pass(pass_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_init_buffer(sg_buffer buf_id, const sg_buffer_desc* desc, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_INIT_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.init_buffer.buffer = buf_id; + } + if (ctx->hooks.init_buffer) { + ctx->hooks.init_buffer(buf_id, desc, ctx->hooks.user_data); + } + if (buf_id.id != SG_INVALID_ID) { + _sg_imgui_buffer_created(ctx, buf_id, _sg_imgui_slot_index(buf_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_init_image(sg_image img_id, const sg_image_desc* desc, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_INIT_IMAGE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.init_image.image = img_id; + } + if (ctx->hooks.init_image) { + ctx->hooks.init_image(img_id, desc, ctx->hooks.user_data); + } + if (img_id.id != SG_INVALID_ID) { + _sg_imgui_image_created(ctx, img_id, _sg_imgui_slot_index(img_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_init_shader(sg_shader shd_id, const sg_shader_desc* desc, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_INIT_SHADER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.init_shader.shader = shd_id; + } + if (ctx->hooks.init_shader) { + ctx->hooks.init_shader(shd_id, desc, ctx->hooks.user_data); + } + if (shd_id.id != SG_INVALID_ID) { + _sg_imgui_shader_created(ctx, shd_id, _sg_imgui_slot_index(shd_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_init_pipeline(sg_pipeline pip_id, const sg_pipeline_desc* desc, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_INIT_PIPELINE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.init_pipeline.pipeline = pip_id; + } + if (ctx->hooks.init_pipeline) { + ctx->hooks.init_pipeline(pip_id, desc, ctx->hooks.user_data); + } + if (pip_id.id != SG_INVALID_ID) { + _sg_imgui_pipeline_created(ctx, pip_id, _sg_imgui_slot_index(pip_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_init_pass(sg_pass pass_id, const sg_pass_desc* desc, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_INIT_PASS; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.init_pass.pass = pass_id; + } + if (ctx->hooks.init_pass) { + ctx->hooks.init_pass(pass_id, desc, ctx->hooks.user_data); + } + if (pass_id.id != SG_INVALID_ID) { + _sg_imgui_pass_created(ctx, pass_id, _sg_imgui_slot_index(pass_id.id), desc); + } +} + +_SOKOL_PRIVATE void _sg_imgui_uninit_buffer(sg_buffer buf, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_UNINIT_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.uninit_buffer.buffer = buf; + } + if (ctx->hooks.uninit_buffer) { + ctx->hooks.uninit_buffer(buf, ctx->hooks.user_data); + } + if (buf.id != SG_INVALID_ID) { + _sg_imgui_buffer_destroyed(ctx, _sg_imgui_slot_index(buf.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_uninit_image(sg_image img, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_UNINIT_IMAGE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.uninit_image.image = img; + } + if (ctx->hooks.uninit_image) { + ctx->hooks.uninit_image(img, ctx->hooks.user_data); + } + if (img.id != SG_INVALID_ID) { + _sg_imgui_image_destroyed(ctx, _sg_imgui_slot_index(img.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_uninit_shader(sg_shader shd, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_UNINIT_SHADER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.uninit_shader.shader = shd; + } + if (ctx->hooks.uninit_shader) { + ctx->hooks.uninit_shader(shd, ctx->hooks.user_data); + } + if (shd.id != SG_INVALID_ID) { + _sg_imgui_shader_destroyed(ctx, _sg_imgui_slot_index(shd.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_uninit_pipeline(sg_pipeline pip, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_UNINIT_PIPELINE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.uninit_pipeline.pipeline = pip; + } + if (ctx->hooks.uninit_pipeline) { + ctx->hooks.uninit_pipeline(pip, ctx->hooks.user_data); + } + if (pip.id != SG_INVALID_ID) { + _sg_imgui_pipeline_destroyed(ctx, _sg_imgui_slot_index(pip.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_uninit_pass(sg_pass pass, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_UNINIT_PIPELINE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.uninit_pass.pass = pass; + } + if (ctx->hooks.uninit_pass) { + ctx->hooks.uninit_pass(pass, ctx->hooks.user_data); + } + if (pass.id != SG_INVALID_ID) { + _sg_imgui_pass_destroyed(ctx, _sg_imgui_slot_index(pass.id)); + } +} + +_SOKOL_PRIVATE void _sg_imgui_fail_buffer(sg_buffer buf_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_FAIL_BUFFER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.fail_buffer.buffer = buf_id; + } + if (ctx->hooks.fail_buffer) { + ctx->hooks.fail_buffer(buf_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_fail_image(sg_image img_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_FAIL_IMAGE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.fail_image.image = img_id; + } + if (ctx->hooks.fail_image) { + ctx->hooks.fail_image(img_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_fail_shader(sg_shader shd_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_FAIL_SHADER; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.fail_shader.shader = shd_id; + } + if (ctx->hooks.fail_shader) { + ctx->hooks.fail_shader(shd_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_fail_pipeline(sg_pipeline pip_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_FAIL_PIPELINE; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.fail_pipeline.pipeline = pip_id; + } + if (ctx->hooks.fail_pipeline) { + ctx->hooks.fail_pipeline(pip_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_fail_pass(sg_pass pass_id, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_FAIL_PASS; + item->color = _SG_IMGUI_COLOR_RSRC; + item->args.fail_pass.pass = pass_id; + } + if (ctx->hooks.fail_pass) { + ctx->hooks.fail_pass(pass_id, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_push_debug_group(const char* name, void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_PUSH_DEBUG_GROUP; + item->color = _SG_IMGUI_COLOR_OTHER; + item->args.push_debug_group.name = _sg_imgui_make_str(name); + } + if (ctx->hooks.push_debug_group) { + ctx->hooks.push_debug_group(name, ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_pop_debug_group(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_POP_DEBUG_GROUP; + item->color = _SG_IMGUI_COLOR_OTHER; + } + if (ctx->hooks.pop_debug_group) { + ctx->hooks.pop_debug_group(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_buffer_pool_exhausted(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_BUFFER_POOL_EXHAUSTED; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_buffer_pool_exhausted) { + ctx->hooks.err_buffer_pool_exhausted(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_image_pool_exhausted(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_IMAGE_POOL_EXHAUSTED; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_image_pool_exhausted) { + ctx->hooks.err_image_pool_exhausted(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_shader_pool_exhausted(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_SHADER_POOL_EXHAUSTED; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_shader_pool_exhausted) { + ctx->hooks.err_shader_pool_exhausted(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_pipeline_pool_exhausted(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_PIPELINE_POOL_EXHAUSTED; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_pipeline_pool_exhausted) { + ctx->hooks.err_pipeline_pool_exhausted(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_pass_pool_exhausted(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_PASS_POOL_EXHAUSTED; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_pass_pool_exhausted) { + ctx->hooks.err_pass_pool_exhausted(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_context_mismatch(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_CONTEXT_MISMATCH; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_context_mismatch) { + ctx->hooks.err_context_mismatch(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_pass_invalid(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_PASS_INVALID; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_pass_invalid) { + ctx->hooks.err_pass_invalid(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_draw_invalid(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_DRAW_INVALID; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_draw_invalid) { + ctx->hooks.err_draw_invalid(ctx->hooks.user_data); + } +} + +_SOKOL_PRIVATE void _sg_imgui_err_bindings_invalid(void* user_data) { + sg_imgui_t* ctx = (sg_imgui_t*) user_data; + SOKOL_ASSERT(ctx); + sg_imgui_capture_item_t* item = _sg_imgui_capture_next_write_item(ctx); + if (item) { + item->cmd = SG_IMGUI_CMD_ERR_BINDINGS_INVALID; + item->color = _SG_IMGUI_COLOR_ERR; + } + if (ctx->hooks.err_bindings_invalid) { + ctx->hooks.err_bindings_invalid(ctx->hooks.user_data); + } +} + +/*--- IMGUI HELPERS ----------------------------------------------------------*/ +_SOKOL_PRIVATE bool _sg_imgui_draw_resid_list_item(uint32_t res_id, const char* label, bool selected) { + igPushID_Int((int)res_id); + bool res; + if (label[0]) { + res = igSelectable_Bool(label, selected, 0, IMVEC2(0,0)); + } + else { + sg_imgui_str_t str; + _sg_imgui_snprintf(&str, "0x%08X", res_id); + res = igSelectable_Bool(str.buf, selected, 0, IMVEC2(0,0)); + } + igPopID(); + return res; +} + +_SOKOL_PRIVATE bool _sg_imgui_draw_resid_link(uint32_t res_type, uint32_t res_id, const char* label) { + SOKOL_ASSERT(label); + sg_imgui_str_t str_buf; + const char* str; + if (label[0]) { + str = label; + } + else { + _sg_imgui_snprintf(&str_buf, "0x%08X", res_id); + str = str_buf.buf; + } + igPushID_Int((int)((res_type<<24)|res_id)); + bool res = igSmallButton(str); + igPopID(); + return res; +} + +_SOKOL_PRIVATE bool _sg_imgui_draw_buffer_link(sg_imgui_t* ctx, sg_buffer buf) { + bool retval = false; + if (buf.id != SG_INVALID_ID) { + const sg_imgui_buffer_t* buf_ui = &ctx->buffers.slots[_sg_imgui_slot_index(buf.id)]; + retval = _sg_imgui_draw_resid_link(1, buf.id, buf_ui->label.buf); + } + return retval; +} + +_SOKOL_PRIVATE bool _sg_imgui_draw_image_link(sg_imgui_t* ctx, sg_image img) { + bool retval = false; + if (img.id != SG_INVALID_ID) { + const sg_imgui_image_t* img_ui = &ctx->images.slots[_sg_imgui_slot_index(img.id)]; + retval = _sg_imgui_draw_resid_link(2, img.id, img_ui->label.buf); + } + return retval; +} + +_SOKOL_PRIVATE bool _sg_imgui_draw_shader_link(sg_imgui_t* ctx, sg_shader shd) { + bool retval = false; + if (shd.id != SG_INVALID_ID) { + const sg_imgui_shader_t* shd_ui = &ctx->shaders.slots[_sg_imgui_slot_index(shd.id)]; + retval = _sg_imgui_draw_resid_link(3, shd.id, shd_ui->label.buf); + } + return retval; +} + +_SOKOL_PRIVATE void _sg_imgui_show_buffer(sg_imgui_t* ctx, sg_buffer buf) { + ctx->buffers.open = true; + ctx->buffers.sel_buf = buf; +} + +_SOKOL_PRIVATE void _sg_imgui_show_image(sg_imgui_t* ctx, sg_image img) { + ctx->images.open = true; + ctx->images.sel_img = img; +} + +_SOKOL_PRIVATE void _sg_imgui_show_shader(sg_imgui_t* ctx, sg_shader shd) { + ctx->shaders.open = true; + ctx->shaders.sel_shd = shd; +} + +_SOKOL_PRIVATE void _sg_imgui_draw_buffer_list(sg_imgui_t* ctx) { + igBeginChild_Str("buffer_list", IMVEC2(_SG_IMGUI_LIST_WIDTH,0), true, 0); + for (int i = 0; i < ctx->buffers.num_slots; i++) { + sg_buffer buf = ctx->buffers.slots[i].res_id; + sg_resource_state state = sg_query_buffer_state(buf); + if ((state != SG_RESOURCESTATE_INVALID) && (state != SG_RESOURCESTATE_INITIAL)) { + bool selected = ctx->buffers.sel_buf.id == buf.id; + if (_sg_imgui_draw_resid_list_item(buf.id, ctx->buffers.slots[i].label.buf, selected)) { + ctx->buffers.sel_buf.id = buf.id; + } + } + } + igEndChild(); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_image_list(sg_imgui_t* ctx) { + igBeginChild_Str("image_list", IMVEC2(_SG_IMGUI_LIST_WIDTH,0), true, 0); + for (int i = 0; i < ctx->images.num_slots; i++) { + sg_image img = ctx->images.slots[i].res_id; + sg_resource_state state = sg_query_image_state(img); + if ((state != SG_RESOURCESTATE_INVALID) && (state != SG_RESOURCESTATE_INITIAL)) { + bool selected = ctx->images.sel_img.id == img.id; + if (_sg_imgui_draw_resid_list_item(img.id, ctx->images.slots[i].label.buf, selected)) { + ctx->images.sel_img.id = img.id; + } + } + } + igEndChild(); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_shader_list(sg_imgui_t* ctx) { + igBeginChild_Str("shader_list", IMVEC2(_SG_IMGUI_LIST_WIDTH,0), true, 0); + for (int i = 0; i < ctx->shaders.num_slots; i++) { + sg_shader shd = ctx->shaders.slots[i].res_id; + sg_resource_state state = sg_query_shader_state(shd); + if ((state != SG_RESOURCESTATE_INVALID) && (state != SG_RESOURCESTATE_INITIAL)) { + bool selected = ctx->shaders.sel_shd.id == shd.id; + if (_sg_imgui_draw_resid_list_item(shd.id, ctx->shaders.slots[i].label.buf, selected)) { + ctx->shaders.sel_shd.id = shd.id; + } + } + } + igEndChild(); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_pipeline_list(sg_imgui_t* ctx) { + igBeginChild_Str("pipeline_list", IMVEC2(_SG_IMGUI_LIST_WIDTH,0), true, 0); + for (int i = 1; i < ctx->pipelines.num_slots; i++) { + sg_pipeline pip = ctx->pipelines.slots[i].res_id; + sg_resource_state state = sg_query_pipeline_state(pip); + if ((state != SG_RESOURCESTATE_INVALID) && (state != SG_RESOURCESTATE_INITIAL)) { + bool selected = ctx->pipelines.sel_pip.id == pip.id; + if (_sg_imgui_draw_resid_list_item(pip.id, ctx->pipelines.slots[i].label.buf, selected)) { + ctx->pipelines.sel_pip.id = pip.id; + } + } + } + igEndChild(); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_pass_list(sg_imgui_t* ctx) { + igBeginChild_Str("pass_list", IMVEC2(_SG_IMGUI_LIST_WIDTH,0), true, 0); + for (int i = 1; i < ctx->passes.num_slots; i++) { + sg_pass pass = ctx->passes.slots[i].res_id; + sg_resource_state state = sg_query_pass_state(pass); + if ((state != SG_RESOURCESTATE_INVALID) && (state != SG_RESOURCESTATE_INITIAL)) { + bool selected = ctx->passes.sel_pass.id == pass.id; + if (_sg_imgui_draw_resid_list_item(pass.id, ctx->passes.slots[i].label.buf, selected)) { + ctx->passes.sel_pass.id = pass.id; + } + } + } + igEndChild(); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_capture_list(sg_imgui_t* ctx) { + igBeginChild_Str("capture_list", IMVEC2(_SG_IMGUI_LIST_WIDTH,0), true, 0); + const int num_items = _sg_imgui_capture_num_read_items(ctx); + uint64_t group_stack = 1; /* bit set: group unfolded, cleared: folded */ + for (int i = 0; i < num_items; i++) { + const sg_imgui_capture_item_t* item = _sg_imgui_capture_read_item_at(ctx, i); + sg_imgui_str_t item_string = _sg_imgui_capture_item_string(ctx, i, item); + igPushStyleColor_U32(ImGuiCol_Text, item->color); + igPushID_Int(i); + if (item->cmd == SG_IMGUI_CMD_PUSH_DEBUG_GROUP) { + if (group_stack & 1) { + group_stack <<= 1; + const char* group_name = item->args.push_debug_group.name.buf; + if (igTreeNode_StrStr(group_name, "Group: %s", group_name)) { + group_stack |= 1; + } + } + else { + group_stack <<= 1; + } + } + else if (item->cmd == SG_IMGUI_CMD_POP_DEBUG_GROUP) { + if (group_stack & 1) { + igTreePop(); + } + group_stack >>= 1; + } + else if (group_stack & 1) { + if (igSelectable_Bool(item_string.buf, ctx->capture.sel_item == i, 0, IMVEC2(0,0))) { + ctx->capture.sel_item = i; + } + if (igIsItemHovered(0)) { + igSetTooltip("%s", item_string.buf); + } + } + igPopID(); + igPopStyleColor(1); + } + igEndChild(); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_buffer_panel(sg_imgui_t* ctx, sg_buffer buf) { + if (buf.id != SG_INVALID_ID) { + igBeginChild_Str("buffer", IMVEC2(0,0), false, 0); + sg_buffer_info info = sg_query_buffer_info(buf); + if (info.slot.state == SG_RESOURCESTATE_VALID) { + const sg_imgui_buffer_t* buf_ui = &ctx->buffers.slots[_sg_imgui_slot_index(buf.id)]; + igText("Label: %s", buf_ui->label.buf[0] ? buf_ui->label.buf : "---"); + _sg_imgui_draw_resource_slot(&info.slot); + igSeparator(); + igText("Type: %s", _sg_imgui_buffertype_string(buf_ui->desc.type)); + igText("Usage: %s", _sg_imgui_usage_string(buf_ui->desc.usage)); + igText("Size: %d", buf_ui->desc.size); + if (buf_ui->desc.usage != SG_USAGE_IMMUTABLE) { + igSeparator(); + igText("Num Slots: %d", info.num_slots); + igText("Active Slot: %d", info.active_slot); + igText("Update Frame Index: %d", info.update_frame_index); + igText("Append Frame Index: %d", info.append_frame_index); + igText("Append Pos: %d", info.append_pos); + igText("Append Overflow: %s", _sg_imgui_bool_string(info.append_overflow)); + } + } + else { + igText("Buffer 0x%08X not valid.", buf.id); + } + igEndChild(); + } +} + +_SOKOL_PRIVATE bool _sg_imgui_image_renderable(sg_image_type type, sg_pixel_format fmt) { + return (type == SG_IMAGETYPE_2D) && sg_query_pixelformat(fmt).sample && !sg_query_pixelformat(fmt).depth; +} + +_SOKOL_PRIVATE void _sg_imgui_draw_embedded_image(sg_imgui_t* ctx, sg_image img, float* scale) { + if (sg_query_image_state(img) == SG_RESOURCESTATE_VALID) { + sg_imgui_image_t* img_ui = &ctx->images.slots[_sg_imgui_slot_index(img.id)]; + if (_sg_imgui_image_renderable(img_ui->desc.type, img_ui->desc.pixel_format)) { + igPushID_Int((int)img.id); + igSliderFloat("Scale", scale, 0.125f, 8.0f, "%.3f", ImGuiSliderFlags_Logarithmic); + float w = (float)img_ui->desc.width * (*scale); + float h = (float)img_ui->desc.height * (*scale); + igImage((ImTextureID)(intptr_t)img.id, IMVEC2(w, h), IMVEC2(0,0), IMVEC2(1,1), IMVEC4(1,1,1,1), IMVEC4(0,0,0,0)); + igPopID(); + } + else { + igText("Image not renderable."); + } + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_image_panel(sg_imgui_t* ctx, sg_image img) { + if (img.id != SG_INVALID_ID) { + igBeginChild_Str("image", IMVEC2(0,0), false, 0); + sg_image_info info = sg_query_image_info(img); + if (info.slot.state == SG_RESOURCESTATE_VALID) { + sg_imgui_image_t* img_ui = &ctx->images.slots[_sg_imgui_slot_index(img.id)]; + const sg_image_desc* desc = &img_ui->desc; + igText("Label: %s", img_ui->label.buf[0] ? img_ui->label.buf : "---"); + _sg_imgui_draw_resource_slot(&info.slot); + igSeparator(); + _sg_imgui_draw_embedded_image(ctx, img, &img_ui->ui_scale); + igSeparator(); + igText("Type: %s", _sg_imgui_imagetype_string(desc->type)); + igText("Usage: %s", _sg_imgui_usage_string(desc->usage)); + igText("Render Target: %s", _sg_imgui_bool_string(desc->render_target)); + igText("Width: %d", desc->width); + igText("Height: %d", desc->height); + igText("Num Slices: %d", desc->num_slices); + igText("Num Mipmaps: %d", desc->num_mipmaps); + igText("Pixel Format: %s", _sg_imgui_pixelformat_string(desc->pixel_format)); + igText("Sample Count: %d", desc->sample_count); + igText("Min Filter: %s", _sg_imgui_filter_string(desc->min_filter)); + igText("Mag Filter: %s", _sg_imgui_filter_string(desc->mag_filter)); + igText("Wrap U: %s", _sg_imgui_wrap_string(desc->wrap_u)); + igText("Wrap V: %s", _sg_imgui_wrap_string(desc->wrap_v)); + igText("Wrap W: %s", _sg_imgui_wrap_string(desc->wrap_w)); + igText("Border Color: %s", _sg_imgui_bordercolor_string(desc->border_color)); + igText("Max Anisotropy: %d", desc->max_anisotropy); + igText("Min LOD: %.3f", desc->min_lod); + igText("Max LOD: %.3f", desc->max_lod); + if (desc->usage != SG_USAGE_IMMUTABLE) { + igSeparator(); + igText("Num Slots: %d", info.num_slots); + igText("Active Slot: %d", info.active_slot); + igText("Update Frame Index: %d", info.upd_frame_index); + } + } + else { + igText("Image 0x%08X not valid.", img.id); + } + igEndChild(); + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_shader_stage(const sg_shader_stage_desc* stage) { + int num_valid_ubs = 0; + for (int i = 0; i < SG_MAX_SHADERSTAGE_UBS; i++) { + const sg_shader_uniform_block_desc* ub = &stage->uniform_blocks[i]; + for (int j = 0; j < SG_MAX_UB_MEMBERS; j++) { + const sg_shader_uniform_desc* u = &ub->uniforms[j]; + if (SG_UNIFORMTYPE_INVALID != u->type) { + num_valid_ubs++; + break; + } + } + } + int num_valid_images = 0; + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + if (_SG_IMAGETYPE_DEFAULT != stage->images[i].image_type) { + num_valid_images++; + } + else { + break; + } + } + if (num_valid_ubs > 0) { + if (igTreeNode_Str("Uniform Blocks")) { + for (int i = 0; i < num_valid_ubs; i++) { + igText("#%d:", i); + const sg_shader_uniform_block_desc* ub = &stage->uniform_blocks[i]; + for (int j = 0; j < SG_MAX_UB_MEMBERS; j++) { + const sg_shader_uniform_desc* u = &ub->uniforms[j]; + if (SG_UNIFORMTYPE_INVALID != u->type) { + if (u->array_count <= 1) { + igText(" %s %s", _sg_imgui_uniformtype_string(u->type), u->name ? u->name : ""); + } + else { + igText(" %s[%d] %s", _sg_imgui_uniformtype_string(u->type), u->array_count, u->name ? u->name : ""); + } + } + } + } + igTreePop(); + } + } + if (num_valid_images > 0) { + if (igTreeNode_Str("Images")) { + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + const sg_shader_image_desc* sid = &stage->images[i]; + if (sid->image_type != _SG_IMAGETYPE_DEFAULT) { + igText("slot: %d\n name: %s\n image_type: %s\n sampler_type: %s", + i, sid->name ? sid->name : "NONE", + _sg_imgui_imagetype_string(sid->image_type), + _sg_imgui_samplertype_string(sid->sampler_type)); + } + else { + break; + } + } + igTreePop(); + } + } + if (stage->entry) { + igText("Entry: %s", stage->entry); + } + if (stage->d3d11_target) { + igText("D3D11 Target: %s", stage->d3d11_target); + } + if (stage->source) { + if (igTreeNode_Str("Source")) { + igText("%s", stage->source); + igTreePop(); + } + } + else if (stage->bytecode.ptr) { + if (igTreeNode_Str("Byte Code")) { + igText("Byte-code display currently not supported."); + igTreePop(); + } + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_shader_panel(sg_imgui_t* ctx, sg_shader shd) { + if (shd.id != SG_INVALID_ID) { + igBeginChild_Str("shader", IMVEC2(0,0), false, ImGuiWindowFlags_HorizontalScrollbar); + sg_shader_info info = sg_query_shader_info(shd); + if (info.slot.state == SG_RESOURCESTATE_VALID) { + const sg_imgui_shader_t* shd_ui = &ctx->shaders.slots[_sg_imgui_slot_index(shd.id)]; + igText("Label: %s", shd_ui->label.buf[0] ? shd_ui->label.buf : "---"); + _sg_imgui_draw_resource_slot(&info.slot); + igSeparator(); + if (igTreeNode_Str("Attrs")) { + for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) { + const sg_shader_attr_desc* a_desc = &shd_ui->desc.attrs[i]; + if (a_desc->name || a_desc->sem_index) { + igText("#%d:", i); + igText(" Name: %s", a_desc->name ? a_desc->name : "---"); + igText(" Sem Name: %s", a_desc->sem_name ? a_desc->sem_name : "---"); + igText(" Sem Index: %d", a_desc->sem_index); + } + } + igTreePop(); + } + if (igTreeNode_Str("Vertex Shader Stage")) { + _sg_imgui_draw_shader_stage(&shd_ui->desc.vs); + igTreePop(); + } + if (igTreeNode_Str("Fragment Shader Stage")) { + _sg_imgui_draw_shader_stage(&shd_ui->desc.fs); + igTreePop(); + } + } + else { + igText("Shader 0x%08X not valid!", shd.id); + } + igEndChild(); + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_vertex_layout(const sg_layout_desc* layout) { + if (igTreeNode_Str("Buffers")) { + for (int i = 0; i < SG_MAX_SHADERSTAGE_BUFFERS; i++) { + const sg_buffer_layout_desc* l_desc = &layout->buffers[i]; + if (l_desc->stride > 0) { + igText("#%d:", i); + igText(" Stride: %d", l_desc->stride); + igText(" Step Func: %s", _sg_imgui_vertexstep_string(l_desc->step_func)); + igText(" Step Rate: %d", l_desc->step_rate); + } + } + igTreePop(); + } + if (igTreeNode_Str("Attrs")) { + for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) { + const sg_vertex_attr_desc* a_desc = &layout->attrs[i]; + if (a_desc->format != SG_VERTEXFORMAT_INVALID) { + igText("#%d:", i); + igText(" Format: %s", _sg_imgui_vertexformat_string(a_desc->format)); + igText(" Offset: %d", a_desc->offset); + igText(" Buffer Index: %d", a_desc->buffer_index); + } + } + igTreePop(); + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_stencil_face_state(const sg_stencil_face_state* sfs) { + igText("Fail Op: %s", _sg_imgui_stencilop_string(sfs->fail_op)); + igText("Depth Fail Op: %s", _sg_imgui_stencilop_string(sfs->depth_fail_op)); + igText("Pass Op: %s", _sg_imgui_stencilop_string(sfs->pass_op)); + igText("Compare: %s", _sg_imgui_comparefunc_string(sfs->compare)); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_stencil_state(const sg_stencil_state* ss) { + igText("Enabled: %s", _sg_imgui_bool_string(ss->enabled)); + igText("Read Mask: 0x%02X", ss->read_mask); + igText("Write Mask: 0x%02X", ss->write_mask); + igText("Ref: 0x%02X", ss->ref); + if (igTreeNode_Str("Front")) { + _sg_imgui_draw_stencil_face_state(&ss->front); + igTreePop(); + } + if (igTreeNode_Str("Back")) { + _sg_imgui_draw_stencil_face_state(&ss->back); + igTreePop(); + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_depth_state(const sg_depth_state* ds) { + igText("Pixel Format: %s", _sg_imgui_pixelformat_string(ds->pixel_format)); + igText("Compare: %s", _sg_imgui_comparefunc_string(ds->compare)); + igText("Write Enabled: %s", _sg_imgui_bool_string(ds->write_enabled)); + igText("Bias: %f", ds->bias); + igText("Bias Slope: %f", ds->bias_slope_scale); + igText("Bias Clamp: %f", ds->bias_clamp); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_blend_state(const sg_blend_state* bs) { + igText("Blend Enabled: %s", _sg_imgui_bool_string(bs->enabled)); + igText("Src Factor RGB: %s", _sg_imgui_blendfactor_string(bs->src_factor_rgb)); + igText("Dst Factor RGB: %s", _sg_imgui_blendfactor_string(bs->dst_factor_rgb)); + igText("Op RGB: %s", _sg_imgui_blendop_string(bs->op_rgb)); + igText("Src Factor Alpha: %s", _sg_imgui_blendfactor_string(bs->src_factor_alpha)); + igText("Dst Factor Alpha: %s", _sg_imgui_blendfactor_string(bs->dst_factor_alpha)); + igText("Op Alpha: %s", _sg_imgui_blendop_string(bs->op_alpha)); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_color_state(const sg_color_state* cs) { + igText("Pixel Format: %s", _sg_imgui_pixelformat_string(cs->pixel_format)); + igText("Write Mask: %s", _sg_imgui_colormask_string(cs->write_mask)); + if (igTreeNode_Str("Blend State:")) { + _sg_imgui_draw_blend_state(&cs->blend); + igTreePop(); + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_pipeline_panel(sg_imgui_t* ctx, sg_pipeline pip) { + if (pip.id != SG_INVALID_ID) { + igBeginChild_Str("pipeline", IMVEC2(0,0), false, 0); + sg_pipeline_info info = sg_query_pipeline_info(pip); + if (info.slot.state == SG_RESOURCESTATE_VALID) { + const sg_imgui_pipeline_t* pip_ui = &ctx->pipelines.slots[_sg_imgui_slot_index(pip.id)]; + igText("Label: %s", pip_ui->label.buf[0] ? pip_ui->label.buf : "---"); + _sg_imgui_draw_resource_slot(&info.slot); + igSeparator(); + igText("Shader: "); igSameLine(0,-1); + if (_sg_imgui_draw_shader_link(ctx, pip_ui->desc.shader)) { + _sg_imgui_show_shader(ctx, pip_ui->desc.shader); + } + if (igTreeNode_Str("Vertex Layout")) { + _sg_imgui_draw_vertex_layout(&pip_ui->desc.layout); + igTreePop(); + } + if (igTreeNode_Str("Depth State")) { + _sg_imgui_draw_depth_state(&pip_ui->desc.depth); + igTreePop(); + } + if (igTreeNode_Str("Stencil State")) { + _sg_imgui_draw_stencil_state(&pip_ui->desc.stencil); + igTreePop(); + } + igText("Color Count: %d", pip_ui->desc.color_count); + for (int i = 0; i < pip_ui->desc.color_count; i++) { + sg_imgui_str_t str; + _sg_imgui_snprintf(&str, "Color %d", i); + if (igTreeNode_Str(str.buf)) { + _sg_imgui_draw_color_state(&pip_ui->desc.colors[i]); + igTreePop(); + } + } + igText("Prim Type: %s", _sg_imgui_primitivetype_string(pip_ui->desc.primitive_type)); + igText("Index Type: %s", _sg_imgui_indextype_string(pip_ui->desc.index_type)); + igText("Cull Mode: %s", _sg_imgui_cullmode_string(pip_ui->desc.cull_mode)); + igText("Face Winding: %s", _sg_imgui_facewinding_string(pip_ui->desc.face_winding)); + igText("Sample Count: %d", pip_ui->desc.sample_count); + sg_imgui_str_t blend_color_str; + igText("Blend Color: %.3f %.3f %.3f %.3f", _sg_imgui_color_string(&blend_color_str, pip_ui->desc.blend_color)); + igText("Alpha To Coverage: %s", _sg_imgui_bool_string(pip_ui->desc.alpha_to_coverage_enabled)); + } + else { + igText("Pipeline 0x%08X not valid.", pip.id); + } + igEndChild(); + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_pass_attachment(sg_imgui_t* ctx, const sg_pass_attachment_desc* att, float* img_scale) { + igText(" Image: "); igSameLine(0,-1); + if (_sg_imgui_draw_image_link(ctx, att->image)) { + _sg_imgui_show_image(ctx, att->image); + } + igText(" Mip Level: %d", att->mip_level); + igText(" Slice: %d", att->slice); + _sg_imgui_draw_embedded_image(ctx, att->image, img_scale); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_pass_panel(sg_imgui_t* ctx, sg_pass pass) { + if (pass.id != SG_INVALID_ID) { + igBeginChild_Str("pass", IMVEC2(0,0), false, 0); + sg_pass_info info = sg_query_pass_info(pass); + if (info.slot.state == SG_RESOURCESTATE_VALID) { + sg_imgui_pass_t* pass_ui = &ctx->passes.slots[_sg_imgui_slot_index(pass.id)]; + igText("Label: %s", pass_ui->label.buf[0] ? pass_ui->label.buf : "---"); + _sg_imgui_draw_resource_slot(&info.slot); + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + if (pass_ui->desc.color_attachments[i].image.id == SG_INVALID_ID) { + break; + } + igSeparator(); + igText("Color Attachment #%d:", i); + _sg_imgui_draw_pass_attachment(ctx, &pass_ui->desc.color_attachments[i], &pass_ui->color_image_scale[i]); + } + if (pass_ui->desc.depth_stencil_attachment.image.id != SG_INVALID_ID) { + igSeparator(); + igText("Depth-Stencil Attachemnt:"); + _sg_imgui_draw_pass_attachment(ctx, &pass_ui->desc.depth_stencil_attachment, &pass_ui->ds_image_scale); + } + } + else { + igText("Pass 0x%08X not valid.", pass.id); + } + igEndChild(); + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_bindings_panel(sg_imgui_t* ctx, const sg_bindings* bnd) { + for (int i = 0; i < SG_MAX_SHADERSTAGE_BUFFERS; i++) { + sg_buffer buf = bnd->vertex_buffers[i]; + if (buf.id != SG_INVALID_ID) { + igSeparator(); + igText("Vertex Buffer Slot #%d:", i); + igText(" Buffer: "); igSameLine(0,-1); + if (_sg_imgui_draw_buffer_link(ctx, buf)) { + _sg_imgui_show_buffer(ctx, buf); + } + igText(" Offset: %d", bnd->vertex_buffer_offsets[i]); + } + else { + break; + } + } + if (bnd->index_buffer.id != SG_INVALID_ID) { + sg_buffer buf = bnd->index_buffer; + if (buf.id != SG_INVALID_ID) { + igSeparator(); + igText("Index Buffer Slot:"); + igText(" Buffer: "); igSameLine(0,-1); + if (_sg_imgui_draw_buffer_link(ctx, buf)) { + _sg_imgui_show_buffer(ctx, buf); + } + igText(" Offset: %d", bnd->index_buffer_offset); + } + } + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + sg_image img = bnd->vs_images[i]; + if (img.id != SG_INVALID_ID) { + igSeparator(); + igText("Vertex Stage Image Slot #%d:", i); + igText(" Image: "); igSameLine(0,-1); + if (_sg_imgui_draw_image_link(ctx, img)) { + _sg_imgui_show_image(ctx, img); + } + } + else { + break; + } + } + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + sg_image img = bnd->fs_images[i]; + if (img.id != SG_INVALID_ID) { + igSeparator(); + igText("Fragment Stage Image Slot #%d:", i); + igText(" Image: "); igSameLine(0,-1); + if (_sg_imgui_draw_image_link(ctx, img)) { + _sg_imgui_show_image(ctx, img); + } + } + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_uniforms_panel(sg_imgui_t* ctx, const sg_imgui_args_apply_uniforms_t* args) { + SOKOL_ASSERT(args->ub_index < SG_MAX_SHADERSTAGE_BUFFERS); + + /* check if all the required information for drawing the structured uniform block content + is available, otherwise just render a generic hexdump + */ + if (sg_query_pipeline_state(args->pipeline) != SG_RESOURCESTATE_VALID) { + igText("Pipeline object not valid!"); + return; + } + sg_imgui_pipeline_t* pip_ui = &ctx->pipelines.slots[_sg_imgui_slot_index(args->pipeline.id)]; + if (sg_query_shader_state(pip_ui->desc.shader) != SG_RESOURCESTATE_VALID) { + igText("Shader object not valid!"); + return; + } + sg_imgui_shader_t* shd_ui = &ctx->shaders.slots[_sg_imgui_slot_index(pip_ui->desc.shader.id)]; + SOKOL_ASSERT(shd_ui->res_id.id == pip_ui->desc.shader.id); + const sg_shader_uniform_block_desc* ub_desc = (args->stage == SG_SHADERSTAGE_VS) ? + &shd_ui->desc.vs.uniform_blocks[args->ub_index] : + &shd_ui->desc.fs.uniform_blocks[args->ub_index]; + SOKOL_ASSERT(args->data_size <= ub_desc->size); + bool draw_dump = false; + if (ub_desc->uniforms[0].type == SG_UNIFORMTYPE_INVALID) { + draw_dump = true; + } + + sg_imgui_capture_bucket_t* bucket = _sg_imgui_capture_get_read_bucket(ctx); + SOKOL_ASSERT((args->ubuf_pos + args->data_size) <= bucket->ubuf_size); + const float* uptrf = (const float*) (bucket->ubuf + args->ubuf_pos); + const int32_t* uptri32 = (const int32_t*) uptrf; + if (!draw_dump) { + uint32_t u_off = 0; + for (int i = 0; i < SG_MAX_UB_MEMBERS; i++) { + const sg_shader_uniform_desc* ud = &ub_desc->uniforms[i]; + if (ud->type == SG_UNIFORMTYPE_INVALID) { + break; + } + int num_items = (ud->array_count > 1) ? ud->array_count : 1; + if (num_items > 1) { + igText("%d: %s %s[%d] =", i, _sg_imgui_uniformtype_string(ud->type), ud->name?ud->name:"", ud->array_count); + } + else { + igText("%d: %s %s =", i, _sg_imgui_uniformtype_string(ud->type), ud->name?ud->name:""); + } + for (int item_index = 0; item_index < num_items; item_index++) { + const uint32_t u_size = _sg_imgui_std140_uniform_size(ud->type, ud->array_count) / 4; + const uint32_t u_align = _sg_imgui_std140_uniform_alignment(ud->type, ud->array_count) / 4; + u_off = _sg_imgui_align_u32(u_off, u_align); + switch (ud->type) { + case SG_UNIFORMTYPE_FLOAT: + igText(" %.3f", uptrf[u_off]); + break; + case SG_UNIFORMTYPE_INT: + igText(" %d", uptri32[u_off]); + break; + case SG_UNIFORMTYPE_FLOAT2: + igText(" %.3f, %.3f", uptrf[u_off], uptrf[u_off+1]); + break; + case SG_UNIFORMTYPE_INT2: + igText(" %d, %d", uptri32[u_off], uptri32[u_off+1]); + break; + case SG_UNIFORMTYPE_FLOAT3: + igText(" %.3f, %.3f, %.3f", uptrf[u_off], uptrf[u_off+1], uptrf[u_off+2]); + break; + case SG_UNIFORMTYPE_INT3: + igText(" %d, %d, %d", uptri32[u_off], uptri32[u_off+1], uptri32[u_off+2]); + break; + case SG_UNIFORMTYPE_FLOAT4: + igText(" %.3f, %.3f, %.3f, %.3f", uptrf[u_off], uptrf[u_off+1], uptrf[u_off+2], uptrf[u_off+3]); + break; + case SG_UNIFORMTYPE_INT4: + igText(" %d, %d, %d, %d", uptri32[u_off], uptri32[u_off+1], uptri32[u_off+2], uptri32[u_off+3]); + break; + case SG_UNIFORMTYPE_MAT4: + igText(" %.3f, %.3f, %.3f, %.3f\n" + " %.3f, %.3f, %.3f, %.3f\n" + " %.3f, %.3f, %.3f, %.3f\n" + " %.3f, %.3f, %.3f, %.3f", + uptrf[u_off+0], uptrf[u_off+1], uptrf[u_off+2], uptrf[u_off+3], + uptrf[u_off+4], uptrf[u_off+5], uptrf[u_off+6], uptrf[u_off+7], + uptrf[u_off+8], uptrf[u_off+9], uptrf[u_off+10], uptrf[u_off+11], + uptrf[u_off+12], uptrf[u_off+13], uptrf[u_off+14], uptrf[u_off+15]); + break; + default: + igText("???"); + break; + } + u_off += u_size; + } + } + } + else { + // FIXME: float vs int + const size_t num_floats = ub_desc->size / sizeof(float); + for (uint32_t i = 0; i < num_floats; i++) { + igText("%.3f, ", uptrf[i]); + if (((i + 1) % 4) != 0) { + igSameLine(0,-1); + } + } + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_passaction_panel(sg_imgui_t* ctx, sg_pass pass, const sg_pass_action* action) { + /* determine number of valid color attachments in the pass */ + int num_color_atts = 0; + if (SG_INVALID_ID == pass.id) { + /* default pass: one color attachment */ + num_color_atts = 1; + } + else { + const sg_imgui_pass_t* pass_ui = &ctx->passes.slots[_sg_imgui_slot_index(pass.id)]; + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + if (pass_ui->desc.color_attachments[i].image.id != SG_INVALID_ID) { + num_color_atts++; + } + } + } + + igText("Pass Action: "); + for (int i = 0; i < num_color_atts; i++) { + const sg_color_attachment_action* c_att = &action->colors[i]; + igText(" Color Attachment %d:", i); + sg_imgui_str_t color_str; + switch (c_att->action) { + case SG_ACTION_LOAD: igText(" SG_ACTION_LOAD"); break; + case SG_ACTION_DONTCARE: igText(" SG_ACTION_DONTCARE"); break; + default: + igText(" SG_ACTION_CLEAR: %s", _sg_imgui_color_string(&color_str, c_att->value)); + break; + } + } + const sg_depth_attachment_action* d_att = &action->depth; + igText(" Depth Attachment:"); + switch (d_att->action) { + case SG_ACTION_LOAD: igText(" SG_ACTION_LOAD"); break; + case SG_ACTION_DONTCARE: igText(" SG_ACTION_DONTCARE"); break; + default: igText(" SG_ACTION_CLEAR: %.3f", d_att->value); break; + } + const sg_stencil_attachment_action* s_att = &action->stencil; + igText(" Stencil Attachment"); + switch (s_att->action) { + case SG_ACTION_LOAD: igText(" SG_ACTION_LOAD"); break; + case SG_ACTION_DONTCARE: igText(" SG_ACTION_DONTCARE"); break; + default: igText(" SG_ACTION_CLEAR: 0x%02X", s_att->value); break; + } +} + +_SOKOL_PRIVATE void _sg_imgui_draw_capture_panel(sg_imgui_t* ctx) { + int sel_item_index = ctx->capture.sel_item; + if (sel_item_index >= _sg_imgui_capture_num_read_items(ctx)) { + return; + } + sg_imgui_capture_item_t* item = _sg_imgui_capture_read_item_at(ctx, sel_item_index); + igBeginChild_Str("capture_item", IMVEC2(0, 0), false, 0); + igPushStyleColor_U32(ImGuiCol_Text, item->color); + igText("%s", _sg_imgui_capture_item_string(ctx, sel_item_index, item).buf); + igPopStyleColor(1); + igSeparator(); + switch (item->cmd) { + case SG_IMGUI_CMD_RESET_STATE_CACHE: + break; + case SG_IMGUI_CMD_MAKE_BUFFER: + _sg_imgui_draw_buffer_panel(ctx, item->args.make_buffer.result); + break; + case SG_IMGUI_CMD_MAKE_IMAGE: + _sg_imgui_draw_image_panel(ctx, item->args.make_image.result); + break; + case SG_IMGUI_CMD_MAKE_SHADER: + _sg_imgui_draw_shader_panel(ctx, item->args.make_shader.result); + break; + case SG_IMGUI_CMD_MAKE_PIPELINE: + _sg_imgui_draw_pipeline_panel(ctx, item->args.make_pipeline.result); + break; + case SG_IMGUI_CMD_MAKE_PASS: + _sg_imgui_draw_pass_panel(ctx, item->args.make_pass.result); + break; + case SG_IMGUI_CMD_DESTROY_BUFFER: + _sg_imgui_draw_buffer_panel(ctx, item->args.destroy_buffer.buffer); + break; + case SG_IMGUI_CMD_DESTROY_IMAGE: + _sg_imgui_draw_image_panel(ctx, item->args.destroy_image.image); + break; + case SG_IMGUI_CMD_DESTROY_SHADER: + _sg_imgui_draw_shader_panel(ctx, item->args.destroy_shader.shader); + break; + case SG_IMGUI_CMD_DESTROY_PIPELINE: + _sg_imgui_draw_pipeline_panel(ctx, item->args.destroy_pipeline.pipeline); + break; + case SG_IMGUI_CMD_DESTROY_PASS: + _sg_imgui_draw_pass_panel(ctx, item->args.destroy_pass.pass); + break; + case SG_IMGUI_CMD_UPDATE_BUFFER: + _sg_imgui_draw_buffer_panel(ctx, item->args.update_buffer.buffer); + break; + case SG_IMGUI_CMD_UPDATE_IMAGE: + _sg_imgui_draw_image_panel(ctx, item->args.update_image.image); + break; + case SG_IMGUI_CMD_APPEND_BUFFER: + _sg_imgui_draw_buffer_panel(ctx, item->args.update_buffer.buffer); + break; + case SG_IMGUI_CMD_BEGIN_DEFAULT_PASS: + { + sg_pass inv_pass = { SG_INVALID_ID }; + _sg_imgui_draw_passaction_panel(ctx, inv_pass, &item->args.begin_default_pass.action); + } + break; + case SG_IMGUI_CMD_BEGIN_PASS: + _sg_imgui_draw_passaction_panel(ctx, item->args.begin_pass.pass, &item->args.begin_pass.action); + igSeparator(); + _sg_imgui_draw_pass_panel(ctx, item->args.begin_pass.pass); + break; + case SG_IMGUI_CMD_APPLY_VIEWPORT: + case SG_IMGUI_CMD_APPLY_SCISSOR_RECT: + break; + case SG_IMGUI_CMD_APPLY_PIPELINE: + _sg_imgui_draw_pipeline_panel(ctx, item->args.apply_pipeline.pipeline); + break; + case SG_IMGUI_CMD_APPLY_BINDINGS: + _sg_imgui_draw_bindings_panel(ctx, &item->args.apply_bindings.bindings); + break; + case SG_IMGUI_CMD_APPLY_UNIFORMS: + _sg_imgui_draw_uniforms_panel(ctx, &item->args.apply_uniforms); + break; + case SG_IMGUI_CMD_DRAW: + case SG_IMGUI_CMD_END_PASS: + case SG_IMGUI_CMD_COMMIT: + break; + case SG_IMGUI_CMD_ALLOC_BUFFER: + _sg_imgui_draw_buffer_panel(ctx, item->args.alloc_buffer.result); + break; + case SG_IMGUI_CMD_ALLOC_IMAGE: + _sg_imgui_draw_image_panel(ctx, item->args.alloc_image.result); + break; + case SG_IMGUI_CMD_ALLOC_SHADER: + _sg_imgui_draw_shader_panel(ctx, item->args.alloc_shader.result); + break; + case SG_IMGUI_CMD_ALLOC_PIPELINE: + _sg_imgui_draw_pipeline_panel(ctx, item->args.alloc_pipeline.result); + break; + case SG_IMGUI_CMD_ALLOC_PASS: + _sg_imgui_draw_pass_panel(ctx, item->args.alloc_pass.result); + break; + case SG_IMGUI_CMD_INIT_BUFFER: + _sg_imgui_draw_buffer_panel(ctx, item->args.init_buffer.buffer); + break; + case SG_IMGUI_CMD_INIT_IMAGE: + _sg_imgui_draw_image_panel(ctx, item->args.init_image.image); + break; + case SG_IMGUI_CMD_INIT_SHADER: + _sg_imgui_draw_shader_panel(ctx, item->args.init_shader.shader); + break; + case SG_IMGUI_CMD_INIT_PIPELINE: + _sg_imgui_draw_pipeline_panel(ctx, item->args.init_pipeline.pipeline); + break; + case SG_IMGUI_CMD_INIT_PASS: + _sg_imgui_draw_pass_panel(ctx, item->args.init_pass.pass); + break; + case SG_IMGUI_CMD_FAIL_BUFFER: + _sg_imgui_draw_buffer_panel(ctx, item->args.fail_buffer.buffer); + break; + case SG_IMGUI_CMD_FAIL_IMAGE: + _sg_imgui_draw_image_panel(ctx, item->args.fail_image.image); + break; + case SG_IMGUI_CMD_FAIL_SHADER: + _sg_imgui_draw_shader_panel(ctx, item->args.fail_shader.shader); + break; + case SG_IMGUI_CMD_FAIL_PIPELINE: + _sg_imgui_draw_pipeline_panel(ctx, item->args.fail_pipeline.pipeline); + break; + case SG_IMGUI_CMD_FAIL_PASS: + _sg_imgui_draw_pass_panel(ctx, item->args.fail_pass.pass); + break; + default: + break; + } + igEndChild(); +} + +_SOKOL_PRIVATE void _sg_imgui_draw_caps_panel(void) { + igText("Backend: %s\n\n", _sg_imgui_backend_string(sg_query_backend())); + sg_features f = sg_query_features(); + igText("Features:"); + igText(" origin_top_left: %s", _sg_imgui_bool_string(f.origin_top_left)); + igText(" image_clamp_to_border: %s", _sg_imgui_bool_string(f.image_clamp_to_border)); + igText(" mrt_independent_blend_state: %s", _sg_imgui_bool_string(f.mrt_independent_blend_state)); + igText(" mrt_independent_write_mask: %s", _sg_imgui_bool_string(f.mrt_independent_write_mask)); + sg_limits l = sg_query_limits(); + igText("\nLimits:\n"); + igText(" max_image_size_2d: %d", l.max_image_size_2d); + igText(" max_image_size_cube: %d", l.max_image_size_cube); + igText(" max_image_size_3d: %d", l.max_image_size_3d); + igText(" max_image_size_array: %d", l.max_image_size_array); + igText(" max_image_array_layers: %d", l.max_image_array_layers); + igText(" max_vertex_attrs: %d", l.max_vertex_attrs); + igText(" gl_max_vertex_uniform_vectors: %d", l.gl_max_vertex_uniform_vectors); + igText(" gl_max_combined_texture_image_units: %d", l.gl_max_combined_texture_image_units); + igText("\nUsable Pixelformats:"); + for (int i = (int)(SG_PIXELFORMAT_NONE+1); i < (int)_SG_PIXELFORMAT_NUM; i++) { + sg_pixel_format fmt = (sg_pixel_format)i; + sg_pixelformat_info info = sg_query_pixelformat(fmt); + if (info.sample) { + igText(" %s: %s%s%s%s%s%s", + _sg_imgui_pixelformat_string(fmt), + info.sample ? "SAMPLE ":"", + info.filter ? "FILTER ":"", + info.blend ? "BLEND ":"", + info.render ? "RENDER ":"", + info.msaa ? "MSAA ":"", + info.depth ? "DEPTH ":""); + } + } +} + +#define _sg_imgui_def(val, def) (((val) == 0) ? (def) : (val)) + +_SOKOL_PRIVATE sg_imgui_desc_t _sg_imgui_desc_defaults(const sg_imgui_desc_t* desc) { + SOKOL_ASSERT((desc->allocator.alloc && desc->allocator.free) || (!desc->allocator.alloc && !desc->allocator.free)); + sg_imgui_desc_t res = *desc; + // FIXME: any additional default overrides would go here + return res; +} + +/*--- PUBLIC FUNCTIONS -------------------------------------------------------*/ +SOKOL_API_IMPL void sg_imgui_init(sg_imgui_t* ctx, const sg_imgui_desc_t* desc) { + SOKOL_ASSERT(ctx && desc); + _sg_imgui_clear(ctx, sizeof(sg_imgui_t)); + ctx->init_tag = 0xABCDABCD; + ctx->desc = _sg_imgui_desc_defaults(desc); + _sg_imgui_capture_init(ctx); + + /* hook into sokol_gfx functions */ + sg_trace_hooks hooks; + _sg_imgui_clear(&hooks, sizeof(hooks)); + hooks.user_data = (void*) ctx; + hooks.reset_state_cache = _sg_imgui_reset_state_cache; + hooks.make_buffer = _sg_imgui_make_buffer; + hooks.make_image = _sg_imgui_make_image; + hooks.make_shader = _sg_imgui_make_shader; + hooks.make_pipeline = _sg_imgui_make_pipeline; + hooks.make_pass = _sg_imgui_make_pass; + hooks.destroy_buffer = _sg_imgui_destroy_buffer; + hooks.destroy_image = _sg_imgui_destroy_image; + hooks.destroy_shader = _sg_imgui_destroy_shader; + hooks.destroy_pipeline = _sg_imgui_destroy_pipeline; + hooks.destroy_pass = _sg_imgui_destroy_pass; + hooks.update_buffer = _sg_imgui_update_buffer; + hooks.update_image = _sg_imgui_update_image; + hooks.append_buffer = _sg_imgui_append_buffer; + hooks.begin_default_pass = _sg_imgui_begin_default_pass; + hooks.begin_pass = _sg_imgui_begin_pass; + hooks.apply_viewport = _sg_imgui_apply_viewport; + hooks.apply_scissor_rect = _sg_imgui_apply_scissor_rect; + hooks.apply_pipeline = _sg_imgui_apply_pipeline; + hooks.apply_bindings = _sg_imgui_apply_bindings; + hooks.apply_uniforms = _sg_imgui_apply_uniforms; + hooks.draw = _sg_imgui_draw; + hooks.end_pass = _sg_imgui_end_pass; + hooks.commit = _sg_imgui_commit; + hooks.alloc_buffer = _sg_imgui_alloc_buffer; + hooks.alloc_image = _sg_imgui_alloc_image; + hooks.alloc_shader = _sg_imgui_alloc_shader; + hooks.alloc_pipeline = _sg_imgui_alloc_pipeline; + hooks.alloc_pass = _sg_imgui_alloc_pass; + hooks.dealloc_buffer = _sg_imgui_dealloc_buffer; + hooks.dealloc_image = _sg_imgui_dealloc_image; + hooks.dealloc_shader = _sg_imgui_dealloc_shader; + hooks.dealloc_pipeline = _sg_imgui_dealloc_pipeline; + hooks.dealloc_pass = _sg_imgui_dealloc_pass; + hooks.init_buffer = _sg_imgui_init_buffer; + hooks.init_image = _sg_imgui_init_image; + hooks.init_shader = _sg_imgui_init_shader; + hooks.init_pipeline = _sg_imgui_init_pipeline; + hooks.init_pass = _sg_imgui_init_pass; + hooks.uninit_buffer = _sg_imgui_uninit_buffer; + hooks.uninit_image = _sg_imgui_uninit_image; + hooks.uninit_shader = _sg_imgui_uninit_shader; + hooks.uninit_pipeline = _sg_imgui_uninit_pipeline; + hooks.uninit_pass = _sg_imgui_uninit_pass; + hooks.fail_buffer = _sg_imgui_fail_buffer; + hooks.fail_image = _sg_imgui_fail_image; + hooks.fail_shader = _sg_imgui_fail_shader; + hooks.fail_pipeline = _sg_imgui_fail_pipeline; + hooks.fail_pass = _sg_imgui_fail_pass; + hooks.push_debug_group = _sg_imgui_push_debug_group; + hooks.pop_debug_group = _sg_imgui_pop_debug_group; + hooks.err_buffer_pool_exhausted = _sg_imgui_err_buffer_pool_exhausted; + hooks.err_image_pool_exhausted = _sg_imgui_err_image_pool_exhausted; + hooks.err_shader_pool_exhausted = _sg_imgui_err_shader_pool_exhausted; + hooks.err_pipeline_pool_exhausted = _sg_imgui_err_pipeline_pool_exhausted; + hooks.err_pass_pool_exhausted = _sg_imgui_err_pass_pool_exhausted; + hooks.err_context_mismatch = _sg_imgui_err_context_mismatch; + hooks.err_pass_invalid = _sg_imgui_err_pass_invalid; + hooks.err_draw_invalid = _sg_imgui_err_draw_invalid; + hooks.err_bindings_invalid = _sg_imgui_err_bindings_invalid; + ctx->hooks = sg_install_trace_hooks(&hooks); + + /* allocate resource debug-info slots */ + const sg_desc sgdesc = sg_query_desc(); + ctx->buffers.num_slots = sgdesc.buffer_pool_size; + ctx->images.num_slots = sgdesc.image_pool_size; + ctx->shaders.num_slots = sgdesc.shader_pool_size; + ctx->pipelines.num_slots = sgdesc.pipeline_pool_size; + ctx->passes.num_slots = sgdesc.pass_pool_size; + + const size_t buffer_pool_size = (size_t)ctx->buffers.num_slots * sizeof(sg_imgui_buffer_t); + ctx->buffers.slots = (sg_imgui_buffer_t*) _sg_imgui_malloc_clear(&ctx->desc.allocator, buffer_pool_size); + + const size_t image_pool_size = (size_t)ctx->images.num_slots * sizeof(sg_imgui_image_t); + ctx->images.slots = (sg_imgui_image_t*) _sg_imgui_malloc_clear(&ctx->desc.allocator, image_pool_size); + + const size_t shader_pool_size = (size_t)ctx->shaders.num_slots * sizeof(sg_imgui_shader_t); + ctx->shaders.slots = (sg_imgui_shader_t*) _sg_imgui_malloc_clear(&ctx->desc.allocator, shader_pool_size); + + const size_t pipeline_pool_size = (size_t)ctx->pipelines.num_slots * sizeof(sg_imgui_pipeline_t); + ctx->pipelines.slots = (sg_imgui_pipeline_t*) _sg_imgui_malloc_clear(&ctx->desc.allocator, pipeline_pool_size); + + const size_t pass_pool_size = (size_t)ctx->passes.num_slots * sizeof(sg_imgui_pass_t); + ctx->passes.slots = (sg_imgui_pass_t*) _sg_imgui_malloc_clear(&ctx->desc.allocator, pass_pool_size); +} + +SOKOL_API_IMPL void sg_imgui_discard(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + /* restore original trace hooks */ + sg_install_trace_hooks(&ctx->hooks); + ctx->init_tag = 0; + _sg_imgui_capture_discard(ctx); + if (ctx->buffers.slots) { + for (int i = 0; i < ctx->buffers.num_slots; i++) { + if (ctx->buffers.slots[i].res_id.id != SG_INVALID_ID) { + _sg_imgui_buffer_destroyed(ctx, i); + } + } + _sg_imgui_free(&ctx->desc.allocator, (void*)ctx->buffers.slots); + ctx->buffers.slots = 0; + } + if (ctx->images.slots) { + for (int i = 0; i < ctx->images.num_slots; i++) { + if (ctx->images.slots[i].res_id.id != SG_INVALID_ID) { + _sg_imgui_image_destroyed(ctx, i); + } + } + _sg_imgui_free(&ctx->desc.allocator, (void*)ctx->images.slots); + ctx->images.slots = 0; + } + if (ctx->shaders.slots) { + for (int i = 0; i < ctx->shaders.num_slots; i++) { + if (ctx->shaders.slots[i].res_id.id != SG_INVALID_ID) { + _sg_imgui_shader_destroyed(ctx, i); + } + } + _sg_imgui_free(&ctx->desc.allocator, (void*)ctx->shaders.slots); + ctx->shaders.slots = 0; + } + if (ctx->pipelines.slots) { + for (int i = 0; i < ctx->pipelines.num_slots; i++) { + if (ctx->pipelines.slots[i].res_id.id != SG_INVALID_ID) { + _sg_imgui_pipeline_destroyed(ctx, i); + } + } + _sg_imgui_free(&ctx->desc.allocator, (void*)ctx->pipelines.slots); + ctx->pipelines.slots = 0; + } + if (ctx->passes.slots) { + for (int i = 0; i < ctx->passes.num_slots; i++) { + if (ctx->passes.slots[i].res_id.id != SG_INVALID_ID) { + _sg_imgui_pass_destroyed(ctx, i); + } + } + _sg_imgui_free(&ctx->desc.allocator, (void*)ctx->passes.slots); + ctx->passes.slots = 0; + } +} + +SOKOL_API_IMPL void sg_imgui_draw(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + sg_imgui_draw_buffers_window(ctx); + sg_imgui_draw_images_window(ctx); + sg_imgui_draw_shaders_window(ctx); + sg_imgui_draw_pipelines_window(ctx); + sg_imgui_draw_passes_window(ctx); + sg_imgui_draw_capture_window(ctx); + sg_imgui_draw_capabilities_window(ctx); +} + +SOKOL_API_IMPL void sg_imgui_draw_buffers_window(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + if (!ctx->buffers.open) { + return; + } + igSetNextWindowSize(IMVEC2(440, 280), ImGuiCond_Once); + if (igBegin("Buffers", &ctx->buffers.open, 0)) { + sg_imgui_draw_buffers_content(ctx); + } + igEnd(); +} + +SOKOL_API_IMPL void sg_imgui_draw_images_window(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + if (!ctx->images.open) { + return; + } + igSetNextWindowSize(IMVEC2(440, 400), ImGuiCond_Once); + if (igBegin("Images", &ctx->images.open, 0)) { + sg_imgui_draw_images_content(ctx); + } + igEnd(); +} + +SOKOL_API_IMPL void sg_imgui_draw_shaders_window(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + if (!ctx->shaders.open) { + return; + } + igSetNextWindowSize(IMVEC2(440, 400), ImGuiCond_Once); + if (igBegin("Shaders", &ctx->shaders.open, 0)) { + sg_imgui_draw_shaders_content(ctx); + } + igEnd(); +} + +SOKOL_API_IMPL void sg_imgui_draw_pipelines_window(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + if (!ctx->pipelines.open) { + return; + } + igSetNextWindowSize(IMVEC2(540, 400), ImGuiCond_Once); + if (igBegin("Pipelines", &ctx->pipelines.open, 0)) { + sg_imgui_draw_pipelines_content(ctx); + } + igEnd(); +} + +SOKOL_API_IMPL void sg_imgui_draw_passes_window(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + if (!ctx->passes.open) { + return; + } + igSetNextWindowSize(IMVEC2(440, 400), ImGuiCond_Once); + if (igBegin("Passes", &ctx->passes.open, 0)) { + sg_imgui_draw_passes_content(ctx); + } + igEnd(); +} + +SOKOL_API_IMPL void sg_imgui_draw_capture_window(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + if (!ctx->capture.open) { + return; + } + igSetNextWindowSize(IMVEC2(640, 400), ImGuiCond_Once); + if (igBegin("Frame Capture", &ctx->capture.open, 0)) { + sg_imgui_draw_capture_content(ctx); + } + igEnd(); +} + +SOKOL_API_IMPL void sg_imgui_draw_capabilities_window(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + if (!ctx->caps.open) { + return; + } + igSetNextWindowSize(IMVEC2(440, 400), ImGuiCond_Once); + if (igBegin("Capabilities", &ctx->caps.open, 0)) { + sg_imgui_draw_capabilities_content(ctx); + } + igEnd(); +} + +SOKOL_API_IMPL void sg_imgui_draw_buffers_content(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + _sg_imgui_draw_buffer_list(ctx); + igSameLine(0,-1); + _sg_imgui_draw_buffer_panel(ctx, ctx->buffers.sel_buf); +} + +SOKOL_API_IMPL void sg_imgui_draw_images_content(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + _sg_imgui_draw_image_list(ctx); + igSameLine(0,-1); + _sg_imgui_draw_image_panel(ctx, ctx->images.sel_img); +} + +SOKOL_API_IMPL void sg_imgui_draw_shaders_content(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + _sg_imgui_draw_shader_list(ctx); + igSameLine(0,-1); + _sg_imgui_draw_shader_panel(ctx, ctx->shaders.sel_shd); +} + +SOKOL_API_IMPL void sg_imgui_draw_pipelines_content(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + _sg_imgui_draw_pipeline_list(ctx); + igSameLine(0,-1); + _sg_imgui_draw_pipeline_panel(ctx, ctx->pipelines.sel_pip); +} + +SOKOL_API_IMPL void sg_imgui_draw_passes_content(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + _sg_imgui_draw_pass_list(ctx); + igSameLine(0,-1); + _sg_imgui_draw_pass_panel(ctx, ctx->passes.sel_pass); +} + +SOKOL_API_IMPL void sg_imgui_draw_capture_content(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + _sg_imgui_draw_capture_list(ctx); + igSameLine(0,-1); + _sg_imgui_draw_capture_panel(ctx); +} + +SOKOL_API_IMPL void sg_imgui_draw_capabilities_content(sg_imgui_t* ctx) { + SOKOL_ASSERT(ctx && (ctx->init_tag == 0xABCDABCD)); + _SOKOL_UNUSED(ctx); + _sg_imgui_draw_caps_panel(); +} + +#endif /* SOKOL_GFX_IMGUI_IMPL */ diff --git a/source/engine/thirdparty/sokol/sokol_gl.h b/source/engine/thirdparty/sokol/sokol_gl.h new file mode 100644 index 0000000..090df21 --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_gl.h @@ -0,0 +1,4318 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_GL_IMPL) +#define SOKOL_GL_IMPL +#endif +#ifndef SOKOL_GL_INCLUDED +/* + sokol_gl.h -- OpenGL 1.x style rendering on top of sokol_gfx.h + + Project URL: https://github.com/floooh/sokol + + Do this: + #define SOKOL_IMPL or + #define SOKOL_GL_IMPL + before you include this file in *one* C or C++ file to create the + implementation. + + The following defines are used by the implementation to select the + platform-specific embedded shader code (these are the same defines as + used by sokol_gfx.h and sokol_app.h): + + SOKOL_GLCORE33 + SOKOL_GLES3 + SOKOL_D3D11 + SOKOL_METAL + SOKOL_WGPU + + ...optionally provide the following macros to override defaults: + + SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) + SOKOL_GL_API_DECL - public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_GL_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) + + If sokol_gl.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + On Windows, SOKOL_DLL will define SOKOL_GL_API_DECL as __declspec(dllexport) + or __declspec(dllimport) as needed. + + Include the following headers before including sokol_gl.h: + + sokol_gfx.h + + Matrix functions have been taken from MESA and Regal. + + FEATURE OVERVIEW: + ================= + sokol_gl.h implements a subset of the OpenGLES 1.x feature set useful for + when you just want to quickly render a bunch of colored triangles or + lines without having to mess with buffers and shaders. + + The current feature set is mostly useful for debug visualizations + and simple UI-style 2D rendering: + + What's implemented: + - vertex components: + - position (x, y, z) + - 2D texture coords (u, v) + - color (r, g, b, a) + - primitive types: + - triangle list and strip + - line list and strip + - quad list (TODO: quad strips) + - point list + - one texture layer (no multi-texturing) + - viewport and scissor-rect with selectable origin (top-left or bottom-left) + - all GL 1.x matrix stack functions, and additionally equivalent + functions for gluPerspective and gluLookat + + Notable GLES 1.x features that are *NOT* implemented: + - vertex lighting (this is the most likely GL feature that might be added later) + - vertex arrays (although providing whole chunks of vertex data at once + might be a useful feature for a later version) + - texture coordinate generation + - line width + - all pixel store functions + - no ALPHA_TEST + - no clear functions (clearing is handled by the sokol-gfx render pass) + - fog + + Notable differences to GL: + - No "enum soup" for render states etc, instead there's a + 'pipeline stack', this is similar to GL's matrix stack, + but for pipeline-state-objects. The pipeline object at + the top of the pipeline stack defines the active set of render states + - All angles are in radians, not degrees (note the sgl_rad() and + sgl_deg() conversion functions) + - No enable/disable state for scissor test, this is always enabled + + STEP BY STEP: + ============= + --- To initialize sokol-gl, call: + + sgl_setup(const sgl_desc_t* desc) + + NOTE that sgl_setup() must be called *after* initializing sokol-gfx + (via sg_setup). This is because sgl_setup() needs to create + sokol-gfx resource objects. + + If you're intending to render to the default pass, and also don't + want to tweak memory usage, and don't want any logging output you can + just keep sgl_desc_t zero-initialized: + + sgl_setup(&(sgl_desc_t*){ 0 }); + + In this case, sokol-gl will create internal sg_pipeline objects that + are compatible with the sokol-app default framebuffer. + + I would recommend to at least install a logging callback so that + you'll see any warnings and errors. The easiest way is through + sokol_log.h: + + #include "sokol_log.h" + + sgl_setup(&(sgl_desc_t){ + .logger.func = slog_func. + }); + + If you want to render into a framebuffer with different pixel-format + and MSAA attributes you need to provide the matching attributes in the + sgl_setup() call: + + sgl_setup(&(sgl_desc_t*){ + .color_format = SG_PIXELFORMAT_..., + .depth_format = SG_PIXELFORMAT_..., + .sample_count = ..., + }); + + To reduce memory usage, or if you need to create more then the default number of + contexts, pipelines, vertices or draw commands, set the following sgl_desc_t + members: + + .context_pool_size (default: 4) + .pipeline_pool_size (default: 64) + .max_vertices (default: 64k) + .max_commands (default: 16k) + + Finally you can change the face winding for front-facing triangles + and quads: + + .face_winding - default is SG_FACEWINDING_CCW + + The default winding for front faces is counter-clock-wise. This is + the same as OpenGL's default, but different from sokol-gfx. + + --- Optionally create additional context objects if you want to render into + multiple sokol-gfx render passes (or generally if you want to + use multiple independent sokol-gl "state buckets") + + sgl_context ctx = sgl_make_context(const sgl_context_desc_t* desc) + + For details on rendering with sokol-gl contexts, search below for + WORKING WITH CONTEXTS. + + --- Optionally create pipeline-state-objects if you need render state + that differs from sokol-gl's default state: + + sgl_pipeline pip = sgl_make_pipeline(const sg_pipeline_desc* desc) + + ...this creates a pipeline object that's compatible with the currently + active context, alternatively call: + + sgl_pipeline_pip = sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline_desc* desc) + + ...to create a pipeline object that's compatible with an explicitly + provided context. + + The similarity with sokol_gfx.h's sg_pipeline type and sg_make_pipeline() + function is intended. sgl_make_pipeline() also takes a standard + sokol-gfx sg_pipeline_desc object to describe the render state, but + without: + - shader + - vertex layout + - color- and depth-pixel-formats + - primitive type (lines, triangles, ...) + - MSAA sample count + Those will be filled in by sgl_make_pipeline(). Note that each + call to sgl_make_pipeline() needs to create several sokol-gfx + pipeline objects (one for each primitive type). + + 'depth.write_enabled' will be forced to 'false' if the context this + pipeline object is intended for has its depth pixel format set to + SG_PIXELFORMAT_NONE (which means the framebuffer this context is used + with doesn't have a depth-stencil surface). + + --- if you need to destroy sgl_pipeline objects before sgl_shutdown(): + + sgl_destroy_pipeline(sgl_pipeline pip) + + --- After sgl_setup() you can call any of the sokol-gl functions anywhere + in a frame, *except* sgl_draw(). The 'vanilla' functions + will only change internal sokol-gl state, and not call any sokol-gfx + functions. + + --- Unlike OpenGL, sokol-gl has a function to reset internal state to + a known default. This is useful at the start of a sequence of + rendering operations: + + void sgl_defaults(void) + + This will set the following default state: + + - current texture coordinate to u=0.0f, v=0.0f + - current color to white (rgba all 1.0f) + - current point size to 1.0f + - unbind the current texture and texturing will be disabled + - *all* matrices will be set to identity (also the projection matrix) + - the default render state will be set by loading the 'default pipeline' + into the top of the pipeline stack + + The current matrix- and pipeline-stack-depths will not be changed by + sgl_defaults(). + + --- change the currently active renderstate through the + pipeline-stack functions, this works similar to the + traditional GL matrix stack: + + ...load the default pipeline state on the top of the pipeline stack: + + sgl_load_default_pipeline() + + ...load a specific pipeline on the top of the pipeline stack: + + sgl_load_pipeline(sgl_pipeline pip) + + ...push and pop the pipeline stack: + sgl_push_pipeline() + sgl_pop_pipeline() + + --- control texturing with: + + sgl_enable_texture() + sgl_disable_texture() + sgl_texture(sg_image img) + + --- set the current viewport and scissor rect with: + + sgl_viewport(int x, int y, int w, int h, bool origin_top_left) + sgl_scissor_rect(int x, int y, int w, int h, bool origin_top_left) + + ...or call these alternatives which take float arguments (this might allow + to avoid casting between float and integer in more strongly typed languages + when floating point pixel coordinates are used): + + sgl_viewportf(float x, float y, float w, float h, bool origin_top_left) + sgl_scissor_rectf(float x, float y, float w, float h, bool origin_top_left) + + ...these calls add a new command to the internal command queue, so + that the viewport or scissor rect are set at the right time relative + to other sokol-gl calls. + + --- adjust the transform matrices, matrix manipulation works just like + the OpenGL matrix stack: + + ...set the current matrix mode: + + sgl_matrix_mode_modelview() + sgl_matrix_mode_projection() + sgl_matrix_mode_texture() + + ...load the identity matrix into the current matrix: + + sgl_load_identity() + + ...translate, rotate and scale the current matrix: + + sgl_translate(float x, float y, float z) + sgl_rotate(float angle_rad, float x, float y, float z) + sgl_scale(float x, float y, float z) + + NOTE that all angles in sokol-gl are in radians, not in degree. + Convert between radians and degree with the helper functions: + + float sgl_rad(float deg) - degrees to radians + float sgl_deg(float rad) - radians to degrees + + ...directly load the current matrix from a float[16] array: + + sgl_load_matrix(const float m[16]) + sgl_load_transpose_matrix(const float m[16]) + + ...directly multiply the current matrix from a float[16] array: + + sgl_mult_matrix(const float m[16]) + sgl_mult_transpose_matrix(const float m[16]) + + The memory layout of those float[16] arrays is the same as in OpenGL. + + ...more matrix functions: + + sgl_frustum(float left, float right, float bottom, float top, float near, float far) + sgl_ortho(float left, float right, float bottom, float top, float near, float far) + sgl_perspective(float fov_y, float aspect, float near, float far) + sgl_lookat(float eye_x, float eye_y, float eye_z, float center_x, float center_y, float center_z, float up_x, float up_y, float up_z) + + These functions work the same as glFrustum(), glOrtho(), gluPerspective() + and gluLookAt(). + + ...and finally to push / pop the current matrix stack: + + sgl_push_matrix(void) + sgl_pop_matrix(void) + + Again, these work the same as glPushMatrix() and glPopMatrix(). + + --- perform primitive rendering: + + ...set the current texture coordinate and color 'registers' with or + point size with: + + sgl_t2f(float u, float v) - set current texture coordinate + sgl_c*(...) - set current color + sgl_point_size(float size) - set current point size + + There are several functions for setting the color (as float values, + unsigned byte values, packed as unsigned 32-bit integer, with + and without alpha). + + NOTE that these are the only functions that can be called both inside + sgl_begin_*() / sgl_end() and outside. + + Also NOTE that point size is currently hardwired to 1.0f if the D3D11 + backend is used. + + ...start a primitive vertex sequence with: + + sgl_begin_points() + sgl_begin_lines() + sgl_begin_line_strip() + sgl_begin_triangles() + sgl_begin_triangle_strip() + sgl_begin_quads() + + ...after sgl_begin_*() specify vertices: + + sgl_v*(...) + sgl_v*_t*(...) + sgl_v*_c*(...) + sgl_v*_t*_c*(...) + + These functions write a new vertex to sokol-gl's internal vertex buffer, + optionally with texture-coords and color. If the texture coordinate + and/or color is missing, it will be taken from the current texture-coord + and color 'register'. + + ...finally, after specifying vertices, call: + + sgl_end() + + This will record a new draw command in sokol-gl's internal command + list, or it will extend the previous draw command if no relevant + state has changed since the last sgl_begin/end pair. + + --- inside a sokol-gfx rendering pass, call the sgl_draw() function + to render the currently active context: + + sgl_draw() + + ...or alternatively call: + + sgl_context_draw(ctx) + + ...to render an explicitly provided context. + + This will render everything that has been recorded in the context since + the last call to sgl_draw() through sokol-gfx, and will 'rewind' the internal + vertex-, uniform- and command-buffers. + + --- each sokol-gl context tracks an internal error code, to query the + current error code for the currently active context call: + + sgl_error_t sgl_error() + + ...alternatively with an explicit context argument: + + sgl_error_t sgl_context_error(ctx); + + ...which can return the following error codes: + + SGL_NO_ERROR - all OK, no error occurred since last sgl_draw() + SGL_ERROR_VERTICES_FULL - internal vertex buffer is full (checked in sgl_end()) + SGL_ERROR_UNIFORMS_FULL - the internal uniforms buffer is full (checked in sgl_end()) + SGL_ERROR_COMMANDS_FULL - the internal command buffer is full (checked in sgl_end()) + SGL_ERROR_STACK_OVERFLOW - matrix- or pipeline-stack overflow + SGL_ERROR_STACK_UNDERFLOW - matrix- or pipeline-stack underflow + SGL_ERROR_NO_CONTEXT - the active context no longer exists + + ...if sokol-gl is in an error-state, sgl_draw() will skip any rendering, + and reset the error code to SGL_NO_ERROR. + + RENDER LAYERS + ============= + Render layers allow to split sokol-gl rendering into separate draw-command + groups which can then be rendered separately in a sokol-gfx draw pass. This + allows to mix/interleave sokol-gl rendering with other render operations. + + Layered rendering is controlled through two functions: + + sgl_layer(int layer_id) + sgl_draw_layer(int layer_id) + + (and the context-variant sgl_draw_layer(): sgl_context_draw_layer() + + The sgl_layer() function sets the 'current layer', any sokol-gl calls + which internally record draw commands will also store the current layer + in the draw command, and later in a sokol-gfx render pass, a call + to sgl_draw_layer() will only render the draw commands that have + a matching layer. + + The default layer is '0', this is active after sokol-gl setup, and + is also restored at the start of a new frame (but *not* by calling + sgl_defaults()). + + NOTE that calling sgl_draw() is equivalent with sgl_draw_layer(0) + (in general you should either use either use sgl_draw() or + sgl_draw_layer() in an application, but not both). + + WORKING WITH CONTEXTS: + ====================== + If you want to render to more than one sokol-gfx render pass you need to + work with additional sokol-gl context objects (one context object for + each offscreen rendering pass, in addition to the implicitly created + 'default context'. + + All sokol-gl state is tracked per context, and there is always a "current + context" (with the notable exception that the currently set context is + destroyed, more on that later). + + Using multiple contexts can also be useful if you only render in + a single pass, but want to maintain multiple independent "state buckets". + + To create new context object, call: + + sgl_context ctx = sgl_make_context(&(sgl_context_desc){ + .max_vertices = ..., // default: 64k + .max_commands = ..., // default: 16k + .color_format = ..., + .depth_format = ..., + .sample_count = ..., + }); + + The color_format, depth_format and sample_count items must be compatible + with the render pass the sgl_draw() or sgL_context_draw() function + will be called in. + + Creating a context does *not* make the context current. To do this, call: + + sgl_set_context(ctx); + + The currently active context will implicitely be used by most sokol-gl functions + which don't take an explicit context handle as argument. + + To switch back to the default context, pass the global constant SGL_DEFAULT_CONTEXT: + + sgl_set_context(SGL_DEFAULT_CONTEXT); + + ...or alternatively use the function sgl_default_context() instead of the + global constant: + + sgl_set_context(sgl_default_context()); + + To get the currently active context, call: + + sgl_context cur_ctx = sgl_get_context(); + + The following functions exist in two variants, one which use the currently + active context (set with sgl_set_context()), and another version which + takes an explicit context handle instead: + + sgl_make_pipeline() vs sgl_context_make_pipeline() + sgl_error() vs sgl_context_error(); + sgl_draw() vs sgl_context_draw(); + + Except for using the currently active context versus a provided context + handle, the two variants are exactlyidentical, e.g. the following + code sequences do the same thing: + + sgl_set_context(ctx); + sgl_pipeline pip = sgl_make_pipeline(...); + sgl_error_t err = sgl_error(); + sgl_draw(); + + vs + + sgl_pipeline pip = sgl_context_make_pipeline(ctx, ...); + sgl_error_t err = sgl_context_error(ctx); + sgl_context_draw(ctx); + + Destroying the currently active context is a 'soft error'. All following + calls which require a currently active context will silently fail, + and sgl_error() will return SGL_ERROR_NO_CONTEXT. + + UNDER THE HOOD: + =============== + sokol_gl.h works by recording vertex data and rendering commands into + memory buffers, and then drawing the recorded commands via sokol_gfx.h + + The only functions which call into sokol_gfx.h are: + - sgl_setup() + - sgl_shutdown() + - sgl_draw() (and variants) + + sgl_setup() must be called after initializing sokol-gfx. + sgl_shutdown() must be called before shutting down sokol-gfx. + sgl_draw() must be called once per frame inside a sokol-gfx render pass. + + All other sokol-gl function can be called anywhere in a frame, since + they just record data into memory buffers owned by sokol-gl. + + What happens in: + + sgl_setup(): + Unique resources shared by all contexts are created: + - a shader object (using embedded shader source or byte code) + - an 8x8 white default texture + The default context is created, which involves: + - 3 memory buffers are created, one for vertex data, + one for uniform data, and one for commands + - a dynamic vertex buffer is created + - the default sgl_pipeline object is created, which involves + creating 5 sg_pipeline objects + + One vertex is 24 bytes: + - float3 position + - float2 texture coords + - uint32_t color + + One uniform block is 128 bytes: + - mat4 model-view-projection matrix + - mat4 texture matrix + + One draw command is ca. 24 bytes for the actual + command code plus command arguments. + + Each sgl_end() consumes one command, and one uniform block + (only when the matrices have changed). + The required size for one sgl_begin/end pair is (at most): + + (152 + 24 * num_verts) bytes + + sgl_shutdown(): + - all sokol-gfx resources (buffer, shader, default-texture and + all pipeline objects) are destroyed + - the 3 memory buffers are freed + + sgl_draw() (and variants) + - copy all recorded vertex data into the dynamic sokol-gfx buffer + via a call to sg_update_buffer() + - for each recorded command: + - if the layer number stored in the command doesn't match + the layer that's to be rendered, skip to the next + command + - if it's a viewport command, call sg_apply_viewport() + - if it's a scissor-rect command, call sg_apply_scissor_rect() + - if it's a draw command: + - depending on what has changed since the last draw command, + call sg_apply_pipeline(), sg_apply_bindings() and + sg_apply_uniforms() + - finally call sg_draw() + + All other functions only modify the internally tracked state, add + data to the vertex, uniform and command buffers, or manipulate + the matrix stack. + + ON DRAW COMMAND MERGING + ======================= + Not every call to sgl_end() will automatically record a new draw command. + If possible, the previous draw command will simply be extended, + resulting in fewer actual draw calls later in sgl_draw(). + + A draw command will be merged with the previous command if "no relevant + state has changed" since the last sgl_end(), meaning: + + - no calls to sgl_viewport() and sgl_scissor_rect() + - the primitive type hasn't changed + - the primitive type isn't a 'strip type' (no line or triangle strip) + - the pipeline state object hasn't changed + - the current layer hasn't changed + - none of the matrices has changed + - none of the texture state has changed + + Merging a draw command simply means that the number of vertices + to render in the previous draw command will be incremented by the + number of vertices in the new draw command. + + MEMORY ALLOCATION OVERRIDE + ========================== + You can override the memory allocation functions at initialization time + like this: + + void* my_alloc(size_t size, void* user_data) { + return malloc(size); + } + + void my_free(void* ptr, void* user_data) { + free(ptr); + } + + ... + sgl_setup(&(sgl_desc_t){ + // ... + .allocator = { + .alloc = my_alloc, + .free = my_free, + .user_data = ...; + } + }); + ... + + If no overrides are provided, malloc and free will be used. + + + ERROR REPORTING AND LOGGING + =========================== + To get any logging information at all you need to provide a logging callback in the setup call, + the easiest way is to use sokol_log.h: + + #include "sokol_log.h" + + sgl_setup(&(sgl_desc_t){ + // ... + .logger.func = slog_func + }); + + To override logging with your own callback, first write a logging function like this: + + void my_log(const char* tag, // e.g. 'sgl' + uint32_t log_level, // 0=panic, 1=error, 2=warn, 3=info + uint32_t log_item_id, // SGL_LOGITEM_* + const char* message_or_null, // a message string, may be nullptr in release mode + uint32_t line_nr, // line number in sokol_gl.h + const char* filename_or_null, // source filename, may be nullptr in release mode + void* user_data) + { + ... + } + + ...and then setup sokol-gl like this: + + sgl_setup(&(sgl_desc_t){ + .logger = { + .func = my_log, + .user_data = my_user_data, + } + }); + + The provided logging function must be reentrant (e.g. be callable from + different threads). + + If you don't want to provide your own custom logger it is highly recommended to use + the standard logger in sokol_log.h instead, otherwise you won't see any warnings or + errors. + + + LICENSE + ======= + zlib/libpng license + + Copyright (c) 2018 Andre Weissflog + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_GL_INCLUDED (1) +#include +#include +#include // size_t, offsetof + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_gl.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_GL_API_DECL) +#define SOKOL_GL_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_GL_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_GL_IMPL) +#define SOKOL_GL_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_GL_API_DECL __declspec(dllimport) +#else +#define SOKOL_GL_API_DECL extern +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + sgl_log_item_t + + Log items are defined via X-Macros, and expanded to an + enum 'sgl_log_item' - and in debug mode only - corresponding strings. + + Used as parameter in the logging callback. +*/ +#define _SGL_LOG_ITEMS \ + _SGL_LOGITEM_XMACRO(OK, "Ok") \ + _SGL_LOGITEM_XMACRO(MALLOC_FAILED, "memory allocation failed") \ + _SGL_LOGITEM_XMACRO(MAKE_PIPELINE_FAILED, "sg_make_pipeline() failed") \ + _SGL_LOGITEM_XMACRO(PIPELINE_POOL_EXHAUSTED, "pipeline pool exhausted (use sgl_desc_t.pipeline_pool_size to adjust)") \ + _SGL_LOGITEM_XMACRO(ADD_COMMIT_LISTENER_FAILED, "sg_add_commit_listener() failed") \ + _SGL_LOGITEM_XMACRO(CONTEXT_POOL_EXHAUSTED, "context pool exhausted (use sgl_desc_t.context_pool_size to adjust)") \ + _SGL_LOGITEM_XMACRO(CANNOT_DESTROY_DEFAULT_CONTEXT, "cannot destroy default context") \ + +#define _SGL_LOGITEM_XMACRO(item,msg) SGL_LOGITEM_##item, +typedef enum sgl_log_item_t { + _SGL_LOG_ITEMS +} sgl_log_item_t; +#undef _SGL_LOGITEM_XMACRO + +/* + sgl_logger_t + + Used in sgl_desc_t to provide a custom logging and error reporting + callback to sokol-gl. +*/ +typedef struct sgl_logger_t { + void (*func)( + const char* tag, // always "sgl" + uint32_t log_level, // 0=panic, 1=error, 2=warning, 3=info + uint32_t log_item_id, // SGL_LOGITEM_* + const char* message_or_null, // a message string, may be nullptr in release mode + uint32_t line_nr, // line number in sokol_gl.h + const char* filename_or_null, // source filename, may be nullptr in release mode + void* user_data); + void* user_data; +} sgl_logger_t; + +/* sokol_gl pipeline handle (created with sgl_make_pipeline()) */ +typedef struct sgl_pipeline { uint32_t id; } sgl_pipeline; + +/* a context handle (created with sgl_make_context()) */ +typedef struct sgl_context { uint32_t id; } sgl_context; + +/* + sgl_error_t + + Errors are reset each frame after calling sgl_draw(), + get the last error code with sgl_error() +*/ +typedef enum sgl_error_t { + SGL_NO_ERROR = 0, + SGL_ERROR_VERTICES_FULL, + SGL_ERROR_UNIFORMS_FULL, + SGL_ERROR_COMMANDS_FULL, + SGL_ERROR_STACK_OVERFLOW, + SGL_ERROR_STACK_UNDERFLOW, + SGL_ERROR_NO_CONTEXT, +} sgl_error_t; + +/* + sgl_context_desc_t + + Describes the initialization parameters of a rendering context. + Creating additional contexts is useful if you want to render + in separate sokol-gfx passes. +*/ +typedef struct sgl_context_desc_t { + int max_vertices; // default: 64k + int max_commands; // default: 16k + sg_pixel_format color_format; + sg_pixel_format depth_format; + int sample_count; +} sgl_context_desc_t; + +/* + sgl_allocator_t + + Used in sgl_desc_t to provide custom memory-alloc and -free functions + to sokol_gl.h. If memory management should be overridden, both the + alloc and free function must be provided (e.g. it's not valid to + override one function but not the other). +*/ +typedef struct sgl_allocator_t { + void* (*alloc)(size_t size, void* user_data); + void (*free)(void* ptr, void* user_data); + void* user_data; +} sgl_allocator_t; + +typedef struct sgl_desc_t { + int max_vertices; // default: 64k + int max_commands; // default: 16k + int context_pool_size; // max number of contexts (including default context), default: 4 + int pipeline_pool_size; // size of internal pipeline pool, default: 64 + sg_pixel_format color_format; + sg_pixel_format depth_format; + int sample_count; + sg_face_winding face_winding; // default: SG_FACEWINDING_CCW + sgl_allocator_t allocator; // optional memory allocation overrides (default: malloc/free) + sgl_logger_t logger; // optional log function override (default: NO LOGGING) +} sgl_desc_t; + +/* the default context handle */ +static const sgl_context SGL_DEFAULT_CONTEXT = { 0x00010001 }; + +/* setup/shutdown/misc */ +SOKOL_GL_API_DECL void sgl_setup(const sgl_desc_t* desc); +SOKOL_GL_API_DECL void sgl_shutdown(void); +SOKOL_GL_API_DECL float sgl_rad(float deg); +SOKOL_GL_API_DECL float sgl_deg(float rad); +SOKOL_GL_API_DECL sgl_error_t sgl_error(void); +SOKOL_GL_API_DECL sgl_error_t sgl_context_error(sgl_context ctx); + +/* context functions */ +SOKOL_GL_API_DECL sgl_context sgl_make_context(const sgl_context_desc_t* desc); +SOKOL_GL_API_DECL void sgl_destroy_context(sgl_context ctx); +SOKOL_GL_API_DECL void sgl_set_context(sgl_context ctx); +SOKOL_GL_API_DECL sgl_context sgl_get_context(void); +SOKOL_GL_API_DECL sgl_context sgl_default_context(void); + +/* draw recorded commands (call inside a sokol-gfx render pass) */ +SOKOL_GL_API_DECL void sgl_draw(); +SOKOL_GL_API_DECL void sgl_context_draw(sgl_context ctx); +SOKOL_GL_API_DECL void sgl_draw_layer(int layer_id); +SOKOL_GL_API_DECL void sgl_context_draw_layer(sgl_context ctx, int layer_id); + +/* create and destroy pipeline objects */ +SOKOL_GL_API_DECL sgl_pipeline sgl_make_pipeline(const sg_pipeline_desc* desc); +SOKOL_GL_API_DECL sgl_pipeline sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline_desc* desc); +SOKOL_GL_API_DECL void sgl_destroy_pipeline(sgl_pipeline pip); + +/* render state functions */ +SOKOL_GL_API_DECL void sgl_defaults(void); +SOKOL_GL_API_DECL void sgl_viewport(int x, int y, int w, int h, bool origin_top_left); +SOKOL_GL_API_DECL void sgl_viewportf(float x, float y, float w, float h, bool origin_top_left); +SOKOL_GL_API_DECL void sgl_scissor_rect(int x, int y, int w, int h, bool origin_top_left); +SOKOL_GL_API_DECL void sgl_scissor_rectf(float x, float y, float w, float h, bool origin_top_left); +SOKOL_GL_API_DECL void sgl_enable_texture(void); +SOKOL_GL_API_DECL void sgl_disable_texture(void); +SOKOL_GL_API_DECL void sgl_texture(sg_image img); +SOKOL_GL_API_DECL void sgl_layer(int layer_id); + +/* pipeline stack functions */ +SOKOL_GL_API_DECL void sgl_load_default_pipeline(void); +SOKOL_GL_API_DECL void sgl_load_pipeline(sgl_pipeline pip); +SOKOL_GL_API_DECL void sgl_push_pipeline(void); +SOKOL_GL_API_DECL void sgl_pop_pipeline(void); + +/* matrix stack functions */ +SOKOL_GL_API_DECL void sgl_matrix_mode_modelview(void); +SOKOL_GL_API_DECL void sgl_matrix_mode_projection(void); +SOKOL_GL_API_DECL void sgl_matrix_mode_texture(void); +SOKOL_GL_API_DECL void sgl_load_identity(void); +SOKOL_GL_API_DECL void sgl_load_matrix(const float m[16]); +SOKOL_GL_API_DECL void sgl_load_transpose_matrix(const float m[16]); +SOKOL_GL_API_DECL void sgl_mult_matrix(const float m[16]); +SOKOL_GL_API_DECL void sgl_mult_transpose_matrix(const float m[16]); +SOKOL_GL_API_DECL void sgl_rotate(float angle_rad, float x, float y, float z); +SOKOL_GL_API_DECL void sgl_scale(float x, float y, float z); +SOKOL_GL_API_DECL void sgl_translate(float x, float y, float z); +SOKOL_GL_API_DECL void sgl_frustum(float l, float r, float b, float t, float n, float f); +SOKOL_GL_API_DECL void sgl_ortho(float l, float r, float b, float t, float n, float f); +SOKOL_GL_API_DECL void sgl_perspective(float fov_y, float aspect, float z_near, float z_far); +SOKOL_GL_API_DECL void sgl_lookat(float eye_x, float eye_y, float eye_z, float center_x, float center_y, float center_z, float up_x, float up_y, float up_z); +SOKOL_GL_API_DECL void sgl_push_matrix(void); +SOKOL_GL_API_DECL void sgl_pop_matrix(void); + +/* these functions only set the internal 'current texcoord / color / point size' (valid inside or outside begin/end) */ +SOKOL_GL_API_DECL void sgl_t2f(float u, float v); +SOKOL_GL_API_DECL void sgl_c3f(float r, float g, float b); +SOKOL_GL_API_DECL void sgl_c4f(float r, float g, float b, float a); +SOKOL_GL_API_DECL void sgl_c3b(uint8_t r, uint8_t g, uint8_t b); +SOKOL_GL_API_DECL void sgl_c4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a); +SOKOL_GL_API_DECL void sgl_c1i(uint32_t rgba); +SOKOL_GL_API_DECL void sgl_point_size(float s); + +/* define primitives, each begin/end is one draw command */ +SOKOL_GL_API_DECL void sgl_begin_points(void); +SOKOL_GL_API_DECL void sgl_begin_lines(void); +SOKOL_GL_API_DECL void sgl_begin_line_strip(void); +SOKOL_GL_API_DECL void sgl_begin_triangles(void); +SOKOL_GL_API_DECL void sgl_begin_triangle_strip(void); +SOKOL_GL_API_DECL void sgl_begin_quads(void); +SOKOL_GL_API_DECL void sgl_v2f(float x, float y); +SOKOL_GL_API_DECL void sgl_v3f(float x, float y, float z); +SOKOL_GL_API_DECL void sgl_v2f_t2f(float x, float y, float u, float v); +SOKOL_GL_API_DECL void sgl_v3f_t2f(float x, float y, float z, float u, float v); +SOKOL_GL_API_DECL void sgl_v2f_c3f(float x, float y, float r, float g, float b); +SOKOL_GL_API_DECL void sgl_v2f_c3b(float x, float y, uint8_t r, uint8_t g, uint8_t b); +SOKOL_GL_API_DECL void sgl_v2f_c4f(float x, float y, float r, float g, float b, float a); +SOKOL_GL_API_DECL void sgl_v2f_c4b(float x, float y, uint8_t r, uint8_t g, uint8_t b, uint8_t a); +SOKOL_GL_API_DECL void sgl_v2f_c1i(float x, float y, uint32_t rgba); +SOKOL_GL_API_DECL void sgl_v3f_c3f(float x, float y, float z, float r, float g, float b); +SOKOL_GL_API_DECL void sgl_v3f_c3b(float x, float y, float z, uint8_t r, uint8_t g, uint8_t b); +SOKOL_GL_API_DECL void sgl_v3f_c4f(float x, float y, float z, float r, float g, float b, float a); +SOKOL_GL_API_DECL void sgl_v3f_c4b(float x, float y, float z, uint8_t r, uint8_t g, uint8_t b, uint8_t a); +SOKOL_GL_API_DECL void sgl_v3f_c1i(float x, float y, float z, uint32_t rgba); +SOKOL_GL_API_DECL void sgl_v2f_t2f_c3f(float x, float y, float u, float v, float r, float g, float b); +SOKOL_GL_API_DECL void sgl_v2f_t2f_c3b(float x, float y, float u, float v, uint8_t r, uint8_t g, uint8_t b); +SOKOL_GL_API_DECL void sgl_v2f_t2f_c4f(float x, float y, float u, float v, float r, float g, float b, float a); +SOKOL_GL_API_DECL void sgl_v2f_t2f_c4b(float x, float y, float u, float v, uint8_t r, uint8_t g, uint8_t b, uint8_t a); +SOKOL_GL_API_DECL void sgl_v2f_t2f_c1i(float x, float y, float u, float v, uint32_t rgba); +SOKOL_GL_API_DECL void sgl_v3f_t2f_c3f(float x, float y, float z, float u, float v, float r, float g, float b); +SOKOL_GL_API_DECL void sgl_v3f_t2f_c3b(float x, float y, float z, float u, float v, uint8_t r, uint8_t g, uint8_t b); +SOKOL_GL_API_DECL void sgl_v3f_t2f_c4f(float x, float y, float z, float u, float v, float r, float g, float b, float a); +SOKOL_GL_API_DECL void sgl_v3f_t2f_c4b(float x, float y, float z, float u, float v, uint8_t r, uint8_t g, uint8_t b, uint8_t a); +SOKOL_GL_API_DECL void sgl_v3f_t2f_c1i(float x, float y, float z, float u, float v, uint32_t rgba); +SOKOL_GL_API_DECL void sgl_end(void); + +#ifdef __cplusplus +} /* extern "C" */ + +/* reference-based equivalents for C++ */ +inline void sgl_setup(const sgl_desc_t& desc) { return sgl_setup(&desc); } +inline sgl_context sgl_make_context(const sgl_context_desc_t& desc) { return sgl_make_context(&desc); } +inline sgl_pipeline sgl_make_pipeline(const sg_pipeline_desc& desc) { return sgl_make_pipeline(&desc); } +inline sgl_pipeline sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline_desc& desc) { return sgl_context_make_pipeline(ctx, &desc); } +#endif +#endif /* SOKOL_GL_INCLUDED */ + +// ██ ███ ███ ██████ ██ ███████ ███ ███ ███████ ███ ██ ████████ █████ ████████ ██ ██████ ███ ██ +// ██ ████ ████ ██ ██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ +// ██ ██ ████ ██ ██████ ██ █████ ██ ████ ██ █████ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ████ ██ ██ ██ ██ ██ ██████ ██ ████ +// +// >>implementation +#ifdef SOKOL_GL_IMPL +#define SOKOL_GL_IMPL_INCLUDED (1) + +#if defined(SOKOL_MALLOC) || defined(SOKOL_CALLOC) || defined(SOKOL_FREE) +#error "SOKOL_MALLOC/CALLOC/FREE macros are no longer supported, please use sgl_desc_t.allocator to override memory allocation functions" +#endif + +#include // malloc/free +#include // memset +#include // M_PI, sqrtf, sinf, cosf + +#ifndef M_PI +#define M_PI 3.14159265358979323846264338327 +#endif + +#ifndef SOKOL_API_IMPL + #define SOKOL_API_IMPL +#endif +#ifndef SOKOL_DEBUG + #ifndef NDEBUG + #define SOKOL_DEBUG + #endif +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif + +#define _sgl_def(val, def) (((val) == 0) ? (def) : (val)) +#define _SGL_INIT_COOKIE (0xABCDABCD) + +/* + Embedded source code compiled with: + + sokol-shdc -i sgl.glsl -o sgl.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + + (not that for Metal and D3D11 byte code, sokol-shdc must be run + on macOS and Windows) + + @vs vs + uniform vs_params { + mat4 mvp; + mat4 tm; + }; + in vec4 position; + in vec2 texcoord0; + in vec4 color0; + in float psize; + out vec4 uv; + out vec4 color; + void main() { + gl_Position = mvp * position; + gl_PointSize = psize; + uv = tm * vec4(texcoord0, 0.0, 1.0); + color = color0; + } + @end + + @fs fs + uniform sampler2D tex; + in vec4 uv; + in vec4 color; + out vec4 frag_color; + void main() { + frag_color = texture(tex, uv.xy) * color; + } + @end + + @program sgl vs fs +*/ + +#if defined(SOKOL_GLCORE33) +static const char _sgl_vs_source_glsl330[478] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e, + 0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x73, + 0x69,0x7a,0x65,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76, + 0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f, + 0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74, + 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65, + 0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74, + 0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69, + 0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a, + 0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30, + 0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c, + 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f, + 0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70,0x73,0x69,0x7a, + 0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34, + 0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x76,0x73,0x5f, + 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28, + 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20, + 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20, + 0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _sgl_fs_source_glsl330[172] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20, + 0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63, + 0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76, + 0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x69,0x6e,0x20,0x76, + 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, + 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75, + 0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x2e,0x78,0x79,0x29,0x20,0x2a, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_GLES3) +static const char _sgl_vs_source_glsl300es[481] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74, + 0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30, + 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20, + 0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70, + 0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d, + 0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65, + 0x63,0x34,0x28,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e, + 0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a, + 0x00, +}; +static const char _sgl_fs_source_glsl300es[245] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x2e,0x78,0x79,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b, + 0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_METAL) +static const uint8_t _sgl_vs_bytecode_metal_macos[3321] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x06,0x00,0x00,0x81,0x0a,0x00,0x0b,0x00, + 0xf9,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe0,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0x80,0x27,0x7a,0x67,0xc7,0xfc,0xfd, + 0xe3,0x47,0x44,0x1b,0xf3,0x40,0x18,0x72,0x5a,0xd3,0x6e,0xad,0xec,0x58,0x70,0xc5, + 0x20,0xfe,0x98,0x5e,0x82,0x7f,0xed,0xf9,0x89,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x40,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x2a,0x00,0x04,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x70,0x73,0x69,0x7a,0x65,0x00,0x03, + 0x80,0x56,0x41,0x54,0x59,0x06,0x00,0x04,0x00,0x06,0x04,0x06,0x03,0x45,0x4e,0x44, + 0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00, + 0x00,0x14,0x00,0x00,0x00,0xc0,0x0b,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0, + 0xde,0x21,0x0c,0x00,0x00,0xed,0x02,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00, + 0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32, + 0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45, + 0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44, + 0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8, + 0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00, + 0x00,0x81,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8,0xff,0xff,0xff,0xff,0x01,0x90,0x80, + 0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87,0x71,0xa0,0x07,0x76,0xc8,0x87,0x36, + 0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72,0x20,0x87,0x36,0x20,0x87,0x74,0xb0, + 0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88,0x07,0x79,0xa0,0x87,0x36,0x30,0x07, + 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1, + 0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e, + 0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c,0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87,0x72,0x98,0x87,0x79,0x68,0x03,0x78, + 0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x76,0x08, + 0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda, + 0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda,0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81, + 0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21,0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8, + 0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30,0x07,0x79,0x08,0x87,0x76,0x28,0x87, + 0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87,0x72,0x90,0x87,0x36,0x28,0x07,0x76, + 0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77,0x68,0x03,0x76,0x28,0x87,0x70,0x30, + 0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70,0x07,0x73,0x98,0x87,0x36,0x30,0x07, + 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01, + 0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1,0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c, + 0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08, + 0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36, + 0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d, + 0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d,0xca,0x81,0x1c,0xda,0x40,0x1f,0xca, + 0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x7a,0x90, + 0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38,0x87,0x36,0x68,0x87,0x70,0xa0,0x07, + 0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61, + 0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1,0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e, + 0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4, + 0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87,0x79,0x08,0x07,0x73,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e, + 0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d,0xe6,0xe1,0x1d,0xcc,0x81,0x1e,0xda, + 0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72, + 0x00,0x36,0x18,0x42,0x01,0x2c,0x40,0x05,0x00,0x49,0x18,0x00,0x00,0x01,0x00,0x00, + 0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48, + 0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90, + 0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x44,0x33,0x00,0xc3,0x08,0x04, + 0x60,0x89,0x10,0x02,0x18,0x46,0x10,0x80,0x24,0x08,0x33,0x51,0xf3,0x40,0x0f,0xf2, + 0x50,0x0f,0xe3,0x40,0x0f,0x6e,0xd0,0x0e,0xe5,0x40,0x0f,0xe1,0xc0,0x0e,0x7a,0xa0, + 0x07,0xed,0x10,0x0e,0xf4,0x20,0x0f,0xe9,0x80,0x0f,0x28,0x20,0x07,0x49,0x53,0x44, + 0x09,0x93,0x5f,0x49,0xff,0x03,0x44,0x00,0x23,0x21,0xa1,0x94,0x41,0x04,0x43,0x28, + 0x86,0x08,0x23,0x80,0x43,0x68,0x20,0x60,0x8e,0x00,0x0c,0x52,0x60,0xcd,0x11,0x80, + 0xc2,0x20,0x42,0x20,0x0c,0x23,0x10,0xcb,0x08,0x00,0x00,0x00,0x00,0x13,0xb2,0x70, + 0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68, + 0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83, + 0x38,0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78, + 0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90, + 0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e, + 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76, + 0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a, + 0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30, + 0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07, + 0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71, + 0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20, + 0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f, + 0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76, + 0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50, + 0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07, + 0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78, + 0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x49,0x00,0x00,0x08,0x00, + 0x00,0x00,0x00,0x00,0xc8,0x02,0x01,0x00,0x00,0x0b,0x00,0x00,0x00,0x32,0x1e,0x98, + 0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02, + 0x50,0x04,0x05,0x18,0x50,0x08,0x65,0x50,0x80,0x02,0x05,0x51,0x20,0xd4,0x46,0x00, + 0x88,0x8d,0x25,0x30,0x00,0x00,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x01,0x01,0x00, + 0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37, + 0xb7,0x21,0xc6,0x32,0x28,0x00,0xb3,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b, + 0xd3,0x2b,0x1b,0x62,0x2c,0x81,0x22,0x2c,0x05,0xe3,0x20,0x08,0x0e,0x8e,0xad,0x0c, + 0xa4,0xad,0x8c,0x2e,0x8c,0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26, + 0x06,0x06,0x26,0xc6,0x65,0x66,0x46,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac, + 0xac,0x65,0x26,0x06,0x06,0x26,0xc6,0x65,0x66,0x46,0x26,0x65,0x88,0xa0,0x10,0x43, + 0x8c,0x25,0x58,0x90,0x45,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x51,0x8e,0x25, + 0x58,0x82,0x45,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6, + 0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36, + 0x44,0x50,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e, + 0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65, + 0x43,0x04,0x65,0x61,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95, + 0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1, + 0x8d,0xa1,0x7d,0x91,0xa5,0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11,0x94,0x86,0x51,0x58, + 0x9a,0x9c,0x8b,0x5d,0x99,0x1c,0x5d,0x19,0xde,0xd7,0x5b,0x1d,0x1d,0x5c,0x1d,0x1d, + 0x97,0xba,0xb9,0x32,0x39,0x14,0xb6,0xb7,0x31,0x37,0x98,0x14,0x46,0x61,0x69,0x72, + 0x2e,0x61,0x72,0x67,0x5f,0x74,0x79,0x70,0x65,0x5f,0x6e,0x61,0x6d,0x65,0x34,0xcc, + 0xd8,0xde,0xc2,0xe8,0x68,0xc8,0x84,0xa5,0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xb9,0x85, + 0xb5,0x95,0x51,0xa8,0xb3,0x1b,0xc2,0x28,0x8f,0x02,0x29,0x91,0x22,0x29,0x93,0x42, + 0x71,0xa9,0x9b,0x2b,0x93,0x43,0x61,0x7b,0x1b,0x73,0x8b,0x49,0x61,0x31,0xf6,0xc6, + 0xf6,0x26,0x37,0x84,0x51,0x1e,0xc5,0x52,0x22,0x45,0x52,0x26,0xe5,0x22,0x13,0x96, + 0x26,0xe7,0x02,0xf7,0x36,0x97,0x46,0x97,0xf6,0xe6,0xc6,0xe5,0x8c,0xed,0x0b,0xea, + 0x6d,0x2e,0x8d,0x2e,0xed,0xcd,0x6d,0x88,0xa2,0x64,0x4a,0xa4,0x48,0xca,0xa4,0x68, + 0x74,0xc2,0xd2,0xe4,0x5c,0xe0,0xde,0xd2,0xdc,0xe8,0xbe,0xe6,0xd2,0xf4,0xca,0x58, + 0x98,0xb1,0xbd,0x85,0xd1,0x91,0x39,0x63,0xfb,0x82,0x7a,0x4b,0x73,0xa3,0x9b,0x4a, + 0xd3,0x2b,0x1b,0xa2,0x28,0x9c,0x12,0x29,0x9d,0x32,0x29,0xde,0x10,0x44,0xa9,0x14, + 0x4c,0xd9,0x94,0x8f,0x50,0x58,0x9a,0x9c,0x8b,0x5d,0x99,0x1c,0x5d,0x19,0xde,0x57, + 0x9a,0x1b,0x5c,0x1d,0x1d,0xa5,0xb0,0x34,0x39,0x17,0xb6,0xb7,0xb1,0x30,0xba,0xb4, + 0x37,0xb7,0xaf,0x34,0x37,0xb2,0x32,0x3c,0x7a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74, + 0x65,0x64,0x28,0x5f,0x5f,0x61,0x69,0x72,0x5f,0x70,0x6c,0x61,0x63,0x65,0x68,0x6f, + 0x6c,0x64,0x65,0x72,0x5f,0x5f,0x29,0x44,0xe0,0xde,0xe6,0xd2,0xe8,0xd2,0xde,0xdc, + 0x86,0x50,0x8b,0xa0,0x84,0x81,0x22,0x06,0x8b,0xb0,0x04,0xca,0x18,0x28,0x91,0x22, + 0x29,0x93,0x42,0x06,0x34,0xcc,0xd8,0xde,0xc2,0xe8,0x64,0x98,0xd0,0x95,0xe1,0x8d, + 0xbd,0xbd,0xc9,0x91,0xc1,0x0c,0xa1,0x96,0x40,0x09,0x03,0x45,0x0c,0x96,0x60,0x09, + 0x94,0x31,0x50,0x22,0xc5,0x0c,0x94,0x49,0x39,0x03,0x1a,0x63,0x6f,0x6c,0x6f,0x72, + 0x30,0x43,0xa8,0x65,0x50,0xc2,0x40,0x11,0x83,0x65,0x58,0x02,0x65,0x0c,0x94,0x48, + 0x91,0x94,0x49,0x49,0x03,0x16,0x70,0x73,0x69,0x7a,0x65,0x43,0xa8,0xc5,0x50,0xc2, + 0x40,0x11,0x83,0xc5,0x58,0x02,0x65,0x0c,0x94,0x48,0xe9,0x94,0x49,0x59,0x03,0x2a, + 0x61,0x69,0x72,0x2e,0x62,0x75,0x66,0x66,0x65,0x72,0x7c,0xc2,0xd2,0xe4,0x5c,0xc4, + 0xea,0xcc,0xcc,0xca,0xe4,0xbe,0xe6,0xd2,0xf4,0xca,0x88,0x84,0xa5,0xc9,0xb9,0xc8, + 0x95,0x85,0x91,0x91,0x0a,0x4b,0x93,0x73,0x99,0xa3,0x93,0xab,0x1b,0xa3,0xfb,0xa2, + 0xcb,0x83,0x2b,0xfb,0x4a,0x73,0x33,0x7b,0x23,0x62,0xc6,0xf6,0x16,0x46,0x47,0x83, + 0x47,0xc3,0xa1,0xcd,0x0e,0x8e,0x02,0x5d,0xdb,0x10,0x6a,0x11,0x16,0x62,0x11,0x94, + 0x38,0x50,0xe4,0x60,0x21,0x16,0x62,0x11,0x94,0x38,0x50,0xe6,0x80,0x51,0x58,0x9a, + 0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d,0x1e,0x5c,0xd9,0xd7,0x5c,0x9a,0x5e,0x19,0xaf, + 0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xba,0x3c,0xb8,0xb2,0xaf,0x30,0xb6,0xb4, + 0x33,0xb7,0xaf,0xb9,0x34,0xbd,0x32,0x26,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x1c,0xbe,0x64,0x62,0x86,0x90,0xc1,0x52,0x28,0x6d,0xa0,0xb8,0xc1,0x72,0x28, + 0x62,0xb0,0x08,0x4b,0xa0,0xbc,0x81,0x02,0x07,0x0a,0x1d,0x28,0x75,0xb0,0x1c,0x8a, + 0x1d,0x2c,0x89,0x12,0x29,0x77,0xa0,0x4c,0x0a,0x1e,0x0c,0x51,0x94,0x32,0x50,0xd0, + 0x40,0x51,0x03,0x85,0x0d,0x94,0x3c,0x18,0x62,0x24,0x80,0x02,0x06,0x8a,0x1e,0xf0, + 0x79,0x6b,0x73,0x4b,0x83,0x7b,0xa3,0x2b,0x73,0xa3,0x03,0x19,0x43,0x0b,0x93,0xe3, + 0x33,0x95,0xd6,0x06,0xc7,0x56,0x06,0x32,0xb4,0xb2,0x02,0x42,0x25,0x14,0x14,0x34, + 0x44,0x50,0xfa,0x60,0x88,0xa1,0xf0,0x81,0xe2,0x07,0x8d,0x32,0xc4,0x50,0xfe,0x40, + 0xf9,0x83,0x46,0x19,0x11,0xb1,0x03,0x3b,0xd8,0x43,0x3b,0xb8,0x41,0x3b,0xbc,0x03, + 0x39,0xd4,0x03,0x3b,0x94,0x83,0x1b,0x98,0x03,0x3b,0x84,0xc3,0x39,0xcc,0xc3,0x14, + 0x21,0x18,0x46,0x28,0xec,0xc0,0x0e,0xf6,0xd0,0x0e,0x6e,0x90,0x0e,0xe4,0x50,0x0e, + 0xee,0x40,0x0f,0x53,0x82,0x62,0xc4,0x12,0x0e,0xe9,0x20,0x0f,0x6e,0x60,0x0f,0xe5, + 0x20,0x0f,0xf3,0x90,0x0e,0xef,0xe0,0x0e,0x53,0x02,0x63,0x04,0x15,0x0e,0xe9,0x20, + 0x0f,0x6e,0xc0,0x0e,0xe1,0xe0,0x0e,0xe7,0x50,0x0f,0xe1,0x70,0x0e,0xe5,0xf0,0x0b, + 0xf6,0x50,0x0e,0xf2,0x30,0x0f,0xe9,0xf0,0x0e,0xee,0x30,0x25,0x40,0x46,0x4c,0xe1, + 0x90,0x0e,0xf2,0xe0,0x06,0xe3,0xf0,0x0e,0xed,0x00,0x0f,0xe9,0xc0,0x0e,0xe5,0xf0, + 0x0b,0xef,0x00,0x0f,0xf4,0x90,0x0e,0xef,0xe0,0x0e,0xf3,0x30,0x65,0x50,0x18,0x67, + 0x84,0x12,0x0e,0xe9,0x20,0x0f,0x6e,0x60,0x0f,0xe5,0x20,0x0f,0xf4,0x50,0x0e,0xf8, + 0x30,0x25,0xd8,0x03,0x00,0x79,0x18,0x00,0x00,0x7b,0x00,0x00,0x00,0x33,0x08,0x80, + 0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80, + 0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80, + 0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88, + 0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78, + 0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03, + 0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f, + 0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c, + 0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39, + 0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b, + 0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60, + 0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87, + 0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e, + 0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6, + 0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94, + 0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03, + 0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07, + 0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f, + 0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33, + 0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc, + 0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c, + 0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78, + 0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca, + 0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21, + 0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43, + 0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87, + 0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c, + 0xe3,0x10,0x0e,0xec,0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e, + 0xe4,0xe1,0x17,0xd8,0xe1,0x1d,0xde,0x01,0x1e,0x66,0x50,0x59,0x38,0xa4,0x83,0x3c, + 0xb8,0x81,0x39,0xd4,0x83,0x3b,0x8c,0x03,0x3d,0xa4,0xc3,0x3b,0xb8,0xc3,0x2f,0x9c, + 0x83,0x3c,0xbc,0x43,0x3d,0xc0,0xc3,0x3c,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00, + 0x00,0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x3e,0x00,0x00, + 0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xf4,0xc6,0x22, + 0x86,0x61,0x18,0xc6,0x22,0x04,0x41,0x10,0xc6,0x22,0x82,0x20,0x08,0xa8,0x95,0x40, + 0x19,0x14,0x01,0xbd,0x11,0x00,0x1a,0x33,0x00,0x24,0x66,0x00,0x28,0xcc,0x00,0x00, + 0x00,0xe3,0x15,0x4b,0x94,0x65,0x11,0x05,0x65,0x90,0x21,0x1a,0x0c,0x13,0x02,0xf9, + 0x8c,0x57,0x3c,0x55,0xd7,0x2d,0x14,0x94,0x41,0x86,0xea,0x70,0x4c,0x08,0xe4,0x63, + 0x41,0x01,0x9f,0xf1,0x0a,0x4a,0x13,0x03,0x31,0x70,0x28,0x28,0x83,0x0c,0x1a,0x43, + 0x99,0x10,0xc8,0xc7,0x8a,0x00,0x3e,0xe3,0x15,0xd9,0x77,0x06,0x67,0x40,0x51,0x50, + 0x06,0x19,0xbe,0x48,0x33,0x21,0x90,0x8f,0x15,0x01,0x7c,0xc6,0x2b,0x3c,0x32,0x68, + 0x03,0x36,0x20,0x03,0x0a,0xca,0x20,0xc3,0x18,0x60,0x99,0x09,0x81,0x7c,0xc6,0x2b, + 0xc4,0x00,0x0d,0xe2,0x00,0x0e,0x3c,0x0a,0xca,0x20,0xc3,0x19,0x70,0x61,0x60,0x42, + 0x20,0x1f,0x0b,0x0a,0xf8,0x8c,0x57,0x9c,0x41,0x1b,0xd8,0x41,0x1d,0x88,0x01,0x05, + 0xc5,0x86,0x00,0x3e,0xb3,0x0d,0x61,0x10,0x00,0xb3,0x0d,0x41,0x1b,0x04,0xb3,0x0d, + 0xc1,0x23,0xcc,0x36,0x04,0x6e,0x30,0x64,0x10,0x10,0x03,0x00,0x00,0x09,0x00,0x00, + 0x00,0x5b,0x86,0x20,0x00,0x85,0x2d,0x43,0x11,0x80,0xc2,0x96,0x41,0x09,0x40,0x61, + 0xcb,0xf0,0x04,0xa0,0xb0,0x65,0xa0,0x02,0x50,0xd8,0x32,0x60,0x01,0x28,0x6c,0x19, + 0xba,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sgl_fs_bytecode_metal_macos[2829] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x06,0x00,0x00,0x81,0x0a,0x00,0x0b,0x00, + 0x0d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x30,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0xeb,0xd5,0xe5,0x1e,0x0a,0x10,0x1a, + 0x32,0xd3,0xbd,0xd9,0xe3,0x31,0x39,0x1e,0x13,0x0d,0xe0,0xb8,0x26,0xfa,0x4f,0x40, + 0xeb,0xf7,0x82,0x75,0x70,0x8a,0xc9,0x08,0x0c,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x14,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x82,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x89,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87, + 0x70,0x30,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74, + 0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e, + 0xde,0xc1,0x1c,0xe8,0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81, + 0x00,0x16,0xa0,0xda,0x80,0x10,0xff,0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5, + 0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,0x18,0x86,0x00,0x2c,0x40,0x05,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44,0x61,0x00,0x00,0x00, + 0x00,0x89,0x20,0x00,0x00,0x1d,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04,0x60,0x83,0x70,0x94, + 0x34,0x45,0x94,0x30,0xf9,0xff,0x44,0x5c,0x13,0x15,0x11,0xbf,0x3d,0xfc,0xd3,0x18, + 0x01,0x30,0x88,0x30,0x04,0x17,0x49,0x53,0x44,0x09,0x93,0xff,0x4b,0x00,0xf3,0x2c, + 0x44,0xf4,0x4f,0x63,0x04,0xc0,0x20,0x42,0x21,0x94,0x42,0x84,0x40,0x0c,0x9d,0x61, + 0x04,0x01,0x98,0x23,0x08,0xe6,0x08,0xc0,0x60,0x18,0x41,0x58,0x0a,0x12,0x88,0x49, + 0x8a,0x29,0x40,0x6d,0x20,0x20,0x05,0xd6,0x08,0x00,0x00,0x00,0x00,0x13,0xb2,0x70, + 0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68, + 0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83, + 0x38,0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78, + 0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90, + 0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e, + 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76, + 0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a, + 0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30, + 0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07, + 0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71, + 0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20, + 0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f, + 0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76, + 0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50, + 0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07, + 0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78, + 0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x41,0x00,0x00,0x08,0x00, + 0x00,0x00,0x00,0x00,0x18,0xc2,0x38,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x64, + 0x81,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c, + 0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50,0x04,0x85,0x50, + 0x10,0x65,0x40,0x70,0x2c,0x81,0x01,0x00,0x00,0x79,0x18,0x00,0x00,0xb8,0x00,0x00, + 0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37, + 0xb7,0x21,0xc6,0x42,0x3c,0x00,0x84,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b, + 0xd3,0x2b,0x1b,0x62,0x2c,0xc2,0x23,0x2c,0x05,0xe3,0x20,0x08,0x0e,0x8e,0xad,0x0c, + 0xa4,0xad,0x8c,0x2e,0x8c,0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26, + 0x06,0x06,0x26,0xc6,0x65,0x66,0x46,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac, + 0xac,0x65,0x26,0x06,0x06,0x26,0xc6,0x65,0x66,0x46,0x26,0x65,0x88,0xf0,0x10,0x43, + 0x8c,0x45,0x58,0x8c,0x65,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x79,0x8e,0x45, + 0x58,0x84,0x65,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6, + 0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36, + 0x44,0x78,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e, + 0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65, + 0x43,0x84,0x67,0x61,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95, + 0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1, + 0x8d,0xa1,0x7d,0x91,0xa5,0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11,0x9e,0x86,0x51,0x58, + 0x9a,0x9c,0x8b,0x5c,0x99,0x1b,0x59,0x99,0xdc,0x17,0x5d,0x98,0xdc,0x59,0x19,0x1d, + 0xa3,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xba,0x3c,0xb8,0xb2,0x2f,0xb7,0xb0, + 0xb6,0x32,0x1a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x64,0xc2,0xd2,0xe4,0x5c,0xc2,0xe4, + 0xce,0xbe,0xdc,0xc2,0xda,0xca,0xa8,0x98,0xc9,0x85,0x9d,0x7d,0x8d,0xbd,0xb1,0xbd, + 0xc9,0x0d,0x61,0x9e,0x67,0x19,0x1e,0xe8,0x89,0x1e,0xe9,0x99,0x86,0x08,0x0f,0x45, + 0x29,0x2c,0x4d,0xce,0xc5,0x4c,0x2e,0xec,0xac,0xad,0xcc,0x8d,0xee,0x2b,0xcd,0x0d, + 0xae,0x8e,0x8e,0x4b,0xdd,0x5c,0x99,0x1c,0x0a,0xdb,0xdb,0x98,0x1b,0x4c,0x0a,0x95, + 0xb0,0x34,0x39,0x97,0xb1,0x32,0x37,0xba,0x32,0x39,0x3e,0x61,0x69,0x72,0x2e,0x70, + 0x65,0x72,0x73,0x70,0x65,0x63,0x74,0x69,0x76,0x65,0x14,0xea,0xec,0x86,0x48,0xcb, + 0xf0,0x58,0xcf,0xf5,0x60,0x4f,0xf6,0x40,0x4f,0xf4,0x48,0x8f,0xc6,0xa5,0x6e,0xae, + 0x4c,0x0e,0x85,0xed,0x6d,0xcc,0x2d,0x26,0x85,0xc5,0xd8,0x1b,0xdb,0x9b,0xdc,0x10, + 0x69,0x11,0x1e,0xeb,0xe1,0x1e,0xec,0xc9,0x1e,0xe8,0x89,0x1e,0xe9,0xe9,0xb8,0x84, + 0xa5,0xc9,0xb9,0xd0,0x95,0xe1,0xd1,0xd5,0xc9,0x95,0x51,0x0a,0x4b,0x93,0x73,0x61, + 0x7b,0x1b,0x0b,0xa3,0x4b,0x7b,0x73,0xfb,0x4a,0x73,0x23,0x2b,0xc3,0xa3,0x12,0x96, + 0x26,0xe7,0x32,0x17,0xd6,0x06,0xc7,0x56,0x46,0x8c,0xae,0x0c,0x8f,0xae,0x4e,0xae, + 0x4c,0x86,0x8c,0xc7,0x8c,0xed,0x2d,0x8c,0x8e,0x05,0x64,0x2e,0xac,0x0d,0x8e,0xad, + 0xcc,0x87,0x03,0x5d,0x19,0xde,0x10,0x6a,0x21,0x9e,0xef,0x01,0x83,0x65,0x58,0x84, + 0x27,0x0c,0x1e,0xe8,0x11,0x83,0x47,0x7a,0xc6,0x80,0x4b,0x58,0x9a,0x9c,0xcb,0x5c, + 0x58,0x1b,0x1c,0x5b,0x99,0x1c,0x8f,0xb9,0xb0,0x36,0x38,0xb6,0x32,0x39,0x22,0x74, + 0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x43,0xa4,0xe5,0x78,0xca,0xe0,0x01,0x83,0x65, + 0x58,0x84,0x07,0x7a,0xcc,0xe0,0x91,0x9e,0x33,0x18,0x82,0x3c,0xdb,0xe3,0x3d,0x64, + 0xf0,0xa0,0xc1,0x10,0x03,0x01,0x9e,0xea,0x49,0x83,0x11,0x11,0x3b,0xb0,0x83,0x3d, + 0xb4,0x83,0x1b,0xb4,0xc3,0x3b,0x90,0x43,0x3d,0xb0,0x43,0x39,0xb8,0x81,0x39,0xb0, + 0x43,0x38,0x9c,0xc3,0x3c,0x4c,0x11,0x82,0x61,0x84,0xc2,0x0e,0xec,0x60,0x0f,0xed, + 0xe0,0x06,0xe9,0x40,0x0e,0xe5,0xe0,0x0e,0xf4,0x30,0x25,0x28,0x46,0x2c,0xe1,0x90, + 0x0e,0xf2,0xe0,0x06,0xf6,0x50,0x0e,0xf2,0x30,0x0f,0xe9,0xf0,0x0e,0xee,0x30,0x25, + 0x30,0x46,0x50,0xe1,0x90,0x0e,0xf2,0xe0,0x06,0xec,0x10,0x0e,0xee,0x70,0x0e,0xf5, + 0x10,0x0e,0xe7,0x50,0x0e,0xbf,0x60,0x0f,0xe5,0x20,0x0f,0xf3,0x90,0x0e,0xef,0xe0, + 0x0e,0x53,0x02,0x64,0xc4,0x14,0x0e,0xe9,0x20,0x0f,0x6e,0x30,0x0e,0xef,0xd0,0x0e, + 0xf0,0x90,0x0e,0xec,0x50,0x0e,0xbf,0xf0,0x0e,0xf0,0x40,0x0f,0xe9,0xf0,0x0e,0xee, + 0x30,0x0f,0x53,0x06,0x85,0x71,0x46,0x30,0xe1,0x90,0x0e,0xf2,0xe0,0x06,0xe6,0x20, + 0x0f,0xe1,0x70,0x0e,0xed,0x50,0x0e,0xee,0x40,0x0f,0x53,0x02,0x35,0x00,0x00,0x00, + 0x00,0x79,0x18,0x00,0x00,0x7b,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c, + 0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07, + 0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42, + 0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83, + 0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07, + 0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70, + 0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3, + 0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2, + 0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc, + 0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68, + 0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07, + 0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72, + 0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec, + 0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc, + 0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8, + 0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03, + 0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c, + 0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74, + 0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4, + 0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc, + 0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1, + 0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50, + 0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51, + 0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21, + 0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06, + 0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c, + 0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77, + 0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c,0xe3,0x10,0x0e,0xec, + 0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e,0xe4,0xe1,0x17,0xd8, + 0xe1,0x1d,0xde,0x01,0x1e,0x66,0x50,0x59,0x38,0xa4,0x83,0x3c,0xb8,0x81,0x39,0xd4, + 0x83,0x3b,0x8c,0x03,0x3d,0xa4,0xc3,0x3b,0xb8,0xc3,0x2f,0x9c,0x83,0x3c,0xbc,0x43, + 0x3d,0xc0,0xc3,0x3c,0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01, + 0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e, + 0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00, + 0x00,0x0f,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x06,0x00,0x00, + 0x00,0xc4,0x46,0x00,0xc6,0x12,0x80,0x80,0xd4,0x08,0x40,0x0d,0x90,0x98,0x01,0xa0, + 0x30,0x03,0x40,0x60,0x04,0x00,0x00,0x00,0x00,0x83,0x0c,0x8b,0x60,0x8c,0x18,0x28, + 0x42,0x40,0x29,0x49,0x50,0x20,0x86,0x60,0x01,0x23,0x9f,0xd9,0x06,0x23,0x00,0x32, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sgl_vs_bytecode_metal_ios[3305] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x06,0x00,0x00,0x82,0x09,0x00,0x00,0x00, + 0xe9,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0xd0,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0x77,0x3d,0x05,0xbd,0x9f,0x26,0xc1, + 0xae,0x87,0x1d,0xc4,0x7e,0x6d,0x86,0xc6,0x23,0xd4,0x40,0x35,0xfc,0x64,0x3f,0x25, + 0xe4,0xe3,0x19,0x09,0x7d,0xba,0xe3,0x12,0x70,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x40,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x2a,0x00,0x04,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x70,0x73,0x69,0x7a,0x65,0x00,0x03, + 0x80,0x56,0x41,0x54,0x59,0x06,0x00,0x04,0x00,0x06,0x04,0x06,0x03,0x45,0x4e,0x44, + 0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00, + 0x00,0x14,0x00,0x00,0x00,0xbc,0x0b,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0, + 0xde,0x21,0x0c,0x00,0x00,0xec,0x02,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00, + 0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32, + 0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45, + 0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44, + 0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8, + 0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00, + 0x00,0x82,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8,0xff,0xff,0xff,0xff,0x01,0x90,0x80, + 0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87,0x71,0xa0,0x07,0x76,0xc8,0x87,0x36, + 0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72,0x20,0x87,0x36,0x20,0x87,0x74,0xb0, + 0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88,0x07,0x79,0xa0,0x87,0x36,0x30,0x07, + 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1, + 0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e, + 0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c,0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87,0x72,0x98,0x87,0x79,0x68,0x03,0x78, + 0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x76,0x08, + 0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda, + 0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda,0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81, + 0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21,0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8, + 0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30,0x07,0x79,0x08,0x87,0x76,0x28,0x87, + 0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87,0x72,0x90,0x87,0x36,0x28,0x07,0x76, + 0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77,0x68,0x03,0x76,0x28,0x87,0x70,0x30, + 0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70,0x07,0x73,0x98,0x87,0x36,0x30,0x07, + 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01, + 0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1,0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c, + 0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08, + 0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36, + 0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d, + 0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d,0xca,0x81,0x1c,0xda,0x40,0x1f,0xca, + 0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x7a,0x90, + 0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38,0x87,0x36,0x68,0x87,0x70,0xa0,0x07, + 0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61, + 0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1,0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e, + 0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4, + 0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87,0x79,0x08,0x07,0x73,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e, + 0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d,0xe6,0xe1,0x1d,0xcc,0x81,0x1e,0xda, + 0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72, + 0x00,0x36,0x20,0x42,0x01,0x24,0xc0,0x02,0x54,0x00,0x00,0x00,0x00,0x49,0x18,0x00, + 0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,0x00,0x20,0x00,0x00, + 0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22, + 0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x44,0x33, + 0x00,0xc3,0x08,0x04,0x60,0x89,0x10,0x02,0x18,0x46,0x10,0x80,0x24,0x08,0x33,0x51, + 0xf3,0x40,0x0f,0xf2,0x50,0x0f,0xe3,0x40,0x0f,0x6e,0xd0,0x0e,0xe5,0x40,0x0f,0xe1, + 0xc0,0x0e,0x7a,0xa0,0x07,0xed,0x10,0x0e,0xf4,0x20,0x0f,0xe9,0x80,0x0f,0x28,0x20, + 0x07,0x49,0x53,0x44,0x09,0x93,0x5f,0x49,0xff,0x03,0x44,0x00,0x23,0x21,0xa1,0x94, + 0x41,0x04,0x43,0x28,0x86,0x08,0x23,0x80,0x43,0x68,0x20,0x60,0x8e,0x00,0x0c,0x52, + 0x60,0xcd,0x11,0x80,0xc2,0x20,0x42,0x20,0x0c,0x23,0x10,0xcb,0x08,0x00,0x00,0x00, + 0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78, + 0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80, + 0x83,0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40, + 0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07, + 0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76, + 0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0, + 0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73, + 0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40, + 0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07, + 0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a, + 0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30, + 0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74, + 0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20, + 0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07, + 0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72, + 0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60, + 0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f, + 0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72, + 0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40, + 0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07, + 0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x98,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x00, + 0x80,0x2c,0x10,0x00,0x00,0x0b,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c, + 0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50,0x04,0x05,0x18, + 0x50,0x08,0x65,0x50,0x80,0x02,0x05,0x51,0x20,0xd4,0x46,0x00,0x88,0x8d,0x25,0x3c, + 0x00,0x00,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x01,0x01,0x00,0x00,0x1a,0x03,0x4c, + 0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x32, + 0x28,0x00,0xb3,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62, + 0x2c,0x81,0x22,0x2c,0x05,0xe3,0x20,0x08,0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e, + 0x8c,0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26,0x06,0x06,0x26,0xc6, + 0x65,0x46,0xa6,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x26,0x06, + 0x06,0x26,0xc6,0x65,0x46,0xa6,0x26,0x65,0x88,0xa0,0x10,0x43,0x8c,0x25,0x58,0x90, + 0x45,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x51,0x8e,0x25,0x58,0x84,0x45,0xe0, + 0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6, + 0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x50,0x12,0x72, + 0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74, + 0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04,0x65,0x21, + 0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85, + 0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x95, + 0xb9,0x85,0x89,0xb1,0x95,0x0d,0x11,0x94,0x86,0x51,0x58,0x9a,0x9c,0x8b,0x5d,0x99, + 0x1c,0x5d,0x19,0xde,0xd7,0x5b,0x1d,0x1d,0x5c,0x1d,0x1d,0x97,0xba,0xb9,0x32,0x39, + 0x14,0xb6,0xb7,0x31,0x37,0x98,0x14,0x46,0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f, + 0x74,0x79,0x70,0x65,0x5f,0x6e,0x61,0x6d,0x65,0x34,0xcc,0xd8,0xde,0xc2,0xe8,0x68, + 0xc8,0x84,0xa5,0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xb9,0x85,0xb5,0x95,0x51,0xa8,0xb3, + 0x1b,0xc2,0x28,0x8f,0x02,0x29,0x91,0x22,0x29,0x93,0x42,0x71,0xa9,0x9b,0x2b,0x93, + 0x43,0x61,0x7b,0x1b,0x73,0x8b,0x49,0x61,0x31,0xf6,0xc6,0xf6,0x26,0x37,0x84,0x51, + 0x1e,0xc5,0x52,0x22,0x45,0x52,0x26,0xe5,0x22,0x13,0x96,0x26,0xe7,0x02,0xf7,0x36, + 0x97,0x46,0x97,0xf6,0xe6,0xc6,0xe5,0x8c,0xed,0x0b,0xea,0x6d,0x2e,0x8d,0x2e,0xed, + 0xcd,0x6d,0x88,0xa2,0x64,0x4a,0xa4,0x48,0xca,0xa4,0x68,0x74,0xc2,0xd2,0xe4,0x5c, + 0xe0,0xde,0xd2,0xdc,0xe8,0xbe,0xe6,0xd2,0xf4,0xca,0x58,0x98,0xb1,0xbd,0x85,0xd1, + 0x91,0x39,0x63,0xfb,0x82,0x7a,0x4b,0x73,0xa3,0x9b,0x4a,0xd3,0x2b,0x1b,0xa2,0x28, + 0x9c,0x12,0x29,0x9d,0x32,0x29,0xde,0x10,0x44,0xa9,0x14,0x4c,0xd9,0x94,0x8f,0x50, + 0x58,0x9a,0x9c,0x8b,0x5d,0x99,0x1c,0x5d,0x19,0xde,0x57,0x9a,0x1b,0x5c,0x1d,0x1d, + 0xa5,0xb0,0x34,0x39,0x17,0xb6,0xb7,0xb1,0x30,0xba,0xb4,0x37,0xb7,0xaf,0x34,0x37, + 0xb2,0x32,0x3c,0x7a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x28,0x5f,0x5f, + 0x61,0x69,0x72,0x5f,0x70,0x6c,0x61,0x63,0x65,0x68,0x6f,0x6c,0x64,0x65,0x72,0x5f, + 0x5f,0x29,0x44,0xe0,0xde,0xe6,0xd2,0xe8,0xd2,0xde,0xdc,0x86,0x50,0x8b,0xa0,0x84, + 0x81,0x22,0x06,0x8b,0xb0,0x04,0xca,0x18,0x28,0x91,0x22,0x29,0x93,0x42,0x06,0x34, + 0xcc,0xd8,0xde,0xc2,0xe8,0x64,0x98,0xd0,0x95,0xe1,0x8d,0xbd,0xbd,0xc9,0x91,0xc1, + 0x0c,0xa1,0x96,0x40,0x09,0x03,0x45,0x0c,0x96,0x60,0x09,0x94,0x31,0x50,0x22,0xc5, + 0x0c,0x94,0x49,0x39,0x03,0x1a,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x43,0xa8,0x65,0x50, + 0xc2,0x40,0x11,0x83,0x65,0x58,0x02,0x65,0x0c,0x94,0x48,0x91,0x94,0x49,0x49,0x03, + 0x16,0x70,0x73,0x69,0x7a,0x65,0x43,0xa8,0xc5,0x50,0xc2,0x40,0x11,0x83,0xc5,0x58, + 0x02,0x65,0x0c,0x94,0x48,0xe9,0x94,0x49,0x59,0x03,0x2a,0x61,0x69,0x72,0x2e,0x62, + 0x75,0x66,0x66,0x65,0x72,0x7c,0xc2,0xd2,0xe4,0x5c,0xc4,0xea,0xcc,0xcc,0xca,0xe4, + 0xbe,0xe6,0xd2,0xf4,0xca,0x88,0x84,0xa5,0xc9,0xb9,0xc8,0x95,0x85,0x91,0x91,0x0a, + 0x4b,0x93,0x73,0x99,0xa3,0x93,0xab,0x1b,0xa3,0xfb,0xa2,0xcb,0x83,0x2b,0xfb,0x4a, + 0x73,0x33,0x7b,0x23,0x62,0xc6,0xf6,0x16,0x46,0x47,0x83,0x47,0xc3,0xa1,0xcd,0x0e, + 0x8e,0x02,0x5d,0xdb,0x10,0x6a,0x11,0x16,0x62,0x11,0x94,0x38,0x50,0xe4,0x60,0x21, + 0x16,0x62,0x11,0x94,0x38,0x50,0xe6,0x80,0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9, + 0x17,0x5d,0x1e,0x5c,0xd9,0xd7,0x5c,0x9a,0x5e,0x19,0xaf,0xb0,0x34,0x39,0x97,0x30, + 0xb9,0xb3,0x2f,0xba,0x3c,0xb8,0xb2,0xaf,0x30,0xb6,0xb4,0x33,0xb7,0xaf,0xb9,0x34, + 0xbd,0x32,0x26,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x1c,0xbe,0x64,0x62, + 0x86,0x90,0xc1,0x52,0x28,0x6d,0xa0,0xb8,0xc1,0x72,0x28,0x62,0xb0,0x08,0x4b,0xa0, + 0xbc,0x81,0x02,0x07,0x0a,0x1d,0x28,0x75,0xb0,0x1c,0x8a,0x1d,0x2c,0x89,0x12,0x29, + 0x77,0xa0,0x4c,0x0a,0x1e,0x0c,0x51,0x94,0x32,0x50,0xd0,0x40,0x51,0x03,0x85,0x0d, + 0x94,0x3c,0x18,0x62,0x24,0x80,0x02,0x06,0x8a,0x1e,0xf0,0x79,0x6b,0x73,0x4b,0x83, + 0x7b,0xa3,0x2b,0x73,0xa3,0x03,0x19,0x43,0x0b,0x93,0xe3,0x33,0x95,0xd6,0x06,0xc7, + 0x56,0x06,0x32,0xb4,0xb2,0x02,0x42,0x25,0x14,0x14,0x34,0x44,0x50,0xfa,0x60,0x88, + 0xa1,0xf0,0x81,0xe2,0x07,0x8d,0x32,0xc4,0x50,0xfe,0x40,0xf9,0x83,0x46,0x19,0x11, + 0xb1,0x03,0x3b,0xd8,0x43,0x3b,0xb8,0x41,0x3b,0xbc,0x03,0x39,0xd4,0x03,0x3b,0x94, + 0x83,0x1b,0x98,0x03,0x3b,0x84,0xc3,0x39,0xcc,0xc3,0x14,0x21,0x18,0x46,0x28,0xec, + 0xc0,0x0e,0xf6,0xd0,0x0e,0x6e,0x90,0x0e,0xe4,0x50,0x0e,0xee,0x40,0x0f,0x53,0x82, + 0x62,0xc4,0x12,0x0e,0xe9,0x20,0x0f,0x6e,0x60,0x0f,0xe5,0x20,0x0f,0xf3,0x90,0x0e, + 0xef,0xe0,0x0e,0x53,0x02,0x63,0x04,0x15,0x0e,0xe9,0x20,0x0f,0x6e,0xc0,0x0e,0xe1, + 0xe0,0x0e,0xe7,0x50,0x0f,0xe1,0x70,0x0e,0xe5,0xf0,0x0b,0xf6,0x50,0x0e,0xf2,0x30, + 0x0f,0xe9,0xf0,0x0e,0xee,0x30,0x25,0x40,0x46,0x4c,0xe1,0x90,0x0e,0xf2,0xe0,0x06, + 0xe3,0xf0,0x0e,0xed,0x00,0x0f,0xe9,0xc0,0x0e,0xe5,0xf0,0x0b,0xef,0x00,0x0f,0xf4, + 0x90,0x0e,0xef,0xe0,0x0e,0xf3,0x30,0x65,0x50,0x18,0x67,0x84,0x12,0x0e,0xe9,0x20, + 0x0f,0x6e,0x60,0x0f,0xe5,0x20,0x0f,0xf4,0x50,0x0e,0xf8,0x30,0x25,0xd8,0x03,0x00, + 0x00,0x79,0x18,0x00,0x00,0x7b,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c, + 0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07, + 0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42, + 0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83, + 0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07, + 0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70, + 0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3, + 0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2, + 0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc, + 0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68, + 0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07, + 0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72, + 0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec, + 0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc, + 0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8, + 0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03, + 0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c, + 0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74, + 0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4, + 0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc, + 0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1, + 0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50, + 0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51, + 0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21, + 0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06, + 0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c, + 0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77, + 0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c,0xe3,0x10,0x0e,0xec, + 0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e,0xe4,0xe1,0x17,0xd8, + 0xe1,0x1d,0xde,0x01,0x1e,0x66,0x50,0x59,0x38,0xa4,0x83,0x3c,0xb8,0x81,0x39,0xd4, + 0x83,0x3b,0x8c,0x03,0x3d,0xa4,0xc3,0x3b,0xb8,0xc3,0x2f,0x9c,0x83,0x3c,0xbc,0x43, + 0x3d,0xc0,0xc3,0x3c,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x50,0x30, + 0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x3e,0x00,0x00,0x00,0x13,0x04,0x41, + 0x2c,0x10,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xf4,0xc6,0x22,0x86,0x61,0x18,0xc6, + 0x22,0x04,0x41,0x10,0xc6,0x22,0x82,0x20,0x08,0xa8,0x95,0x40,0x19,0x14,0x01,0xbd, + 0x11,0x00,0x1a,0x33,0x00,0x24,0x66,0x00,0x28,0xcc,0x00,0x00,0x00,0xe3,0x15,0x4b, + 0x94,0x65,0x11,0x05,0x65,0x90,0x21,0x1a,0x0c,0x13,0x02,0xf9,0x8c,0x57,0x3c,0x55, + 0xd7,0x2d,0x14,0x94,0x41,0x86,0xea,0x70,0x4c,0x08,0xe4,0x63,0x41,0x01,0x9f,0xf1, + 0x0a,0x4a,0x13,0x03,0x31,0x70,0x28,0x28,0x83,0x0c,0x1a,0x43,0x99,0x10,0xc8,0xc7, + 0x8a,0x00,0x3e,0xe3,0x15,0xd9,0x77,0x06,0x67,0x40,0x51,0x50,0x06,0x19,0xbe,0x48, + 0x33,0x21,0x90,0x8f,0x15,0x01,0x7c,0xc6,0x2b,0x3c,0x32,0x68,0x03,0x36,0x20,0x03, + 0x0a,0xca,0x20,0xc3,0x18,0x60,0x99,0x09,0x81,0x7c,0xc6,0x2b,0xc4,0x00,0x0d,0xe2, + 0x00,0x0e,0x3c,0x0a,0xca,0x20,0xc3,0x19,0x70,0x61,0x60,0x42,0x20,0x1f,0x0b,0x0a, + 0xf8,0x8c,0x57,0x9c,0x41,0x1b,0xd8,0x41,0x1d,0x88,0x01,0x05,0xc5,0x86,0x00,0x3e, + 0xb3,0x0d,0x61,0x10,0x00,0xb3,0x0d,0x41,0x1b,0x04,0xb3,0x0d,0xc1,0x23,0xcc,0x36, + 0x04,0x6e,0x30,0x64,0x10,0x10,0x03,0x00,0x00,0x09,0x00,0x00,0x00,0x5b,0x86,0x20, + 0x00,0x85,0x2d,0x43,0x11,0x80,0xc2,0x96,0x41,0x09,0x40,0x61,0xcb,0xf0,0x04,0xa0, + 0xb0,0x65,0xa0,0x02,0x50,0xd8,0x32,0x60,0x01,0x28,0x6c,0x19,0xba,0x00,0x14,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sgl_fs_bytecode_metal_ios[2813] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x06,0x00,0x00,0x82,0x09,0x00,0x00,0x00, + 0xfd,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x20,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0xa2,0xfb,0x9e,0x58,0x9a,0x22,0x99, + 0x8e,0xdc,0x41,0x5a,0x15,0xf4,0x1f,0xbc,0xfa,0xdd,0xa2,0x32,0xf3,0xff,0x3e,0xe2, + 0x2c,0x7f,0x20,0x9e,0x14,0xb3,0xef,0x8e,0x56,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x08,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x7f,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x89,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87, + 0x70,0x30,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74, + 0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e, + 0xde,0xc1,0x1c,0xe8,0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81, + 0x00,0x16,0xa0,0xda,0x80,0x10,0xff,0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5, + 0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,0x18,0x86,0x00,0x2c,0x40,0x05,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44,0x61,0x00,0x00,0x00, + 0x00,0x89,0x20,0x00,0x00,0x1d,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04,0x60,0x83,0x70,0x94, + 0x34,0x45,0x94,0x30,0xf9,0xff,0x44,0x5c,0x13,0x15,0x11,0xbf,0x3d,0xfc,0xd3,0x18, + 0x01,0x30,0x88,0x30,0x04,0x17,0x49,0x53,0x44,0x09,0x93,0xff,0x4b,0x00,0xf3,0x2c, + 0x44,0xf4,0x4f,0x63,0x04,0xc0,0x20,0x42,0x21,0x94,0x42,0x84,0x40,0x0c,0x9d,0x61, + 0x04,0x01,0x98,0x23,0x08,0xe6,0x08,0xc0,0x60,0x18,0x41,0x58,0x0a,0x12,0x88,0x49, + 0x8a,0x29,0x40,0x6d,0x20,0x20,0x05,0xd6,0x08,0x00,0x00,0x00,0x00,0x13,0xa8,0x70, + 0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68, + 0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80,0x83,0x0d,0xb7,0x51, + 0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78, + 0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60, + 0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07, + 0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a, + 0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30, + 0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07, + 0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76, + 0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0, + 0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06, + 0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6, + 0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x90, + 0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06, + 0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72, + 0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0, + 0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07, + 0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x75,0x10,0x07,0x72, + 0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xd0,0x06,0xf6,0x10, + 0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07, + 0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x73, + 0x20,0x07,0x43,0x18,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x21,0x8c,0x03, + 0x04,0x80,0x00,0x00,0x00,0x00,0x00,0x40,0x16,0x08,0x00,0x00,0x00,0x08,0x00,0x00, + 0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43, + 0x5a,0x23,0x00,0x25,0x50,0x04,0x85,0x50,0x10,0x65,0x40,0x70,0x2c,0xe1,0x01,0x00, + 0x00,0x79,0x18,0x00,0x00,0xb7,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2, + 0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x42,0x3c,0x00,0x84,0x50, + 0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x2c,0xc3,0x23,0x2c, + 0x05,0xe3,0x20,0x08,0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e,0x8c,0x0d,0xc4,0xae, + 0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26,0x06,0x06,0x26,0xc6,0x65,0x46,0xa6,0x06, + 0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x26,0x06,0x06,0x26,0xc6,0x65, + 0x46,0xa6,0x26,0x65,0x88,0xf0,0x10,0x43,0x8c,0x65,0x58,0x8c,0x45,0x60,0xd1,0x54, + 0x46,0x17,0xc6,0x36,0x04,0x79,0x8e,0x65,0x58,0x84,0x45,0xe0,0x16,0x96,0x26,0xe7, + 0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7, + 0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x78,0x12,0x72,0x61,0x69,0x72,0x2e, + 0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74, + 0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x21,0x19,0x84,0xa5,0xc9, + 0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5, + 0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x95,0xb9,0x85,0x89,0xb1, + 0x95,0x0d,0x11,0x9e,0x86,0x51,0x58,0x9a,0x9c,0x8b,0x5c,0x99,0x1b,0x59,0x99,0xdc, + 0x17,0x5d,0x98,0xdc,0x59,0x19,0x1d,0xa3,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f, + 0xba,0x3c,0xb8,0xb2,0x2f,0xb7,0xb0,0xb6,0x32,0x1a,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x64,0xc2,0xd2,0xe4,0x5c,0xc2,0xe4,0xce,0xbe,0xdc,0xc2,0xda,0xca,0xa8,0x98,0xc9, + 0x85,0x9d,0x7d,0x8d,0xbd,0xb1,0xbd,0xc9,0x0d,0x61,0x9e,0x67,0x11,0x1e,0xe8,0x89, + 0x1e,0xe9,0x99,0x86,0x08,0x0f,0x45,0x29,0x2c,0x4d,0xce,0xc5,0x4c,0x2e,0xec,0xac, + 0xad,0xcc,0x8d,0xee,0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x4b,0xdd,0x5c,0x99,0x1c,0x0a, + 0xdb,0xdb,0x98,0x1b,0x4c,0x0a,0x95,0xb0,0x34,0x39,0x97,0xb1,0x32,0x37,0xba,0x32, + 0x39,0x3e,0x61,0x69,0x72,0x2e,0x70,0x65,0x72,0x73,0x70,0x65,0x63,0x74,0x69,0x76, + 0x65,0x14,0xea,0xec,0x86,0x48,0x8b,0xf0,0x58,0xcf,0xf5,0x60,0x4f,0xf6,0x40,0x4f, + 0xf4,0x48,0x8f,0xc6,0xa5,0x6e,0xae,0x4c,0x0e,0x85,0xed,0x6d,0xcc,0x2d,0x26,0x85, + 0xc5,0xd8,0x1b,0xdb,0x9b,0xdc,0x10,0x69,0x19,0x1e,0xeb,0xe1,0x1e,0xec,0xc9,0x1e, + 0xe8,0x89,0x1e,0xe9,0xe9,0xb8,0x84,0xa5,0xc9,0xb9,0xd0,0x95,0xe1,0xd1,0xd5,0xc9, + 0x95,0x51,0x0a,0x4b,0x93,0x73,0x61,0x7b,0x1b,0x0b,0xa3,0x4b,0x7b,0x73,0xfb,0x4a, + 0x73,0x23,0x2b,0xc3,0xa3,0x12,0x96,0x26,0xe7,0x32,0x17,0xd6,0x06,0xc7,0x56,0x46, + 0x8c,0xae,0x0c,0x8f,0xae,0x4e,0xae,0x4c,0x86,0x8c,0xc7,0x8c,0xed,0x2d,0x8c,0x8e, + 0x05,0x64,0x2e,0xac,0x0d,0x8e,0xad,0xcc,0x87,0x03,0x5d,0x19,0xde,0x10,0x6a,0x21, + 0x9e,0xef,0x01,0x83,0x45,0x58,0x86,0x27,0x0c,0x1e,0xe8,0x11,0x83,0x47,0x7a,0xc6, + 0x80,0x4b,0x58,0x9a,0x9c,0xcb,0x5c,0x58,0x1b,0x1c,0x5b,0x99,0x1c,0x8f,0xb9,0xb0, + 0x36,0x38,0xb6,0x32,0x39,0x22,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x43,0xa4, + 0xe5,0x78,0xca,0xe0,0x01,0x83,0x45,0x58,0x86,0x07,0x7a,0xcc,0xe0,0x91,0x9e,0x33, + 0x18,0x82,0x3c,0xdb,0xe3,0x3d,0x64,0xf0,0xa0,0xc1,0x10,0x03,0x01,0x9e,0xea,0x49, + 0x83,0x11,0x11,0x3b,0xb0,0x83,0x3d,0xb4,0x83,0x1b,0xb4,0xc3,0x3b,0x90,0x43,0x3d, + 0xb0,0x43,0x39,0xb8,0x81,0x39,0xb0,0x43,0x38,0x9c,0xc3,0x3c,0x4c,0x11,0x82,0x61, + 0x84,0xc2,0x0e,0xec,0x60,0x0f,0xed,0xe0,0x06,0xe9,0x40,0x0e,0xe5,0xe0,0x0e,0xf4, + 0x30,0x25,0x28,0x46,0x2c,0xe1,0x90,0x0e,0xf2,0xe0,0x06,0xf6,0x50,0x0e,0xf2,0x30, + 0x0f,0xe9,0xf0,0x0e,0xee,0x30,0x25,0x30,0x46,0x50,0xe1,0x90,0x0e,0xf2,0xe0,0x06, + 0xec,0x10,0x0e,0xee,0x70,0x0e,0xf5,0x10,0x0e,0xe7,0x50,0x0e,0xbf,0x60,0x0f,0xe5, + 0x20,0x0f,0xf3,0x90,0x0e,0xef,0xe0,0x0e,0x53,0x02,0x64,0xc4,0x14,0x0e,0xe9,0x20, + 0x0f,0x6e,0x30,0x0e,0xef,0xd0,0x0e,0xf0,0x90,0x0e,0xec,0x50,0x0e,0xbf,0xf0,0x0e, + 0xf0,0x40,0x0f,0xe9,0xf0,0x0e,0xee,0x30,0x0f,0x53,0x06,0x85,0x71,0x46,0x30,0xe1, + 0x90,0x0e,0xf2,0xe0,0x06,0xe6,0x20,0x0f,0xe1,0x70,0x0e,0xed,0x50,0x0e,0xee,0x40, + 0x0f,0x53,0x02,0x35,0x00,0x79,0x18,0x00,0x00,0x7b,0x00,0x00,0x00,0x33,0x08,0x80, + 0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80, + 0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80, + 0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88, + 0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78, + 0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03, + 0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f, + 0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c, + 0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39, + 0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b, + 0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60, + 0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87, + 0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e, + 0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6, + 0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94, + 0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03, + 0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07, + 0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f, + 0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33, + 0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc, + 0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c, + 0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78, + 0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca, + 0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21, + 0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43, + 0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87, + 0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c, + 0xe3,0x10,0x0e,0xec,0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e, + 0xe4,0xe1,0x17,0xd8,0xe1,0x1d,0xde,0x01,0x1e,0x66,0x50,0x59,0x38,0xa4,0x83,0x3c, + 0xb8,0x81,0x39,0xd4,0x83,0x3b,0x8c,0x03,0x3d,0xa4,0xc3,0x3b,0xb8,0xc3,0x2f,0x9c, + 0x83,0x3c,0xbc,0x43,0x3d,0xc0,0xc3,0x3c,0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00, + 0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45, + 0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00, + 0x00,0x61,0x20,0x00,0x00,0x0f,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00, + 0x00,0x06,0x00,0x00,0x00,0xc4,0x46,0x00,0xc6,0x12,0x80,0x80,0xd4,0x08,0x40,0x0d, + 0x90,0x98,0x01,0xa0,0x30,0x03,0x40,0x60,0x04,0x00,0x00,0x00,0x00,0x83,0x0c,0x8b, + 0x60,0x8c,0x18,0x28,0x42,0x40,0x29,0x49,0x50,0x20,0x86,0x60,0x01,0x23,0x9f,0xd9, + 0x06,0x23,0x00,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const char _sgl_vs_source_metal_sim[856] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x74,0x6d,0x3b,0x0a,0x7d,0x3b, + 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f, + 0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, + 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a, + 0x65,0x20,0x5b,0x5b,0x70,0x6f,0x69,0x6e,0x74,0x5f,0x73,0x69,0x7a,0x65,0x5d,0x5d, + 0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69, + 0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74, + 0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72, + 0x64,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31, + 0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75, + 0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x70,0x73,0x69,0x7a,0x65,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69, + 0x62,0x75,0x74,0x65,0x28,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23, + 0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22,0x73,0x67,0x6c,0x2e,0x67,0x6c,0x73, + 0x6c,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e, + 0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f, + 0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x31,0x20,0x5b,0x5b,0x62,0x75, + 0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20, + 0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d, + 0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22,0x73, + 0x67,0x6c,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, + 0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f, + 0x32,0x31,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22, + 0x73,0x67,0x6c,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75, + 0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d, + 0x20,0x69,0x6e,0x2e,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65, + 0x20,0x31,0x39,0x20,0x22,0x73,0x67,0x6c,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20, + 0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x5f,0x32,0x31,0x2e, + 0x74,0x6d,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x74, + 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31, + 0x2e,0x30,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x30,0x20,0x22,0x73, + 0x67,0x6c,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, + 0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f, + 0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _sgl_fs_source_metal_sim[489] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d, + 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, + 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20, + 0x31,0x31,0x20,0x22,0x73,0x67,0x6c,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x66,0x72, + 0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74, + 0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20, + 0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c, + 0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74, + 0x3e,0x20,0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28, + 0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x65, + 0x78,0x53,0x6d,0x70,0x6c,0x72,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72, + 0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69, + 0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b, + 0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x31,0x20,0x22,0x73,0x67,0x6c,0x2e,0x67, + 0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61, + 0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x28,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x69, + 0x6e,0x2e,0x75,0x76,0x2e,0x78,0x79,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_D3D11) +static const uint8_t _sgl_vs_bytecode_hlsl4[1032] = { + 0x44,0x58,0x42,0x43,0x09,0x96,0xbb,0xbb,0xfc,0x44,0x44,0xa8,0xa4,0x1c,0x9e,0x45, + 0x50,0x97,0xf1,0xde,0x01,0x00,0x00,0x00,0x08,0x04,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0x14,0x01,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x02,0x00,0x00, + 0x8c,0x03,0x00,0x00,0x52,0x44,0x45,0x46,0xd8,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xfe,0xff, + 0x10,0x81,0x00,0x00,0xaf,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x00,0xab,0xab,0x3c,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x60,0x00,0x00,0x00, + 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x98,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5f,0x32,0x31,0x5f, + 0x6d,0x76,0x70,0x00,0x02,0x00,0x03,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x5f,0x32,0x31,0x5f,0x74,0x6d,0x00,0x4d,0x69,0x63,0x72,0x6f, + 0x73,0x6f,0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68, + 0x61,0x64,0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30, + 0x2e,0x31,0x00,0xab,0x49,0x53,0x47,0x4e,0x74,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x68,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x03,0x03,0x00,0x00,0x68,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x68,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x68,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, + 0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44, + 0x00,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0xab,0xab,0xab, + 0x53,0x48,0x44,0x52,0x84,0x01,0x00,0x00,0x40,0x00,0x01,0x00,0x61,0x00,0x00,0x00, + 0x59,0x00,0x00,0x04,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x03, + 0x32,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00, + 0x02,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00, + 0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x67,0x00,0x00,0x04, + 0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x68,0x00,0x00,0x02, + 0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x08,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00, + 0x56,0x15,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00, + 0x06,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08, + 0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x36,0x00,0x00,0x05, + 0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x02,0x00,0x00,0x00, + 0x38,0x00,0x00,0x08,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x56,0x15,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x06,0x10,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00, + 0x00,0x00,0x00,0x00,0xa6,0x1a,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00, + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00, + 0x32,0x00,0x00,0x0a,0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0xf6,0x1f,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x01,0x53,0x54,0x41,0x54, + 0x74,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x06,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sgl_fs_bytecode_hlsl4[620] = { + 0x44,0x58,0x42,0x43,0x4f,0x7a,0xe1,0xcf,0x0c,0x89,0xc0,0x09,0x50,0x5a,0xca,0xe9, + 0x75,0x77,0xd1,0x26,0x01,0x00,0x00,0x00,0x6c,0x02,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0x20,0x01,0x00,0x00,0x54,0x01,0x00,0x00, + 0xf0,0x01,0x00,0x00,0x52,0x44,0x45,0x46,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xff,0xff, + 0x10,0x81,0x00,0x00,0x6d,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x69,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x00,0x74,0x65,0x78,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f, + 0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64, + 0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31, + 0x00,0xab,0xab,0xab,0x49,0x53,0x47,0x4e,0x44,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x03,0x00,0x00,0x38,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x2c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65, + 0x74,0x00,0xab,0xab,0x53,0x48,0x44,0x52,0x94,0x00,0x00,0x00,0x40,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x5a,0x00,0x00,0x03,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x58,0x18,0x00,0x04,0x00,0x70,0x10,0x00,0x00,0x00,0x00,0x00,0x55,0x55,0x00,0x00, + 0x62,0x10,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x00,0x03, + 0xf2,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00, + 0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x02,0x01,0x00,0x00,0x00,0x45,0x00,0x00,0x09, + 0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x7e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x38,0x00,0x00,0x07,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x01,0x00,0x00,0x00,0x3e,0x00,0x00,0x01, + 0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +#elif defined(SOKOL_WGPU) +static const uint8_t _sgl_vs_bytecode_wgpu[1968] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x35,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x21,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x33,0x00,0x00,0x00, + 0x07,0x00,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x05,0x00, + 0x07,0x00,0x00,0x00,0x73,0x67,0x6c,0x2e,0x67,0x6c,0x73,0x6c,0x00,0x00,0x00,0x00, + 0x03,0x00,0x37,0x00,0x02,0x00,0x00,0x00,0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65, + 0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e, + 0x74,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f, + 0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64, + 0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x2e,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65, + 0x74,0x2d,0x65,0x6e,0x76,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20, + 0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65, + 0x64,0x20,0x65,0x6e,0x74,0x72,0x79,0x2d,0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61, + 0x69,0x6e,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00, + 0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,0x05,0x00,0x06,0x00, + 0x0d,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x65,0x72,0x56,0x65,0x72,0x74,0x65,0x78, + 0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x06,0x00,0x07,0x00, + 0x0d,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74, + 0x53,0x69,0x7a,0x65,0x00,0x00,0x00,0x00,0x06,0x00,0x07,0x00,0x0d,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x67,0x6c,0x5f,0x43,0x6c,0x69,0x70,0x44,0x69,0x73,0x74,0x61, + 0x6e,0x63,0x65,0x00,0x06,0x00,0x07,0x00,0x0d,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x43,0x75,0x6c,0x6c,0x44,0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x00, + 0x05,0x00,0x03,0x00,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00, + 0x13,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x00,0x00,0x00, + 0x06,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6d,0x76,0x70,0x00, + 0x06,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x74,0x6d,0x00,0x00, + 0x05,0x00,0x03,0x00,0x15,0x00,0x00,0x00,0x5f,0x32,0x31,0x00,0x05,0x00,0x05,0x00, + 0x1a,0x00,0x00,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x00,0x00, + 0x05,0x00,0x04,0x00,0x21,0x00,0x00,0x00,0x70,0x73,0x69,0x7a,0x65,0x00,0x00,0x00, + 0x05,0x00,0x03,0x00,0x25,0x00,0x00,0x00,0x75,0x76,0x00,0x00,0x05,0x00,0x05,0x00, + 0x2a,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x00,0x00, + 0x05,0x00,0x04,0x00,0x32,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00, + 0x05,0x00,0x04,0x00,0x33,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x00, + 0x48,0x00,0x05,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0d,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x48,0x00,0x05,0x00, + 0x0d,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x47,0x00,0x03,0x00,0x0d,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x48,0x00,0x04,0x00, + 0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x48,0x00,0x05,0x00, + 0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x48,0x00,0x05,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x48,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x23,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x13,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x47,0x00,0x03,0x00, + 0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x15,0x00,0x00,0x00, + 0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x15,0x00,0x00,0x00, + 0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x1a,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x21,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x25,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x2a,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x32,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x33,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00, + 0x21,0x00,0x03,0x00,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00, + 0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x09,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x15,0x00,0x04,0x00,0x0a,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x0a,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x04,0x00,0x0c,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x1e,0x00,0x06,0x00,0x0d,0x00,0x00,0x00, + 0x09,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x0c,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0d,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x15,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x18,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x1e,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x12,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x19,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x1d,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x20,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x23,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x1d,0x00,0x00,0x00,0x25,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x28,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x29,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x28,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x29,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,0x80,0x3f, + 0x3b,0x00,0x04,0x00,0x1d,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x19,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x36,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x07,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x05,0x00, + 0x16,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x11,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x1a,0x00,0x00,0x00, + 0x91,0x00,0x05,0x00,0x09,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x18,0x00,0x00,0x00, + 0x1b,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x1d,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x0f,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x1e,0x00,0x00,0x00, + 0x1c,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x22,0x00,0x00,0x00, + 0x21,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x23,0x00,0x00,0x00,0x24,0x00,0x00,0x00, + 0x0f,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x24,0x00,0x00,0x00, + 0x22,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x14,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x16,0x00,0x00,0x00,0x26,0x00,0x00,0x00, + 0x15,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x12,0x00,0x00,0x00, + 0x27,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x28,0x00,0x00,0x00, + 0x2b,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x51,0x00,0x05,0x00,0x08,0x00,0x00,0x00, + 0x2e,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0x00,0x05,0x00, + 0x08,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x50,0x00,0x07,0x00,0x09,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x2e,0x00,0x00,0x00, + 0x2f,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x91,0x00,0x05,0x00, + 0x09,0x00,0x00,0x00,0x31,0x00,0x00,0x00,0x27,0x00,0x00,0x00,0x30,0x00,0x00,0x00, + 0x3e,0x00,0x03,0x00,0x25,0x00,0x00,0x00,0x31,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x07,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x09,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x3e,0x00,0x03,0x00, + 0x32,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +static const uint8_t _sgl_fs_bytecode_wgpu[936] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x1a,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x08,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x10,0x00,0x03,0x00,0x05,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x00,0x03,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x05,0x00,0x07,0x00,0x00,0x00, + 0x73,0x67,0x6c,0x2e,0x67,0x6c,0x73,0x6c,0x00,0x00,0x00,0x00,0x03,0x00,0x37,0x00, + 0x02,0x00,0x00,0x00,0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x2f,0x2f,0x20,0x4f, + 0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64, + 0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x30, + 0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f, + 0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x6f,0x70, + 0x65,0x6e,0x67,0x6c,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64, + 0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72, + 0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x2e, + 0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f, + 0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e, + 0x76,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f, + 0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x65,0x6e, + 0x74,0x72,0x79,0x2d,0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x0a,0x23, + 0x6c,0x69,0x6e,0x65,0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00,0x05,0x00,0x00,0x00, + 0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00,0x0b,0x00,0x00,0x00, + 0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x05,0x00,0x03,0x00, + 0x0f,0x00,0x00,0x00,0x74,0x65,0x78,0x00,0x05,0x00,0x03,0x00,0x12,0x00,0x00,0x00, + 0x75,0x76,0x00,0x00,0x05,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f, + 0x72,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x0b,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x22,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x21,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x21,0x00,0x03,0x00, + 0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00,0x08,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x09,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x0a,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x19,0x00,0x09,0x00,0x0c,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x03,0x00,0x0d,0x00,0x00,0x00, + 0x0c,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x0d,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x09,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x12,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x36,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00, + 0x08,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x12,0x00,0x00,0x00, + 0x4f,0x00,0x07,0x00,0x13,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x14,0x00,0x00,0x00, + 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x57,0x00,0x05,0x00, + 0x09,0x00,0x00,0x00,0x16,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x15,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x85,0x00,0x05,0x00,0x09,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x16,0x00,0x00,0x00, + 0x18,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x0b,0x00,0x00,0x00,0x19,0x00,0x00,0x00, + 0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +#elif defined(SOKOL_DUMMY_BACKEND) +static const char* _sgl_vs_source_dummy = ""; +static const char* _sgl_fs_source_dummy = ""; +#else +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#endif + +// ████████ ██ ██ ██████ ███████ ███████ +// ██ ██ ██ ██ ██ ██ ██ +// ██ ████ ██████ █████ ███████ +// ██ ██ ██ ██ ██ +// ██ ██ ██ ███████ ███████ +// +// >>types +typedef enum { + SGL_PRIMITIVETYPE_POINTS = 0, + SGL_PRIMITIVETYPE_LINES, + SGL_PRIMITIVETYPE_LINE_STRIP, + SGL_PRIMITIVETYPE_TRIANGLES, + SGL_PRIMITIVETYPE_TRIANGLE_STRIP, + SGL_PRIMITIVETYPE_QUADS, + SGL_NUM_PRIMITIVE_TYPES, +} _sgl_primitive_type_t; + +typedef struct { + uint32_t id; + sg_resource_state state; +} _sgl_slot_t; + +typedef struct { + int size; + int queue_top; + uint32_t* gen_ctrs; + int* free_queue; +} _sgl_pool_t; + +typedef struct { + _sgl_slot_t slot; + sg_pipeline pip[SGL_NUM_PRIMITIVE_TYPES]; +} _sgl_pipeline_t; + +typedef struct { + _sgl_pool_t pool; + _sgl_pipeline_t* pips; +} _sgl_pipeline_pool_t; + +typedef enum { + SGL_MATRIXMODE_MODELVIEW, + SGL_MATRIXMODE_PROJECTION, + SGL_MATRIXMODE_TEXTURE, + SGL_NUM_MATRIXMODES +} _sgl_matrix_mode_t; + +typedef struct { + float pos[3]; + float uv[2]; + uint32_t rgba; + float psize; +} _sgl_vertex_t; + +typedef struct { + float v[4][4]; +} _sgl_matrix_t; + +typedef struct { + _sgl_matrix_t mvp; /* model-view-projection matrix */ + _sgl_matrix_t tm; /* texture matrix */ +} _sgl_uniform_t; + +typedef enum { + SGL_COMMAND_DRAW, + SGL_COMMAND_VIEWPORT, + SGL_COMMAND_SCISSOR_RECT, +} _sgl_command_type_t; + +typedef struct { + sg_pipeline pip; + sg_image img; + int base_vertex; + int num_vertices; + int uniform_index; +} _sgl_draw_args_t; + +typedef struct { + int x, y, w, h; + bool origin_top_left; +} _sgl_viewport_args_t; + +typedef struct { + int x, y, w, h; + bool origin_top_left; +} _sgl_scissor_rect_args_t; + +typedef union { + _sgl_draw_args_t draw; + _sgl_viewport_args_t viewport; + _sgl_scissor_rect_args_t scissor_rect; +} _sgl_args_t; + +typedef struct { + _sgl_command_type_t cmd; + int layer_id; + _sgl_args_t args; +} _sgl_command_t; + +#define _SGL_INVALID_SLOT_INDEX (0) +#define _SGL_MAX_STACK_DEPTH (64) +#define _SGL_DEFAULT_CONTEXT_POOL_SIZE (4) +#define _SGL_DEFAULT_PIPELINE_POOL_SIZE (64) +#define _SGL_DEFAULT_MAX_VERTICES (1<<16) +#define _SGL_DEFAULT_MAX_COMMANDS (1<<14) +#define _SGL_SLOT_SHIFT (16) +#define _SGL_MAX_POOL_SIZE (1<<_SGL_SLOT_SHIFT) +#define _SGL_SLOT_MASK (_SGL_MAX_POOL_SIZE-1) + +typedef struct { + _sgl_slot_t slot; + sgl_context_desc_t desc; + uint32_t frame_id; + uint32_t update_frame_id; + struct { + int cap; + int next; + _sgl_vertex_t* ptr; + } vertices; + struct { + int cap; + int next; + _sgl_uniform_t* ptr; + } uniforms; + struct { + int cap; + int next; + _sgl_command_t* ptr; + } commands; + + /* state tracking */ + int base_vertex; + int vtx_count; /* number of times vtx function has been called, used for non-triangle primitives */ + sgl_error_t error; + bool in_begin; + int layer_id; + float u, v; + uint32_t rgba; + float point_size; + _sgl_primitive_type_t cur_prim_type; + sg_image cur_img; + bool texturing_enabled; + bool matrix_dirty; /* reset in sgl_end(), set in any of the matrix stack functions */ + + /* sokol-gfx resources */ + sg_buffer vbuf; + sgl_pipeline def_pip; + sg_bindings bind; + + /* pipeline stack */ + int pip_tos; + sgl_pipeline pip_stack[_SGL_MAX_STACK_DEPTH]; + + /* matrix stacks */ + _sgl_matrix_mode_t cur_matrix_mode; + int matrix_tos[SGL_NUM_MATRIXMODES]; + _sgl_matrix_t matrix_stack[SGL_NUM_MATRIXMODES][_SGL_MAX_STACK_DEPTH]; +} _sgl_context_t; + +typedef struct { + _sgl_pool_t pool; + _sgl_context_t* contexts; +} _sgl_context_pool_t; + +typedef struct { + uint32_t init_cookie; + sgl_desc_t desc; + sg_image def_img; // a default white texture + sg_shader shd; // same shader for all contexts + sgl_context def_ctx_id; + sgl_context cur_ctx_id; + _sgl_context_t* cur_ctx; // may be 0! + _sgl_pipeline_pool_t pip_pool; + _sgl_context_pool_t context_pool; +} _sgl_t; +static _sgl_t _sgl; + +// ██ ██████ ██████ ██████ ██ ███ ██ ██████ +// ██ ██ ██ ██ ██ ██ ████ ██ ██ +// ██ ██ ██ ██ ███ ██ ███ ██ ██ ██ ██ ██ ███ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██████ ██████ ██████ ██ ██ ████ ██████ +// +// >>logging +#if defined(SOKOL_DEBUG) +#define _SGL_LOGITEM_XMACRO(item,msg) #item ": " msg, +static const char* _sgl_log_messages[] = { + _SGL_LOG_ITEMS +}; +#undef _SGL_LOGITEM_XMACRO +#endif // SOKOL_DEBUG + +#define _SGL_PANIC(code) _sgl_log(SGL_LOGITEM_ ##code, 0, __LINE__) +#define _SGL_ERROR(code) _sgl_log(SGL_LOGITEM_ ##code, 1, __LINE__) +#define _SGL_WARN(code) _sgl_log(SGL_LOGITEM_ ##code, 2, __LINE__) +#define _SGL_INFO(code) _sgl_log(SGL_LOGITEM_ ##code, 3, __LINE__) + +static void _sgl_log(sgl_log_item_t log_item, uint32_t log_level, uint32_t line_nr) { + if (_sgl.desc.logger.func) { + #if defined(SOKOL_DEBUG) + const char* filename = __FILE__; + const char* message = _sgl_log_messages[log_item]; + #else + const char* filename = 0; + const char* message = 0; + #endif + _sgl.desc.logger.func("sgl", log_level, log_item, message, line_nr, filename, _sgl.desc.logger.user_data); + } + else { + // for log level PANIC it would be 'undefined behaviour' to continue + if (log_level == 0) { + abort(); + } + } +} + +// ███ ███ ███████ ███ ███ ██████ ██████ ██ ██ +// ████ ████ ██ ████ ████ ██ ██ ██ ██ ██ ██ +// ██ ████ ██ █████ ██ ████ ██ ██ ██ ██████ ████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ███████ ██ ██ ██████ ██ ██ ██ +// +// >>memory +static void _sgl_clear(void* ptr, size_t size) { + SOKOL_ASSERT(ptr && (size > 0)); + memset(ptr, 0, size); +} + +static void* _sgl_malloc(size_t size) { + SOKOL_ASSERT(size > 0); + void* ptr; + if (_sgl.desc.allocator.alloc) { + ptr = _sgl.desc.allocator.alloc(size, _sgl.desc.allocator.user_data); + } + else { + ptr = malloc(size); + } + if (0 == ptr) { + _SGL_PANIC(MALLOC_FAILED); + } + return ptr; +} + +static void* _sgl_malloc_clear(size_t size) { + void* ptr = _sgl_malloc(size); + _sgl_clear(ptr, size); + return ptr; +} + +static void _sgl_free(void* ptr) { + if (_sgl.desc.allocator.free) { + _sgl.desc.allocator.free(ptr, _sgl.desc.allocator.user_data); + } + else { + free(ptr); + } +} + +// ██████ ██████ ██████ ██ +// ██ ██ ██ ██ ██ ██ ██ +// ██████ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ +// ██ ██████ ██████ ███████ +// +// >>pool +static void _sgl_init_pool(_sgl_pool_t* pool, int num) { + SOKOL_ASSERT(pool && (num >= 1)); + /* slot 0 is reserved for the 'invalid id', so bump the pool size by 1 */ + pool->size = num + 1; + pool->queue_top = 0; + /* generation counters indexable by pool slot index, slot 0 is reserved */ + size_t gen_ctrs_size = sizeof(uint32_t) * (size_t)pool->size; + pool->gen_ctrs = (uint32_t*) _sgl_malloc_clear(gen_ctrs_size); + /* it's not a bug to only reserve 'num' here */ + pool->free_queue = (int*) _sgl_malloc_clear(sizeof(int) * (size_t)num); + /* never allocate the zero-th pool item since the invalid id is 0 */ + for (int i = pool->size-1; i >= 1; i--) { + pool->free_queue[pool->queue_top++] = i; + } +} + +static void _sgl_discard_pool(_sgl_pool_t* pool) { + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + _sgl_free(pool->free_queue); + pool->free_queue = 0; + SOKOL_ASSERT(pool->gen_ctrs); + _sgl_free(pool->gen_ctrs); + pool->gen_ctrs = 0; + pool->size = 0; + pool->queue_top = 0; +} + +static int _sgl_pool_alloc_index(_sgl_pool_t* pool) { + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + if (pool->queue_top > 0) { + int slot_index = pool->free_queue[--pool->queue_top]; + SOKOL_ASSERT((slot_index > 0) && (slot_index < pool->size)); + return slot_index; + } + else { + /* pool exhausted */ + return _SGL_INVALID_SLOT_INDEX; + } +} + +static void _sgl_pool_free_index(_sgl_pool_t* pool, int slot_index) { + SOKOL_ASSERT((slot_index > _SGL_INVALID_SLOT_INDEX) && (slot_index < pool->size)); + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + SOKOL_ASSERT(pool->queue_top < pool->size); + #ifdef SOKOL_DEBUG + /* debug check against double-free */ + for (int i = 0; i < pool->queue_top; i++) { + SOKOL_ASSERT(pool->free_queue[i] != slot_index); + } + #endif + pool->free_queue[pool->queue_top++] = slot_index; + SOKOL_ASSERT(pool->queue_top <= (pool->size-1)); +} + +/* allocate the slot at slot_index: + - bump the slot's generation counter + - create a resource id from the generation counter and slot index + - set the slot's id to this id + - set the slot's state to ALLOC + - return the resource id +*/ +static uint32_t _sgl_slot_alloc(_sgl_pool_t* pool, _sgl_slot_t* slot, int slot_index) { + /* FIXME: add handling for an overflowing generation counter, + for now, just overflow (another option is to disable + the slot) + */ + SOKOL_ASSERT(pool && pool->gen_ctrs); + SOKOL_ASSERT((slot_index > _SGL_INVALID_SLOT_INDEX) && (slot_index < pool->size)); + SOKOL_ASSERT((slot->state == SG_RESOURCESTATE_INITIAL) && (slot->id == SG_INVALID_ID)); + uint32_t ctr = ++pool->gen_ctrs[slot_index]; + slot->id = (ctr<<_SGL_SLOT_SHIFT)|(slot_index & _SGL_SLOT_MASK); + slot->state = SG_RESOURCESTATE_ALLOC; + return slot->id; +} + +/* extract slot index from id */ +static int _sgl_slot_index(uint32_t id) { + int slot_index = (int) (id & _SGL_SLOT_MASK); + SOKOL_ASSERT(_SGL_INVALID_SLOT_INDEX != slot_index); + return slot_index; +} + +// ██████ ██ ██████ ███████ ██ ██ ███ ██ ███████ ███████ +// ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ +// ██████ ██ ██████ █████ ██ ██ ██ ██ ██ █████ ███████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ███████ ███████ ██ ██ ████ ███████ ███████ +// +// >>pipelines +static void _sgl_reset_pipeline(_sgl_pipeline_t* pip) { + SOKOL_ASSERT(pip); + _sgl_clear(pip, sizeof(_sgl_pipeline_t)); +} + +static void _sgl_setup_pipeline_pool(int pool_size) { + /* note: the pools here will have an additional item, since slot 0 is reserved */ + SOKOL_ASSERT((pool_size > 0) && (pool_size < _SGL_MAX_POOL_SIZE)); + _sgl_init_pool(&_sgl.pip_pool.pool, pool_size); + size_t pool_byte_size = sizeof(_sgl_pipeline_t) * (size_t)_sgl.pip_pool.pool.size; + _sgl.pip_pool.pips = (_sgl_pipeline_t*) _sgl_malloc_clear(pool_byte_size); +} + +static void _sgl_discard_pipeline_pool(void) { + SOKOL_ASSERT(0 != _sgl.pip_pool.pips); + _sgl_free(_sgl.pip_pool.pips); _sgl.pip_pool.pips = 0; + _sgl_discard_pool(&_sgl.pip_pool.pool); +} + +/* get pipeline pointer without id-check */ +static _sgl_pipeline_t* _sgl_pipeline_at(uint32_t pip_id) { + SOKOL_ASSERT(SG_INVALID_ID != pip_id); + int slot_index = _sgl_slot_index(pip_id); + SOKOL_ASSERT((slot_index > _SGL_INVALID_SLOT_INDEX) && (slot_index < _sgl.pip_pool.pool.size)); + return &_sgl.pip_pool.pips[slot_index]; +} + +/* get pipeline pointer with id-check, returns 0 if no match */ +static _sgl_pipeline_t* _sgl_lookup_pipeline(uint32_t pip_id) { + if (SG_INVALID_ID != pip_id) { + _sgl_pipeline_t* pip = _sgl_pipeline_at(pip_id); + if (pip->slot.id == pip_id) { + return pip; + } + } + return 0; +} + +/* make pipeline id from uint32_t id */ +static sgl_pipeline _sgl_make_pip_id(uint32_t pip_id) { + sgl_pipeline pip = { pip_id }; + return pip; +} + +static sgl_pipeline _sgl_alloc_pipeline(void) { + sgl_pipeline res; + int slot_index = _sgl_pool_alloc_index(&_sgl.pip_pool.pool); + if (_SGL_INVALID_SLOT_INDEX != slot_index) { + res = _sgl_make_pip_id(_sgl_slot_alloc(&_sgl.pip_pool.pool, &_sgl.pip_pool.pips[slot_index].slot, slot_index)); + } + else { + /* pool is exhausted */ + res = _sgl_make_pip_id(SG_INVALID_ID); + } + return res; +} + +static void _sgl_init_pipeline(sgl_pipeline pip_id, const sg_pipeline_desc* in_desc, const sgl_context_desc_t* ctx_desc) { + SOKOL_ASSERT((pip_id.id != SG_INVALID_ID) && in_desc && ctx_desc); + + /* create a new desc with 'patched' shader and pixel format state */ + sg_pipeline_desc desc = *in_desc; + desc.layout.buffers[0].stride = sizeof(_sgl_vertex_t); + { + sg_vertex_attr_desc* pos = &desc.layout.attrs[0]; + pos->offset = offsetof(_sgl_vertex_t, pos); + pos->format = SG_VERTEXFORMAT_FLOAT3; + } + { + sg_vertex_attr_desc* uv = &desc.layout.attrs[1]; + uv->offset = offsetof(_sgl_vertex_t, uv); + uv->format = SG_VERTEXFORMAT_FLOAT2; + } + { + sg_vertex_attr_desc* rgba = &desc.layout.attrs[2]; + rgba->offset = offsetof(_sgl_vertex_t, rgba); + rgba->format = SG_VERTEXFORMAT_UBYTE4N; + } + { + sg_vertex_attr_desc* psize = &desc.layout.attrs[3]; + psize->offset = offsetof(_sgl_vertex_t, psize); + psize->format = SG_VERTEXFORMAT_FLOAT; + } + if (in_desc->shader.id == SG_INVALID_ID) { + desc.shader = _sgl.shd; + } + desc.index_type = SG_INDEXTYPE_NONE; + desc.sample_count = ctx_desc->sample_count; + if (desc.face_winding == _SG_FACEWINDING_DEFAULT) { + desc.face_winding = _sgl.desc.face_winding; + } + desc.depth.pixel_format = ctx_desc->depth_format; + if (ctx_desc->depth_format == SG_PIXELFORMAT_NONE) { + desc.depth.write_enabled = false; + } + desc.colors[0].pixel_format = ctx_desc->color_format; + if (desc.colors[0].write_mask == _SG_COLORMASK_DEFAULT) { + desc.colors[0].write_mask = SG_COLORMASK_RGB; + } + + _sgl_pipeline_t* pip = _sgl_lookup_pipeline(pip_id.id); + SOKOL_ASSERT(pip && (pip->slot.state == SG_RESOURCESTATE_ALLOC)); + pip->slot.state = SG_RESOURCESTATE_VALID; + for (int i = 0; i < SGL_NUM_PRIMITIVE_TYPES; i++) { + switch (i) { + case SGL_PRIMITIVETYPE_POINTS: + desc.primitive_type = SG_PRIMITIVETYPE_POINTS; + break; + case SGL_PRIMITIVETYPE_LINES: + desc.primitive_type = SG_PRIMITIVETYPE_LINES; + break; + case SGL_PRIMITIVETYPE_LINE_STRIP: + desc.primitive_type = SG_PRIMITIVETYPE_LINE_STRIP; + break; + case SGL_PRIMITIVETYPE_TRIANGLES: + desc.primitive_type = SG_PRIMITIVETYPE_TRIANGLES; + break; + case SGL_PRIMITIVETYPE_TRIANGLE_STRIP: + case SGL_PRIMITIVETYPE_QUADS: + desc.primitive_type = SG_PRIMITIVETYPE_TRIANGLE_STRIP; + break; + } + if (SGL_PRIMITIVETYPE_QUADS == i) { + /* quads are emulated via triangles, use the same pipeline object */ + pip->pip[i] = pip->pip[SGL_PRIMITIVETYPE_TRIANGLES]; + } + else { + pip->pip[i] = sg_make_pipeline(&desc); + if (pip->pip[i].id == SG_INVALID_ID) { + _SGL_ERROR(MAKE_PIPELINE_FAILED); + pip->slot.state = SG_RESOURCESTATE_FAILED; + } + } + } +} + +static sgl_pipeline _sgl_make_pipeline(const sg_pipeline_desc* desc, const sgl_context_desc_t* ctx_desc) { + SOKOL_ASSERT(desc && ctx_desc); + sgl_pipeline pip_id = _sgl_alloc_pipeline(); + if (pip_id.id != SG_INVALID_ID) { + _sgl_init_pipeline(pip_id, desc, ctx_desc); + } + else { + _SGL_ERROR(PIPELINE_POOL_EXHAUSTED); + } + return pip_id; +} + +static void _sgl_destroy_pipeline(sgl_pipeline pip_id) { + _sgl_pipeline_t* pip = _sgl_lookup_pipeline(pip_id.id); + if (pip) { + sg_push_debug_group("sokol-gl"); + for (int i = 0; i < SGL_NUM_PRIMITIVE_TYPES; i++) { + if (i != SGL_PRIMITIVETYPE_QUADS) { + sg_destroy_pipeline(pip->pip[i]); + } + } + sg_pop_debug_group(); + _sgl_reset_pipeline(pip); + _sgl_pool_free_index(&_sgl.pip_pool.pool, _sgl_slot_index(pip_id.id)); + } +} + +static sg_pipeline _sgl_get_pipeline(sgl_pipeline pip_id, _sgl_primitive_type_t prim_type) { + _sgl_pipeline_t* pip = _sgl_lookup_pipeline(pip_id.id); + if (pip) { + return pip->pip[prim_type]; + } + else { + sg_pipeline dummy_id = { SG_INVALID_ID }; + return dummy_id; + } +} + +// ██████ ██████ ███ ██ ████████ ███████ ██ ██ ████████ ███████ +// ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ █████ ███ ██ ███████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██████ ██████ ██ ████ ██ ███████ ██ ██ ██ ███████ +// +// >>contexts +static void _sgl_reset_context(_sgl_context_t* ctx) { + SOKOL_ASSERT(ctx); + SOKOL_ASSERT(0 == ctx->vertices.ptr); + SOKOL_ASSERT(0 == ctx->uniforms.ptr); + SOKOL_ASSERT(0 == ctx->commands.ptr); + _sgl_clear(ctx, sizeof(_sgl_context_t)); +} + +static void _sgl_setup_context_pool(int pool_size) { + /* note: the pools here will have an additional item, since slot 0 is reserved */ + SOKOL_ASSERT((pool_size > 0) && (pool_size < _SGL_MAX_POOL_SIZE)); + _sgl_init_pool(&_sgl.context_pool.pool, pool_size); + size_t pool_byte_size = sizeof(_sgl_context_t) * (size_t)_sgl.context_pool.pool.size; + _sgl.context_pool.contexts = (_sgl_context_t*) _sgl_malloc_clear(pool_byte_size); +} + +static void _sgl_discard_context_pool(void) { + SOKOL_ASSERT(0 != _sgl.context_pool.contexts); + _sgl_free(_sgl.context_pool.contexts); _sgl.context_pool.contexts = 0; + _sgl_discard_pool(&_sgl.context_pool.pool); +} + +// get context pointer without id-check +static _sgl_context_t* _sgl_context_at(uint32_t ctx_id) { + SOKOL_ASSERT(SG_INVALID_ID != ctx_id); + int slot_index = _sgl_slot_index(ctx_id); + SOKOL_ASSERT((slot_index > _SGL_INVALID_SLOT_INDEX) && (slot_index < _sgl.context_pool.pool.size)); + return &_sgl.context_pool.contexts[slot_index]; +} + +// get context pointer with id-check, returns 0 if no match +static _sgl_context_t* _sgl_lookup_context(uint32_t ctx_id) { + if (SG_INVALID_ID != ctx_id) { + _sgl_context_t* ctx = _sgl_context_at(ctx_id); + if (ctx->slot.id == ctx_id) { + return ctx; + } + } + return 0; +} + +// make context id from uint32_t id +static sgl_context _sgl_make_ctx_id(uint32_t ctx_id) { + sgl_context ctx = { ctx_id }; + return ctx; +} + +static sgl_context _sgl_alloc_context(void) { + sgl_context res; + int slot_index = _sgl_pool_alloc_index(&_sgl.context_pool.pool); + if (_SGL_INVALID_SLOT_INDEX != slot_index) { + res = _sgl_make_ctx_id(_sgl_slot_alloc(&_sgl.context_pool.pool, &_sgl.context_pool.contexts[slot_index].slot, slot_index)); + } + else { + // pool is exhausted + res = _sgl_make_ctx_id(SG_INVALID_ID); + } + return res; +} + +// return sgl_context_desc_t with patched defaults +static sgl_context_desc_t _sgl_context_desc_defaults(const sgl_context_desc_t* desc) { + sgl_context_desc_t res = *desc; + res.max_vertices = _sgl_def(desc->max_vertices, _SGL_DEFAULT_MAX_VERTICES); + res.max_commands = _sgl_def(desc->max_commands, _SGL_DEFAULT_MAX_COMMANDS); + return res; +} + +static void _sgl_identity(_sgl_matrix_t*); +static sg_commit_listener _sgl_make_commit_listener(_sgl_context_t* ctx); +static void _sgl_init_context(sgl_context ctx_id, const sgl_context_desc_t* in_desc) { + SOKOL_ASSERT((ctx_id.id != SG_INVALID_ID) && in_desc); + _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id); + SOKOL_ASSERT(ctx); + ctx->desc = _sgl_context_desc_defaults(in_desc); + // NOTE: frame_id must be non-zero, so that updates trigger in first frame + ctx->frame_id = 1; + ctx->cur_img = _sgl.def_img; + + // allocate buffers and pools + ctx->vertices.cap = ctx->desc.max_vertices; + ctx->commands.cap = ctx->uniforms.cap = ctx->desc.max_commands; + ctx->vertices.ptr = (_sgl_vertex_t*) _sgl_malloc((size_t)ctx->vertices.cap * sizeof(_sgl_vertex_t)); + ctx->uniforms.ptr = (_sgl_uniform_t*) _sgl_malloc((size_t)ctx->uniforms.cap * sizeof(_sgl_uniform_t)); + ctx->commands.ptr = (_sgl_command_t*) _sgl_malloc((size_t)ctx->commands.cap * sizeof(_sgl_command_t)); + + // create sokol-gfx resource objects + sg_push_debug_group("sokol-gl"); + + sg_buffer_desc vbuf_desc; + _sgl_clear(&vbuf_desc, sizeof(vbuf_desc)); + vbuf_desc.size = (size_t)ctx->vertices.cap * sizeof(_sgl_vertex_t); + vbuf_desc.type = SG_BUFFERTYPE_VERTEXBUFFER; + vbuf_desc.usage = SG_USAGE_STREAM; + vbuf_desc.label = "sgl-vertex-buffer"; + ctx->vbuf = sg_make_buffer(&vbuf_desc); + SOKOL_ASSERT(SG_INVALID_ID != ctx->vbuf.id); + ctx->bind.vertex_buffers[0] = ctx->vbuf; + + sg_pipeline_desc def_pip_desc; + _sgl_clear(&def_pip_desc, sizeof(def_pip_desc)); + def_pip_desc.depth.write_enabled = true; + ctx->def_pip = _sgl_make_pipeline(&def_pip_desc, &ctx->desc); + if (!sg_add_commit_listener(_sgl_make_commit_listener(ctx))) { + _SGL_ERROR(ADD_COMMIT_LISTENER_FAILED); + } + sg_pop_debug_group(); + + // default state + ctx->rgba = 0xFFFFFFFF; + ctx->point_size = 1.0f; + for (int i = 0; i < SGL_NUM_MATRIXMODES; i++) { + _sgl_identity(&ctx->matrix_stack[i][0]); + } + ctx->pip_stack[0] = ctx->def_pip; + ctx->matrix_dirty = true; +} + +static sgl_context _sgl_make_context(const sgl_context_desc_t* desc) { + SOKOL_ASSERT(desc); + sgl_context ctx_id = _sgl_alloc_context(); + if (ctx_id.id != SG_INVALID_ID) { + _sgl_init_context(ctx_id, desc); + } + else { + _SGL_ERROR(CONTEXT_POOL_EXHAUSTED); + } + return ctx_id; +} + +static void _sgl_destroy_context(sgl_context ctx_id) { + _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id); + if (ctx) { + SOKOL_ASSERT(ctx->vertices.ptr); + SOKOL_ASSERT(ctx->uniforms.ptr); + SOKOL_ASSERT(ctx->commands.ptr); + + _sgl_free(ctx->vertices.ptr); + _sgl_free(ctx->uniforms.ptr); + _sgl_free(ctx->commands.ptr); + ctx->vertices.ptr = 0; + ctx->uniforms.ptr = 0; + ctx->commands.ptr = 0; + + sg_push_debug_group("sokol-gl"); + sg_destroy_buffer(ctx->vbuf); + _sgl_destroy_pipeline(ctx->def_pip); + sg_remove_commit_listener(_sgl_make_commit_listener(ctx)); + sg_pop_debug_group(); + + _sgl_reset_context(ctx); + _sgl_pool_free_index(&_sgl.context_pool.pool, _sgl_slot_index(ctx_id.id)); + } +} + +// ███ ███ ██ ███████ ██████ +// ████ ████ ██ ██ ██ +// ██ ████ ██ ██ ███████ ██ +// ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ███████ ██████ +// +// >>misc +static void _sgl_begin(_sgl_context_t* ctx, _sgl_primitive_type_t mode) { + ctx->in_begin = true; + ctx->base_vertex = ctx->vertices.next; + ctx->vtx_count = 0; + ctx->cur_prim_type = mode; +} + +static void _sgl_rewind(_sgl_context_t* ctx) { + ctx->frame_id++; + ctx->vertices.next = 0; + ctx->uniforms.next = 0; + ctx->commands.next = 0; + ctx->base_vertex = 0; + ctx->error = SGL_NO_ERROR; + ctx->layer_id = 0; + ctx->matrix_dirty = true; +} + +// called from inside sokol-gfx sg_commit() +static void _sgl_commit_listener(void* userdata) { + _sgl_context_t* ctx = _sgl_lookup_context((uint32_t)(uintptr_t)userdata); + if (ctx) { + _sgl_rewind(ctx); + } +} + +static sg_commit_listener _sgl_make_commit_listener(_sgl_context_t* ctx) { + sg_commit_listener listener = { _sgl_commit_listener, (void*)(uintptr_t)(ctx->slot.id) }; + return listener; +} + +static _sgl_vertex_t* _sgl_next_vertex(_sgl_context_t* ctx) { + if (ctx->vertices.next < ctx->vertices.cap) { + return &ctx->vertices.ptr[ctx->vertices.next++]; + } + else { + ctx->error = SGL_ERROR_VERTICES_FULL; + return 0; + } +} + +static _sgl_uniform_t* _sgl_next_uniform(_sgl_context_t* ctx) { + if (ctx->uniforms.next < ctx->uniforms.cap) { + return &ctx->uniforms.ptr[ctx->uniforms.next++]; + } + else { + ctx->error = SGL_ERROR_UNIFORMS_FULL; + return 0; + } +} + +static _sgl_command_t* _sgl_cur_command(_sgl_context_t* ctx) { + if (ctx->commands.next > 0) { + return &ctx->commands.ptr[ctx->commands.next - 1]; + } + else { + return 0; + } +} + +static _sgl_command_t* _sgl_next_command(_sgl_context_t* ctx) { + if (ctx->commands.next < ctx->commands.cap) { + return &ctx->commands.ptr[ctx->commands.next++]; + } + else { + ctx->error = SGL_ERROR_COMMANDS_FULL; + return 0; + } +} + +static uint32_t _sgl_pack_rgbab(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + return (uint32_t)(((uint32_t)a<<24)|((uint32_t)b<<16)|((uint32_t)g<<8)|r); +} + +static float _sgl_clamp(float v, float lo, float hi) { + if (v < lo) return lo; + else if (v > hi) return hi; + else return v; +} + +static uint32_t _sgl_pack_rgbaf(float r, float g, float b, float a) { + uint8_t r_u8 = (uint8_t) (_sgl_clamp(r, 0.0f, 1.0f) * 255.0f); + uint8_t g_u8 = (uint8_t) (_sgl_clamp(g, 0.0f, 1.0f) * 255.0f); + uint8_t b_u8 = (uint8_t) (_sgl_clamp(b, 0.0f, 1.0f) * 255.0f); + uint8_t a_u8 = (uint8_t) (_sgl_clamp(a, 0.0f, 1.0f) * 255.0f); + return _sgl_pack_rgbab(r_u8, g_u8, b_u8, a_u8); +} + +static void _sgl_vtx(_sgl_context_t* ctx, float x, float y, float z, float u, float v, uint32_t rgba) { + SOKOL_ASSERT(ctx->in_begin); + _sgl_vertex_t* vtx; + /* handle non-native primitive types */ + if ((ctx->cur_prim_type == SGL_PRIMITIVETYPE_QUADS) && ((ctx->vtx_count & 3) == 3)) { + /* for quads, before writing the last quad vertex, reuse + the first and third vertex to start the second triangle in the quad + */ + vtx = _sgl_next_vertex(ctx); + if (vtx) { *vtx = *(vtx - 3); } + vtx = _sgl_next_vertex(ctx); + if (vtx) { *vtx = *(vtx - 2); } + } + vtx = _sgl_next_vertex(ctx); + if (vtx) { + vtx->pos[0] = x; vtx->pos[1] = y; vtx->pos[2] = z; + vtx->uv[0] = u; vtx->uv[1] = v; + vtx->rgba = rgba; + vtx->psize = ctx->point_size; + } + ctx->vtx_count++; +} + +static void _sgl_identity(_sgl_matrix_t* m) { + for (int c = 0; c < 4; c++) { + for (int r = 0; r < 4; r++) { + m->v[c][r] = (r == c) ? 1.0f : 0.0f; + } + } +} + +static void _sgl_transpose(_sgl_matrix_t* dst, const _sgl_matrix_t* m) { + SOKOL_ASSERT(dst != m); + for (int c = 0; c < 4; c++) { + for (int r = 0; r < 4; r++) { + dst->v[r][c] = m->v[c][r]; + } + } +} + +/* _sgl_rotate, _sgl_frustum, _sgl_ortho from MESA m_matric.c */ +static void _sgl_matmul4(_sgl_matrix_t* p, const _sgl_matrix_t* a, const _sgl_matrix_t* b) { + for (int r = 0; r < 4; r++) { + float ai0=a->v[0][r], ai1=a->v[1][r], ai2=a->v[2][r], ai3=a->v[3][r]; + p->v[0][r] = ai0*b->v[0][0] + ai1*b->v[0][1] + ai2*b->v[0][2] + ai3*b->v[0][3]; + p->v[1][r] = ai0*b->v[1][0] + ai1*b->v[1][1] + ai2*b->v[1][2] + ai3*b->v[1][3]; + p->v[2][r] = ai0*b->v[2][0] + ai1*b->v[2][1] + ai2*b->v[2][2] + ai3*b->v[2][3]; + p->v[3][r] = ai0*b->v[3][0] + ai1*b->v[3][1] + ai2*b->v[3][2] + ai3*b->v[3][3]; + } +} + +static void _sgl_mul(_sgl_matrix_t* dst, const _sgl_matrix_t* m) { + _sgl_matmul4(dst, dst, m); +} + +static void _sgl_rotate(_sgl_matrix_t* dst, float a, float x, float y, float z) { + + float s = sinf(a); + float c = cosf(a); + + float mag = sqrtf(x*x + y*y + z*z); + if (mag < 1.0e-4F) { + return; + } + x /= mag; + y /= mag; + z /= mag; + float xx = x * x; + float yy = y * y; + float zz = z * z; + float xy = x * y; + float yz = y * z; + float zx = z * x; + float xs = x * s; + float ys = y * s; + float zs = z * s; + float one_c = 1.0f - c; + + _sgl_matrix_t m; + m.v[0][0] = (one_c * xx) + c; + m.v[1][0] = (one_c * xy) - zs; + m.v[2][0] = (one_c * zx) + ys; + m.v[3][0] = 0.0f; + m.v[0][1] = (one_c * xy) + zs; + m.v[1][1] = (one_c * yy) + c; + m.v[2][1] = (one_c * yz) - xs; + m.v[3][1] = 0.0f; + m.v[0][2] = (one_c * zx) - ys; + m.v[1][2] = (one_c * yz) + xs; + m.v[2][2] = (one_c * zz) + c; + m.v[3][2] = 0.0f; + m.v[0][3] = 0.0f; + m.v[1][3] = 0.0f; + m.v[2][3] = 0.0f; + m.v[3][3] = 1.0f; + _sgl_mul(dst, &m); +} + +static void _sgl_scale(_sgl_matrix_t* dst, float x, float y, float z) { + for (int r = 0; r < 4; r++) { + dst->v[0][r] *= x; + dst->v[1][r] *= y; + dst->v[2][r] *= z; + } +} + +static void _sgl_translate(_sgl_matrix_t* dst, float x, float y, float z) { + for (int r = 0; r < 4; r++) { + dst->v[3][r] = dst->v[0][r]*x + dst->v[1][r]*y + dst->v[2][r]*z + dst->v[3][r]; + } +} + +static void _sgl_frustum(_sgl_matrix_t* dst, float left, float right, float bottom, float top, float znear, float zfar) { + float x = (2.0f * znear) / (right - left); + float y = (2.0f * znear) / (top - bottom); + float a = (right + left) / (right - left); + float b = (top + bottom) / (top - bottom); + float c = -(zfar + znear) / (zfar - znear); + float d = -(2.0f * zfar * znear) / (zfar - znear); + _sgl_matrix_t m; + m.v[0][0] = x; m.v[0][1] = 0.0f; m.v[0][2] = 0.0f; m.v[0][3] = 0.0f; + m.v[1][0] = 0.0f; m.v[1][1] = y; m.v[1][2] = 0.0f; m.v[1][3] = 0.0f; + m.v[2][0] = a; m.v[2][1] = b; m.v[2][2] = c; m.v[2][3] = -1.0f; + m.v[3][0] = 0.0f; m.v[3][1] = 0.0f; m.v[3][2] = d; m.v[3][3] = 0.0f; + _sgl_mul(dst, &m); +} + +static void _sgl_ortho(_sgl_matrix_t* dst, float left, float right, float bottom, float top, float znear, float zfar) { + _sgl_matrix_t m; + m.v[0][0] = 2.0f / (right - left); + m.v[1][0] = 0.0f; + m.v[2][0] = 0.0f; + m.v[3][0] = -(right + left) / (right - left); + m.v[0][1] = 0.0f; + m.v[1][1] = 2.0f / (top - bottom); + m.v[2][1] = 0.0f; + m.v[3][1] = -(top + bottom) / (top - bottom); + m.v[0][2] = 0.0f; + m.v[1][2] = 0.0f; + m.v[2][2] = -2.0f / (zfar - znear); + m.v[3][2] = -(zfar + znear) / (zfar - znear); + m.v[0][3] = 0.0f; + m.v[1][3] = 0.0f; + m.v[2][3] = 0.0f; + m.v[3][3] = 1.0f; + + _sgl_mul(dst, &m); +} + +/* _sgl_perspective, _sgl_lookat from Regal project.c */ +static void _sgl_perspective(_sgl_matrix_t* dst, float fovy, float aspect, float znear, float zfar) { + float sine = sinf(fovy / 2.0f); + float delta_z = zfar - znear; + if ((delta_z == 0.0f) || (sine == 0.0f) || (aspect == 0.0f)) { + return; + } + float cotan = cosf(fovy / 2.0f) / sine; + _sgl_matrix_t m; + _sgl_identity(&m); + m.v[0][0] = cotan / aspect; + m.v[1][1] = cotan; + m.v[2][2] = -(zfar + znear) / delta_z; + m.v[2][3] = -1.0f; + m.v[3][2] = -2.0f * znear * zfar / delta_z; + m.v[3][3] = 0.0f; + _sgl_mul(dst, &m); +} + +static void _sgl_normalize(float v[3]) { + float r = sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + if (r == 0.0f) { + return; + } + v[0] /= r; + v[1] /= r; + v[2] /= r; +} + +static void _sgl_cross(float v1[3], float v2[3], float res[3]) { + res[0] = v1[1]*v2[2] - v1[2]*v2[1]; + res[1] = v1[2]*v2[0] - v1[0]*v2[2]; + res[2] = v1[0]*v2[1] - v1[1]*v2[0]; +} + +static void _sgl_lookat(_sgl_matrix_t* dst, + float eye_x, float eye_y, float eye_z, + float center_x, float center_y, float center_z, + float up_x, float up_y, float up_z) +{ + float fwd[3], side[3], up[3]; + + fwd[0] = center_x - eye_x; fwd[1] = center_y - eye_y; fwd[2] = center_z - eye_z; + up[0] = up_x; up[1] = up_y; up[2] = up_z; + _sgl_normalize(fwd); + _sgl_cross(fwd, up, side); + _sgl_normalize(side); + _sgl_cross(side, fwd, up); + + _sgl_matrix_t m; + _sgl_identity(&m); + m.v[0][0] = side[0]; + m.v[1][0] = side[1]; + m.v[2][0] = side[2]; + m.v[0][1] = up[0]; + m.v[1][1] = up[1]; + m.v[2][1] = up[2]; + m.v[0][2] = -fwd[0]; + m.v[1][2] = -fwd[1]; + m.v[2][2] = -fwd[2]; + _sgl_mul(dst, &m); + _sgl_translate(dst, -eye_x, -eye_y, -eye_z); +} + +/* current top-of-stack projection matrix */ +static _sgl_matrix_t* _sgl_matrix_projection(_sgl_context_t* ctx) { + return &ctx->matrix_stack[SGL_MATRIXMODE_PROJECTION][ctx->matrix_tos[SGL_MATRIXMODE_PROJECTION]]; +} + +/* get top-of-stack modelview matrix */ +static _sgl_matrix_t* _sgl_matrix_modelview(_sgl_context_t* ctx) { + return &ctx->matrix_stack[SGL_MATRIXMODE_MODELVIEW][ctx->matrix_tos[SGL_MATRIXMODE_MODELVIEW]]; +} + +/* get top-of-stack texture matrix */ +static _sgl_matrix_t* _sgl_matrix_texture(_sgl_context_t* ctx) { + return &ctx->matrix_stack[SGL_MATRIXMODE_TEXTURE][ctx->matrix_tos[SGL_MATRIXMODE_TEXTURE]]; +} + +/* get pointer to current top-of-stack of current matrix mode */ +static _sgl_matrix_t* _sgl_matrix(_sgl_context_t* ctx) { + return &ctx->matrix_stack[ctx->cur_matrix_mode][ctx->matrix_tos[ctx->cur_matrix_mode]]; +} + +// return sg_context_desc_t with patched defaults +static sgl_desc_t _sgl_desc_defaults(const sgl_desc_t* desc) { + SOKOL_ASSERT((desc->allocator.alloc && desc->allocator.free) || (!desc->allocator.alloc && !desc->allocator.free)); + sgl_desc_t res = *desc; + res.max_vertices = _sgl_def(desc->max_vertices, _SGL_DEFAULT_MAX_VERTICES); + res.max_commands = _sgl_def(desc->max_commands, _SGL_DEFAULT_MAX_COMMANDS); + res.context_pool_size = _sgl_def(desc->context_pool_size, _SGL_DEFAULT_CONTEXT_POOL_SIZE); + res.pipeline_pool_size = _sgl_def(desc->pipeline_pool_size, _SGL_DEFAULT_PIPELINE_POOL_SIZE); + res.face_winding = _sgl_def(desc->face_winding, SG_FACEWINDING_CCW); + return res; +} + +// create resources which are shared between all contexts +static void _sgl_setup_common(void) { + sg_push_debug_group("sokol-gl"); + + uint32_t pixels[64]; + for (int i = 0; i < 64; i++) { + pixels[i] = 0xFFFFFFFF; + } + sg_image_desc img_desc; + _sgl_clear(&img_desc, sizeof(img_desc)); + img_desc.type = SG_IMAGETYPE_2D; + img_desc.width = 8; + img_desc.height = 8; + img_desc.num_mipmaps = 1; + img_desc.pixel_format = SG_PIXELFORMAT_RGBA8; + img_desc.min_filter = SG_FILTER_NEAREST; + img_desc.mag_filter = SG_FILTER_NEAREST; + img_desc.data.subimage[0][0] = SG_RANGE(pixels); + img_desc.label = "sgl-default-texture"; + _sgl.def_img = sg_make_image(&img_desc); + SOKOL_ASSERT(SG_INVALID_ID != _sgl.def_img.id); + + // one shader for all contexts + sg_shader_desc shd_desc; + _sgl_clear(&shd_desc, sizeof(shd_desc)); + shd_desc.attrs[0].name = "position"; + shd_desc.attrs[1].name = "texcoord0"; + shd_desc.attrs[2].name = "color0"; + shd_desc.attrs[3].name = "psize"; + shd_desc.attrs[0].sem_name = "TEXCOORD"; + shd_desc.attrs[0].sem_index = 0; + shd_desc.attrs[1].sem_name = "TEXCOORD"; + shd_desc.attrs[1].sem_index = 1; + shd_desc.attrs[2].sem_name = "TEXCOORD"; + shd_desc.attrs[2].sem_index = 2; + shd_desc.attrs[3].sem_name = "TEXCOORD"; + shd_desc.attrs[3].sem_index = 3; + sg_shader_uniform_block_desc* ub = &shd_desc.vs.uniform_blocks[0]; + ub->size = sizeof(_sgl_uniform_t); + ub->uniforms[0].name = "vs_params"; + ub->uniforms[0].type = SG_UNIFORMTYPE_FLOAT4; + ub->uniforms[0].array_count = 8; + shd_desc.fs.images[0].name = "tex"; + shd_desc.fs.images[0].image_type = SG_IMAGETYPE_2D; + shd_desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; + shd_desc.label = "sgl-shader"; + #if defined(SOKOL_GLCORE33) + shd_desc.vs.source = _sgl_vs_source_glsl330; + shd_desc.fs.source = _sgl_fs_source_glsl330; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _sgl_vs_source_glsl300es; + shd_desc.fs.source = _sgl_fs_source_glsl300es; + #elif defined(SOKOL_METAL) + shd_desc.vs.entry = "main0"; + shd_desc.fs.entry = "main0"; + switch (sg_query_backend()) { + case SG_BACKEND_METAL_MACOS: + shd_desc.vs.bytecode = SG_RANGE(_sgl_vs_bytecode_metal_macos); + shd_desc.fs.bytecode = SG_RANGE(_sgl_fs_bytecode_metal_macos); + break; + case SG_BACKEND_METAL_IOS: + shd_desc.vs.bytecode = SG_RANGE(_sgl_vs_bytecode_metal_ios); + shd_desc.fs.bytecode = SG_RANGE(_sgl_fs_bytecode_metal_ios); + break; + default: + shd_desc.vs.source = _sgl_vs_source_metal_sim; + shd_desc.fs.source = _sgl_fs_source_metal_sim; + break; + } + #elif defined(SOKOL_D3D11) + shd_desc.vs.bytecode = SG_RANGE(_sgl_vs_bytecode_hlsl4); + shd_desc.fs.bytecode = SG_RANGE(_sgl_fs_bytecode_hlsl4); + #elif defined(SOKOL_WGPU) + shd_desc.vs.bytecode = SG_RANGE(_sgl_vs_bytecode_wgpu); + shd_desc.fs.bytecode = SG_RANGE(_sgl_fs_bytecode_wgpu); + #else + shd_desc.vs.source = _sgl_vs_source_dummy; + shd_desc.fs.source = _sgl_fs_source_dummy; + #endif + _sgl.shd = sg_make_shader(&shd_desc); + SOKOL_ASSERT(SG_INVALID_ID != _sgl.shd.id); + sg_pop_debug_group(); +} + +// discard resources which are shared between all contexts +static void _sgl_discard_common(void) { + sg_push_debug_group("sokol-gl"); + sg_destroy_image(_sgl.def_img); + sg_destroy_shader(_sgl.shd); + sg_pop_debug_group(); +} + +static bool _sgl_is_default_context(sgl_context ctx_id) { + return ctx_id.id == SGL_DEFAULT_CONTEXT.id; +} + +static void _sgl_draw(_sgl_context_t* ctx, int layer_id) { + SOKOL_ASSERT(ctx); + if ((ctx->error == SGL_NO_ERROR) && (ctx->vertices.next > 0) && (ctx->commands.next > 0)) { + sg_push_debug_group("sokol-gl"); + + uint32_t cur_pip_id = SG_INVALID_ID; + uint32_t cur_img_id = SG_INVALID_ID; + int cur_uniform_index = -1; + + if (ctx->update_frame_id != ctx->frame_id) { + ctx->update_frame_id = ctx->frame_id; + const sg_range range = { ctx->vertices.ptr, (size_t)ctx->vertices.next * sizeof(_sgl_vertex_t) }; + sg_update_buffer(ctx->vbuf, &range); + } + + for (int i = 0; i < ctx->commands.next; i++) { + const _sgl_command_t* cmd = &ctx->commands.ptr[i]; + if (cmd->layer_id != layer_id) { + continue; + } + switch (cmd->cmd) { + case SGL_COMMAND_VIEWPORT: + { + const _sgl_viewport_args_t* args = &cmd->args.viewport; + sg_apply_viewport(args->x, args->y, args->w, args->h, args->origin_top_left); + } + break; + case SGL_COMMAND_SCISSOR_RECT: + { + const _sgl_scissor_rect_args_t* args = &cmd->args.scissor_rect; + sg_apply_scissor_rect(args->x, args->y, args->w, args->h, args->origin_top_left); + } + break; + case SGL_COMMAND_DRAW: + { + const _sgl_draw_args_t* args = &cmd->args.draw; + if (args->pip.id != cur_pip_id) { + sg_apply_pipeline(args->pip); + cur_pip_id = args->pip.id; + /* when pipeline changes, also need to re-apply uniforms and bindings */ + cur_img_id = SG_INVALID_ID; + cur_uniform_index = -1; + } + if (cur_img_id != args->img.id) { + ctx->bind.fs_images[0] = args->img; + sg_apply_bindings(&ctx->bind); + cur_img_id = args->img.id; + } + if (cur_uniform_index != args->uniform_index) { + const sg_range ub_range = { &ctx->uniforms.ptr[args->uniform_index], sizeof(_sgl_uniform_t) }; + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &ub_range); + cur_uniform_index = args->uniform_index; + } + /* FIXME: what if number of vertices doesn't match the primitive type? */ + if (args->num_vertices > 0) { + sg_draw(args->base_vertex, args->num_vertices, 1); + } + } + break; + } + } + sg_pop_debug_group(); + } +} + +static sgl_context_desc_t _sgl_as_context_desc(const sgl_desc_t* desc) { + sgl_context_desc_t ctx_desc; + _sgl_clear(&ctx_desc, sizeof(ctx_desc)); + ctx_desc.max_vertices = desc->max_vertices; + ctx_desc.max_commands = desc->max_commands; + ctx_desc.color_format = desc->color_format; + ctx_desc.depth_format = desc->depth_format; + ctx_desc.sample_count = desc->sample_count; + return ctx_desc; +} + +// ██████ ██ ██ ██████ ██ ██ ██████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██████ ██ ██ ██████ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██████ ██████ ███████ ██ ██████ +// +// >>public +SOKOL_API_IMPL void sgl_setup(const sgl_desc_t* desc) { + SOKOL_ASSERT(desc); + _sgl_clear(&_sgl, sizeof(_sgl)); + _sgl.init_cookie = _SGL_INIT_COOKIE; + _sgl.desc = _sgl_desc_defaults(desc); + _sgl_setup_pipeline_pool(_sgl.desc.pipeline_pool_size); + _sgl_setup_context_pool(_sgl.desc.context_pool_size); + _sgl_setup_common(); + const sgl_context_desc_t ctx_desc = _sgl_as_context_desc(&_sgl.desc); + _sgl.def_ctx_id = sgl_make_context(&ctx_desc); + SOKOL_ASSERT(SGL_DEFAULT_CONTEXT.id == _sgl.def_ctx_id.id); + sgl_set_context(_sgl.def_ctx_id); +} + +SOKOL_API_IMPL void sgl_shutdown(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + // contexts own a pipeline, so destroy contexts before pipelines + for (int i = 0; i < _sgl.context_pool.pool.size; i++) { + _sgl_context_t* ctx = &_sgl.context_pool.contexts[i]; + _sgl_destroy_context(_sgl_make_ctx_id(ctx->slot.id)); + } + for (int i = 0; i < _sgl.pip_pool.pool.size; i++) { + _sgl_pipeline_t* pip = &_sgl.pip_pool.pips[i]; + _sgl_destroy_pipeline(_sgl_make_pip_id(pip->slot.id)); + } + _sgl_discard_context_pool(); + _sgl_discard_pipeline_pool(); + _sgl_discard_common(); + _sgl.init_cookie = 0; +} + +SOKOL_API_IMPL sgl_error_t sgl_error(void) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + return ctx->error; + } + else { + return SGL_ERROR_NO_CONTEXT; + } +} + +SOKOL_API_IMPL sgl_error_t sgl_context_error(sgl_context ctx_id) { + const _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id); + if (ctx) { + return ctx->error; + } + else { + return SGL_ERROR_NO_CONTEXT; + } +} + +SOKOL_API_IMPL float sgl_rad(float deg) { + return (deg * (float)M_PI) / 180.0f; +} + +SOKOL_API_IMPL float sgl_deg(float rad) { + return (rad * 180.0f) / (float)M_PI; +} + +SOKOL_API_IMPL sgl_context sgl_make_context(const sgl_context_desc_t* desc) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + return _sgl_make_context(desc); +} + +SOKOL_API_IMPL void sgl_destroy_context(sgl_context ctx_id) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + if (_sgl_is_default_context(ctx_id)) { + _SGL_WARN(CANNOT_DESTROY_DEFAULT_CONTEXT); + return; + } + _sgl_destroy_context(ctx_id); + // re-validate the current context pointer (this will return a nullptr + // if we just destroyed the current context) + _sgl.cur_ctx = _sgl_lookup_context(_sgl.cur_ctx_id.id); +} + +SOKOL_API_IMPL void sgl_set_context(sgl_context ctx_id) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + if (_sgl_is_default_context(ctx_id)) { + _sgl.cur_ctx_id = _sgl.def_ctx_id; + } + else { + _sgl.cur_ctx_id = ctx_id; + } + // this will return null if the handle isn't valid + _sgl.cur_ctx = _sgl_lookup_context(_sgl.cur_ctx_id.id); +} + +SOKOL_API_IMPL sgl_context sgl_get_context(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + return _sgl.cur_ctx_id; +} + +SOKOL_API_IMPL sgl_context sgl_default_context(void) { + return SGL_DEFAULT_CONTEXT; +} + +SOKOL_API_IMPL sgl_pipeline sgl_make_pipeline(const sg_pipeline_desc* desc) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + return _sgl_make_pipeline(desc, &ctx->desc); + } + else { + return _sgl_make_pip_id(SG_INVALID_ID); + } +} + +SOKOL_API_IMPL sgl_pipeline sgl_context_make_pipeline(sgl_context ctx_id, const sg_pipeline_desc* desc) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + const _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id); + if (ctx) { + return _sgl_make_pipeline(desc, &ctx->desc); + } + else { + return _sgl_make_pip_id(SG_INVALID_ID); + } +} + +SOKOL_API_IMPL void sgl_destroy_pipeline(sgl_pipeline pip_id) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_destroy_pipeline(pip_id); +} + +SOKOL_API_IMPL void sgl_load_pipeline(sgl_pipeline pip_id) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT((ctx->pip_tos >= 0) && (ctx->pip_tos < _SGL_MAX_STACK_DEPTH)); + ctx->pip_stack[ctx->pip_tos] = pip_id; +} + +SOKOL_API_IMPL void sgl_load_default_pipeline(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT((ctx->pip_tos >= 0) && (ctx->pip_tos < _SGL_MAX_STACK_DEPTH)); + ctx->pip_stack[ctx->pip_tos] = ctx->def_pip; +} + +SOKOL_API_IMPL void sgl_push_pipeline(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + if (ctx->pip_tos < (_SGL_MAX_STACK_DEPTH - 1)) { + ctx->pip_tos++; + ctx->pip_stack[ctx->pip_tos] = ctx->pip_stack[ctx->pip_tos-1]; + } + else { + ctx->error = SGL_ERROR_STACK_OVERFLOW; + } +} + +SOKOL_API_IMPL void sgl_pop_pipeline(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + if (ctx->pip_tos > 0) { + ctx->pip_tos--; + } + else { + ctx->error = SGL_ERROR_STACK_UNDERFLOW; + } +} + +SOKOL_API_IMPL void sgl_defaults(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + ctx->u = 0.0f; ctx->v = 0.0f; + ctx->rgba = 0xFFFFFFFF; + ctx->point_size = 1.0f; + ctx->texturing_enabled = false; + ctx->cur_img = _sgl.def_img; + sgl_load_default_pipeline(); + _sgl_identity(_sgl_matrix_texture(ctx)); + _sgl_identity(_sgl_matrix_modelview(ctx)); + _sgl_identity(_sgl_matrix_projection(ctx)); + ctx->cur_matrix_mode = SGL_MATRIXMODE_MODELVIEW; + ctx->matrix_dirty = true; +} + +SOKOL_API_IMPL void sgl_layer(int layer_id) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + ctx->layer_id = layer_id; +} + +SOKOL_API_IMPL void sgl_viewport(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + _sgl_command_t* cmd = _sgl_next_command(ctx); + if (cmd) { + cmd->cmd = SGL_COMMAND_VIEWPORT; + cmd->layer_id = ctx->layer_id; + cmd->args.viewport.x = x; + cmd->args.viewport.y = y; + cmd->args.viewport.w = w; + cmd->args.viewport.h = h; + cmd->args.viewport.origin_top_left = origin_top_left; + } +} + +SOKOL_API_IMPL void sgl_viewportf(float x, float y, float w, float h, bool origin_top_left) { + sgl_viewport((int)x, (int)y, (int)w, (int)h, origin_top_left); +} + +SOKOL_API_IMPL void sgl_scissor_rect(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + _sgl_command_t* cmd = _sgl_next_command(ctx); + if (cmd) { + cmd->cmd = SGL_COMMAND_SCISSOR_RECT; + cmd->layer_id = ctx->layer_id; + cmd->args.scissor_rect.x = x; + cmd->args.scissor_rect.y = y; + cmd->args.scissor_rect.w = w; + cmd->args.scissor_rect.h = h; + cmd->args.scissor_rect.origin_top_left = origin_top_left; + } +} + +SOKOL_API_IMPL void sgl_scissor_rectf(float x, float y, float w, float h, bool origin_top_left) { + sgl_scissor_rect((int)x, (int)y, (int)w, (int)h, origin_top_left); +} + +SOKOL_API_IMPL void sgl_enable_texture(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + ctx->texturing_enabled = true; +} + +SOKOL_API_IMPL void sgl_disable_texture(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + ctx->texturing_enabled = false; +} + +SOKOL_API_IMPL void sgl_texture(sg_image img) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + if (SG_INVALID_ID != img.id) { + ctx->cur_img = img; + } + else { + ctx->cur_img = _sgl.def_img; + } +} + +SOKOL_API_IMPL void sgl_begin_points(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + _sgl_begin(ctx, SGL_PRIMITIVETYPE_POINTS); +} + +SOKOL_API_IMPL void sgl_begin_lines(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + _sgl_begin(ctx, SGL_PRIMITIVETYPE_LINES); +} + +SOKOL_API_IMPL void sgl_begin_line_strip(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + _sgl_begin(ctx, SGL_PRIMITIVETYPE_LINE_STRIP); +} + +SOKOL_API_IMPL void sgl_begin_triangles(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + _sgl_begin(ctx, SGL_PRIMITIVETYPE_TRIANGLES); +} + +SOKOL_API_IMPL void sgl_begin_triangle_strip(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + _sgl_begin(ctx, SGL_PRIMITIVETYPE_TRIANGLE_STRIP); +} + +SOKOL_API_IMPL void sgl_begin_quads(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(!ctx->in_begin); + _sgl_begin(ctx, SGL_PRIMITIVETYPE_QUADS); +} + +SOKOL_API_IMPL void sgl_end(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT(ctx->in_begin); + SOKOL_ASSERT(ctx->vertices.next >= ctx->base_vertex); + ctx->in_begin = false; + bool matrix_dirty = ctx->matrix_dirty; + if (matrix_dirty) { + ctx->matrix_dirty = false; + _sgl_uniform_t* uni = _sgl_next_uniform(ctx); + if (uni) { + _sgl_matmul4(&uni->mvp, _sgl_matrix_projection(ctx), _sgl_matrix_modelview(ctx)); + uni->tm = *_sgl_matrix_texture(ctx); + } + } + /* check if command can be merged with current command */ + sg_pipeline pip = _sgl_get_pipeline(ctx->pip_stack[ctx->pip_tos], ctx->cur_prim_type); + sg_image img = ctx->texturing_enabled ? ctx->cur_img : _sgl.def_img; + _sgl_command_t* cur_cmd = _sgl_cur_command(ctx); + bool merge_cmd = false; + if (cur_cmd) { + if ((cur_cmd->cmd == SGL_COMMAND_DRAW) && + (cur_cmd->layer_id == ctx->layer_id) && + (ctx->cur_prim_type != SGL_PRIMITIVETYPE_LINE_STRIP) && + (ctx->cur_prim_type != SGL_PRIMITIVETYPE_TRIANGLE_STRIP) && + !matrix_dirty && + (cur_cmd->args.draw.img.id == img.id) && + (cur_cmd->args.draw.pip.id == pip.id)) + { + merge_cmd = true; + } + } + if (merge_cmd) { + /* draw command can be merged with the previous command */ + cur_cmd->args.draw.num_vertices += ctx->vertices.next - ctx->base_vertex; + } + else { + /* append a new draw command */ + _sgl_command_t* cmd = _sgl_next_command(ctx); + if (cmd) { + SOKOL_ASSERT(ctx->uniforms.next > 0); + cmd->cmd = SGL_COMMAND_DRAW; + cmd->layer_id = ctx->layer_id; + cmd->args.draw.img = img; + cmd->args.draw.pip = _sgl_get_pipeline(ctx->pip_stack[ctx->pip_tos], ctx->cur_prim_type); + cmd->args.draw.base_vertex = ctx->base_vertex; + cmd->args.draw.num_vertices = ctx->vertices.next - ctx->base_vertex; + cmd->args.draw.uniform_index = ctx->uniforms.next - 1; + } + } +} + +SOKOL_API_IMPL void sgl_point_size(float s) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->point_size = s; + } +} + +SOKOL_API_IMPL void sgl_t2f(float u, float v) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->u = u; + ctx->v = v; + } +} + +SOKOL_API_IMPL void sgl_c3f(float r, float g, float b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->rgba = _sgl_pack_rgbaf(r, g, b, 1.0f); + } +} + +SOKOL_API_IMPL void sgl_c4f(float r, float g, float b, float a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->rgba = _sgl_pack_rgbaf(r, g, b, a); + } +} + +SOKOL_API_IMPL void sgl_c3b(uint8_t r, uint8_t g, uint8_t b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->rgba = _sgl_pack_rgbab(r, g, b, 255); + } +} + +SOKOL_API_IMPL void sgl_c4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->rgba = _sgl_pack_rgbab(r, g, b, a); + } +} + +SOKOL_API_IMPL void sgl_c1i(uint32_t rgba) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->rgba = rgba; + } +} + +SOKOL_API_IMPL void sgl_v2f(float x, float y) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, ctx->rgba); + } +} + +SOKOL_API_IMPL void sgl_v3f(float x, float y, float z) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, ctx->rgba); + } +} + +SOKOL_API_IMPL void sgl_v2f_t2f(float x, float y, float u, float v) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, u, v, ctx->rgba); + } +} + +SOKOL_API_IMPL void sgl_v3f_t2f(float x, float y, float z, float u, float v) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, u, v, ctx->rgba); + } +} + +SOKOL_API_IMPL void sgl_v2f_c3f(float x, float y, float r, float g, float b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, _sgl_pack_rgbaf(r, g, b, 1.0f)); + } +} + +SOKOL_API_IMPL void sgl_v2f_c3b(float x, float y, uint8_t r, uint8_t g, uint8_t b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, _sgl_pack_rgbab(r, g, b, 255)); + } +} + +SOKOL_API_IMPL void sgl_v2f_c4f(float x, float y, float r, float g, float b, float a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, _sgl_pack_rgbaf(r, g, b, a)); + } +} + +SOKOL_API_IMPL void sgl_v2f_c4b(float x, float y, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, _sgl_pack_rgbab(r, g, b, a)); + } +} + +SOKOL_API_IMPL void sgl_v2f_c1i(float x, float y, uint32_t rgba) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, rgba); + } +} + +SOKOL_API_IMPL void sgl_v3f_c3f(float x, float y, float z, float r, float g, float b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, _sgl_pack_rgbaf(r, g, b, 1.0f)); + } +} + +SOKOL_API_IMPL void sgl_v3f_c3b(float x, float y, float z, uint8_t r, uint8_t g, uint8_t b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, _sgl_pack_rgbab(r, g, b, 255)); + } +} + +SOKOL_API_IMPL void sgl_v3f_c4f(float x, float y, float z, float r, float g, float b, float a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, _sgl_pack_rgbaf(r, g, b, a)); + } +} + +SOKOL_API_IMPL void sgl_v3f_c4b(float x, float y, float z, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, _sgl_pack_rgbab(r, g, b, a)); + } +} + +SOKOL_API_IMPL void sgl_v3f_c1i(float x, float y, float z, uint32_t rgba) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, rgba); + } +} + +SOKOL_API_IMPL void sgl_v2f_t2f_c3f(float x, float y, float u, float v, float r, float g, float b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, u, v, _sgl_pack_rgbaf(r, g, b, 1.0f)); + } +} + +SOKOL_API_IMPL void sgl_v2f_t2f_c3b(float x, float y, float u, float v, uint8_t r, uint8_t g, uint8_t b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, u, v, _sgl_pack_rgbab(r, g, b, 255)); + } +} + +SOKOL_API_IMPL void sgl_v2f_t2f_c4f(float x, float y, float u, float v, float r, float g, float b, float a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, u, v, _sgl_pack_rgbaf(r, g, b, a)); + } +} + +SOKOL_API_IMPL void sgl_v2f_t2f_c4b(float x, float y, float u, float v, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, u, v, _sgl_pack_rgbab(r, g, b, a)); + } +} + +SOKOL_API_IMPL void sgl_v2f_t2f_c1i(float x, float y, float u, float v, uint32_t rgba) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, 0.0f, u, v, rgba); + } +} + +SOKOL_API_IMPL void sgl_v3f_t2f_c3f(float x, float y, float z, float u, float v, float r, float g, float b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, u, v, _sgl_pack_rgbaf(r, g, b, 1.0f)); + } +} + +SOKOL_API_IMPL void sgl_v3f_t2f_c3b(float x, float y, float z, float u, float v, uint8_t r, uint8_t g, uint8_t b) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, u, v, _sgl_pack_rgbab(r, g, b, 255)); + } +} + +SOKOL_API_IMPL void sgl_v3f_t2f_c4f(float x, float y, float z, float u, float v, float r, float g, float b, float a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, u, v, _sgl_pack_rgbaf(r, g, b, a)); + } +} + +SOKOL_API_IMPL void sgl_v3f_t2f_c4b(float x, float y, float z, float u, float v, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx, x, y, z, u, v, _sgl_pack_rgbab(r, g, b, a)); + } +} + +SOKOL_API_IMPL void sgl_v3f_t2f_c1i(float x, float y, float z, float u, float v, uint32_t rgba) { + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_vtx(ctx,x, y, z, u, v, rgba); + } +} + +SOKOL_API_IMPL void sgl_matrix_mode_modelview(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->cur_matrix_mode = SGL_MATRIXMODE_MODELVIEW; + } +} + +SOKOL_API_IMPL void sgl_matrix_mode_projection(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->cur_matrix_mode = SGL_MATRIXMODE_PROJECTION; + } +} + +SOKOL_API_IMPL void sgl_matrix_mode_texture(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + ctx->cur_matrix_mode = SGL_MATRIXMODE_TEXTURE; + } +} + +SOKOL_API_IMPL void sgl_load_identity(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_identity(_sgl_matrix(ctx)); +} + +SOKOL_API_IMPL void sgl_load_matrix(const float m[16]) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + memcpy(&_sgl_matrix(ctx)->v[0][0], &m[0], 64); +} + +SOKOL_API_IMPL void sgl_load_transpose_matrix(const float m[16]) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_transpose(_sgl_matrix(ctx), (const _sgl_matrix_t*) &m[0]); +} + +SOKOL_API_IMPL void sgl_mult_matrix(const float m[16]) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + const _sgl_matrix_t* m0 = (const _sgl_matrix_t*) &m[0]; + _sgl_mul(_sgl_matrix(ctx), m0); +} + +SOKOL_API_IMPL void sgl_mult_transpose_matrix(const float m[16]) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_matrix_t m0; + _sgl_transpose(&m0, (const _sgl_matrix_t*) &m[0]); + _sgl_mul(_sgl_matrix(ctx), &m0); +} + +SOKOL_API_IMPL void sgl_rotate(float angle_rad, float x, float y, float z) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_rotate(_sgl_matrix(ctx), angle_rad, x, y, z); +} + +SOKOL_API_IMPL void sgl_scale(float x, float y, float z) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_scale(_sgl_matrix(ctx), x, y, z); +} + +SOKOL_API_IMPL void sgl_translate(float x, float y, float z) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_translate(_sgl_matrix(ctx), x, y, z); +} + +SOKOL_API_IMPL void sgl_frustum(float l, float r, float b, float t, float n, float f) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_frustum(_sgl_matrix(ctx), l, r, b, t, n, f); +} + +SOKOL_API_IMPL void sgl_ortho(float l, float r, float b, float t, float n, float f) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_ortho(_sgl_matrix(ctx), l, r, b, t, n, f); +} + +SOKOL_API_IMPL void sgl_perspective(float fov_y, float aspect, float z_near, float z_far) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_perspective(_sgl_matrix(ctx), fov_y, aspect, z_near, z_far); +} + +SOKOL_API_IMPL void sgl_lookat(float eye_x, float eye_y, float eye_z, float center_x, float center_y, float center_z, float up_x, float up_y, float up_z) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + ctx->matrix_dirty = true; + _sgl_lookat(_sgl_matrix(ctx), eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z); +} + +SOKOL_GL_API_DECL void sgl_push_matrix(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT((ctx->cur_matrix_mode >= 0) && (ctx->cur_matrix_mode < SGL_NUM_MATRIXMODES)); + ctx->matrix_dirty = true; + if (ctx->matrix_tos[ctx->cur_matrix_mode] < (_SGL_MAX_STACK_DEPTH - 1)) { + const _sgl_matrix_t* src = _sgl_matrix(ctx); + ctx->matrix_tos[ctx->cur_matrix_mode]++; + _sgl_matrix_t* dst = _sgl_matrix(ctx); + *dst = *src; + } + else { + ctx->error = SGL_ERROR_STACK_OVERFLOW; + } +} + +SOKOL_GL_API_DECL void sgl_pop_matrix(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (!ctx) { + return; + } + SOKOL_ASSERT((ctx->cur_matrix_mode >= 0) && (ctx->cur_matrix_mode < SGL_NUM_MATRIXMODES)); + ctx->matrix_dirty = true; + if (ctx->matrix_tos[ctx->cur_matrix_mode] > 0) { + ctx->matrix_tos[ctx->cur_matrix_mode]--; + } + else { + ctx->error = SGL_ERROR_STACK_UNDERFLOW; + } +} + +SOKOL_API_IMPL void sgl_draw(void) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_draw(ctx, 0); + } +} + +SOKOL_API_IMPL void sgl_draw_layer(int layer_id) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl.cur_ctx; + if (ctx) { + _sgl_draw(ctx, layer_id); + } +} + +SOKOL_API_IMPL void sgl_context_draw(sgl_context ctx_id) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id); + if (ctx) { + _sgl_draw(ctx, 0); + } +} + +SOKOL_API_IMPL void sgl_context_draw_layer(sgl_context ctx_id, int layer_id) { + SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie); + _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id); + if (ctx) { + _sgl_draw(ctx, layer_id); + } +} + +#endif /* SOKOL_GL_IMPL */ diff --git a/source/engine/thirdparty/sokol/sokol_imgui.h b/source/engine/thirdparty/sokol/sokol_imgui.h new file mode 100644 index 0000000..48e36f5 --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_imgui.h @@ -0,0 +1,2457 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_IMGUI_IMPL) +#define SOKOL_IMGUI_IMPL +#endif +#ifndef SOKOL_IMGUI_INCLUDED +/* + sokol_imgui.h -- drop-in Dear ImGui renderer/event-handler for sokol_gfx.h + + Project URL: https://github.com/floooh/sokol + + Do this: + #define SOKOL_IMPL or + #define SOKOL_IMGUI_IMPL + + before you include this file in *one* C or C++ file to create the + implementation. + + NOTE that the implementation can be compiled either as C++ or as C. + When compiled as C++, sokol_imgui.h will directly call into the + Dear ImGui C++ API. When compiled as C, sokol_imgui.h will call + cimgui.h functions instead. + + NOTE that the formerly separate header sokol_cimgui.h has been + merged into sokol_imgui.h + + The following defines are used by the implementation to select the + platform-specific embedded shader code (these are the same defines as + used by sokol_gfx.h and sokol_app.h): + + SOKOL_GLCORE33 + SOKOL_GLES3 + SOKOL_D3D11 + SOKOL_METAL + SOKOL_WGPU + + Optionally provide the following configuration defines before including the + implementation: + + SOKOL_IMGUI_NO_SOKOL_APP - don't depend on sokol_app.h (see below for details) + + Optionally provide the following macros before including the implementation + to override defaults: + + SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) + SOKOL_IMGUI_API_DECL- public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_IMGUI_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + + If sokol_imgui.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + On Windows, SOKOL_DLL will define SOKOL_IMGUI_API_DECL as __declspec(dllexport) + or __declspec(dllimport) as needed. + + Include the following headers before sokol_imgui.h (both before including + the declaration and implementation): + + sokol_gfx.h + sokol_app.h (except SOKOL_IMGUI_NO_SOKOL_APP) + + Additionally, include the following headers before including the + implementation: + + If the implementation is compiled as C++: + imgui.h + + If the implementation is compiled as C: + cimgui.h + + + FEATURE OVERVIEW: + ================= + sokol_imgui.h implements the initialization, rendering and event-handling + code for Dear ImGui (https://github.com/ocornut/imgui) on top of + sokol_gfx.h and (optionally) sokol_app.h. + + The sokol_app.h dependency is optional and used for input event handling. + If you only use sokol_gfx.h but not sokol_app.h in your application, + define SOKOL_IMGUI_NO_SOKOL_APP before including the implementation + of sokol_imgui.h, this will remove any dependency to sokol_app.h, but + you must feed input events into Dear ImGui yourself. + + sokol_imgui.h is not thread-safe, all calls must be made from the + same thread where sokol_gfx.h is running. + + HOWTO: + ====== + + --- To initialize sokol-imgui, call: + + simgui_setup(const simgui_desc_t* desc) + + This will initialize Dear ImGui and create sokol-gfx resources + (two buffers for vertices and indices, a font texture and a pipeline- + state-object). + + Use the following simgui_desc_t members to configure behaviour: + + int max_vertices + The maximum number of vertices used for UI rendering, default is 65536. + sokol-imgui will use this to compute the size of the vertex- + and index-buffers allocated via sokol_gfx.h + + sg_pixel_format color_format + The color pixel format of the render pass where the UI + will be rendered. The default (0) matches sokoL_gfx.h's + default pass. + + sg_pixel_format depth_format + The depth-buffer pixel format of the render pass where + the UI will be rendered. The default (0) matches + sokol_gfx.h's default pass depth format. + + int sample_count + The MSAA sample-count of the render pass where the UI + will be rendered. The default (0) matches sokol_gfx.h's + default pass sample count. + + const char* ini_filename + Sets this path as ImGui::GetIO().IniFilename where ImGui will store + and load UI persistency data. By default this is 0, so that Dear ImGui + will not preserve state between sessions (and also won't do + any filesystem calls). Also see the ImGui functions: + - LoadIniSettingsFromMemory() + - SaveIniSettingsFromMemory() + These functions give you explicit control over loading and saving + UI state while using your own filesystem wrapper functions (in this + case keep simgui_desc.ini_filename zero) + + bool no_default_font + Set this to true if you don't want to use ImGui's default + font. In this case you need to initialize the font + yourself after simgui_setup() is called. + + bool disable_paste_override + If set to true, sokol_imgui.h will not 'emulate' a Dear Imgui + clipboard paste action on SAPP_EVENTTYPE_CLIPBOARD_PASTED event. + This is mainly a hack/workaround to allow external workarounds + for making copy/paste work on the web platform. In general, + copy/paste support isn't properly fleshed out in sokol_imgui.h yet. + + bool disable_set_mouse_cursor + If true, sokol_imgui.h will not control the mouse cursor type + by calling sapp_set_mouse_cursor(). + + bool disable_windows_resize_from_edges + If true, windows can only be resized from the bottom right corner. + The default is false, meaning windows can be resized from edges. + + bool write_alpha_channel + Set this to true if you want alpha values written to the + framebuffer. By default this behavior is disabled to prevent + undesired behavior on platforms like the web where the canvas is + always alpha-blended with the background. + + simgui_allocator_t allocator + Used to override memory allocation functions. See further below + for details. + + --- At the start of a frame, call: + + simgui_new_frame(&(simgui_frame_desc_t){.width = ..., .height = ..., .delta_time = ..., .dpi_scale = ...}); + + 'width' and 'height' are the dimensions of the rendering surface, + passed to ImGui::GetIO().DisplaySize. + + 'delta_time' is the frame duration passed to ImGui::GetIO().DeltaTime. + + 'dpi_scale' is the current DPI scale factor, if this is left zero-initialized, + 1.0f will be used instead. Typical values for dpi_scale are >= 1.0f. + + For example, if you're using sokol_app.h and render to the default framebuffer: + + simgui_new_frame(&(simgui_frame_desc_t){ + .width = sapp_width(), + .height = sapp_height(), + .delta_time = sapp_frame_duration(), + .dpi_scale = sapp_dpi_scale() + }); + + --- at the end of the frame, before the sg_end_pass() where you + want to render the UI, call: + + simgui_render() + + This will first call ImGui::Render(), and then render ImGui's draw list + through sokol_gfx.h + + --- if you're using sokol_app.h, from inside the sokol_app.h event callback, + call: + + bool simgui_handle_event(const sapp_event* ev); + + The return value is the value of ImGui::GetIO().WantCaptureKeyboard, + if this is true, you might want to skip keyboard input handling + in your own event handler. + + If you want to use the ImGui functions for checking if a key is pressed + (e.g. ImGui::IsKeyPressed()) the following helper function to map + an sapp_keycode to an ImGuiKey value may be useful: + + int simgui_map_keycode(sapp_keycode c); + + Note that simgui_map_keycode() can be called outside simgui_setup()/simgui_shutdown(). + + --- finally, on application shutdown, call + + simgui_shutdown() + + + MEMORY ALLOCATION OVERRIDE + ========================== + You can override the memory allocation functions at initialization time + like this: + + void* my_alloc(size_t size, void* user_data) { + return malloc(size); + } + + void my_free(void* ptr, void* user_data) { + free(ptr); + } + + ... + simgui_setup(&(simgui_desc_t){ + // ... + .allocator = { + .alloc = my_alloc, + .free = my_free, + .user_data = ...; + } + }); + ... + + If no overrides are provided, malloc and free will be used. + + This only affects memory allocation calls done by sokol_imgui.h + itself though, not any allocations in Dear ImGui. + + + LICENSE + ======= + + zlib/libpng license + + Copyright (c) 2018 Andre Weissflog + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_IMGUI_INCLUDED (1) +#include +#include +#include // size_t + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_imgui.h" +#endif +#if !defined(SOKOL_IMGUI_NO_SOKOL_APP) && !defined(SOKOL_APP_INCLUDED) +#error "Please include sokol_app.h before sokol_imgui.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_IMGUI_API_DECL) +#define SOKOL_IMGUI_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_IMGUI_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_IMGUI_IMPL) +#define SOKOL_IMGUI_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_IMGUI_API_DECL __declspec(dllimport) +#else +#define SOKOL_IMGUI_API_DECL extern +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + simgui_allocator_t + + Used in simgui_desc_t to provide custom memory-alloc and -free functions + to sokol_imgui.h. If memory management should be overridden, both the + alloc and free function must be provided (e.g. it's not valid to + override one function but not the other). +*/ +typedef struct simgui_allocator_t { + void* (*alloc)(size_t size, void* user_data); + void (*free)(void* ptr, void* user_data); + void* user_data; +} simgui_allocator_t; + +typedef struct simgui_desc_t { + int max_vertices; + sg_pixel_format color_format; + sg_pixel_format depth_format; + int sample_count; + const char* ini_filename; + bool no_default_font; + bool disable_paste_override; // if true, don't send Ctrl-V on EVENTTYPE_CLIPBOARD_PASTED + bool disable_set_mouse_cursor; // if true, don't control the mouse cursor type via sapp_set_mouse_cursor() + bool disable_windows_resize_from_edges; // if true, only resize edges from the bottom right corner + bool write_alpha_channel; // if true, alpha values get written into the framebuffer + simgui_allocator_t allocator; // optional memory allocation overrides (default: malloc/free) +} simgui_desc_t; + +typedef struct simgui_frame_desc_t { + int width; + int height; + double delta_time; + float dpi_scale; +} simgui_frame_desc_t; + +SOKOL_IMGUI_API_DECL void simgui_setup(const simgui_desc_t* desc); +SOKOL_IMGUI_API_DECL void simgui_new_frame(const simgui_frame_desc_t* desc); +SOKOL_IMGUI_API_DECL void simgui_render(void); +#if !defined(SOKOL_IMGUI_NO_SOKOL_APP) +SOKOL_IMGUI_API_DECL bool simgui_handle_event(const sapp_event* ev); +SOKOL_IMGUI_API_DECL int simgui_map_keycode(sapp_keycode keycode); // returns ImGuiKey_* +#endif +SOKOL_IMGUI_API_DECL void simgui_shutdown(void); + +#ifdef __cplusplus +} /* extern "C" */ + +/* reference-based equivalents for C++ */ +inline void simgui_setup(const simgui_desc_t& desc) { return simgui_setup(&desc); } +inline void simgui_new_frame(const simgui_frame_desc_t& desc) { return simgui_new_frame(&desc); } + +#endif +#endif /* SOKOL_IMGUI_INCLUDED */ + +/*-- IMPLEMENTATION ----------------------------------------------------------*/ +#ifdef SOKOL_IMGUI_IMPL +#define SOKOL_IMGUI_IMPL_INCLUDED (1) + +#if defined(SOKOL_MALLOC) || defined(SOKOL_CALLOC) || defined(SOKOL_FREE) +#error "SOKOL_MALLOC/CALLOC/FREE macros are no longer supported, please use simgui_desc_t.allocator to override memory allocation functions" +#endif + +#if defined(__cplusplus) + #if !defined(IMGUI_VERSION) + #error "Please include imgui.h before the sokol_imgui.h implementation" + #endif +#else + #if !defined(CIMGUI_INCLUDED) + #error "Please include cimgui.h before the sokol_imgui.h implementation" + #endif +#endif + +#include // memset +#include // malloc/free + +#if defined(__EMSCRIPTEN__) && !defined(SOKOL_DUMMY_BACKEND) +#include +#endif + +#ifndef SOKOL_API_IMPL +#define SOKOL_API_IMPL +#endif +#ifndef SOKOL_DEBUG + #ifndef NDEBUG + #define SOKOL_DEBUG + #endif +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif +#ifndef _SOKOL_PRIVATE + #if defined(__GNUC__) || defined(__clang__) + #define _SOKOL_PRIVATE __attribute__((unused)) static + #else + #define _SOKOL_PRIVATE static + #endif +#endif + +/* helper macros and constants */ +#define _simgui_def(val, def) (((val) == 0) ? (def) : (val)) + +typedef struct { + ImVec2 disp_size; + uint8_t _pad_8[8]; +} _simgui_vs_params_t; + +typedef struct { + simgui_desc_t desc; + float cur_dpi_scale; + sg_buffer vbuf; + sg_buffer ibuf; + sg_image img; + sg_shader shd; + sg_pipeline pip; + sg_range vertices; + sg_range indices; + bool is_osx; // return true if running on OSX (or HTML5 OSX), needed for copy/paste +} _simgui_state_t; +static _simgui_state_t _simgui; + +/* + Embedded source code compiled with: + + sokol-shdc -i simgui.glsl -o simgui.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + + (not that for Metal and D3D11 byte code, sokol-shdc must be run + on macOS and Windows) + + @vs vs + uniform vs_params { + vec2 disp_size; + }; + in vec2 position; + in vec2 texcoord0; + in vec4 color0; + out vec2 uv; + out vec4 color; + void main() { + gl_Position = vec4(((position/disp_size)-0.5)*vec2(2.0,-2.0), 0.5, 1.0); + uv = texcoord0; + color = color0; + } + @end + + @fs fs + uniform sampler2D tex; + in vec2 uv; + in vec4 color; + out vec4 frag_color; + void main() { + frag_color = texture(tex, uv) * color; + } + @end + + @program simgui vs fs +*/ +#if defined(SOKOL_GLCORE33) +static const char _simgui_vs_source_glsl330[341] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e, + 0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20, + 0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f, + 0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28, + 0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20,0x76,0x73,0x5f, + 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2d,0x20, + 0x76,0x65,0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63, + 0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x2c,0x20,0x30,0x2e, + 0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20, + 0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b, + 0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _simgui_fs_source_glsl330[169] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20, + 0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63, + 0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76, + 0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69,0x6e,0x20,0x76, + 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, + 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75, + 0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_GLES3) +static const char _simgui_vs_source_glsl300es[344] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c, + 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20, + 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f, + 0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65, + 0x63,0x34,0x28,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x29, + 0x20,0x2d,0x20,0x76,0x65,0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20, + 0x76,0x65,0x63,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x2c, + 0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _simgui_fs_source_glsl300es[242] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a, + 0x0a,0x00, +}; +#elif defined(SOKOL_METAL) +static const uint8_t _simgui_vs_bytecode_metal_macos[3216] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x90,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x80,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0xef,0xd7,0x24,0x0b,0xf0,0x26,0xba, + 0xcd,0xc3,0x6f,0x48,0x91,0x7a,0x7c,0x38,0xca,0xb8,0xf1,0xb1,0xe3,0xc7,0x99,0x8d, + 0xac,0x39,0x8e,0x2f,0xf8,0xa3,0x19,0x68,0x22,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x37,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x22,0x00,0x03,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x56,0x41,0x54,0x59,0x05,0x00,0x03, + 0x00,0x04,0x04,0x06,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54, + 0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x60,0x0b,0x00,0x00, + 0xff,0xff,0xff,0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0xd5,0x02,0x00,0x00, + 0x0b,0x82,0x20,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91, + 0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19, + 0x1e,0x04,0x8b,0x62,0x80,0x10,0x45,0x02,0x42,0x92,0x0b,0x42,0x84,0x10,0x32,0x14, + 0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80, + 0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x08,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0, + 0x01,0x00,0x00,0x00,0x51,0x18,0x00,0x00,0x81,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8, + 0xff,0xff,0xff,0xff,0x01,0x90,0x80,0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87, + 0x71,0xa0,0x07,0x76,0xc8,0x87,0x36,0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72, + 0x20,0x87,0x36,0x20,0x87,0x74,0xb0,0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88, + 0x07,0x79,0xa0,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41, + 0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e,0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c, + 0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87, + 0x72,0x98,0x87,0x79,0x68,0x03,0x78,0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72, + 0x68,0x03,0x73,0x80,0x87,0x76,0x08,0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e, + 0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda, + 0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81,0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21, + 0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30, + 0x07,0x79,0x08,0x87,0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87, + 0x72,0x90,0x87,0x36,0x28,0x07,0x76,0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77, + 0x68,0x03,0x76,0x28,0x87,0x70,0x30,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70, + 0x07,0x73,0x98,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1, + 0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08, + 0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87, + 0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41, + 0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d, + 0xca,0x81,0x1c,0xda,0x40,0x1f,0xca,0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0, + 0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80, + 0x70,0x87,0x77,0x68,0x03,0x7a,0x90,0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38, + 0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00, + 0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61,0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1, + 0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e,0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4,0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87, + 0x79,0x08,0x07,0x73,0x28,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a, + 0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d, + 0xe6,0xe1,0x1d,0xcc,0x81,0x1e,0xda,0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00, + 0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x36,0x18,0x02,0x01,0x2c,0x40,0x05,0x00, + 0x49,0x18,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,0x00, + 0x1b,0x00,0x00,0x00,0x32,0x22,0x08,0x09,0x20,0x64,0x85,0x04,0x13,0x22,0xa4,0x84, + 0x04,0x13,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x88,0x8c,0x0b,0x84,0x84,0x4c, + 0x10,0x3c,0x33,0x00,0xc3,0x08,0x02,0x30,0x8c,0x40,0x00,0x77,0x49,0x53,0x44,0x09, + 0x93,0xcf,0x00,0x48,0x43,0xff,0x0e,0x35,0xf9,0x0f,0x20,0x28,0xc4,0x80,0x87,0x10, + 0x39,0x48,0x9a,0x22,0x4a,0x98,0xfc,0x4a,0xfa,0x1f,0x20,0x02,0x18,0x09,0x05,0x31, + 0x88,0x40,0x08,0xa5,0x98,0x08,0x29,0xb2,0x81,0x80,0x39,0x02,0x30,0xc8,0x81,0x9c, + 0x23,0x00,0x85,0x41,0x84,0x40,0x18,0x46,0x20,0x92,0x11,0x00,0x00,0x00,0x00,0x00, + 0x13,0xb2,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60, + 0x87,0x72,0x68,0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03, + 0x37,0x88,0x83,0x38,0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71, + 0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80, + 0x07,0x6d,0x90,0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07, + 0x6d,0x90,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d, + 0x90,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60, + 0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71, + 0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40, + 0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07, + 0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a, + 0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60, + 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07, + 0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78, + 0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10, + 0x07,0x79,0x20,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07, + 0x6d,0x60,0x0f,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72, + 0x50,0x07,0x76,0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20, + 0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07, + 0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d, + 0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x39,0x00, + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xc8,0x02,0x01,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0xda, + 0x11,0x00,0xca,0x12,0x18,0x01,0x28,0x88,0x22,0x28,0x84,0x32,0x20,0x1d,0x6b,0x50, + 0x1e,0x82,0x60,0x8c,0x00,0x04,0x41,0x50,0x04,0x03,0x00,0x00,0x79,0x18,0x00,0x00, + 0x16,0x01,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9, + 0xb9,0xb4,0x37,0xb7,0x21,0x46,0x52,0x20,0x80,0x82,0x50,0xb9,0x1b,0x43,0x0b,0x93, + 0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x24,0x02,0x22,0x24,0x06,0xd9,0x20,0x08,0x0e, + 0x8e,0xad,0x0c,0x84,0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d, + 0x24,0x07,0x46,0xc6,0x25,0x86,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac, + 0x25,0x07,0x46,0xc6,0x25,0x86,0xc6,0x25,0x27,0x65,0x88,0x80,0x10,0x43,0x8c,0x44, + 0x48,0x88,0x64,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x41,0x8e,0x44,0x48,0x84, + 0x64,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56, + 0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x40, + 0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61, + 0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04, + 0x64,0x61,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98, + 0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1, + 0x7d,0x91,0xa5,0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11,0x90,0x86,0x61,0x10,0x96,0x26, + 0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6, + 0x45,0xf6,0x56,0x27,0xc6,0x56,0xf6,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44, + 0x40,0x1e,0x92,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b, + 0x5b,0x18,0x5d,0x9a,0x5d,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9, + 0x17,0x59,0xda,0x5c,0x98,0x18,0x5b,0xd9,0x10,0x01,0x89,0x78,0x06,0x61,0x69,0x72, + 0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f, + 0x77,0x69,0x64,0x65,0x5f,0x76,0x65,0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73, + 0x61,0x62,0x6c,0x65,0x43,0x04,0x64,0x62,0x14,0x96,0x26,0xe7,0x62,0x57,0x26,0x47, + 0x57,0x86,0xf7,0xf5,0x56,0x47,0x07,0x57,0x47,0xc7,0xa5,0x6e,0xae,0x4c,0x0e,0x85, + 0xed,0x6d,0xcc,0x0d,0x26,0x85,0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d, + 0x1e,0x5c,0xd9,0x97,0x5b,0x58,0x5b,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x32, + 0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x6e,0x61,0x6d,0x65,0x14,0xea,0xec,0x86, + 0x30,0x48,0x85,0x58,0xc8,0x85,0x60,0x48,0x86,0x68,0x5c,0xea,0xe6,0xca,0xe4,0x50, + 0xd8,0xde,0xc6,0xdc,0x62,0x52,0x68,0x98,0xb1,0xbd,0x85,0xd1,0xd1,0xb0,0x18,0x7b, + 0x63,0x7b,0x93,0x1b,0xc2,0x20,0x15,0xc2,0x21,0x17,0xd2,0x21,0x19,0xe2,0x91,0x09, + 0x4b,0x93,0x73,0x81,0x7b,0x9b,0x4b,0xa3,0x4b,0x7b,0x73,0xe3,0x72,0xc6,0xf6,0x05, + 0xf5,0x36,0x97,0x46,0x97,0xf6,0xe6,0x36,0x44,0x41,0xc0,0x00,0xb9,0x90,0x0e,0xc9, + 0x90,0x30,0x18,0x62,0x20,0x1b,0xf2,0x21,0x62,0x40,0x28,0x2c,0x4d,0xce,0xc5,0xae, + 0x4c,0x8e,0xae,0x0c,0xef,0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x52,0x58,0x9a,0x9c,0x0b, + 0xdb,0xdb,0x58,0x18,0x5d,0xda,0x9b,0xdb,0x57,0x9a,0x1b,0x59,0x19,0x1e,0xb3,0xb3, + 0x32,0xb7,0x32,0xb9,0x30,0xba,0x32,0x32,0x14,0x1c,0xb8,0xb7,0xb9,0x34,0xba,0xb4, + 0x37,0x37,0x22,0x3b,0x99,0x2f,0xb3,0x14,0x22,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x43,0xa8,0x64,0x40,0xc8,0x00,0x29,0x83,0x64,0x48,0x04,0xc4,0x0c,0x90,0x0b, + 0xc1,0x90,0x0c,0x39,0x03,0x6a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x28, + 0x39,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x44,0x76,0x32,0x5f,0x66,0x29, + 0x4c,0xe8,0xca,0xf0,0xc6,0xde,0xde,0xe4,0xc8,0x60,0x86,0x50,0x89,0x80,0x90,0x01, + 0x52,0x06,0x89,0x90,0x08,0x48,0x1a,0x20,0x17,0x82,0x21,0x19,0xa2,0x06,0xbc,0xce, + 0xca,0xdc,0xca,0xe4,0xc2,0xe8,0xca,0xc8,0x50,0x6c,0xc6,0xde,0xd8,0xde,0xe4,0x60, + 0x88,0xec,0x68,0xbe,0xcc,0x52,0x68,0x8c,0xbd,0xb1,0xbd,0xc9,0xc1,0x0c,0xa1,0x92, + 0x02,0x21,0x03,0xa4,0x0c,0x92,0x22,0x11,0x10,0x36,0x40,0x2e,0xa4,0x43,0x32,0xa4, + 0x0d,0xa8,0x84,0xa5,0xc9,0xb9,0x88,0xd5,0x99,0x99,0x95,0xc9,0xf1,0x09,0x4b,0x93, + 0x73,0x11,0xab,0x33,0x33,0x2b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x23,0x12,0x96,0x26, + 0xe7,0x22,0x57,0x16,0x46,0x46,0x2a,0x2c,0x4d,0xce,0x65,0x8e,0x4e,0xae,0x6e,0x8c, + 0xee,0x8b,0x2e,0x0f,0xae,0xec,0x2b,0xcd,0xcd,0xec,0x8d,0x09,0x59,0xda,0x1c,0xdc, + 0xd7,0x5c,0x9a,0x5e,0xd9,0x10,0x25,0x19,0x12,0x22,0x19,0x10,0x0c,0x99,0x03,0x46, + 0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x74,0x79,0x70,0x65,0x5f,0x73,0x69,0x7a, + 0x65,0xbc,0xc2,0xd2,0xe4,0x5c,0xc2,0xe4,0xce,0xbe,0xe8,0xf2,0xe0,0xca,0xbe,0xc2, + 0xd8,0xd2,0xce,0xdc,0xbe,0xe6,0xd2,0xf4,0xca,0x98,0xd8,0xcd,0x7d,0xc1,0x85,0xc9, + 0x85,0xb5,0xcd,0x71,0xf8,0x92,0x99,0x19,0x42,0x06,0xc9,0x81,0xbc,0x01,0x02,0x07, + 0x09,0x81,0x94,0x41,0x32,0x24,0x02,0x12,0x07,0x88,0x1c,0x20,0x74,0x80,0xd4,0x41, + 0x42,0x20,0x76,0x90,0x10,0xc8,0x85,0xdc,0x01,0x92,0x21,0x78,0x30,0x04,0x41,0xd0, + 0x00,0x59,0x03,0xc4,0x0d,0x90,0x3c,0x18,0x62,0x1c,0x00,0x32,0x06,0x88,0x1e,0xf0, + 0x79,0x6b,0x73,0x4b,0x83,0x7b,0xa3,0x2b,0x73,0xa3,0x03,0x19,0x43,0x0b,0x93,0xe3, + 0x33,0x95,0xd6,0x06,0xc7,0x56,0x06,0x32,0xb4,0xb2,0x02,0x42,0x25,0x14,0x14,0x34, + 0x44,0x40,0xfa,0x60,0x88,0x81,0xf0,0x01,0xe2,0x07,0x4b,0x30,0xc4,0x40,0xfe,0x00, + 0xf9,0x83,0x25,0x18,0x22,0x00,0xc9,0x88,0x88,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d, + 0xda,0xe1,0x1d,0xc8,0xa1,0x1e,0xd8,0xa1,0x1c,0xdc,0xc0,0x1c,0xd8,0x21,0x1c,0xce, + 0x61,0x1e,0xa6,0x08,0xc1,0x30,0x42,0x61,0x07,0x76,0xb0,0x87,0x76,0x70,0x83,0x74, + 0x20,0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0x14,0x23,0x96,0x70,0x48,0x07,0x79,0x70, + 0x03,0x7b,0x28,0x07,0x79,0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12,0x18,0x23,0xa8, + 0x70,0x48,0x07,0x79,0x70,0x03,0x76,0x08,0x07,0x77,0x38,0x87,0x7a,0x08,0x87,0x73, + 0x28,0x87,0x5f,0xb0,0x87,0x72,0x90,0x87,0x79,0x48,0x87,0x77,0x70,0x87,0x29,0x01, + 0x32,0x62,0x0a,0x87,0x74,0x90,0x07,0x37,0x18,0x87,0x77,0x68,0x07,0x78,0x48,0x07, + 0x76,0x28,0x87,0x5f,0x78,0x07,0x78,0xa0,0x87,0x74,0x78,0x07,0x77,0x98,0x87,0x29, + 0x86,0xc2,0x38,0x90,0x44,0x8d,0x50,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c, + 0xe4,0x81,0x1e,0xca,0x01,0x1f,0xa6,0x04,0x7b,0x00,0x00,0x00,0x79,0x18,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88, + 0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6, + 0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce, + 0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8, + 0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48, + 0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11, + 0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e, + 0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89, + 0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b, + 0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37, + 0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78, + 0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81, + 0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1, + 0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c, + 0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39, + 0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc, + 0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58, + 0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87, + 0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f, + 0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e, + 0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66, + 0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b, + 0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0, + 0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e, + 0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc, + 0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3, + 0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07, + 0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00, + 0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x24,0x00,0x00,0x00, + 0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0xd4,0x63,0x11,0x40, + 0x60,0x1c,0x73,0x10,0x83,0x00,0x41,0x94,0x33,0x00,0x14,0x63,0x09,0x20,0x08,0x82, + 0xf0,0x2f,0x80,0x20,0x08,0xc2,0xbf,0x30,0x96,0x00,0x82,0x20,0x08,0x82,0x01,0x08, + 0x82,0x20,0x08,0x0e,0x33,0x00,0x24,0x73,0x10,0x18,0x76,0x59,0x34,0x33,0x00,0x04, + 0x63,0x04,0x20,0x08,0x82,0xf8,0x37,0x46,0x00,0x82,0x20,0x08,0x7f,0x33,0x00,0x00, + 0xe3,0x0d,0x0c,0x66,0x51,0x40,0x2c,0x0a,0xe8,0x63,0xc1,0x02,0x1f,0x0b,0x16,0xf9, + 0x0c,0x32,0x04,0xcb,0x33,0xc8,0x10,0x2c,0xd1,0x6c,0xc3,0x52,0x01,0xb3,0x0d,0x41, + 0x15,0xcc,0x36,0x04,0x83,0x90,0x41,0x40,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x5b,0x86,0x20,0x00,0x85,0x2d,0x83,0x30,0x84,0x02,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _simgui_fs_bytecode_metal_macos[2909] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x5d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x80,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0x17,0xe5,0xa2,0xb3,0x7d,0x00,0xfc, + 0xde,0x00,0x5f,0xbd,0x79,0x5e,0xd5,0x95,0xff,0xb6,0xf4,0xce,0x41,0x07,0xfb,0x8f, + 0x49,0x6b,0x95,0x79,0x7a,0xd1,0xcf,0x19,0xde,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x60,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x95,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x89,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87, + 0x70,0x30,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74, + 0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e, + 0xde,0xc1,0x1c,0xe8,0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81, + 0x00,0x16,0xa0,0xda,0x80,0x10,0xff,0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5, + 0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,0x18,0x86,0x00,0x2c,0x40,0x05,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44,0x61,0x00,0x00,0x00, + 0x00,0x89,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04,0x70,0x90,0x34,0x45, + 0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x13,0x0a,0xc2,0x30,0x82,0x00,0x1c, + 0x25,0x4d,0x11,0x25,0x4c,0xfe,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0xff,0x34, + 0x46,0x00,0x0c,0x22,0x10,0xc1,0x45,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x12,0xc0,0x3c, + 0x0b,0x11,0xfd,0xd3,0x18,0x01,0x30,0x88,0x60,0x08,0xa5,0x10,0x23,0x94,0x43,0x68, + 0x8e,0x20,0x98,0x23,0x00,0x83,0x61,0x04,0x61,0x29,0x48,0x28,0x67,0x28,0xa6,0x00, + 0xb5,0x81,0x80,0x1c,0x58,0x23,0x00,0x00,0x00,0x13,0xb2,0x70,0x48,0x07,0x79,0xb0, + 0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x76,0x08,0x87, + 0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83,0x38,0x70,0x03,0x38, + 0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0, + 0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x71,0x60,0x07, + 0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e,0x73,0x20,0x07,0x7a, + 0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76,0x40,0x07,0x7a,0x60, + 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0, + 0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07, + 0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73, + 0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40, + 0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07, + 0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72, + 0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0, + 0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20,0x07,0x7a,0x20,0x07, + 0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x72,0x50,0x07,0x76, + 0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x50, + 0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07, + 0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74, + 0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60, + 0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x49,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00, + 0x18,0xc2,0x38,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x64,0x81,0x00,0x00,0x00, + 0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26, + 0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50,0x04,0x85,0x50,0x10,0x65,0x40,0x70, + 0xac,0x41,0x79,0x08,0x00,0x79,0x18,0x00,0x00,0xd9,0x00,0x00,0x00,0x1a,0x03,0x4c, + 0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x42, + 0x3c,0x00,0x84,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62, + 0x2c,0xc2,0x23,0x2c,0x05,0xd9,0x20,0x08,0x0e,0x8e,0xad,0x0c,0x84,0x89,0xc9,0xaa, + 0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x24,0x07,0x46,0xc6,0x25,0x86,0x06, + 0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x25,0x07,0x46,0xc6,0x25,0x86,0xc6, + 0x25,0x27,0x65,0x88,0xf0,0x10,0x43,0x8c,0x45,0x58,0x8c,0x65,0x60,0xd1,0x54,0x46, + 0x17,0xc6,0x36,0x04,0x79,0x8e,0x45,0x58,0x84,0x65,0xe0,0x16,0x96,0x26,0xe7,0x32, + 0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45, + 0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x78,0x12,0x72,0x61,0x69,0x72,0x2e,0x63, + 0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68, + 0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x61,0x19,0x84,0xa5,0xc9,0xb9, + 0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99, + 0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x91,0xa5,0xcd,0x85,0x89,0xb1, + 0x95,0x0d,0x11,0x9e,0x86,0x61,0x10,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6, + 0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6,0x45,0xf6,0x56,0x27,0xc6,0x56,0xf6, + 0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x78,0x1e,0x92,0x41,0x58,0x9a,0x9c, + 0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b,0x5b,0x18,0x5d,0x9a,0x5d,0xd9,0x17, + 0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0x59,0xda,0x5c,0x98,0x18,0x5b, + 0xd9,0x10,0xe1,0x89,0x78,0x06,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c, + 0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f,0x77,0x69,0x64,0x65,0x5f,0x76,0x65, + 0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43,0x84,0x67, + 0x62,0x14,0x96,0x26,0xe7,0x22,0x57,0xe6,0x46,0x56,0x26,0xf7,0x45,0x17,0x26,0x77, + 0x56,0x46,0xc7,0x28,0x2c,0x4d,0xce,0x25,0x4c,0xee,0xec,0x8b,0x2e,0x0f,0xae,0xec, + 0xcb,0x2d,0xac,0xad,0x8c,0x86,0x19,0xdb,0x5b,0x18,0x1d,0x0d,0x99,0xb0,0x34,0x39, + 0x97,0x30,0xb9,0xb3,0x2f,0xb7,0xb0,0xb6,0x32,0x2a,0x66,0x72,0x61,0x67,0x5f,0x63, + 0x6f,0x6c,0x6f,0x72,0x43,0x98,0xa7,0x5a,0x86,0xc7,0x7a,0xae,0x07,0x7b,0xb2,0x21, + 0xc2,0xa3,0x51,0x0a,0x4b,0x93,0x73,0x31,0x93,0x0b,0x3b,0x6b,0x2b,0x73,0xa3,0xfb, + 0x4a,0x73,0x83,0xab,0xa3,0xe3,0x52,0x37,0x57,0x26,0x87,0xc2,0xf6,0x36,0xe6,0x06, + 0x93,0x42,0x25,0x2c,0x4d,0xce,0x65,0xac,0xcc,0x8d,0xae,0x4c,0x8e,0x4f,0x58,0x9a, + 0x9c,0x0b,0x5c,0x99,0xdc,0x1c,0x5c,0xd9,0x18,0x5d,0x9a,0x5d,0x19,0x0d,0x33,0xb6, + 0xb7,0x30,0x3a,0x19,0x0a,0x75,0x76,0x43,0xa4,0x65,0x78,0xb8,0xa7,0x7b,0xbc,0xe7, + 0x7b,0xac,0x07,0x0c,0x1e,0xec,0x09,0x03,0x2e,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f, + 0x63,0x6e,0x31,0x29,0x2c,0xc6,0xde,0xd8,0xde,0xe4,0x86,0x48,0x8b,0xf0,0x70,0xcf, + 0x18,0x3c,0xde,0xf3,0x3d,0xd6,0x73,0x3d,0xd8,0x43,0x06,0x5c,0xc2,0xd2,0xe4,0x5c, + 0xe8,0xca,0xf0,0xe8,0xea,0xe4,0xca,0x28,0x85,0xa5,0xc9,0xb9,0xb0,0xbd,0x8d,0x85, + 0xd1,0xa5,0xbd,0xb9,0x7d,0xa5,0xb9,0x91,0x95,0xe1,0x51,0x09,0x4b,0x93,0x73,0x99, + 0x0b,0x6b,0x83,0x63,0x2b,0x23,0x46,0x57,0x86,0x47,0x57,0x27,0x57,0x26,0x43,0xc6, + 0x63,0xc6,0xf6,0x16,0x46,0xc7,0x02,0x32,0x17,0xd6,0x06,0xc7,0x56,0xe6,0xc3,0x81, + 0xae,0x0c,0x6f,0x08,0xb5,0x10,0x8f,0x19,0x3c,0x67,0xb0,0x0c,0x8b,0xf0,0xa0,0xc1, + 0x63,0x3d,0x69,0xf0,0x60,0x8f,0x1a,0x70,0x09,0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83, + 0x63,0x2b,0x93,0xe3,0x31,0x17,0xd6,0x06,0xc7,0x56,0x26,0x47,0x84,0xae,0x0c,0x6f, + 0xaa,0x0d,0x8e,0x4d,0x6e,0x88,0xb4,0x1c,0x0f,0x1b,0x3c,0x67,0xb0,0x0c,0x8b,0xf0, + 0x58,0x4f,0x1b,0x3c,0xd8,0xe3,0x06,0x43,0x90,0x47,0x0c,0x9e,0x32,0x78,0xd6,0xe0, + 0x79,0x83,0x21,0x46,0x02,0x3c,0xdb,0x03,0x07,0x23,0x22,0x76,0x60,0x07,0x7b,0x68, + 0x07,0x37,0x68,0x87,0x77,0x20,0x87,0x7a,0x60,0x87,0x72,0x70,0x03,0x73,0x60,0x87, + 0x70,0x38,0x87,0x79,0x98,0x22,0x04,0xc3,0x08,0x85,0x1d,0xd8,0xc1,0x1e,0xda,0xc1, + 0x0d,0xd2,0x81,0x1c,0xca,0xc1,0x1d,0xe8,0x61,0x4a,0x50,0x8c,0x58,0xc2,0x21,0x1d, + 0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x61,0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x4a,0x60, + 0x8c,0xa0,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xd8,0x21,0x1c,0xdc,0xe1,0x1c,0xea,0x21, + 0x1c,0xce,0xa1,0x1c,0x7e,0xc1,0x1e,0xca,0x41,0x1e,0xe6,0x21,0x1d,0xde,0xc1,0x1d, + 0xa6,0x04,0xc8,0x88,0x29,0x1c,0xd2,0x41,0x1e,0xdc,0x60,0x1c,0xde,0xa1,0x1d,0xe0, + 0x21,0x1d,0xd8,0xa1,0x1c,0x7e,0xe1,0x1d,0xe0,0x81,0x1e,0xd2,0xe1,0x1d,0xdc,0x61, + 0x1e,0xa6,0x18,0x0a,0xe3,0x40,0x12,0x35,0x82,0x09,0x87,0x74,0x90,0x07,0x37,0x30, + 0x07,0x79,0x08,0x87,0x73,0x68,0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0xc4,0x01,0x00, + 0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c, + 0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07, + 0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42, + 0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83, + 0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07, + 0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70, + 0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3, + 0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2, + 0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc, + 0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68, + 0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07, + 0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72, + 0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec, + 0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc, + 0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8, + 0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03, + 0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c, + 0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74, + 0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4, + 0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc, + 0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1, + 0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50, + 0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51, + 0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21, + 0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06, + 0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c, + 0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77, + 0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00, + 0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f, + 0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20, + 0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00,0x00,0x0c,0x00,0x00,0x00,0x13,0x04,0x41, + 0x2c,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xc4,0x46,0x00,0x48,0x8d,0x00,0xd4, + 0x00,0x89,0x19,0x00,0x02,0x23,0x00,0x00,0x00,0x23,0x06,0x8a,0x10,0x44,0x87,0x91, + 0x0c,0x05,0x11,0x58,0x90,0xc8,0x67,0xb6,0x81,0x08,0x80,0x0c,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _simgui_vs_bytecode_metal_ios[3200] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x80,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x70,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0xcb,0xdd,0xe3,0x08,0x7a,0x87,0xef, + 0xdd,0xe0,0x68,0xe7,0xe8,0x6b,0xe6,0xea,0x8b,0x6d,0x4a,0xe0,0x3d,0x6a,0xfe,0xe4, + 0xfe,0x32,0x1d,0xbe,0xb6,0x10,0x11,0xee,0x75,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x37,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x22,0x00,0x03,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x56,0x41,0x54,0x59,0x05,0x00,0x03, + 0x00,0x04,0x04,0x06,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54, + 0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x5c,0x0b,0x00,0x00, + 0xff,0xff,0xff,0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0xd4,0x02,0x00,0x00, + 0x0b,0x82,0x20,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91, + 0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19, + 0x1e,0x04,0x8b,0x62,0x80,0x10,0x45,0x02,0x42,0x92,0x0b,0x42,0x84,0x10,0x32,0x14, + 0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80, + 0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x08,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0, + 0x01,0x00,0x00,0x00,0x51,0x18,0x00,0x00,0x82,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8, + 0xff,0xff,0xff,0xff,0x01,0x90,0x80,0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87, + 0x71,0xa0,0x07,0x76,0xc8,0x87,0x36,0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72, + 0x20,0x87,0x36,0x20,0x87,0x74,0xb0,0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88, + 0x07,0x79,0xa0,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41, + 0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e,0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c, + 0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87, + 0x72,0x98,0x87,0x79,0x68,0x03,0x78,0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72, + 0x68,0x03,0x73,0x80,0x87,0x76,0x08,0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e, + 0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda, + 0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81,0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21, + 0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30, + 0x07,0x79,0x08,0x87,0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87, + 0x72,0x90,0x87,0x36,0x28,0x07,0x76,0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77, + 0x68,0x03,0x76,0x28,0x87,0x70,0x30,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70, + 0x07,0x73,0x98,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1, + 0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08, + 0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87, + 0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41, + 0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d, + 0xca,0x81,0x1c,0xda,0x40,0x1f,0xca,0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0, + 0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80, + 0x70,0x87,0x77,0x68,0x03,0x7a,0x90,0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38, + 0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00, + 0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61,0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1, + 0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e,0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4,0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87, + 0x79,0x08,0x07,0x73,0x28,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a, + 0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d, + 0xe6,0xe1,0x1d,0xcc,0x81,0x1e,0xda,0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00, + 0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x36,0x20,0x02,0x01,0x24,0xc0,0x02,0x54, + 0x00,0x00,0x00,0x00,0x49,0x18,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00, + 0x89,0x20,0x00,0x00,0x1b,0x00,0x00,0x00,0x32,0x22,0x08,0x09,0x20,0x64,0x85,0x04, + 0x13,0x22,0xa4,0x84,0x04,0x13,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x88,0x8c, + 0x0b,0x84,0x84,0x4c,0x10,0x3c,0x33,0x00,0xc3,0x08,0x02,0x30,0x8c,0x40,0x00,0x77, + 0x49,0x53,0x44,0x09,0x93,0xcf,0x00,0x48,0x43,0xff,0x0e,0x35,0xf9,0x0f,0x20,0x28, + 0xc4,0x80,0x87,0x10,0x39,0x48,0x9a,0x22,0x4a,0x98,0xfc,0x4a,0xfa,0x1f,0x20,0x02, + 0x18,0x09,0x05,0x31,0x88,0x40,0x08,0xa5,0x98,0x08,0x29,0xb2,0x81,0x80,0x39,0x02, + 0x30,0x48,0x81,0x9c,0x23,0x00,0x85,0x41,0x84,0x40,0x18,0x46,0x20,0x92,0x11,0x00, + 0x00,0x00,0x00,0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70, + 0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80, + 0x03,0x37,0x80,0x83,0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07, + 0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9, + 0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30, + 0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07, + 0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72, + 0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07, + 0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73, + 0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a, + 0x60,0x07,0x74,0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0, + 0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07, + 0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72, + 0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20, + 0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07, + 0x6d,0x60,0x0f,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75, + 0x10,0x07,0x72,0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00, + 0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80,0x07, + 0x7a,0x10,0x07,0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x98,0x03,0x00,0x80,0x00,0x00, + 0x00,0x00,0x00,0x80,0x2c,0x10,0x00,0x00,0x0b,0x00,0x00,0x00,0x32,0x1e,0x98,0x10, + 0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0xda,0x11,0x00,0xca,0x12, + 0x18,0x01,0x28,0x88,0x22,0x28,0x84,0x32,0x20,0x1d,0x4b,0x68,0x0a,0x82,0x31,0x02, + 0x10,0x04,0x41,0x11,0x0c,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x16,0x01,0x00,0x00, + 0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7, + 0x21,0x46,0x52,0x20,0x80,0x82,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3, + 0x2b,0x1b,0x62,0x24,0x02,0x22,0x24,0x06,0xd9,0x20,0x08,0x0e,0x8e,0xad,0x0c,0x84, + 0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26,0x07,0x46, + 0xc6,0xc5,0xe6,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x26,0x07, + 0x46,0xc6,0xc5,0xe6,0x26,0x65,0x88,0x80,0x10,0x43,0x8c,0x44,0x48,0x88,0x64,0x60, + 0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x41,0x8e,0x44,0x48,0x86,0x64,0xe0,0x16,0x96, + 0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7, + 0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x40,0x12,0x72,0x61,0x69, + 0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d, + 0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04,0x64,0x21,0x19,0x84, + 0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95, + 0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x95,0xb9,0x85, + 0x89,0xb1,0x95,0x0d,0x11,0x90,0x86,0x61,0x10,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06, + 0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6,0x45,0xf6,0x56,0x27,0xc6, + 0x56,0xf6,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x40,0x1e,0x92,0x41,0x58, + 0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b,0x5b,0x18,0x5d,0x9a,0x5d, + 0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0x59,0xda,0x5c,0x98, + 0x18,0x5b,0xd9,0x10,0x01,0x89,0x78,0x06,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70, + 0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f,0x77,0x69,0x64,0x65,0x5f, + 0x76,0x65,0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43, + 0x04,0x64,0x62,0x14,0x96,0x26,0xe7,0x62,0x57,0x26,0x47,0x57,0x86,0xf7,0xf5,0x56, + 0x47,0x07,0x57,0x47,0xc7,0xa5,0x6e,0xae,0x4c,0x0e,0x85,0xed,0x6d,0xcc,0x0d,0x26, + 0x85,0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d,0x1e,0x5c,0xd9,0x97,0x5b, + 0x58,0x5b,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x32,0x61,0x69,0x72,0x2e,0x61, + 0x72,0x67,0x5f,0x6e,0x61,0x6d,0x65,0x14,0xea,0xec,0x86,0x30,0x48,0x85,0x58,0xc8, + 0x85,0x60,0x48,0x86,0x68,0x5c,0xea,0xe6,0xca,0xe4,0x50,0xd8,0xde,0xc6,0xdc,0x62, + 0x52,0x68,0x98,0xb1,0xbd,0x85,0xd1,0xd1,0xb0,0x18,0x7b,0x63,0x7b,0x93,0x1b,0xc2, + 0x20,0x15,0xc2,0x21,0x17,0xd2,0x21,0x19,0xe2,0x91,0x09,0x4b,0x93,0x73,0x81,0x7b, + 0x9b,0x4b,0xa3,0x4b,0x7b,0x73,0xe3,0x72,0xc6,0xf6,0x05,0xf5,0x36,0x97,0x46,0x97, + 0xf6,0xe6,0x36,0x44,0x41,0xc0,0x00,0xb9,0x90,0x0e,0xc9,0x90,0x30,0x18,0x62,0x20, + 0x1b,0xf2,0x21,0x62,0x40,0x28,0x2c,0x4d,0xce,0xc5,0xae,0x4c,0x8e,0xae,0x0c,0xef, + 0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x52,0x58,0x9a,0x9c,0x0b,0xdb,0xdb,0x58,0x18,0x5d, + 0xda,0x9b,0xdb,0x57,0x9a,0x1b,0x59,0x19,0x1e,0xb3,0xb3,0x32,0xb7,0x32,0xb9,0x30, + 0xba,0x32,0x32,0x14,0x1c,0xb8,0xb7,0xb9,0x34,0xba,0xb4,0x37,0x37,0x22,0x3b,0x99, + 0x2f,0xb3,0x14,0x22,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x43,0xa8,0x64,0x40, + 0xc8,0x00,0x29,0x83,0x64,0x48,0x04,0xc4,0x0c,0x90,0x0b,0xc1,0x90,0x0c,0x39,0x03, + 0x6a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x28,0x39,0x74,0x65,0x78,0x63, + 0x6f,0x6f,0x72,0x64,0x30,0x44,0x76,0x32,0x5f,0x66,0x29,0x4c,0xe8,0xca,0xf0,0xc6, + 0xde,0xde,0xe4,0xc8,0x60,0x86,0x50,0x89,0x80,0x90,0x01,0x52,0x06,0x89,0x90,0x08, + 0x48,0x1a,0x20,0x17,0x82,0x21,0x19,0xa2,0x06,0xbc,0xce,0xca,0xdc,0xca,0xe4,0xc2, + 0xe8,0xca,0xc8,0x50,0x6c,0xc6,0xde,0xd8,0xde,0xe4,0x60,0x88,0xec,0x68,0xbe,0xcc, + 0x52,0x68,0x8c,0xbd,0xb1,0xbd,0xc9,0xc1,0x0c,0xa1,0x92,0x02,0x21,0x03,0xa4,0x0c, + 0x92,0x22,0x11,0x10,0x36,0x40,0x2e,0xa4,0x43,0x32,0xa4,0x0d,0xa8,0x84,0xa5,0xc9, + 0xb9,0x88,0xd5,0x99,0x99,0x95,0xc9,0xf1,0x09,0x4b,0x93,0x73,0x11,0xab,0x33,0x33, + 0x2b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x23,0x12,0x96,0x26,0xe7,0x22,0x57,0x16,0x46, + 0x46,0x2a,0x2c,0x4d,0xce,0x65,0x8e,0x4e,0xae,0x6e,0x8c,0xee,0x8b,0x2e,0x0f,0xae, + 0xec,0x2b,0xcd,0xcd,0xec,0x8d,0x09,0x59,0xda,0x1c,0xdc,0xd7,0x5c,0x9a,0x5e,0xd9, + 0x10,0x25,0x19,0x12,0x22,0x19,0x10,0x0c,0x99,0x03,0x46,0x61,0x69,0x72,0x2e,0x61, + 0x72,0x67,0x5f,0x74,0x79,0x70,0x65,0x5f,0x73,0x69,0x7a,0x65,0xbc,0xc2,0xd2,0xe4, + 0x5c,0xc2,0xe4,0xce,0xbe,0xe8,0xf2,0xe0,0xca,0xbe,0xc2,0xd8,0xd2,0xce,0xdc,0xbe, + 0xe6,0xd2,0xf4,0xca,0x98,0xd8,0xcd,0x7d,0xc1,0x85,0xc9,0x85,0xb5,0xcd,0x71,0xf8, + 0x92,0x99,0x19,0x42,0x06,0xc9,0x81,0xbc,0x01,0x02,0x07,0x09,0x81,0x94,0x41,0x32, + 0x24,0x02,0x12,0x07,0x88,0x1c,0x20,0x74,0x80,0xd4,0x41,0x42,0x20,0x76,0x90,0x10, + 0xc8,0x85,0xdc,0x01,0x92,0x21,0x78,0x30,0x04,0x41,0xd0,0x00,0x59,0x03,0xc4,0x0d, + 0x90,0x3c,0x18,0x62,0x1c,0x00,0x32,0x06,0x88,0x1e,0xf0,0x79,0x6b,0x73,0x4b,0x83, + 0x7b,0xa3,0x2b,0x73,0xa3,0x03,0x19,0x43,0x0b,0x93,0xe3,0x33,0x95,0xd6,0x06,0xc7, + 0x56,0x06,0x32,0xb4,0xb2,0x02,0x42,0x25,0x14,0x14,0x34,0x44,0x40,0xfa,0x60,0x88, + 0x81,0xf0,0x01,0xe2,0x07,0x4b,0x30,0xc4,0x40,0xfe,0x00,0xf9,0x83,0x25,0x18,0x22, + 0x00,0xc9,0x88,0x88,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d,0xda,0xe1,0x1d,0xc8,0xa1, + 0x1e,0xd8,0xa1,0x1c,0xdc,0xc0,0x1c,0xd8,0x21,0x1c,0xce,0x61,0x1e,0xa6,0x08,0xc1, + 0x30,0x42,0x61,0x07,0x76,0xb0,0x87,0x76,0x70,0x83,0x74,0x20,0x87,0x72,0x70,0x07, + 0x7a,0x98,0x12,0x14,0x23,0x96,0x70,0x48,0x07,0x79,0x70,0x03,0x7b,0x28,0x07,0x79, + 0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12,0x18,0x23,0xa8,0x70,0x48,0x07,0x79,0x70, + 0x03,0x76,0x08,0x07,0x77,0x38,0x87,0x7a,0x08,0x87,0x73,0x28,0x87,0x5f,0xb0,0x87, + 0x72,0x90,0x87,0x79,0x48,0x87,0x77,0x70,0x87,0x29,0x01,0x32,0x62,0x0a,0x87,0x74, + 0x90,0x07,0x37,0x18,0x87,0x77,0x68,0x07,0x78,0x48,0x07,0x76,0x28,0x87,0x5f,0x78, + 0x07,0x78,0xa0,0x87,0x74,0x78,0x07,0x77,0x98,0x87,0x29,0x86,0xc2,0x38,0x90,0x44, + 0x8d,0x50,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x81,0x1e,0xca,0x01, + 0x1f,0xa6,0x04,0x7b,0x00,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3, + 0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10, + 0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30, + 0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03, + 0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07, + 0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e, + 0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d, + 0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b, + 0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76, + 0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90, + 0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87, + 0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e, + 0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c, + 0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca, + 0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8, + 0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82, + 0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83, + 0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f, + 0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec, + 0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc, + 0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0, + 0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60, + 0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e, + 0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1, + 0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43, + 0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c, + 0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72, + 0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x50,0x30,0x00, + 0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x24,0x00,0x00,0x00,0x13,0x04,0x41,0x2c, + 0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0xd4,0x63,0x11,0x40,0x60,0x1c,0x73,0x10, + 0x83,0x00,0x41,0x94,0x33,0x00,0x14,0x63,0x09,0x20,0x08,0x82,0xf0,0x2f,0x80,0x20, + 0x08,0xc2,0xbf,0x30,0x96,0x00,0x82,0x20,0x08,0x82,0x01,0x08,0x82,0x20,0x08,0x0e, + 0x33,0x00,0x24,0x73,0x10,0x18,0x76,0x59,0x34,0x33,0x00,0x04,0x63,0x04,0x20,0x08, + 0x82,0xf8,0x37,0x46,0x00,0x82,0x20,0x08,0x7f,0x33,0x00,0x00,0xe3,0x0d,0x0c,0x66, + 0x51,0x40,0x2c,0x0a,0xe8,0x63,0xc1,0x02,0x1f,0x0b,0x16,0xf9,0x0c,0x32,0x04,0xcb, + 0x33,0xc8,0x10,0x2c,0xd1,0x6c,0xc3,0x52,0x01,0xb3,0x0d,0x41,0x15,0xcc,0x36,0x04, + 0x83,0x90,0x41,0x40,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x5b,0x86,0x20,0x00, + 0x85,0x2d,0x83,0x30,0x84,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _simgui_fs_bytecode_metal_ios[2893] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x4d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x70,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0xe9,0x4a,0xc6,0xd1,0xba,0x33,0x39, + 0x67,0xdf,0xcd,0xe3,0x58,0xde,0xd4,0xb8,0x81,0x4c,0x26,0x44,0xbc,0x9d,0x14,0xdc, + 0xa9,0x02,0x93,0x08,0x5a,0xcd,0x66,0x1c,0x30,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x58,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x93,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x89,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87, + 0x70,0x30,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74, + 0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e, + 0xde,0xc1,0x1c,0xe8,0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81, + 0x00,0x16,0xa0,0xda,0x80,0x10,0xff,0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5, + 0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,0x18,0x86,0x00,0x2c,0x40,0x05,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44,0x61,0x00,0x00,0x00, + 0x00,0x89,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04,0x70,0x90,0x34,0x45, + 0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x13,0x0a,0xc2,0x30,0x82,0x00,0x1c, + 0x25,0x4d,0x11,0x25,0x4c,0xfe,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0xff,0x34, + 0x46,0x00,0x0c,0x22,0x10,0xc1,0x45,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x12,0xc0,0x3c, + 0x0b,0x11,0xfd,0xd3,0x18,0x01,0x30,0x88,0x60,0x08,0xa5,0x10,0x23,0x94,0x43,0x68, + 0x8e,0x20,0x98,0x23,0x00,0x83,0x61,0x04,0x61,0x29,0x48,0x28,0x67,0x28,0xa6,0x00, + 0xb5,0x81,0x80,0x14,0x58,0x23,0x00,0x00,0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0, + 0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87, + 0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80,0x83,0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9, + 0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0, + 0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07, + 0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72, + 0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0, + 0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06, + 0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6, + 0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20, + 0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78, + 0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07, + 0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72, + 0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60, + 0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07, + 0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a, + 0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10, + 0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07, + 0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74, + 0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x98, + 0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x21,0x8c,0x03,0x04,0x80,0x00,0x00, + 0x00,0x00,0x00,0x40,0x16,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98, + 0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x23,0x00,0x25, + 0x50,0x04,0x85,0x50,0x10,0x65,0x40,0x70,0x2c,0xa1,0x29,0x00,0x00,0x79,0x18,0x00, + 0x00,0xd9,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32, + 0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x42,0x3c,0x00,0x84,0x50,0xb9,0x1b,0x43,0x0b, + 0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x2c,0xc3,0x23,0x2c,0x05,0xd9,0x20,0x08, + 0x0e,0x8e,0xad,0x0c,0x84,0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd, + 0x0d,0x64,0x26,0x07,0x46,0xc6,0xc5,0xe6,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd, + 0xac,0xac,0x65,0x26,0x07,0x46,0xc6,0xc5,0xe6,0x26,0x65,0x88,0xf0,0x10,0x43,0x8c, + 0x65,0x58,0x8c,0x45,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x79,0x8e,0x65,0x58, + 0x84,0x45,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42, + 0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44, + 0x78,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66, + 0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43, + 0x84,0x67,0x21,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9, + 0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d, + 0xa1,0x7d,0x95,0xb9,0x85,0x89,0xb1,0x95,0x0d,0x11,0x9e,0x86,0x61,0x10,0x96,0x26, + 0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6, + 0x45,0xf6,0x56,0x27,0xc6,0x56,0xf6,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44, + 0x78,0x1e,0x92,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b, + 0x5b,0x18,0x5d,0x9a,0x5d,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9, + 0x17,0x59,0xda,0x5c,0x98,0x18,0x5b,0xd9,0x10,0xe1,0x89,0x78,0x06,0x61,0x69,0x72, + 0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f, + 0x77,0x69,0x64,0x65,0x5f,0x76,0x65,0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73, + 0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x62,0x14,0x96,0x26,0xe7,0x22,0x57,0xe6,0x46, + 0x56,0x26,0xf7,0x45,0x17,0x26,0x77,0x56,0x46,0xc7,0x28,0x2c,0x4d,0xce,0x25,0x4c, + 0xee,0xec,0x8b,0x2e,0x0f,0xae,0xec,0xcb,0x2d,0xac,0xad,0x8c,0x86,0x19,0xdb,0x5b, + 0x18,0x1d,0x0d,0x99,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xb7,0xb0,0xb6,0x32, + 0x2a,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x43,0x98,0xa7,0x5a,0x84, + 0xc7,0x7a,0xae,0x07,0x7b,0xb2,0x21,0xc2,0xa3,0x51,0x0a,0x4b,0x93,0x73,0x31,0x93, + 0x0b,0x3b,0x6b,0x2b,0x73,0xa3,0xfb,0x4a,0x73,0x83,0xab,0xa3,0xe3,0x52,0x37,0x57, + 0x26,0x87,0xc2,0xf6,0x36,0xe6,0x06,0x93,0x42,0x25,0x2c,0x4d,0xce,0x65,0xac,0xcc, + 0x8d,0xae,0x4c,0x8e,0x4f,0x58,0x9a,0x9c,0x0b,0x5c,0x99,0xdc,0x1c,0x5c,0xd9,0x18, + 0x5d,0x9a,0x5d,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x0a,0x75,0x76,0x43,0xa4, + 0x45,0x78,0xb8,0xa7,0x7b,0xbc,0xe7,0x7b,0xac,0x07,0x0c,0x1e,0xec,0x09,0x03,0x2e, + 0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x2c,0xc6,0xde,0xd8,0xde, + 0xe4,0x86,0x48,0xcb,0xf0,0x70,0xcf,0x18,0x3c,0xde,0xf3,0x3d,0xd6,0x73,0x3d,0xd8, + 0x43,0x06,0x5c,0xc2,0xd2,0xe4,0x5c,0xe8,0xca,0xf0,0xe8,0xea,0xe4,0xca,0x28,0x85, + 0xa5,0xc9,0xb9,0xb0,0xbd,0x8d,0x85,0xd1,0xa5,0xbd,0xb9,0x7d,0xa5,0xb9,0x91,0x95, + 0xe1,0x51,0x09,0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83,0x63,0x2b,0x23,0x46,0x57,0x86, + 0x47,0x57,0x27,0x57,0x26,0x43,0xc6,0x63,0xc6,0xf6,0x16,0x46,0xc7,0x02,0x32,0x17, + 0xd6,0x06,0xc7,0x56,0xe6,0xc3,0x81,0xae,0x0c,0x6f,0x08,0xb5,0x10,0x8f,0x19,0x3c, + 0x67,0xb0,0x08,0xcb,0xf0,0xa0,0xc1,0x63,0x3d,0x69,0xf0,0x60,0x8f,0x1a,0x70,0x09, + 0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83,0x63,0x2b,0x93,0xe3,0x31,0x17,0xd6,0x06,0xc7, + 0x56,0x26,0x47,0x84,0xae,0x0c,0x6f,0xaa,0x0d,0x8e,0x4d,0x6e,0x88,0xb4,0x1c,0x0f, + 0x1b,0x3c,0x67,0xb0,0x08,0xcb,0xf0,0x58,0x4f,0x1b,0x3c,0xd8,0xe3,0x06,0x43,0x90, + 0x47,0x0c,0x9e,0x32,0x78,0xd6,0xe0,0x79,0x83,0x21,0x46,0x02,0x3c,0xdb,0x03,0x07, + 0x23,0x22,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x77,0x20,0x87,0x7a,0x60, + 0x87,0x72,0x70,0x03,0x73,0x60,0x87,0x70,0x38,0x87,0x79,0x98,0x22,0x04,0xc3,0x08, + 0x85,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d,0xd2,0x81,0x1c,0xca,0xc1,0x1d,0xe8,0x61, + 0x4a,0x50,0x8c,0x58,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x61,0x1e, + 0xd2,0xe1,0x1d,0xdc,0x61,0x4a,0x60,0x8c,0xa0,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xd8, + 0x21,0x1c,0xdc,0xe1,0x1c,0xea,0x21,0x1c,0xce,0xa1,0x1c,0x7e,0xc1,0x1e,0xca,0x41, + 0x1e,0xe6,0x21,0x1d,0xde,0xc1,0x1d,0xa6,0x04,0xc8,0x88,0x29,0x1c,0xd2,0x41,0x1e, + 0xdc,0x60,0x1c,0xde,0xa1,0x1d,0xe0,0x21,0x1d,0xd8,0xa1,0x1c,0x7e,0xe1,0x1d,0xe0, + 0x81,0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x1e,0xa6,0x18,0x0a,0xe3,0x40,0x12,0x35,0x82, + 0x09,0x87,0x74,0x90,0x07,0x37,0x30,0x07,0x79,0x08,0x87,0x73,0x68,0x87,0x72,0x70, + 0x07,0x7a,0x98,0x12,0xc4,0x01,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00, + 0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84, + 0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed, + 0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66, + 0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c, + 0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70, + 0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90, + 0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4, + 0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83, + 0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14, + 0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70, + 0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80, + 0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0, + 0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1, + 0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d, + 0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39, + 0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc, + 0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70, + 0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53, + 0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e, + 0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c, + 0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38, + 0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37, + 0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33, + 0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4, + 0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0, + 0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3, + 0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07, + 0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01, + 0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e, + 0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00, + 0x00,0x0c,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x04,0x00,0x00, + 0x00,0xc4,0x46,0x00,0x48,0x8d,0x00,0xd4,0x00,0x89,0x19,0x00,0x02,0x23,0x00,0x00, + 0x00,0x23,0x06,0x8a,0x10,0x44,0x87,0x91,0x0c,0x05,0x11,0x58,0x90,0xc8,0x67,0xb6, + 0x81,0x08,0x80,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const char _simgui_vs_source_metal_sim[720] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x32,0x20,0x64,0x69,0x73,0x70,0x5f,0x73,0x69,0x7a,0x65,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x32,0x20,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63, + 0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c, + 0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20, + 0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b, + 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69, + 0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62, + 0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x5b, + 0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x32, + 0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31, + 0x35,0x20,0x22,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f, + 0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x33,0x20,0x5b,0x5b, + 0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74, + 0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x35,0x20, + 0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f, + 0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28, + 0x28,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20, + 0x5f,0x32,0x33,0x2e,0x64,0x69,0x73,0x70,0x5f,0x73,0x69,0x7a,0x65,0x29,0x20,0x2d, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30, + 0x29,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x23,0x6c, + 0x69,0x6e,0x65,0x20,0x31,0x36,0x20,0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75, + 0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,0x30,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22,0x22, + 0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d, + 0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _simgui_fs_source_metal_sim[470] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d, + 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20, + 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20, + 0x31,0x31,0x20,0x22,0x22,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61, + 0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65, + 0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74,0x65,0x78,0x20,0x5b,0x5b, + 0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x20,0x5b, + 0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f, + 0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31, + 0x31,0x20,0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61, + 0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x28,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x69, + 0x6e,0x2e,0x75,0x76,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74, + 0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_D3D11) +static const uint8_t _simgui_vs_bytecode_hlsl4[892] = { + 0x44,0x58,0x42,0x43,0x05,0xf8,0x0b,0x1e,0x7a,0x13,0x49,0x07,0x83,0x60,0x2e,0x88, + 0x06,0xfa,0x10,0x2e,0x01,0x00,0x00,0x00,0x7c,0x03,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0xd0,0x01,0x00,0x00, + 0x00,0x03,0x00,0x00,0x52,0x44,0x45,0x46,0xc0,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xfe,0xff, + 0x10,0x81,0x00,0x00,0x98,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x00,0xab,0xab,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x60,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x88,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x5f,0x32,0x33,0x5f,0x64,0x69,0x73,0x70,0x5f,0x73,0x69,0x7a, + 0x65,0x00,0xab,0xab,0x01,0x00,0x03,0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x28,0x52, + 0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64,0x65,0x72,0x20,0x43,0x6f, + 0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31,0x00,0x49,0x53,0x47,0x4e, + 0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x50,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x03,0x00,0x00,0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x50,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x68,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x0c,0x00,0x00,0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, + 0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44, + 0x00,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0xab,0xab,0xab, + 0x53,0x48,0x44,0x52,0x28,0x01,0x00,0x00,0x40,0x00,0x01,0x00,0x4a,0x00,0x00,0x00, + 0x59,0x00,0x00,0x04,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x5f,0x00,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x03, + 0x32,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00, + 0x02,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0x32,0x20,0x10,0x00,0x00,0x00,0x00,0x00, + 0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x67,0x00,0x00,0x04, + 0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x68,0x00,0x00,0x02, + 0x01,0x00,0x00,0x00,0x36,0x00,0x00,0x05,0x32,0x20,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x36,0x00,0x00,0x05,0xf2,0x20,0x10,0x00, + 0x01,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x02,0x00,0x00,0x00,0x0e,0x00,0x00,0x08, + 0x32,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x80,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a, + 0x32,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x00,0x10,0x00,0x00,0x00,0x00,0x00, + 0x02,0x40,0x00,0x00,0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x0a,0x32,0x20,0x10,0x00,0x02,0x00,0x00,0x00, + 0x46,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x40, + 0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x08, + 0xc2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x00,0x80,0x3f,0x3e,0x00,0x00,0x01, + 0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _simgui_fs_bytecode_hlsl4[620] = { + 0x44,0x58,0x42,0x43,0xd1,0x93,0x1f,0x1b,0x9d,0x70,0x90,0xeb,0xc2,0x7c,0x26,0x07, + 0xdf,0x52,0xda,0x49,0x01,0x00,0x00,0x00,0x6c,0x02,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0x20,0x01,0x00,0x00,0x54,0x01,0x00,0x00, + 0xf0,0x01,0x00,0x00,0x52,0x44,0x45,0x46,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xff,0xff, + 0x10,0x81,0x00,0x00,0x6d,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x69,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x00,0x74,0x65,0x78,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f, + 0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64, + 0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31, + 0x00,0xab,0xab,0xab,0x49,0x53,0x47,0x4e,0x44,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x38,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x2c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65, + 0x74,0x00,0xab,0xab,0x53,0x48,0x44,0x52,0x94,0x00,0x00,0x00,0x40,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x5a,0x00,0x00,0x03,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x58,0x18,0x00,0x04,0x00,0x70,0x10,0x00,0x00,0x00,0x00,0x00,0x55,0x55,0x00,0x00, + 0x62,0x10,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x00,0x03, + 0xf2,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00, + 0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x02,0x01,0x00,0x00,0x00,0x45,0x00,0x00,0x09, + 0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x7e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x38,0x00,0x00,0x07,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x01,0x00,0x00,0x00,0x3e,0x00,0x00,0x01, + 0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +#elif defined(SOKOL_WGPU) +static const uint8_t _simgui_vs_bytecode_wgpu[1868] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x34,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x2a,0x00,0x00,0x00, + 0x2b,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x32,0x00,0x00,0x00, + 0x33,0x00,0x00,0x00,0x07,0x00,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x37,0x00,0x02,0x00,0x00,0x00,0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65, + 0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e, + 0x74,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f, + 0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64, + 0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x2e,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65, + 0x74,0x2d,0x65,0x6e,0x76,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20, + 0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65, + 0x64,0x20,0x65,0x6e,0x74,0x72,0x79,0x2d,0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61, + 0x69,0x6e,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00, + 0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,0x05,0x00,0x06,0x00, + 0x0c,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x65,0x72,0x56,0x65,0x72,0x74,0x65,0x78, + 0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x06,0x00,0x07,0x00, + 0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74, + 0x53,0x69,0x7a,0x65,0x00,0x00,0x00,0x00,0x06,0x00,0x07,0x00,0x0c,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x67,0x6c,0x5f,0x43,0x6c,0x69,0x70,0x44,0x69,0x73,0x74,0x61, + 0x6e,0x63,0x65,0x00,0x06,0x00,0x07,0x00,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x43,0x75,0x6c,0x6c,0x44,0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x00, + 0x05,0x00,0x03,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00, + 0x13,0x00,0x00,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x00,0x00, + 0x05,0x00,0x05,0x00,0x15,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x64,0x69,0x73,0x70,0x5f,0x73,0x69,0x7a,0x65,0x00,0x00,0x00,0x05,0x00,0x03,0x00, + 0x17,0x00,0x00,0x00,0x5f,0x32,0x33,0x00,0x05,0x00,0x03,0x00,0x2a,0x00,0x00,0x00, + 0x75,0x76,0x00,0x00,0x05,0x00,0x05,0x00,0x2b,0x00,0x00,0x00,0x74,0x65,0x78,0x63, + 0x6f,0x6f,0x72,0x64,0x30,0x00,0x00,0x00,0x05,0x00,0x04,0x00,0x2d,0x00,0x00,0x00, + 0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00,0x05,0x00,0x04,0x00,0x2f,0x00,0x00,0x00, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x00,0x05,0x00,0x05,0x00,0x32,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x56,0x65,0x72,0x74,0x65,0x78,0x49,0x44,0x00,0x05,0x00,0x06,0x00, + 0x33,0x00,0x00,0x00,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49, + 0x44,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x48,0x00,0x05,0x00, + 0x0c,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x47,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x48,0x00,0x05,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x03,0x00,0x15,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x2a,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x2b,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x2d,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x2f,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x32,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x05,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x33,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x06,0x00,0x00,0x00, + 0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x21,0x00,0x03,0x00,0x04,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x15,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x1c,0x00,0x04,0x00,0x0b,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x0a,0x00,0x00,0x00, + 0x1e,0x00,0x06,0x00,0x0c,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x0d,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x0d,0x00,0x00,0x00, + 0x0e,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x15,0x00,0x04,0x00,0x0f,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x0f,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x11,0x00,0x00,0x00, + 0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x12,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x12,0x00,0x00,0x00, + 0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1e,0x00,0x03,0x00,0x15,0x00,0x00,0x00, + 0x11,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x15,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x18,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x11,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x1c,0x00,0x00,0x00, + 0x00,0x00,0x00,0x3f,0x2c,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x1d,0x00,0x00,0x00, + 0x1c,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00, + 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x2c,0x00,0x05,0x00,0x11,0x00,0x00,0x00, + 0x21,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x2b,0x00,0x04,0x00, + 0x07,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0x80,0x3f,0x20,0x00,0x04,0x00, + 0x27,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x04,0x00, + 0x29,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x29,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x12,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x27,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x20,0x00,0x04,0x00, + 0x2e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x2e,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x20,0x00,0x04,0x00, + 0x31,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x31,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x31,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x36,0x00,0x05,0x00, + 0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x01,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x11,0x00,0x00,0x00, + 0x14,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x18,0x00,0x00,0x00, + 0x19,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x11,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x88,0x00,0x05,0x00, + 0x11,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x1a,0x00,0x00,0x00, + 0x83,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1b,0x00,0x00,0x00, + 0x1d,0x00,0x00,0x00,0x85,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x22,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x51,0x00,0x05,0x00,0x07,0x00,0x00,0x00, + 0x24,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0x00,0x05,0x00, + 0x07,0x00,0x00,0x00,0x25,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x50,0x00,0x07,0x00,0x08,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x24,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x41,0x00,0x05,0x00, + 0x27,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x3e,0x00,0x03,0x00,0x28,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x11,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x3e,0x00,0x03,0x00, + 0x2a,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x01,0x00,0x00,0x00, + 0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x08,0x00,0x00,0x00, + 0x30,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x2d,0x00,0x00,0x00, + 0x30,0x00,0x00,0x00,0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +static const uint8_t _simgui_fs_bytecode_wgpu[904] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x19,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x08,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x16,0x00,0x00,0x00, + 0x10,0x00,0x03,0x00,0x05,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x00,0x03,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x37,0x00,0x02,0x00,0x00,0x00, + 0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64, + 0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69, + 0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x30,0x30,0x0a,0x2f,0x2f, + 0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73, + 0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c, + 0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50, + 0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d, + 0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x2e,0x30,0x0a,0x2f,0x2f, + 0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73, + 0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x6f,0x70, + 0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65, + 0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x65,0x6e,0x74,0x72,0x79,0x2d, + 0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x0a,0x23,0x6c,0x69,0x6e,0x65, + 0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00,0x0a,0x00,0x00,0x00,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x05,0x00,0x03,0x00,0x0e,0x00,0x00,0x00, + 0x74,0x65,0x78,0x00,0x05,0x00,0x03,0x00,0x12,0x00,0x00,0x00,0x75,0x76,0x00,0x00, + 0x05,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0a,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x21,0x00,0x03,0x00,0x04,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x19,0x00,0x09,0x00,0x0b,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x1b,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x15,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x15,0x00,0x00,0x00,0x16,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x36,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x0c,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x10,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x57,0x00,0x05,0x00, + 0x08,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x16,0x00,0x00,0x00, + 0x85,0x00,0x05,0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x14,0x00,0x00,0x00, + 0x17,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x0a,0x00,0x00,0x00,0x18,0x00,0x00,0x00, + 0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +#elif defined(SOKOL_DUMMY_BACKEND) +static const char* _simgui_vs_source_dummy = ""; +static const char* _simgui_fs_source_dummy = ""; +#else +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#endif + +#if !defined(SOKOL_IMGUI_NO_SOKOL_APP) +static void _simgui_set_clipboard(void* user_data, const char* text) { + (void)user_data; + sapp_set_clipboard_string(text); +} + +static const char* _simgui_get_clipboard(void* user_data) { + (void)user_data; + return sapp_get_clipboard_string(); +} +#endif + +#if defined(__EMSCRIPTEN__) && !defined(SOKOL_DUMMY_BACKEND) +EM_JS(int, simgui_js_is_osx, (void), { + if (navigator.userAgent.includes('Macintosh')) { + return 1; + } + else { + return 0; + } +}); +#endif + +static void _simgui_clear(void* ptr, size_t size) { + SOKOL_ASSERT(ptr && (size > 0)); + memset(ptr, 0, size); +} + +static void* _simgui_malloc(size_t size) { + SOKOL_ASSERT(size > 0); + void* ptr; + if (_simgui.desc.allocator.alloc) { + ptr = _simgui.desc.allocator.alloc(size, _simgui.desc.allocator.user_data); + } + else { + ptr = malloc(size); + } + SOKOL_ASSERT(ptr); + return ptr; +} + +static void _simgui_free(void* ptr) { + if (_simgui.desc.allocator.free) { + _simgui.desc.allocator.free(ptr, _simgui.desc.allocator.user_data); + } + else { + free(ptr); + } +} + +static bool _simgui_is_osx(void) { + #if defined(SOKOL_DUMMY_BACKEND) + return false; + #elif defined(__EMSCRIPTEN__) + return simgui_js_is_osx(); + #elif defined(__APPLE__) + return true; + #else + return false; + #endif +} + +static simgui_desc_t _simgui_desc_defaults(const simgui_desc_t* desc) { + SOKOL_ASSERT((desc->allocator.alloc && desc->allocator.free) || (!desc->allocator.alloc && !desc->allocator.free)); + simgui_desc_t res = *desc; + res.max_vertices = _simgui_def(res.max_vertices, 65536); + return res; +} + +SOKOL_API_IMPL void simgui_setup(const simgui_desc_t* desc) { + SOKOL_ASSERT(desc); + _simgui_clear(&_simgui, sizeof(_simgui)); + _simgui.desc = _simgui_desc_defaults(desc); + _simgui.cur_dpi_scale = 1.0f; + #if !defined(SOKOL_IMGUI_NO_SOKOL_APP) + _simgui.is_osx = _simgui_is_osx(); + #endif + /* can keep color_format, depth_format and sample_count as is, + since sokol_gfx.h will do its own default-value handling + */ + + /* allocate an intermediate vertex- and index-buffer */ + SOKOL_ASSERT(_simgui.desc.max_vertices > 0); + _simgui.vertices.size = (size_t)_simgui.desc.max_vertices * sizeof(ImDrawVert); + _simgui.vertices.ptr = _simgui_malloc(_simgui.vertices.size); + _simgui.indices.size = (size_t)_simgui.desc.max_vertices * 3 * sizeof(ImDrawIdx); + _simgui.indices.ptr = _simgui_malloc(_simgui.indices.size); + + /* initialize Dear ImGui */ + #if defined(__cplusplus) + ImGui::CreateContext(); + ImGui::StyleColorsDark(); + ImGuiIO* io = &ImGui::GetIO(); + if (!_simgui.desc.no_default_font) { + io->Fonts->AddFontDefault(); + } + #else + igCreateContext(NULL); + igStyleColorsDark(igGetStyle()); + ImGuiIO* io = igGetIO(); + if (!_simgui.desc.no_default_font) { + ImFontAtlas_AddFontDefault(io->Fonts, NULL); + } + #endif + io->IniFilename = _simgui.desc.ini_filename; + io->ConfigMacOSXBehaviors = _simgui_is_osx(); + io->BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; + #if !defined(SOKOL_IMGUI_NO_SOKOL_APP) + if (!_simgui.desc.disable_set_mouse_cursor) { + io->BackendFlags |= ImGuiBackendFlags_HasMouseCursors; + } + io->SetClipboardTextFn = _simgui_set_clipboard; + io->GetClipboardTextFn = _simgui_get_clipboard; + #endif + io->ConfigWindowsResizeFromEdges = !_simgui.desc.disable_windows_resize_from_edges; + + /* create sokol-gfx resources */ + sg_push_debug_group("sokol-imgui"); + + /* NOTE: since we're in C++ mode here we can't use C99 designated init */ + sg_buffer_desc vb_desc; + _simgui_clear(&vb_desc, sizeof(vb_desc)); + vb_desc.usage = SG_USAGE_STREAM; + vb_desc.size = _simgui.vertices.size; + vb_desc.label = "sokol-imgui-vertices"; + _simgui.vbuf = sg_make_buffer(&vb_desc); + + sg_buffer_desc ib_desc; + _simgui_clear(&ib_desc, sizeof(ib_desc)); + ib_desc.type = SG_BUFFERTYPE_INDEXBUFFER; + ib_desc.usage = SG_USAGE_STREAM; + ib_desc.size = _simgui.indices.size; + ib_desc.label = "sokol-imgui-indices"; + _simgui.ibuf = sg_make_buffer(&ib_desc); + + /* default font texture */ + if (!_simgui.desc.no_default_font) { + unsigned char* font_pixels; + int font_width, font_height; + #if defined(__cplusplus) + io->Fonts->GetTexDataAsRGBA32(&font_pixels, &font_width, &font_height); + #else + int bytes_per_pixel; + ImFontAtlas_GetTexDataAsRGBA32(io->Fonts, &font_pixels, &font_width, &font_height, &bytes_per_pixel); + #endif + sg_image_desc img_desc; + _simgui_clear(&img_desc, sizeof(img_desc)); + img_desc.width = font_width; + img_desc.height = font_height; + img_desc.pixel_format = SG_PIXELFORMAT_RGBA8; + img_desc.wrap_u = SG_WRAP_CLAMP_TO_EDGE; + img_desc.wrap_v = SG_WRAP_CLAMP_TO_EDGE; + img_desc.min_filter = SG_FILTER_LINEAR; + img_desc.mag_filter = SG_FILTER_LINEAR; + img_desc.data.subimage[0][0].ptr = font_pixels; + img_desc.data.subimage[0][0].size = (size_t)(font_width * font_height) * sizeof(uint32_t); + img_desc.label = "sokol-imgui-font"; + _simgui.img = sg_make_image(&img_desc); + io->Fonts->TexID = (ImTextureID)(uintptr_t) _simgui.img.id; + } + + /* shader object for using the embedded shader source (or bytecode) */ + sg_shader_desc shd_desc; + _simgui_clear(&shd_desc, sizeof(shd_desc)); + shd_desc.attrs[0].name = "position"; + shd_desc.attrs[1].name = "texcoord0"; + shd_desc.attrs[2].name = "color0"; + shd_desc.attrs[0].sem_name = "TEXCOORD"; + shd_desc.attrs[0].sem_index = 0; + shd_desc.attrs[1].sem_name = "TEXCOORD"; + shd_desc.attrs[1].sem_index = 1; + shd_desc.attrs[2].sem_name = "TEXCOORD"; + shd_desc.attrs[2].sem_index = 2; + sg_shader_uniform_block_desc* ub = &shd_desc.vs.uniform_blocks[0]; + ub->size = sizeof(_simgui_vs_params_t); + ub->uniforms[0].name = "vs_params"; + ub->uniforms[0].type = SG_UNIFORMTYPE_FLOAT4; + ub->uniforms[0].array_count = 1; + shd_desc.fs.images[0].name = "tex"; + shd_desc.fs.images[0].image_type = SG_IMAGETYPE_2D; + shd_desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; + shd_desc.label = "sokol-imgui-shader"; + #if defined(SOKOL_GLCORE33) + shd_desc.vs.source = _simgui_vs_source_glsl330; + shd_desc.fs.source = _simgui_fs_source_glsl330; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _simgui_vs_source_glsl300es; + shd_desc.fs.source = _simgui_fs_source_glsl300es; + #elif defined(SOKOL_METAL) + shd_desc.vs.entry = "main0"; + shd_desc.fs.entry = "main0"; + switch (sg_query_backend()) { + case SG_BACKEND_METAL_MACOS: + shd_desc.vs.bytecode = SG_RANGE(_simgui_vs_bytecode_metal_macos); + shd_desc.fs.bytecode = SG_RANGE(_simgui_fs_bytecode_metal_macos); + break; + case SG_BACKEND_METAL_IOS: + shd_desc.vs.bytecode = SG_RANGE(_simgui_vs_bytecode_metal_ios); + shd_desc.fs.bytecode = SG_RANGE(_simgui_fs_bytecode_metal_ios); + break; + default: + shd_desc.vs.source = _simgui_vs_source_metal_sim; + shd_desc.fs.source = _simgui_fs_source_metal_sim; + break; + } + #elif defined(SOKOL_D3D11) + shd_desc.vs.bytecode = SG_RANGE(_simgui_vs_bytecode_hlsl4); + shd_desc.fs.bytecode = SG_RANGE(_simgui_fs_bytecode_hlsl4); + #elif defined(SOKOL_WGPU) + shd_desc.vs.bytecode = SG_RANGE(_simgui_vs_bytecode_wgpu); + shd_desc.fs.bytecode = SG_RANGE(_simgui_fs_bytecode_wgpu); + #else + shd_desc.vs.source = _simgui_vs_source_dummy; + shd_desc.fs.source = _simgui_fs_source_dummy; + #endif + _simgui.shd = sg_make_shader(&shd_desc); + + /* pipeline object for imgui rendering */ + sg_pipeline_desc pip_desc; + _simgui_clear(&pip_desc, sizeof(pip_desc)); + pip_desc.layout.buffers[0].stride = sizeof(ImDrawVert); + { + sg_vertex_attr_desc* attr = &pip_desc.layout.attrs[0]; + attr->offset = offsetof(ImDrawVert, pos); + attr->format = SG_VERTEXFORMAT_FLOAT2; + } + { + sg_vertex_attr_desc* attr = &pip_desc.layout.attrs[1]; + attr->offset = offsetof(ImDrawVert, uv); + attr->format = SG_VERTEXFORMAT_FLOAT2; + } + { + sg_vertex_attr_desc* attr = &pip_desc.layout.attrs[2]; + attr->offset = offsetof(ImDrawVert, col); + attr->format = SG_VERTEXFORMAT_UBYTE4N; + } + pip_desc.shader = _simgui.shd; + pip_desc.index_type = SG_INDEXTYPE_UINT16; + pip_desc.sample_count = _simgui.desc.sample_count; + pip_desc.depth.pixel_format = _simgui.desc.depth_format; + pip_desc.colors[0].pixel_format = _simgui.desc.color_format; + pip_desc.colors[0].write_mask = _simgui.desc.write_alpha_channel ? SG_COLORMASK_RGBA : SG_COLORMASK_RGB; + pip_desc.colors[0].blend.enabled = true; + pip_desc.colors[0].blend.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA; + pip_desc.colors[0].blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + if (_simgui.desc.write_alpha_channel) { + pip_desc.colors[0].blend.src_factor_alpha = SG_BLENDFACTOR_ONE; + pip_desc.colors[0].blend.dst_factor_alpha = SG_BLENDFACTOR_ONE; + } + pip_desc.label = "sokol-imgui-pipeline"; + _simgui.pip = sg_make_pipeline(&pip_desc); + + sg_pop_debug_group(); +} + +SOKOL_API_IMPL void simgui_shutdown(void) { + #if defined(__cplusplus) + ImGui::DestroyContext(); + #else + igDestroyContext(0); + #endif + /* NOTE: it's valid to call the destroy funcs with SG_INVALID_ID */ + sg_push_debug_group("sokol-imgui"); + sg_destroy_pipeline(_simgui.pip); + sg_destroy_shader(_simgui.shd); + sg_destroy_image(_simgui.img); + sg_destroy_buffer(_simgui.ibuf); + sg_destroy_buffer(_simgui.vbuf); + sg_pop_debug_group(); + SOKOL_ASSERT(_simgui.vertices.ptr); + _simgui_free((void*)_simgui.vertices.ptr); + SOKOL_ASSERT(_simgui.indices.ptr); + _simgui_free((void*)_simgui.indices.ptr); +} + +SOKOL_API_IMPL void simgui_new_frame(const simgui_frame_desc_t* desc) { + SOKOL_ASSERT(desc); + SOKOL_ASSERT(desc->width > 0); + SOKOL_ASSERT(desc->height > 0); + _simgui.cur_dpi_scale = _simgui_def(desc->dpi_scale, 1.0f); + #if defined(__cplusplus) + ImGuiIO* io = &ImGui::GetIO(); + #else + ImGuiIO* io = igGetIO(); + #endif + io->DisplaySize.x = ((float)desc->width) / _simgui.cur_dpi_scale; + io->DisplaySize.y = ((float)desc->height) / _simgui.cur_dpi_scale; + io->DeltaTime = (float)desc->delta_time; + #if !defined(SOKOL_IMGUI_NO_SOKOL_APP) + if (io->WantTextInput && !sapp_keyboard_shown()) { + sapp_show_keyboard(true); + } + if (!io->WantTextInput && sapp_keyboard_shown()) { + sapp_show_keyboard(false); + } + if (!_simgui.desc.disable_set_mouse_cursor) { + #if defined(__cplusplus) + ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); + #else + ImGuiMouseCursor imgui_cursor = igGetMouseCursor(); + #endif + sapp_mouse_cursor cursor = sapp_get_mouse_cursor(); + switch (imgui_cursor) { + case ImGuiMouseCursor_Arrow: cursor = SAPP_MOUSECURSOR_ARROW; break; + case ImGuiMouseCursor_TextInput: cursor = SAPP_MOUSECURSOR_IBEAM; break; + case ImGuiMouseCursor_ResizeAll: cursor = SAPP_MOUSECURSOR_RESIZE_ALL; break; + case ImGuiMouseCursor_ResizeNS: cursor = SAPP_MOUSECURSOR_RESIZE_NS; break; + case ImGuiMouseCursor_ResizeEW: cursor = SAPP_MOUSECURSOR_RESIZE_EW; break; + case ImGuiMouseCursor_ResizeNESW: cursor = SAPP_MOUSECURSOR_RESIZE_NESW; break; + case ImGuiMouseCursor_ResizeNWSE: cursor = SAPP_MOUSECURSOR_RESIZE_NWSE; break; + case ImGuiMouseCursor_Hand: cursor = SAPP_MOUSECURSOR_POINTING_HAND; break; + case ImGuiMouseCursor_NotAllowed: cursor = SAPP_MOUSECURSOR_NOT_ALLOWED; break; + default: break; + } + sapp_set_mouse_cursor(cursor); + } + #endif + #if defined(__cplusplus) + ImGui::NewFrame(); + #else + igNewFrame(); + #endif +} + +SOKOL_API_IMPL void simgui_render(void) { + #if defined(__cplusplus) + ImGui::Render(); + ImDrawData* draw_data = ImGui::GetDrawData(); + ImGuiIO* io = &ImGui::GetIO(); + #else + igRender(); + ImDrawData* draw_data = igGetDrawData(); + ImGuiIO* io = igGetIO(); + #endif + if (0 == draw_data) { + return; + } + if (draw_data->CmdListsCount == 0) { + return; + } + /* copy vertices and indices into an intermediate buffer so that + they can be updated with a single sg_update_buffer() call each + (sg_append_buffer() has performance problems on some GL platforms), + also keep track of valid number of command lists in case of a + buffer overflow + */ + size_t all_vtx_size = 0; + size_t all_idx_size = 0; + int cmd_list_count = 0; + for (int cl_index = 0; cl_index < draw_data->CmdListsCount; cl_index++, cmd_list_count++) { + ImDrawList* cl = draw_data->CmdLists[cl_index]; + const size_t vtx_size = (size_t)cl->VtxBuffer.Size * sizeof(ImDrawVert); + const size_t idx_size = (size_t)cl->IdxBuffer.Size * sizeof(ImDrawIdx); + + /* check for buffer overflow */ + if (((all_vtx_size + vtx_size) > _simgui.vertices.size) || + ((all_idx_size + idx_size) > _simgui.indices.size)) + { + break; + } + + /* copy vertices and indices into common buffers */ + if (vtx_size > 0) { + const ImDrawVert* src_vtx_ptr = cl->VtxBuffer.Data; + void* dst_vtx_ptr = (void*) (((uint8_t*)_simgui.vertices.ptr) + all_vtx_size); + memcpy(dst_vtx_ptr, src_vtx_ptr, vtx_size); + } + if (idx_size > 0) { + const ImDrawIdx* src_idx_ptr = cl->IdxBuffer.Data; + void* dst_idx_ptr = (void*) (((uint8_t*)_simgui.indices.ptr) + all_idx_size); + memcpy(dst_idx_ptr, src_idx_ptr, idx_size); + } + all_vtx_size += vtx_size; + all_idx_size += idx_size; + } + if (0 == cmd_list_count) { + return; + } + + /* update the sokol-gfx vertex- and index-buffer */ + sg_push_debug_group("sokol-imgui"); + if (all_vtx_size > 0) { + sg_range vtx_data = _simgui.vertices; + vtx_data.size = all_vtx_size; + sg_update_buffer(_simgui.vbuf, &vtx_data); + } + if (all_idx_size > 0) { + sg_range idx_data = _simgui.indices; + idx_data.size = all_idx_size; + sg_update_buffer(_simgui.ibuf, &idx_data); + } + + /* render the ImGui command list */ + const float dpi_scale = _simgui.cur_dpi_scale; + const int fb_width = (int) (io->DisplaySize.x * dpi_scale); + const int fb_height = (int) (io->DisplaySize.y * dpi_scale); + sg_apply_viewport(0, 0, fb_width, fb_height, true); + sg_apply_scissor_rect(0, 0, fb_width, fb_height, true); + + sg_apply_pipeline(_simgui.pip); + _simgui_vs_params_t vs_params; + _simgui_clear((void*)&vs_params, sizeof(vs_params)); + vs_params.disp_size.x = io->DisplaySize.x; + vs_params.disp_size.y = io->DisplaySize.y; + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(vs_params)); + sg_bindings bind; + _simgui_clear((void*)&bind, sizeof(bind)); + bind.vertex_buffers[0] = _simgui.vbuf; + bind.index_buffer = _simgui.ibuf; + ImTextureID tex_id = io->Fonts->TexID; + bind.fs_images[0].id = (uint32_t)(uintptr_t)tex_id; + int vb_offset = 0; + int ib_offset = 0; + for (int cl_index = 0; cl_index < cmd_list_count; cl_index++) { + const ImDrawList* cl = draw_data->CmdLists[cl_index]; + + bind.vertex_buffer_offsets[0] = vb_offset; + bind.index_buffer_offset = ib_offset; + sg_apply_bindings(&bind); + + #if defined(__cplusplus) + const int num_cmds = cl->CmdBuffer.size(); + #else + const int num_cmds = cl->CmdBuffer.Size; + #endif + uint32_t vtx_offset = 0; + for (int cmd_index = 0; cmd_index < num_cmds; cmd_index++) { + ImDrawCmd* pcmd = &cl->CmdBuffer.Data[cmd_index]; + if (pcmd->UserCallback) { + pcmd->UserCallback(cl, pcmd); + // need to re-apply all state after calling a user callback + sg_apply_viewport(0, 0, fb_width, fb_height, true); + sg_apply_pipeline(_simgui.pip); + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, SG_RANGE_REF(vs_params)); + sg_apply_bindings(&bind); + } + else { + if ((tex_id != pcmd->TextureId) || (vtx_offset != pcmd->VtxOffset)) { + tex_id = pcmd->TextureId; + vtx_offset = pcmd->VtxOffset; + bind.fs_images[0].id = (uint32_t)(uintptr_t)tex_id; + bind.vertex_buffer_offsets[0] = vb_offset + (int)(pcmd->VtxOffset * sizeof(ImDrawVert)); + sg_apply_bindings(&bind); + } + const int scissor_x = (int) (pcmd->ClipRect.x * dpi_scale); + const int scissor_y = (int) (pcmd->ClipRect.y * dpi_scale); + const int scissor_w = (int) ((pcmd->ClipRect.z - pcmd->ClipRect.x) * dpi_scale); + const int scissor_h = (int) ((pcmd->ClipRect.w - pcmd->ClipRect.y) * dpi_scale); + sg_apply_scissor_rect(scissor_x, scissor_y, scissor_w, scissor_h, true); + sg_draw((int)pcmd->IdxOffset, (int)pcmd->ElemCount, 1); + } + } + #if defined(__cplusplus) + const size_t vtx_size = (size_t)cl->VtxBuffer.size() * sizeof(ImDrawVert); + const size_t idx_size = (size_t)cl->IdxBuffer.size() * sizeof(ImDrawIdx); + #else + const size_t vtx_size = (size_t)cl->VtxBuffer.Size * sizeof(ImDrawVert); + const size_t idx_size = (size_t)cl->IdxBuffer.Size * sizeof(ImDrawIdx); + #endif + vb_offset += (int)vtx_size; + ib_offset += (int)idx_size; + } + sg_apply_viewport(0, 0, fb_width, fb_height, true); + sg_apply_scissor_rect(0, 0, fb_width, fb_height, true); + sg_pop_debug_group(); +} + +#if !defined(SOKOL_IMGUI_NO_SOKOL_APP) +_SOKOL_PRIVATE bool _simgui_is_ctrl(uint32_t modifiers) { + if (_simgui.is_osx) { + return 0 != (modifiers & SAPP_MODIFIER_SUPER); + } + else { + return 0 != (modifiers & SAPP_MODIFIER_CTRL); + } +} + +_SOKOL_PRIVATE ImGuiKey _simgui_map_keycode(sapp_keycode key) { + switch (key) { + case SAPP_KEYCODE_SPACE: return ImGuiKey_Space; + case SAPP_KEYCODE_APOSTROPHE: return ImGuiKey_Apostrophe; + case SAPP_KEYCODE_COMMA: return ImGuiKey_Comma; + case SAPP_KEYCODE_MINUS: return ImGuiKey_Minus; + case SAPP_KEYCODE_PERIOD: return ImGuiKey_Apostrophe; + case SAPP_KEYCODE_SLASH: return ImGuiKey_Slash; + case SAPP_KEYCODE_0: return ImGuiKey_0; + case SAPP_KEYCODE_1: return ImGuiKey_1; + case SAPP_KEYCODE_2: return ImGuiKey_2; + case SAPP_KEYCODE_3: return ImGuiKey_3; + case SAPP_KEYCODE_4: return ImGuiKey_4; + case SAPP_KEYCODE_5: return ImGuiKey_5; + case SAPP_KEYCODE_6: return ImGuiKey_6; + case SAPP_KEYCODE_7: return ImGuiKey_7; + case SAPP_KEYCODE_8: return ImGuiKey_8; + case SAPP_KEYCODE_9: return ImGuiKey_9; + case SAPP_KEYCODE_SEMICOLON: return ImGuiKey_Semicolon; + case SAPP_KEYCODE_EQUAL: return ImGuiKey_Equal; + case SAPP_KEYCODE_A: return ImGuiKey_A; + case SAPP_KEYCODE_B: return ImGuiKey_B; + case SAPP_KEYCODE_C: return ImGuiKey_C; + case SAPP_KEYCODE_D: return ImGuiKey_D; + case SAPP_KEYCODE_E: return ImGuiKey_E; + case SAPP_KEYCODE_F: return ImGuiKey_F; + case SAPP_KEYCODE_G: return ImGuiKey_G; + case SAPP_KEYCODE_H: return ImGuiKey_H; + case SAPP_KEYCODE_I: return ImGuiKey_I; + case SAPP_KEYCODE_J: return ImGuiKey_J; + case SAPP_KEYCODE_K: return ImGuiKey_K; + case SAPP_KEYCODE_L: return ImGuiKey_L; + case SAPP_KEYCODE_M: return ImGuiKey_M; + case SAPP_KEYCODE_N: return ImGuiKey_N; + case SAPP_KEYCODE_O: return ImGuiKey_O; + case SAPP_KEYCODE_P: return ImGuiKey_P; + case SAPP_KEYCODE_Q: return ImGuiKey_Q; + case SAPP_KEYCODE_R: return ImGuiKey_R; + case SAPP_KEYCODE_S: return ImGuiKey_S; + case SAPP_KEYCODE_T: return ImGuiKey_T; + case SAPP_KEYCODE_U: return ImGuiKey_U; + case SAPP_KEYCODE_V: return ImGuiKey_V; + case SAPP_KEYCODE_W: return ImGuiKey_W; + case SAPP_KEYCODE_X: return ImGuiKey_X; + case SAPP_KEYCODE_Y: return ImGuiKey_Y; + case SAPP_KEYCODE_Z: return ImGuiKey_Z; + case SAPP_KEYCODE_LEFT_BRACKET: return ImGuiKey_LeftBracket; + case SAPP_KEYCODE_BACKSLASH: return ImGuiKey_Backslash; + case SAPP_KEYCODE_RIGHT_BRACKET:return ImGuiKey_RightBracket; + case SAPP_KEYCODE_GRAVE_ACCENT: return ImGuiKey_GraveAccent; + case SAPP_KEYCODE_ESCAPE: return ImGuiKey_Escape; + case SAPP_KEYCODE_ENTER: return ImGuiKey_Enter; + case SAPP_KEYCODE_TAB: return ImGuiKey_Tab; + case SAPP_KEYCODE_BACKSPACE: return ImGuiKey_Backspace; + case SAPP_KEYCODE_INSERT: return ImGuiKey_Insert; + case SAPP_KEYCODE_DELETE: return ImGuiKey_Delete; + case SAPP_KEYCODE_RIGHT: return ImGuiKey_RightArrow; + case SAPP_KEYCODE_LEFT: return ImGuiKey_LeftArrow; + case SAPP_KEYCODE_DOWN: return ImGuiKey_DownArrow; + case SAPP_KEYCODE_UP: return ImGuiKey_UpArrow; + case SAPP_KEYCODE_PAGE_UP: return ImGuiKey_PageUp; + case SAPP_KEYCODE_PAGE_DOWN: return ImGuiKey_PageDown; + case SAPP_KEYCODE_HOME: return ImGuiKey_Home; + case SAPP_KEYCODE_END: return ImGuiKey_End; + case SAPP_KEYCODE_CAPS_LOCK: return ImGuiKey_CapsLock; + case SAPP_KEYCODE_SCROLL_LOCK: return ImGuiKey_ScrollLock; + case SAPP_KEYCODE_NUM_LOCK: return ImGuiKey_NumLock; + case SAPP_KEYCODE_PRINT_SCREEN: return ImGuiKey_PrintScreen; + case SAPP_KEYCODE_PAUSE: return ImGuiKey_Pause; + case SAPP_KEYCODE_F1: return ImGuiKey_F1; + case SAPP_KEYCODE_F2: return ImGuiKey_F2; + case SAPP_KEYCODE_F3: return ImGuiKey_F3; + case SAPP_KEYCODE_F4: return ImGuiKey_F4; + case SAPP_KEYCODE_F5: return ImGuiKey_F5; + case SAPP_KEYCODE_F6: return ImGuiKey_F6; + case SAPP_KEYCODE_F7: return ImGuiKey_F7; + case SAPP_KEYCODE_F8: return ImGuiKey_F8; + case SAPP_KEYCODE_F9: return ImGuiKey_F9; + case SAPP_KEYCODE_F10: return ImGuiKey_F10; + case SAPP_KEYCODE_F11: return ImGuiKey_F11; + case SAPP_KEYCODE_F12: return ImGuiKey_F12; + case SAPP_KEYCODE_KP_0: return ImGuiKey_Keypad0; + case SAPP_KEYCODE_KP_1: return ImGuiKey_Keypad1; + case SAPP_KEYCODE_KP_2: return ImGuiKey_Keypad2; + case SAPP_KEYCODE_KP_3: return ImGuiKey_Keypad3; + case SAPP_KEYCODE_KP_4: return ImGuiKey_Keypad4; + case SAPP_KEYCODE_KP_5: return ImGuiKey_Keypad5; + case SAPP_KEYCODE_KP_6: return ImGuiKey_Keypad6; + case SAPP_KEYCODE_KP_7: return ImGuiKey_Keypad7; + case SAPP_KEYCODE_KP_8: return ImGuiKey_Keypad8; + case SAPP_KEYCODE_KP_9: return ImGuiKey_Keypad9; + case SAPP_KEYCODE_KP_DECIMAL: return ImGuiKey_KeypadDecimal; + case SAPP_KEYCODE_KP_DIVIDE: return ImGuiKey_KeypadDivide; + case SAPP_KEYCODE_KP_MULTIPLY: return ImGuiKey_KeypadMultiply; + case SAPP_KEYCODE_KP_SUBTRACT: return ImGuiKey_KeypadSubtract; + case SAPP_KEYCODE_KP_ADD: return ImGuiKey_KeypadAdd; + case SAPP_KEYCODE_KP_ENTER: return ImGuiKey_KeypadEnter; + case SAPP_KEYCODE_KP_EQUAL: return ImGuiKey_KeypadEqual; + case SAPP_KEYCODE_LEFT_SHIFT: return ImGuiKey_LeftShift; + case SAPP_KEYCODE_LEFT_CONTROL: return ImGuiKey_LeftCtrl; + case SAPP_KEYCODE_LEFT_ALT: return ImGuiKey_LeftAlt; + case SAPP_KEYCODE_LEFT_SUPER: return ImGuiKey_LeftSuper; + case SAPP_KEYCODE_RIGHT_SHIFT: return ImGuiKey_RightShift; + case SAPP_KEYCODE_RIGHT_CONTROL:return ImGuiKey_RightCtrl; + case SAPP_KEYCODE_RIGHT_ALT: return ImGuiKey_RightAlt; + case SAPP_KEYCODE_RIGHT_SUPER: return ImGuiKey_RightSuper; + case SAPP_KEYCODE_MENU: return ImGuiKey_Menu; + default: return ImGuiKey_None; + } +} + +_SOKOL_PRIVATE void _simgui_add_focus_event(ImGuiIO* io, bool focus) { + #if defined(__cplusplus) + io->AddFocusEvent(focus); + #else + ImGuiIO_AddFocusEvent(io, focus); + #endif +} + +_SOKOL_PRIVATE void _simgui_add_mouse_pos_event(ImGuiIO* io, float x, float y) { + #if defined(__cplusplus) + io->AddMousePosEvent(x, y); + #else + ImGuiIO_AddMousePosEvent(io, x, y); + #endif +} + +_SOKOL_PRIVATE void _simgui_add_mouse_button_event(ImGuiIO* io, int mouse_button, bool down) { + #if defined(__cplusplus) + io->AddMouseButtonEvent(mouse_button, down); + #else + ImGuiIO_AddMouseButtonEvent(io, mouse_button, down); + #endif +} + +_SOKOL_PRIVATE void _simgui_add_mouse_wheel_event(ImGuiIO* io, float wheel_x, float wheel_y) { + #if defined(__cplusplus) + io->AddMouseWheelEvent(wheel_x, wheel_y); + #else + ImGuiIO_AddMouseWheelEvent(io, wheel_x, wheel_y); + #endif +} + +_SOKOL_PRIVATE void _simgui_add_sapp_key_event(ImGuiIO* io, sapp_keycode sapp_key, bool down) { + const ImGuiKey imgui_key = _simgui_map_keycode(sapp_key); + #if defined(__cplusplus) + io->AddKeyEvent(imgui_key, down); + io->SetKeyEventNativeData(imgui_key, (int)sapp_key, 0, -1); + #else + ImGuiIO_AddKeyEvent(io, imgui_key, down); + ImGuiIO_SetKeyEventNativeData(io, imgui_key, (int)sapp_key, 0, -1); + #endif +} + +_SOKOL_PRIVATE void _simgui_add_imgui_key_event(ImGuiIO* io, ImGuiKey imgui_key, bool down) { + #if defined(__cplusplus) + io->AddKeyEvent(imgui_key, down); + #else + ImGuiIO_AddKeyEvent(io, imgui_key, down); + #endif +} + +_SOKOL_PRIVATE void _simgui_add_input_character(ImGuiIO* io, uint32_t c) { + #if defined(__cplusplus) + io->AddInputCharacter(c); + #else + ImGuiIO_AddInputCharacter(io, c); + #endif +} + +_SOKOL_PRIVATE void _simgui_update_modifiers(ImGuiIO* io, uint32_t mods) { + _simgui_add_imgui_key_event(io, ImGuiMod_Ctrl, (mods & SAPP_MODIFIER_CTRL) != 0); + _simgui_add_imgui_key_event(io, ImGuiMod_Shift, (mods & SAPP_MODIFIER_SHIFT) != 0); + _simgui_add_imgui_key_event(io, ImGuiMod_Alt, (mods & SAPP_MODIFIER_ALT) != 0); + _simgui_add_imgui_key_event(io, ImGuiMod_Super, (mods & SAPP_MODIFIER_SUPER) != 0); +} + +// returns Ctrl or Super, depending on platform +_SOKOL_PRIVATE ImGuiKey _simgui_copypaste_modifier(void) { + return _simgui.is_osx ? ImGuiMod_Super : ImGuiMod_Ctrl; +} + +SOKOL_API_IMPL int simgui_map_keycode(sapp_keycode keycode) { + return (int)_simgui_map_keycode(keycode); +} + +SOKOL_API_IMPL bool simgui_handle_event(const sapp_event* ev) { + const float dpi_scale = _simgui.cur_dpi_scale; + #if defined(__cplusplus) + ImGuiIO* io = &ImGui::GetIO(); + #else + ImGuiIO* io = igGetIO(); + #endif + switch (ev->type) { + case SAPP_EVENTTYPE_FOCUSED: + _simgui_add_focus_event(io, true); + break; + case SAPP_EVENTTYPE_UNFOCUSED: + _simgui_add_focus_event(io, false); + break; + case SAPP_EVENTTYPE_MOUSE_DOWN: + _simgui_add_mouse_pos_event(io, ev->mouse_x / dpi_scale, ev->mouse_y / dpi_scale); + _simgui_add_mouse_button_event(io, (int)ev->mouse_button, true); + _simgui_update_modifiers(io, ev->modifiers); + break; + case SAPP_EVENTTYPE_MOUSE_UP: + _simgui_add_mouse_pos_event(io, ev->mouse_x / dpi_scale, ev->mouse_y / dpi_scale); + _simgui_add_mouse_button_event(io, (int)ev->mouse_button, false); + _simgui_update_modifiers(io, ev->modifiers); + break; + case SAPP_EVENTTYPE_MOUSE_MOVE: + _simgui_add_mouse_pos_event(io, ev->mouse_x / dpi_scale, ev->mouse_y / dpi_scale); + break; + case SAPP_EVENTTYPE_MOUSE_ENTER: + case SAPP_EVENTTYPE_MOUSE_LEAVE: + // FIXME: since the sokol_app.h emscripten backend doesn't support + // mouse capture, mouse buttons must be released when the mouse leaves the + // browser window, so that they don't "stick" when released outside the window. + // A cleaner solution would be a new sokol_app.h function to query + // "platform behaviour flags". + #if defined(__EMSCRIPTEN__) + for (int i = 0; i < SAPP_MAX_MOUSEBUTTONS; i++) { + _simgui_add_mouse_button_event(io, i, false); + } + #endif + break; + case SAPP_EVENTTYPE_MOUSE_SCROLL: + _simgui_add_mouse_wheel_event(io, ev->scroll_x, ev->scroll_y); + break; + case SAPP_EVENTTYPE_TOUCHES_BEGAN: + _simgui_add_mouse_pos_event(io, ev->touches[0].pos_x / dpi_scale, ev->touches[0].pos_y / dpi_scale); + _simgui_add_mouse_button_event(io, 0, true); + break; + case SAPP_EVENTTYPE_TOUCHES_MOVED: + _simgui_add_mouse_pos_event(io, ev->touches[0].pos_x / dpi_scale, ev->touches[0].pos_y / dpi_scale); + break; + case SAPP_EVENTTYPE_TOUCHES_ENDED: + _simgui_add_mouse_pos_event(io, ev->touches[0].pos_x / dpi_scale, ev->touches[0].pos_y / dpi_scale); + _simgui_add_mouse_button_event(io, 0, false); + break; + case SAPP_EVENTTYPE_TOUCHES_CANCELLED: + _simgui_add_mouse_button_event(io, 0, false); + break; + case SAPP_EVENTTYPE_KEY_DOWN: + _simgui_update_modifiers(io, ev->modifiers); + /* intercept Ctrl-V, this is handled via EVENTTYPE_CLIPBOARD_PASTED */ + if (!_simgui.desc.disable_paste_override) { + if (_simgui_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_V)) { + break; + } + } + /* on web platform, don't forward Ctrl-X, Ctrl-V to the browser */ + if (_simgui_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_X)) { + sapp_consume_event(); + } + if (_simgui_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_C)) { + sapp_consume_event(); + } + // it's ok to add ImGuiKey_None key events + _simgui_add_sapp_key_event(io, ev->key_code, true); + break; + case SAPP_EVENTTYPE_KEY_UP: + _simgui_update_modifiers(io, ev->modifiers); + /* intercept Ctrl-V, this is handled via EVENTTYPE_CLIPBOARD_PASTED */ + if (_simgui_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_V)) { + break; + } + /* on web platform, don't forward Ctrl-X, Ctrl-V to the browser */ + if (_simgui_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_X)) { + sapp_consume_event(); + } + if (_simgui_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_C)) { + sapp_consume_event(); + } + // it's ok to add ImGuiKey_None key events + _simgui_add_sapp_key_event(io, ev->key_code, false); + break; + case SAPP_EVENTTYPE_CHAR: + /* on some platforms, special keys may be reported as + characters, which may confuse some ImGui widgets, + drop those, also don't forward characters if some + modifiers have been pressed + */ + _simgui_update_modifiers(io, ev->modifiers); + if ((ev->char_code >= 32) && + (ev->char_code != 127) && + (0 == (ev->modifiers & (SAPP_MODIFIER_ALT|SAPP_MODIFIER_CTRL|SAPP_MODIFIER_SUPER)))) + { + _simgui_add_input_character(io, ev->char_code); + } + break; + case SAPP_EVENTTYPE_CLIPBOARD_PASTED: + /* simulate a Ctrl-V key down/up */ + if (!_simgui.desc.disable_paste_override) { + _simgui_add_imgui_key_event(io, _simgui_copypaste_modifier(), true); + _simgui_add_imgui_key_event(io, ImGuiKey_V, true); + _simgui_add_imgui_key_event(io, ImGuiKey_V, false); + _simgui_add_imgui_key_event(io, _simgui_copypaste_modifier(), false); + } + break; + default: + break; + } + return io->WantCaptureKeyboard || io->WantCaptureMouse; +} +#endif // SOKOL_IMGUI_NO_SOKOL_APP + +#endif // SOKOL_IMPL diff --git a/source/engine/thirdparty/sokol/sokol_memtrack.h b/source/engine/thirdparty/sokol/sokol_memtrack.h new file mode 100644 index 0000000..dc0b469 --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_memtrack.h @@ -0,0 +1,167 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_MEMTRACK_IMPL) +#define SOKOL_MEMTRACK_IMPL +#endif +#ifndef SOKOL_MEMTRACK_INCLUDED +/* + sokol_memtrack.h -- memory allocation wrapper to track memory usage + of sokol libraries + + Project URL: https://github.com/floooh/sokol + + Optionally provide the following defines with your own implementations: + + SOKOL_MEMTRACK_API_DECL - public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_MEMTRACK_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + + If sokol_memtrack.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + USAGE + ===== + Just plug the malloc/free wrapper functions into the desc.allocator + struct provided by most sokol header setup functions: + + sg_setup(&(sg_desc){ + //... + .allocator = { + .alloc = smemtrack_alloc, + .free = smemtrack_free, + } + }); + + Then call smemtrack_info() to get information about current number + of allocations and overall allocation size: + + const smemtrack_info_t info = smemtrack_info(); + const int num_allocs = info.num_allocs; + const int num_bytes = info.num_bytes; + + Note the sokol_memtrack.h can only track allocations issued by + the sokol headers, not allocations that happen under the hood + in system libraries. + + LICENSE + ======= + + zlib/libpng license + + Copyright (c) 2018 Andre Weissflog + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_MEMTRACK_INCLUDED (1) +#include +#include // size_t + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_MEMTRACK_API_DECL) +#define SOKOL_MEMTRACK_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_MEMTRACK_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_MEMTRACK_IMPL) +#define SOKOL_MEMTRACK_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_MEMTRACK_API_DECL __declspec(dllimport) +#else +#define SOKOL_MEMTRACK_API_DECL extern +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct smemtrack_info_t { + int num_allocs; + int num_bytes; +} smemtrack_info_t; + +SOKOL_MEMTRACK_API_DECL smemtrack_info_t smemtrack_info(void); +SOKOL_MEMTRACK_API_DECL void* smemtrack_alloc(size_t size, void* user_data); +SOKOL_MEMTRACK_API_DECL void smemtrack_free(void* ptr, void* user_data); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* SOKOL_MEMTRACK_INCLUDED */ + +/*=== IMPLEMENTATION =========================================================*/ +#ifdef SOKOL_MEMTRACK_IMPL +#define SOKOL_MEMTRACK_IMPL_INCLUDED (1) +#include // malloc, free +#include // memset + +#ifndef SOKOL_API_IMPL + #define SOKOL_API_IMPL +#endif +#ifndef SOKOL_DEBUG + #ifndef NDEBUG + #define SOKOL_DEBUG + #endif +#endif +#ifndef _SOKOL_PRIVATE + #if defined(__GNUC__) || defined(__clang__) + #define _SOKOL_PRIVATE __attribute__((unused)) static + #else + #define _SOKOL_PRIVATE static + #endif +#endif + +// per-allocation header used to keep track of the allocation size +#define _SMEMTRACK_HEADER_SIZE (16) + +static struct { + smemtrack_info_t state; +} _smemtrack; + +SOKOL_API_IMPL void* smemtrack_alloc(size_t size, void* user_data) { + (void)user_data; + uint8_t* ptr = (uint8_t*) malloc(size + _SMEMTRACK_HEADER_SIZE); + if (ptr) { + // store allocation size (for allocation size tracking) + *(size_t*)ptr = size; + _smemtrack.state.num_allocs++; + _smemtrack.state.num_bytes += (int) size; + return ptr + _SMEMTRACK_HEADER_SIZE; + } + else { + // allocation failed, return null pointer + return ptr; + } +} + +SOKOL_API_IMPL void smemtrack_free(void* ptr, void* user_data) { + (void)user_data; + if (ptr) { + uint8_t* alloc_ptr = ((uint8_t*)ptr) - _SMEMTRACK_HEADER_SIZE; + size_t size = *(size_t*)alloc_ptr; + _smemtrack.state.num_allocs--; + _smemtrack.state.num_bytes -= (int) size; + free(alloc_ptr); + } +} + +SOKOL_API_IMPL smemtrack_info_t smemtrack_info(void) { + return _smemtrack.state; +} + +#endif /* SOKOL_MEMTRACK_IMPL */ diff --git a/source/engine/thirdparty/sokol/sokol_nuklear.h b/source/engine/thirdparty/sokol/sokol_nuklear.h new file mode 100644 index 0000000..a380bc8 --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_nuklear.h @@ -0,0 +1,2180 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_NUKLEAR_IMPL) +#define SOKOL_NUKLEAR_IMPL +#endif +#ifndef SOKOL_NUKLEAR_INCLUDED +/* + sokol_nuklear.h -- drop-in Nuklear renderer/event-handler for sokol_gfx.h + + Project URL: https://github.com/floooh/sokol + + Do this: + #define SOKOL_IMPL or + #define SOKOL_NUKLEAR_IMPL + + before you include this file in *one* C or C++ file to create the + implementation. + + The following defines are used by the implementation to select the + platform-specific embedded shader code (these are the same defines as + used by sokol_gfx.h and sokol_app.h): + + SOKOL_GLCORE33 + SOKOL_GLES3 + SOKOL_D3D11 + SOKOL_METAL + SOKOL_WGPU + + Optionally provide the following configuration defines before including the + implementation: + + SOKOL_NUKLEAR_NO_SOKOL_APP - don't depend on sokol_app.h (see below for details) + + Optionally provide the following macros before including the implementation + to override defaults: + + SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) + SOKOL_NUKLEAR_API_DECL- public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_NUKLEAR_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + + If sokol_nuklear.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + On Windows, SOKOL_DLL will define SOKOL_NUKLEAR_API_DECL as __declspec(dllexport) + or __declspec(dllimport) as needed. + + Include the following headers before sokol_nuklear.h (both before including + the declaration and implementation): + + sokol_gfx.h + sokol_app.h (except SOKOL_NUKLEAR_NO_SOKOL_APP) + + Additionally, include the following headers before including the + implementation: + + nuklear.h + + NOTE: Unlike most other sokol-headers, the implementation must be compiled + as C, compiling as C++ isn't supported. The interface is callable + from C++ of course. + + + FEATURE OVERVIEW: + ================= + sokol_nuklear.h implements the initialization, rendering and event-handling + code for Nuklear (https://github.com/Immediate-Mode-UI/Nuklear) on top of + sokol_gfx.h and (optionally) sokol_app.h. + + The sokol_app.h dependency is optional and used for input event handling. + If you only use sokol_gfx.h but not sokol_app.h in your application, + define SOKOL_NUKLEAR_NO_SOKOL_APP before including the implementation + of sokol_nuklear.h, this will remove any dependency to sokol_app.h, but + you must feed input events into Nuklear yourself. + + sokol_nuklear.h is not thread-safe, all calls must be made from the + same thread where sokol_gfx.h is running. + + HOWTO: + ====== + + --- To initialize sokol-nuklear, call: + + snk_setup(const snk_desc_t* desc) + + This will initialize Nuklear and create sokol-gfx resources + (two buffers for vertices and indices, a font texture and a pipeline- + state-object). + + Use the following snk_desc_t members to configure behaviour: + + int max_vertices + The maximum number of vertices used for UI rendering, default is 65536. + sokol-nuklear will use this to compute the size of the vertex- + and index-buffers allocated via sokol_gfx.h + + sg_pixel_format color_format + The color pixel format of the render pass where the UI + will be rendered. The default is SG_PIXELFORMAT_RGBA8 + + sg_pixel_format depth_format + The depth-buffer pixel format of the render pass where + the UI will be rendered. The default is SG_PIXELFORMAT_DEPTHSTENCIL. + + int sample_count + The MSAA sample-count of the render pass where the UI + will be rendered. The default is 1. + + float dpi_scale + DPI scaling factor. Set this to the result of sapp_dpi_scale(). + To render in high resolution on a Retina Mac this would + typically be 2.0. The default value is 1.0 + + bool no_default_font + Set this to true if you don't want to use Nuklear's default + font. In this case you need to initialize the font + yourself after snk_setup() is called. + + --- At the start of a frame, call: + + struct nk_context *snk_new_frame() + + This updates Nuklear's event handling state and then returns + a Nuklear context pointer which you use to build the UI. For + example: + + struct nk_context *ctx = snk_new_frame(); + if (nk_begin(ctx, "Demo", nk_rect(50, 50, 200, 200), ... + + + --- at the end of the frame, before the sg_end_pass() where you + want to render the UI, call: + + snk_render(int width, int height) + + where 'width' and 'height' are the dimensions of the rendering surface. + For example, if you're using sokol_app.h and render to the default + framebuffer: + + snk_render(sapp_width(), sapp_height()); + + This will convert Nuklear's command list into a vertex and index buffer, + and then render that through sokol_gfx.h + + --- if you're using sokol_app.h, from inside the sokol_app.h event callback, + call: + + void snk_handle_event(const sapp_event* ev); + + --- finally, on application shutdown, call + + snk_shutdown() + + --- Note that for touch-based systems, like iOS, there is a wrapper around + nk_edit_string(...), called snk_edit_string(...) which will show + and hide the onscreen keyboard as required. + + LICENSE + ======= + + zlib/libpng license + + Copyright (c) 2020 Warren Merrifield + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_NUKLEAR_INCLUDED (1) +#include +#include + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_nuklear.h" +#endif +#if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) && !defined(SOKOL_APP_INCLUDED) +#error "Please include sokol_app.h before sokol_nuklear.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_NUKLEAR_API_DECL) +#define SOKOL_NUKLEAR_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_NUKLEAR_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_NUKLEAR_IMPL) +#define SOKOL_NUKLEAR_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_NUKLEAR_API_DECL __declspec(dllimport) +#else +#define SOKOL_NUKLEAR_API_DECL extern +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct snk_desc_t { + int max_vertices; + sg_pixel_format color_format; + sg_pixel_format depth_format; + int sample_count; + float dpi_scale; + bool no_default_font; +} snk_desc_t; + +SOKOL_NUKLEAR_API_DECL void snk_setup(const snk_desc_t* desc); +SOKOL_NUKLEAR_API_DECL struct nk_context* snk_new_frame(void); +SOKOL_NUKLEAR_API_DECL void snk_render(int width, int height); +#if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) +SOKOL_NUKLEAR_API_DECL void snk_handle_event(const sapp_event* ev); +SOKOL_NUKLEAR_API_DECL nk_flags snk_edit_string(struct nk_context *ctx, nk_flags flags, + char *memory, int *len, int max, nk_plugin_filter filter); +#endif +SOKOL_NUKLEAR_API_DECL void snk_shutdown(void); + +#ifdef __cplusplus +} /* extern "C" */ + +/* reference-based equivalents for C++ */ +inline void snk_setup(const snk_desc_t& desc) { return snk_setup(&desc); } + +#endif +#endif /* SOKOL_NUKLEAR_INCLUDED */ + +/*-- IMPLEMENTATION ----------------------------------------------------------*/ + +#ifdef SOKOL_NUKLEAR_IMPL +#define SOKOL_NUKLEAR_IMPL_INCLUDED (1) + +#if !defined(NK_UNDEFINED) +#error "Please include nuklear.h before the sokol_nuklear.h implementation" +#endif + +#if !defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) +#error "Please ensure that NK_INCLUDE_VERTEX_BUFFER_OUTPUT is #defined before including nuklear.h" +#endif + +#ifdef __cplusplus +#error "The sokol_nuklear.h implementation must be compiled as C." +#endif + + +#include /* offsetof */ +#include /* memset */ + +#if defined(__EMSCRIPTEN__) && !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) && !defined(SOKOL_DUMMY_BACKEND) +#include +#endif + +#ifndef SOKOL_API_IMPL +#define SOKOL_API_IMPL +#endif +#ifndef SOKOL_DEBUG + #ifndef NDEBUG + #define SOKOL_DEBUG + #endif +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif +#ifndef _SOKOL_PRIVATE + #if defined(__GNUC__) || defined(__clang__) + #define _SOKOL_PRIVATE __attribute__((unused)) static + #else + #define _SOKOL_PRIVATE static + #endif +#endif + +/* helper macros */ +#define _snk_def(val, def) (((val) == 0) ? (def) : (val)) + +typedef struct _snk_vertex_t { + float pos[2]; + float uv[2]; + uint8_t col[4]; +} _snk_vertex_t; + +typedef struct _snk_vs_params_t { + float disp_size[2]; + uint8_t _pad_8[8]; +} _snk_vs_params_t; + +typedef struct { + snk_desc_t desc; + struct nk_context ctx; + struct nk_font_atlas atlas; + _snk_vs_params_t vs_params; + size_t vertex_buffer_size; + size_t index_buffer_size; + sg_buffer vbuf; + sg_buffer ibuf; + sg_image img; + sg_shader shd; + sg_pipeline pip; + bool is_osx; /* return true if running on OSX (or HTML5 OSX), needed for copy/paste */ + #if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) + int mouse_pos[2]; + float mouse_scroll[2]; + bool mouse_did_move; + bool mouse_did_scroll; + bool btn_down[NK_BUTTON_MAX]; + bool btn_up[NK_BUTTON_MAX]; + char char_buffer[NK_INPUT_MAX]; + bool keys_down[NK_KEY_MAX]; + bool keys_up[NK_KEY_MAX]; + #endif +} _snk_state_t; +static _snk_state_t _snuklear; + +/* + Embedded source code compiled with: + + sokol-shdc -i snuk.glsl -o snuk.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + + (not that for Metal and D3D11 byte code, sokol-shdc must be run + on macOS and Windows) + + @vs vs + uniform vs_params { + vec2 disp_size; + }; + in vec2 position; + in vec2 texcoord0; + in vec4 color0; + out vec2 uv; + out vec4 color; + void main() { + gl_Position = vec4(((position/disp_size)-0.5)*vec2(2.0,-2.0), 0.5, 1.0); + uv = texcoord0; + color = color0; + } + @end + + @fs fs + uniform sampler2D tex; + in vec2 uv; + in vec4 color; + out vec4 frag_color; + void main() { + frag_color = texture(tex, uv) * color; + } + @end + + @program snuk vs fs +*/ +#if defined(SOKOL_GLCORE33) +static const char _snk_vs_source_glsl330[341] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e, + 0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20, + 0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f, + 0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28, + 0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20,0x76,0x73,0x5f, + 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2d,0x20, + 0x76,0x65,0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63, + 0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x2c,0x20,0x30,0x2e, + 0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20, + 0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b, + 0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _snk_fs_source_glsl330[169] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20, + 0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63, + 0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76, + 0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69,0x6e,0x20,0x76, + 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, + 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75, + 0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_GLES3) +static const char _snk_vs_source_glsl300es[344] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c, + 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20, + 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f, + 0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65, + 0x63,0x34,0x28,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x29, + 0x20,0x2d,0x20,0x76,0x65,0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20, + 0x76,0x65,0x63,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x2c, + 0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _snk_fs_source_glsl300es[242] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a, + 0x0a,0x00, +}; +#elif defined(SOKOL_METAL) +static const uint8_t _snk_vs_bytecode_metal_macos[3216] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x90,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x80,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0xef,0xd7,0x24,0x0b,0xf0,0x26,0xba, + 0xcd,0xc3,0x6f,0x48,0x91,0x7a,0x7c,0x38,0xca,0xb8,0xf1,0xb1,0xe3,0xc7,0x99,0x8d, + 0xac,0x39,0x8e,0x2f,0xf8,0xa3,0x19,0x68,0x22,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x37,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x22,0x00,0x03,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x56,0x41,0x54,0x59,0x05,0x00,0x03, + 0x00,0x04,0x04,0x06,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54, + 0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x60,0x0b,0x00,0x00, + 0xff,0xff,0xff,0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0xd5,0x02,0x00,0x00, + 0x0b,0x82,0x20,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91, + 0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19, + 0x1e,0x04,0x8b,0x62,0x80,0x10,0x45,0x02,0x42,0x92,0x0b,0x42,0x84,0x10,0x32,0x14, + 0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80, + 0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x08,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0, + 0x01,0x00,0x00,0x00,0x51,0x18,0x00,0x00,0x81,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8, + 0xff,0xff,0xff,0xff,0x01,0x90,0x80,0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87, + 0x71,0xa0,0x07,0x76,0xc8,0x87,0x36,0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72, + 0x20,0x87,0x36,0x20,0x87,0x74,0xb0,0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88, + 0x07,0x79,0xa0,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41, + 0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e,0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c, + 0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87, + 0x72,0x98,0x87,0x79,0x68,0x03,0x78,0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72, + 0x68,0x03,0x73,0x80,0x87,0x76,0x08,0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e, + 0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda, + 0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81,0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21, + 0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30, + 0x07,0x79,0x08,0x87,0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87, + 0x72,0x90,0x87,0x36,0x28,0x07,0x76,0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77, + 0x68,0x03,0x76,0x28,0x87,0x70,0x30,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70, + 0x07,0x73,0x98,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1, + 0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08, + 0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87, + 0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41, + 0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d, + 0xca,0x81,0x1c,0xda,0x40,0x1f,0xca,0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0, + 0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80, + 0x70,0x87,0x77,0x68,0x03,0x7a,0x90,0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38, + 0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00, + 0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61,0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1, + 0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e,0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4,0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87, + 0x79,0x08,0x07,0x73,0x28,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a, + 0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d, + 0xe6,0xe1,0x1d,0xcc,0x81,0x1e,0xda,0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00, + 0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x36,0x18,0x02,0x01,0x2c,0x40,0x05,0x00, + 0x49,0x18,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,0x00, + 0x1b,0x00,0x00,0x00,0x32,0x22,0x08,0x09,0x20,0x64,0x85,0x04,0x13,0x22,0xa4,0x84, + 0x04,0x13,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x88,0x8c,0x0b,0x84,0x84,0x4c, + 0x10,0x3c,0x33,0x00,0xc3,0x08,0x02,0x30,0x8c,0x40,0x00,0x77,0x49,0x53,0x44,0x09, + 0x93,0xcf,0x00,0x48,0x43,0xff,0x0e,0x35,0xf9,0x0f,0x20,0x28,0xc4,0x80,0x87,0x10, + 0x39,0x48,0x9a,0x22,0x4a,0x98,0xfc,0x4a,0xfa,0x1f,0x20,0x02,0x18,0x09,0x05,0x31, + 0x88,0x40,0x08,0xa5,0x98,0x08,0x29,0xb2,0x81,0x80,0x39,0x02,0x30,0xc8,0x81,0x9c, + 0x23,0x00,0x85,0x41,0x84,0x40,0x18,0x46,0x20,0x92,0x11,0x00,0x00,0x00,0x00,0x00, + 0x13,0xb2,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60, + 0x87,0x72,0x68,0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03, + 0x37,0x88,0x83,0x38,0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71, + 0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80, + 0x07,0x6d,0x90,0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07, + 0x6d,0x90,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d, + 0x90,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60, + 0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71, + 0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40, + 0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07, + 0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a, + 0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60, + 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07, + 0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78, + 0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10, + 0x07,0x79,0x20,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07, + 0x6d,0x60,0x0f,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72, + 0x50,0x07,0x76,0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20, + 0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07, + 0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d, + 0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x39,0x00, + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xc8,0x02,0x01,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0xda, + 0x11,0x00,0xca,0x12,0x18,0x01,0x28,0x88,0x22,0x28,0x84,0x32,0x20,0x1d,0x6b,0x50, + 0x1e,0x82,0x60,0x8c,0x00,0x04,0x41,0x50,0x04,0x03,0x00,0x00,0x79,0x18,0x00,0x00, + 0x16,0x01,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9, + 0xb9,0xb4,0x37,0xb7,0x21,0x46,0x52,0x20,0x80,0x82,0x50,0xb9,0x1b,0x43,0x0b,0x93, + 0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x24,0x02,0x22,0x24,0x06,0xd9,0x20,0x08,0x0e, + 0x8e,0xad,0x0c,0x84,0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d, + 0x24,0x07,0x46,0xc6,0x25,0x86,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac, + 0x25,0x07,0x46,0xc6,0x25,0x86,0xc6,0x25,0x27,0x65,0x88,0x80,0x10,0x43,0x8c,0x44, + 0x48,0x88,0x64,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x41,0x8e,0x44,0x48,0x84, + 0x64,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56, + 0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x40, + 0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61, + 0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04, + 0x64,0x61,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98, + 0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1, + 0x7d,0x91,0xa5,0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11,0x90,0x86,0x61,0x10,0x96,0x26, + 0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6, + 0x45,0xf6,0x56,0x27,0xc6,0x56,0xf6,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44, + 0x40,0x1e,0x92,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b, + 0x5b,0x18,0x5d,0x9a,0x5d,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9, + 0x17,0x59,0xda,0x5c,0x98,0x18,0x5b,0xd9,0x10,0x01,0x89,0x78,0x06,0x61,0x69,0x72, + 0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f, + 0x77,0x69,0x64,0x65,0x5f,0x76,0x65,0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73, + 0x61,0x62,0x6c,0x65,0x43,0x04,0x64,0x62,0x14,0x96,0x26,0xe7,0x62,0x57,0x26,0x47, + 0x57,0x86,0xf7,0xf5,0x56,0x47,0x07,0x57,0x47,0xc7,0xa5,0x6e,0xae,0x4c,0x0e,0x85, + 0xed,0x6d,0xcc,0x0d,0x26,0x85,0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d, + 0x1e,0x5c,0xd9,0x97,0x5b,0x58,0x5b,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x32, + 0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x6e,0x61,0x6d,0x65,0x14,0xea,0xec,0x86, + 0x30,0x48,0x85,0x58,0xc8,0x85,0x60,0x48,0x86,0x68,0x5c,0xea,0xe6,0xca,0xe4,0x50, + 0xd8,0xde,0xc6,0xdc,0x62,0x52,0x68,0x98,0xb1,0xbd,0x85,0xd1,0xd1,0xb0,0x18,0x7b, + 0x63,0x7b,0x93,0x1b,0xc2,0x20,0x15,0xc2,0x21,0x17,0xd2,0x21,0x19,0xe2,0x91,0x09, + 0x4b,0x93,0x73,0x81,0x7b,0x9b,0x4b,0xa3,0x4b,0x7b,0x73,0xe3,0x72,0xc6,0xf6,0x05, + 0xf5,0x36,0x97,0x46,0x97,0xf6,0xe6,0x36,0x44,0x41,0xc0,0x00,0xb9,0x90,0x0e,0xc9, + 0x90,0x30,0x18,0x62,0x20,0x1b,0xf2,0x21,0x62,0x40,0x28,0x2c,0x4d,0xce,0xc5,0xae, + 0x4c,0x8e,0xae,0x0c,0xef,0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x52,0x58,0x9a,0x9c,0x0b, + 0xdb,0xdb,0x58,0x18,0x5d,0xda,0x9b,0xdb,0x57,0x9a,0x1b,0x59,0x19,0x1e,0xb3,0xb3, + 0x32,0xb7,0x32,0xb9,0x30,0xba,0x32,0x32,0x14,0x1c,0xb8,0xb7,0xb9,0x34,0xba,0xb4, + 0x37,0x37,0x22,0x3b,0x99,0x2f,0xb3,0x14,0x22,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x43,0xa8,0x64,0x40,0xc8,0x00,0x29,0x83,0x64,0x48,0x04,0xc4,0x0c,0x90,0x0b, + 0xc1,0x90,0x0c,0x39,0x03,0x6a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x28, + 0x39,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x44,0x76,0x32,0x5f,0x66,0x29, + 0x4c,0xe8,0xca,0xf0,0xc6,0xde,0xde,0xe4,0xc8,0x60,0x86,0x50,0x89,0x80,0x90,0x01, + 0x52,0x06,0x89,0x90,0x08,0x48,0x1a,0x20,0x17,0x82,0x21,0x19,0xa2,0x06,0xbc,0xce, + 0xca,0xdc,0xca,0xe4,0xc2,0xe8,0xca,0xc8,0x50,0x6c,0xc6,0xde,0xd8,0xde,0xe4,0x60, + 0x88,0xec,0x68,0xbe,0xcc,0x52,0x68,0x8c,0xbd,0xb1,0xbd,0xc9,0xc1,0x0c,0xa1,0x92, + 0x02,0x21,0x03,0xa4,0x0c,0x92,0x22,0x11,0x10,0x36,0x40,0x2e,0xa4,0x43,0x32,0xa4, + 0x0d,0xa8,0x84,0xa5,0xc9,0xb9,0x88,0xd5,0x99,0x99,0x95,0xc9,0xf1,0x09,0x4b,0x93, + 0x73,0x11,0xab,0x33,0x33,0x2b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x23,0x12,0x96,0x26, + 0xe7,0x22,0x57,0x16,0x46,0x46,0x2a,0x2c,0x4d,0xce,0x65,0x8e,0x4e,0xae,0x6e,0x8c, + 0xee,0x8b,0x2e,0x0f,0xae,0xec,0x2b,0xcd,0xcd,0xec,0x8d,0x09,0x59,0xda,0x1c,0xdc, + 0xd7,0x5c,0x9a,0x5e,0xd9,0x10,0x25,0x19,0x12,0x22,0x19,0x10,0x0c,0x99,0x03,0x46, + 0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x74,0x79,0x70,0x65,0x5f,0x73,0x69,0x7a, + 0x65,0xbc,0xc2,0xd2,0xe4,0x5c,0xc2,0xe4,0xce,0xbe,0xe8,0xf2,0xe0,0xca,0xbe,0xc2, + 0xd8,0xd2,0xce,0xdc,0xbe,0xe6,0xd2,0xf4,0xca,0x98,0xd8,0xcd,0x7d,0xc1,0x85,0xc9, + 0x85,0xb5,0xcd,0x71,0xf8,0x92,0x99,0x19,0x42,0x06,0xc9,0x81,0xbc,0x01,0x02,0x07, + 0x09,0x81,0x94,0x41,0x32,0x24,0x02,0x12,0x07,0x88,0x1c,0x20,0x74,0x80,0xd4,0x41, + 0x42,0x20,0x76,0x90,0x10,0xc8,0x85,0xdc,0x01,0x92,0x21,0x78,0x30,0x04,0x41,0xd0, + 0x00,0x59,0x03,0xc4,0x0d,0x90,0x3c,0x18,0x62,0x1c,0x00,0x32,0x06,0x88,0x1e,0xf0, + 0x79,0x6b,0x73,0x4b,0x83,0x7b,0xa3,0x2b,0x73,0xa3,0x03,0x19,0x43,0x0b,0x93,0xe3, + 0x33,0x95,0xd6,0x06,0xc7,0x56,0x06,0x32,0xb4,0xb2,0x02,0x42,0x25,0x14,0x14,0x34, + 0x44,0x40,0xfa,0x60,0x88,0x81,0xf0,0x01,0xe2,0x07,0x4b,0x30,0xc4,0x40,0xfe,0x00, + 0xf9,0x83,0x25,0x18,0x22,0x00,0xc9,0x88,0x88,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d, + 0xda,0xe1,0x1d,0xc8,0xa1,0x1e,0xd8,0xa1,0x1c,0xdc,0xc0,0x1c,0xd8,0x21,0x1c,0xce, + 0x61,0x1e,0xa6,0x08,0xc1,0x30,0x42,0x61,0x07,0x76,0xb0,0x87,0x76,0x70,0x83,0x74, + 0x20,0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0x14,0x23,0x96,0x70,0x48,0x07,0x79,0x70, + 0x03,0x7b,0x28,0x07,0x79,0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12,0x18,0x23,0xa8, + 0x70,0x48,0x07,0x79,0x70,0x03,0x76,0x08,0x07,0x77,0x38,0x87,0x7a,0x08,0x87,0x73, + 0x28,0x87,0x5f,0xb0,0x87,0x72,0x90,0x87,0x79,0x48,0x87,0x77,0x70,0x87,0x29,0x01, + 0x32,0x62,0x0a,0x87,0x74,0x90,0x07,0x37,0x18,0x87,0x77,0x68,0x07,0x78,0x48,0x07, + 0x76,0x28,0x87,0x5f,0x78,0x07,0x78,0xa0,0x87,0x74,0x78,0x07,0x77,0x98,0x87,0x29, + 0x86,0xc2,0x38,0x90,0x44,0x8d,0x50,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c, + 0xe4,0x81,0x1e,0xca,0x01,0x1f,0xa6,0x04,0x7b,0x00,0x00,0x00,0x79,0x18,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88, + 0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6, + 0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce, + 0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8, + 0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48, + 0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11, + 0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e, + 0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89, + 0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b, + 0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37, + 0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78, + 0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81, + 0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1, + 0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c, + 0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39, + 0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc, + 0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58, + 0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87, + 0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f, + 0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e, + 0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66, + 0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b, + 0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0, + 0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e, + 0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc, + 0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3, + 0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07, + 0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00, + 0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x24,0x00,0x00,0x00, + 0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0xd4,0x63,0x11,0x40, + 0x60,0x1c,0x73,0x10,0x83,0x00,0x41,0x94,0x33,0x00,0x14,0x63,0x09,0x20,0x08,0x82, + 0xf0,0x2f,0x80,0x20,0x08,0xc2,0xbf,0x30,0x96,0x00,0x82,0x20,0x08,0x82,0x01,0x08, + 0x82,0x20,0x08,0x0e,0x33,0x00,0x24,0x73,0x10,0x18,0x76,0x59,0x34,0x33,0x00,0x04, + 0x63,0x04,0x20,0x08,0x82,0xf8,0x37,0x46,0x00,0x82,0x20,0x08,0x7f,0x33,0x00,0x00, + 0xe3,0x0d,0x0c,0x66,0x51,0x40,0x2c,0x0a,0xe8,0x63,0xc1,0x02,0x1f,0x0b,0x16,0xf9, + 0x0c,0x32,0x04,0xcb,0x33,0xc8,0x10,0x2c,0xd1,0x6c,0xc3,0x52,0x01,0xb3,0x0d,0x41, + 0x15,0xcc,0x36,0x04,0x83,0x90,0x41,0x40,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x5b,0x86,0x20,0x00,0x85,0x2d,0x83,0x30,0x84,0x02,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _snk_fs_bytecode_metal_macos[2909] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x5d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x80,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0x17,0xe5,0xa2,0xb3,0x7d,0x00,0xfc, + 0xde,0x00,0x5f,0xbd,0x79,0x5e,0xd5,0x95,0xff,0xb6,0xf4,0xce,0x41,0x07,0xfb,0x8f, + 0x49,0x6b,0x95,0x79,0x7a,0xd1,0xcf,0x19,0xde,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x60,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x95,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x89,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87, + 0x70,0x30,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74, + 0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e, + 0xde,0xc1,0x1c,0xe8,0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81, + 0x00,0x16,0xa0,0xda,0x80,0x10,0xff,0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5, + 0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,0x18,0x86,0x00,0x2c,0x40,0x05,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44,0x61,0x00,0x00,0x00, + 0x00,0x89,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04,0x70,0x90,0x34,0x45, + 0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x13,0x0a,0xc2,0x30,0x82,0x00,0x1c, + 0x25,0x4d,0x11,0x25,0x4c,0xfe,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0xff,0x34, + 0x46,0x00,0x0c,0x22,0x10,0xc1,0x45,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x12,0xc0,0x3c, + 0x0b,0x11,0xfd,0xd3,0x18,0x01,0x30,0x88,0x60,0x08,0xa5,0x10,0x23,0x94,0x43,0x68, + 0x8e,0x20,0x98,0x23,0x00,0x83,0x61,0x04,0x61,0x29,0x48,0x28,0x67,0x28,0xa6,0x00, + 0xb5,0x81,0x80,0x1c,0x58,0x23,0x00,0x00,0x00,0x13,0xb2,0x70,0x48,0x07,0x79,0xb0, + 0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x76,0x08,0x87, + 0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83,0x38,0x70,0x03,0x38, + 0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0, + 0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x71,0x60,0x07, + 0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e,0x73,0x20,0x07,0x7a, + 0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76,0x40,0x07,0x7a,0x60, + 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0, + 0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07, + 0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73, + 0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40, + 0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07, + 0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72, + 0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0, + 0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20,0x07,0x7a,0x20,0x07, + 0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x72,0x50,0x07,0x76, + 0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x50, + 0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07, + 0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74, + 0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60, + 0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x49,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00, + 0x18,0xc2,0x38,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x64,0x81,0x00,0x00,0x00, + 0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26, + 0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50,0x04,0x85,0x50,0x10,0x65,0x40,0x70, + 0xac,0x41,0x79,0x08,0x00,0x79,0x18,0x00,0x00,0xd9,0x00,0x00,0x00,0x1a,0x03,0x4c, + 0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x42, + 0x3c,0x00,0x84,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62, + 0x2c,0xc2,0x23,0x2c,0x05,0xd9,0x20,0x08,0x0e,0x8e,0xad,0x0c,0x84,0x89,0xc9,0xaa, + 0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x24,0x07,0x46,0xc6,0x25,0x86,0x06, + 0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x25,0x07,0x46,0xc6,0x25,0x86,0xc6, + 0x25,0x27,0x65,0x88,0xf0,0x10,0x43,0x8c,0x45,0x58,0x8c,0x65,0x60,0xd1,0x54,0x46, + 0x17,0xc6,0x36,0x04,0x79,0x8e,0x45,0x58,0x84,0x65,0xe0,0x16,0x96,0x26,0xe7,0x32, + 0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45, + 0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x78,0x12,0x72,0x61,0x69,0x72,0x2e,0x63, + 0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68, + 0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x61,0x19,0x84,0xa5,0xc9,0xb9, + 0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99, + 0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x91,0xa5,0xcd,0x85,0x89,0xb1, + 0x95,0x0d,0x11,0x9e,0x86,0x61,0x10,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6, + 0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6,0x45,0xf6,0x56,0x27,0xc6,0x56,0xf6, + 0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x78,0x1e,0x92,0x41,0x58,0x9a,0x9c, + 0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b,0x5b,0x18,0x5d,0x9a,0x5d,0xd9,0x17, + 0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0x59,0xda,0x5c,0x98,0x18,0x5b, + 0xd9,0x10,0xe1,0x89,0x78,0x06,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c, + 0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f,0x77,0x69,0x64,0x65,0x5f,0x76,0x65, + 0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43,0x84,0x67, + 0x62,0x14,0x96,0x26,0xe7,0x22,0x57,0xe6,0x46,0x56,0x26,0xf7,0x45,0x17,0x26,0x77, + 0x56,0x46,0xc7,0x28,0x2c,0x4d,0xce,0x25,0x4c,0xee,0xec,0x8b,0x2e,0x0f,0xae,0xec, + 0xcb,0x2d,0xac,0xad,0x8c,0x86,0x19,0xdb,0x5b,0x18,0x1d,0x0d,0x99,0xb0,0x34,0x39, + 0x97,0x30,0xb9,0xb3,0x2f,0xb7,0xb0,0xb6,0x32,0x2a,0x66,0x72,0x61,0x67,0x5f,0x63, + 0x6f,0x6c,0x6f,0x72,0x43,0x98,0xa7,0x5a,0x86,0xc7,0x7a,0xae,0x07,0x7b,0xb2,0x21, + 0xc2,0xa3,0x51,0x0a,0x4b,0x93,0x73,0x31,0x93,0x0b,0x3b,0x6b,0x2b,0x73,0xa3,0xfb, + 0x4a,0x73,0x83,0xab,0xa3,0xe3,0x52,0x37,0x57,0x26,0x87,0xc2,0xf6,0x36,0xe6,0x06, + 0x93,0x42,0x25,0x2c,0x4d,0xce,0x65,0xac,0xcc,0x8d,0xae,0x4c,0x8e,0x4f,0x58,0x9a, + 0x9c,0x0b,0x5c,0x99,0xdc,0x1c,0x5c,0xd9,0x18,0x5d,0x9a,0x5d,0x19,0x0d,0x33,0xb6, + 0xb7,0x30,0x3a,0x19,0x0a,0x75,0x76,0x43,0xa4,0x65,0x78,0xb8,0xa7,0x7b,0xbc,0xe7, + 0x7b,0xac,0x07,0x0c,0x1e,0xec,0x09,0x03,0x2e,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f, + 0x63,0x6e,0x31,0x29,0x2c,0xc6,0xde,0xd8,0xde,0xe4,0x86,0x48,0x8b,0xf0,0x70,0xcf, + 0x18,0x3c,0xde,0xf3,0x3d,0xd6,0x73,0x3d,0xd8,0x43,0x06,0x5c,0xc2,0xd2,0xe4,0x5c, + 0xe8,0xca,0xf0,0xe8,0xea,0xe4,0xca,0x28,0x85,0xa5,0xc9,0xb9,0xb0,0xbd,0x8d,0x85, + 0xd1,0xa5,0xbd,0xb9,0x7d,0xa5,0xb9,0x91,0x95,0xe1,0x51,0x09,0x4b,0x93,0x73,0x99, + 0x0b,0x6b,0x83,0x63,0x2b,0x23,0x46,0x57,0x86,0x47,0x57,0x27,0x57,0x26,0x43,0xc6, + 0x63,0xc6,0xf6,0x16,0x46,0xc7,0x02,0x32,0x17,0xd6,0x06,0xc7,0x56,0xe6,0xc3,0x81, + 0xae,0x0c,0x6f,0x08,0xb5,0x10,0x8f,0x19,0x3c,0x67,0xb0,0x0c,0x8b,0xf0,0xa0,0xc1, + 0x63,0x3d,0x69,0xf0,0x60,0x8f,0x1a,0x70,0x09,0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83, + 0x63,0x2b,0x93,0xe3,0x31,0x17,0xd6,0x06,0xc7,0x56,0x26,0x47,0x84,0xae,0x0c,0x6f, + 0xaa,0x0d,0x8e,0x4d,0x6e,0x88,0xb4,0x1c,0x0f,0x1b,0x3c,0x67,0xb0,0x0c,0x8b,0xf0, + 0x58,0x4f,0x1b,0x3c,0xd8,0xe3,0x06,0x43,0x90,0x47,0x0c,0x9e,0x32,0x78,0xd6,0xe0, + 0x79,0x83,0x21,0x46,0x02,0x3c,0xdb,0x03,0x07,0x23,0x22,0x76,0x60,0x07,0x7b,0x68, + 0x07,0x37,0x68,0x87,0x77,0x20,0x87,0x7a,0x60,0x87,0x72,0x70,0x03,0x73,0x60,0x87, + 0x70,0x38,0x87,0x79,0x98,0x22,0x04,0xc3,0x08,0x85,0x1d,0xd8,0xc1,0x1e,0xda,0xc1, + 0x0d,0xd2,0x81,0x1c,0xca,0xc1,0x1d,0xe8,0x61,0x4a,0x50,0x8c,0x58,0xc2,0x21,0x1d, + 0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x61,0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x4a,0x60, + 0x8c,0xa0,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xd8,0x21,0x1c,0xdc,0xe1,0x1c,0xea,0x21, + 0x1c,0xce,0xa1,0x1c,0x7e,0xc1,0x1e,0xca,0x41,0x1e,0xe6,0x21,0x1d,0xde,0xc1,0x1d, + 0xa6,0x04,0xc8,0x88,0x29,0x1c,0xd2,0x41,0x1e,0xdc,0x60,0x1c,0xde,0xa1,0x1d,0xe0, + 0x21,0x1d,0xd8,0xa1,0x1c,0x7e,0xe1,0x1d,0xe0,0x81,0x1e,0xd2,0xe1,0x1d,0xdc,0x61, + 0x1e,0xa6,0x18,0x0a,0xe3,0x40,0x12,0x35,0x82,0x09,0x87,0x74,0x90,0x07,0x37,0x30, + 0x07,0x79,0x08,0x87,0x73,0x68,0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0xc4,0x01,0x00, + 0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c, + 0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07, + 0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42, + 0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83, + 0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07, + 0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70, + 0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3, + 0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2, + 0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc, + 0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68, + 0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07, + 0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72, + 0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec, + 0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc, + 0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8, + 0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03, + 0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c, + 0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74, + 0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4, + 0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc, + 0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1, + 0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50, + 0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51, + 0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21, + 0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06, + 0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c, + 0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77, + 0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00, + 0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f, + 0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20, + 0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00,0x00,0x0c,0x00,0x00,0x00,0x13,0x04,0x41, + 0x2c,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xc4,0x46,0x00,0x48,0x8d,0x00,0xd4, + 0x00,0x89,0x19,0x00,0x02,0x23,0x00,0x00,0x00,0x23,0x06,0x8a,0x10,0x44,0x87,0x91, + 0x0c,0x05,0x11,0x58,0x90,0xc8,0x67,0xb6,0x81,0x08,0x80,0x0c,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _snk_vs_bytecode_metal_ios[3200] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x80,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x70,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0xcb,0xdd,0xe3,0x08,0x7a,0x87,0xef, + 0xdd,0xe0,0x68,0xe7,0xe8,0x6b,0xe6,0xea,0x8b,0x6d,0x4a,0xe0,0x3d,0x6a,0xfe,0xe4, + 0xfe,0x32,0x1d,0xbe,0xb6,0x10,0x11,0xee,0x75,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x37,0x00,0x00, + 0x00,0x56,0x41,0x54,0x54,0x22,0x00,0x03,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x00,0x00,0x80,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x02,0x80,0x56,0x41,0x54,0x59,0x05,0x00,0x03, + 0x00,0x04,0x04,0x06,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54, + 0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x5c,0x0b,0x00,0x00, + 0xff,0xff,0xff,0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0xd4,0x02,0x00,0x00, + 0x0b,0x82,0x20,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91, + 0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19, + 0x1e,0x04,0x8b,0x62,0x80,0x10,0x45,0x02,0x42,0x92,0x0b,0x42,0x84,0x10,0x32,0x14, + 0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80, + 0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x08,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0, + 0x01,0x00,0x00,0x00,0x51,0x18,0x00,0x00,0x82,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8, + 0xff,0xff,0xff,0xff,0x01,0x90,0x80,0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87, + 0x71,0xa0,0x07,0x76,0xc8,0x87,0x36,0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72, + 0x20,0x87,0x36,0x20,0x87,0x74,0xb0,0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88, + 0x07,0x79,0xa0,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41, + 0x1c,0xd8,0xa1,0x1c,0xda,0x80,0x1e,0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c, + 0xd8,0x81,0x1d,0xe6,0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87, + 0x72,0x98,0x87,0x79,0x68,0x03,0x78,0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72, + 0x68,0x03,0x73,0x80,0x87,0x76,0x08,0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e, + 0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda, + 0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81,0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21, + 0x1d,0xda,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30, + 0x07,0x79,0x08,0x87,0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87, + 0x72,0x90,0x87,0x36,0x28,0x07,0x76,0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77, + 0x68,0x03,0x76,0x28,0x87,0x70,0x30,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70, + 0x07,0x73,0x98,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07, + 0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1, + 0x1d,0xe0,0xa1,0x0d,0xe8,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08, + 0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87, + 0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41, + 0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d, + 0xca,0x81,0x1c,0xda,0x40,0x1f,0xca,0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0, + 0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80, + 0x70,0x87,0x77,0x68,0x03,0x7a,0x90,0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38, + 0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00, + 0x62,0x1e,0xe8,0x21,0x1c,0xc6,0x61,0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1, + 0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e,0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x0d,0xe6,0x21,0x1d,0xf4,0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87, + 0x79,0x08,0x07,0x73,0x28,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a, + 0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d, + 0xe6,0xe1,0x1d,0xcc,0x81,0x1e,0xda,0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00, + 0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x36,0x20,0x02,0x01,0x24,0xc0,0x02,0x54, + 0x00,0x00,0x00,0x00,0x49,0x18,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00, + 0x89,0x20,0x00,0x00,0x1b,0x00,0x00,0x00,0x32,0x22,0x08,0x09,0x20,0x64,0x85,0x04, + 0x13,0x22,0xa4,0x84,0x04,0x13,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x88,0x8c, + 0x0b,0x84,0x84,0x4c,0x10,0x3c,0x33,0x00,0xc3,0x08,0x02,0x30,0x8c,0x40,0x00,0x77, + 0x49,0x53,0x44,0x09,0x93,0xcf,0x00,0x48,0x43,0xff,0x0e,0x35,0xf9,0x0f,0x20,0x28, + 0xc4,0x80,0x87,0x10,0x39,0x48,0x9a,0x22,0x4a,0x98,0xfc,0x4a,0xfa,0x1f,0x20,0x02, + 0x18,0x09,0x05,0x31,0x88,0x40,0x08,0xa5,0x98,0x08,0x29,0xb2,0x81,0x80,0x39,0x02, + 0x30,0x48,0x81,0x9c,0x23,0x00,0x85,0x41,0x84,0x40,0x18,0x46,0x20,0x92,0x11,0x00, + 0x00,0x00,0x00,0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70, + 0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80, + 0x03,0x37,0x80,0x83,0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07, + 0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9, + 0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30, + 0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07, + 0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72, + 0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07, + 0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73, + 0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a, + 0x60,0x07,0x74,0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0, + 0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07, + 0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72, + 0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20, + 0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07, + 0x6d,0x60,0x0f,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75, + 0x10,0x07,0x72,0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00, + 0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80,0x07, + 0x7a,0x10,0x07,0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x98,0x03,0x00,0x80,0x00,0x00, + 0x00,0x00,0x00,0x80,0x2c,0x10,0x00,0x00,0x0b,0x00,0x00,0x00,0x32,0x1e,0x98,0x10, + 0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0xda,0x11,0x00,0xca,0x12, + 0x18,0x01,0x28,0x88,0x22,0x28,0x84,0x32,0x20,0x1d,0x4b,0x68,0x0a,0x82,0x31,0x02, + 0x10,0x04,0x41,0x11,0x0c,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x16,0x01,0x00,0x00, + 0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7, + 0x21,0x46,0x52,0x20,0x80,0x82,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3, + 0x2b,0x1b,0x62,0x24,0x02,0x22,0x24,0x06,0xd9,0x20,0x08,0x0e,0x8e,0xad,0x0c,0x84, + 0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26,0x07,0x46, + 0xc6,0xc5,0xe6,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x26,0x07, + 0x46,0xc6,0xc5,0xe6,0x26,0x65,0x88,0x80,0x10,0x43,0x8c,0x44,0x48,0x88,0x64,0x60, + 0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x41,0x8e,0x44,0x48,0x86,0x64,0xe0,0x16,0x96, + 0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7, + 0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x40,0x12,0x72,0x61,0x69, + 0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d, + 0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04,0x64,0x21,0x19,0x84, + 0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95, + 0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x95,0xb9,0x85, + 0x89,0xb1,0x95,0x0d,0x11,0x90,0x86,0x61,0x10,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06, + 0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6,0x45,0xf6,0x56,0x27,0xc6, + 0x56,0xf6,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x40,0x1e,0x92,0x41,0x58, + 0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b,0x5b,0x18,0x5d,0x9a,0x5d, + 0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0x59,0xda,0x5c,0x98, + 0x18,0x5b,0xd9,0x10,0x01,0x89,0x78,0x06,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70, + 0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f,0x77,0x69,0x64,0x65,0x5f, + 0x76,0x65,0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x43, + 0x04,0x64,0x62,0x14,0x96,0x26,0xe7,0x62,0x57,0x26,0x47,0x57,0x86,0xf7,0xf5,0x56, + 0x47,0x07,0x57,0x47,0xc7,0xa5,0x6e,0xae,0x4c,0x0e,0x85,0xed,0x6d,0xcc,0x0d,0x26, + 0x85,0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d,0x1e,0x5c,0xd9,0x97,0x5b, + 0x58,0x5b,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x32,0x61,0x69,0x72,0x2e,0x61, + 0x72,0x67,0x5f,0x6e,0x61,0x6d,0x65,0x14,0xea,0xec,0x86,0x30,0x48,0x85,0x58,0xc8, + 0x85,0x60,0x48,0x86,0x68,0x5c,0xea,0xe6,0xca,0xe4,0x50,0xd8,0xde,0xc6,0xdc,0x62, + 0x52,0x68,0x98,0xb1,0xbd,0x85,0xd1,0xd1,0xb0,0x18,0x7b,0x63,0x7b,0x93,0x1b,0xc2, + 0x20,0x15,0xc2,0x21,0x17,0xd2,0x21,0x19,0xe2,0x91,0x09,0x4b,0x93,0x73,0x81,0x7b, + 0x9b,0x4b,0xa3,0x4b,0x7b,0x73,0xe3,0x72,0xc6,0xf6,0x05,0xf5,0x36,0x97,0x46,0x97, + 0xf6,0xe6,0x36,0x44,0x41,0xc0,0x00,0xb9,0x90,0x0e,0xc9,0x90,0x30,0x18,0x62,0x20, + 0x1b,0xf2,0x21,0x62,0x40,0x28,0x2c,0x4d,0xce,0xc5,0xae,0x4c,0x8e,0xae,0x0c,0xef, + 0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x52,0x58,0x9a,0x9c,0x0b,0xdb,0xdb,0x58,0x18,0x5d, + 0xda,0x9b,0xdb,0x57,0x9a,0x1b,0x59,0x19,0x1e,0xb3,0xb3,0x32,0xb7,0x32,0xb9,0x30, + 0xba,0x32,0x32,0x14,0x1c,0xb8,0xb7,0xb9,0x34,0xba,0xb4,0x37,0x37,0x22,0x3b,0x99, + 0x2f,0xb3,0x14,0x22,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x43,0xa8,0x64,0x40, + 0xc8,0x00,0x29,0x83,0x64,0x48,0x04,0xc4,0x0c,0x90,0x0b,0xc1,0x90,0x0c,0x39,0x03, + 0x6a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x28,0x39,0x74,0x65,0x78,0x63, + 0x6f,0x6f,0x72,0x64,0x30,0x44,0x76,0x32,0x5f,0x66,0x29,0x4c,0xe8,0xca,0xf0,0xc6, + 0xde,0xde,0xe4,0xc8,0x60,0x86,0x50,0x89,0x80,0x90,0x01,0x52,0x06,0x89,0x90,0x08, + 0x48,0x1a,0x20,0x17,0x82,0x21,0x19,0xa2,0x06,0xbc,0xce,0xca,0xdc,0xca,0xe4,0xc2, + 0xe8,0xca,0xc8,0x50,0x6c,0xc6,0xde,0xd8,0xde,0xe4,0x60,0x88,0xec,0x68,0xbe,0xcc, + 0x52,0x68,0x8c,0xbd,0xb1,0xbd,0xc9,0xc1,0x0c,0xa1,0x92,0x02,0x21,0x03,0xa4,0x0c, + 0x92,0x22,0x11,0x10,0x36,0x40,0x2e,0xa4,0x43,0x32,0xa4,0x0d,0xa8,0x84,0xa5,0xc9, + 0xb9,0x88,0xd5,0x99,0x99,0x95,0xc9,0xf1,0x09,0x4b,0x93,0x73,0x11,0xab,0x33,0x33, + 0x2b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x23,0x12,0x96,0x26,0xe7,0x22,0x57,0x16,0x46, + 0x46,0x2a,0x2c,0x4d,0xce,0x65,0x8e,0x4e,0xae,0x6e,0x8c,0xee,0x8b,0x2e,0x0f,0xae, + 0xec,0x2b,0xcd,0xcd,0xec,0x8d,0x09,0x59,0xda,0x1c,0xdc,0xd7,0x5c,0x9a,0x5e,0xd9, + 0x10,0x25,0x19,0x12,0x22,0x19,0x10,0x0c,0x99,0x03,0x46,0x61,0x69,0x72,0x2e,0x61, + 0x72,0x67,0x5f,0x74,0x79,0x70,0x65,0x5f,0x73,0x69,0x7a,0x65,0xbc,0xc2,0xd2,0xe4, + 0x5c,0xc2,0xe4,0xce,0xbe,0xe8,0xf2,0xe0,0xca,0xbe,0xc2,0xd8,0xd2,0xce,0xdc,0xbe, + 0xe6,0xd2,0xf4,0xca,0x98,0xd8,0xcd,0x7d,0xc1,0x85,0xc9,0x85,0xb5,0xcd,0x71,0xf8, + 0x92,0x99,0x19,0x42,0x06,0xc9,0x81,0xbc,0x01,0x02,0x07,0x09,0x81,0x94,0x41,0x32, + 0x24,0x02,0x12,0x07,0x88,0x1c,0x20,0x74,0x80,0xd4,0x41,0x42,0x20,0x76,0x90,0x10, + 0xc8,0x85,0xdc,0x01,0x92,0x21,0x78,0x30,0x04,0x41,0xd0,0x00,0x59,0x03,0xc4,0x0d, + 0x90,0x3c,0x18,0x62,0x1c,0x00,0x32,0x06,0x88,0x1e,0xf0,0x79,0x6b,0x73,0x4b,0x83, + 0x7b,0xa3,0x2b,0x73,0xa3,0x03,0x19,0x43,0x0b,0x93,0xe3,0x33,0x95,0xd6,0x06,0xc7, + 0x56,0x06,0x32,0xb4,0xb2,0x02,0x42,0x25,0x14,0x14,0x34,0x44,0x40,0xfa,0x60,0x88, + 0x81,0xf0,0x01,0xe2,0x07,0x4b,0x30,0xc4,0x40,0xfe,0x00,0xf9,0x83,0x25,0x18,0x22, + 0x00,0xc9,0x88,0x88,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d,0xda,0xe1,0x1d,0xc8,0xa1, + 0x1e,0xd8,0xa1,0x1c,0xdc,0xc0,0x1c,0xd8,0x21,0x1c,0xce,0x61,0x1e,0xa6,0x08,0xc1, + 0x30,0x42,0x61,0x07,0x76,0xb0,0x87,0x76,0x70,0x83,0x74,0x20,0x87,0x72,0x70,0x07, + 0x7a,0x98,0x12,0x14,0x23,0x96,0x70,0x48,0x07,0x79,0x70,0x03,0x7b,0x28,0x07,0x79, + 0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12,0x18,0x23,0xa8,0x70,0x48,0x07,0x79,0x70, + 0x03,0x76,0x08,0x07,0x77,0x38,0x87,0x7a,0x08,0x87,0x73,0x28,0x87,0x5f,0xb0,0x87, + 0x72,0x90,0x87,0x79,0x48,0x87,0x77,0x70,0x87,0x29,0x01,0x32,0x62,0x0a,0x87,0x74, + 0x90,0x07,0x37,0x18,0x87,0x77,0x68,0x07,0x78,0x48,0x07,0x76,0x28,0x87,0x5f,0x78, + 0x07,0x78,0xa0,0x87,0x74,0x78,0x07,0x77,0x98,0x87,0x29,0x86,0xc2,0x38,0x90,0x44, + 0x8d,0x50,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x81,0x1e,0xca,0x01, + 0x1f,0xa6,0x04,0x7b,0x00,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3, + 0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10, + 0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30, + 0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03, + 0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07, + 0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e, + 0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d, + 0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b, + 0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76, + 0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90, + 0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87, + 0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e, + 0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c, + 0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca, + 0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8, + 0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82, + 0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83, + 0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f, + 0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec, + 0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc, + 0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0, + 0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60, + 0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e, + 0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1, + 0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43, + 0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c, + 0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72, + 0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x50,0x30,0x00, + 0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x24,0x00,0x00,0x00,0x13,0x04,0x41,0x2c, + 0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0xd4,0x63,0x11,0x40,0x60,0x1c,0x73,0x10, + 0x83,0x00,0x41,0x94,0x33,0x00,0x14,0x63,0x09,0x20,0x08,0x82,0xf0,0x2f,0x80,0x20, + 0x08,0xc2,0xbf,0x30,0x96,0x00,0x82,0x20,0x08,0x82,0x01,0x08,0x82,0x20,0x08,0x0e, + 0x33,0x00,0x24,0x73,0x10,0x18,0x76,0x59,0x34,0x33,0x00,0x04,0x63,0x04,0x20,0x08, + 0x82,0xf8,0x37,0x46,0x00,0x82,0x20,0x08,0x7f,0x33,0x00,0x00,0xe3,0x0d,0x0c,0x66, + 0x51,0x40,0x2c,0x0a,0xe8,0x63,0xc1,0x02,0x1f,0x0b,0x16,0xf9,0x0c,0x32,0x04,0xcb, + 0x33,0xc8,0x10,0x2c,0xd1,0x6c,0xc3,0x52,0x01,0xb3,0x0d,0x41,0x15,0xcc,0x36,0x04, + 0x83,0x90,0x41,0x40,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x5b,0x86,0x20,0x00, + 0x85,0x2d,0x83,0x30,0x84,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _snk_fs_bytecode_metal_ios[2893] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x4d,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x70,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0xe9,0x4a,0xc6,0xd1,0xba,0x33,0x39, + 0x67,0xdf,0xcd,0xe3,0x58,0xde,0xd4,0xb8,0x81,0x4c,0x26,0x44,0xbc,0x9d,0x14,0xdc, + 0xa9,0x02,0x93,0x08,0x5a,0xcd,0x66,0x1c,0x30,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x45,0x4e,0x44,0x54,0x04,0x00,0x00, + 0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17, + 0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x58,0x0a,0x00,0x00,0xff,0xff,0xff, + 0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0x93,0x02,0x00,0x00,0x0b,0x82,0x20, + 0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04, + 0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b, + 0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18, + 0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21, + 0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00, + 0x00,0x51,0x18,0x00,0x00,0x89,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff, + 0xff,0x01,0x60,0x00,0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07, + 0x7a,0x60,0x87,0x7c,0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72, + 0x68,0x03,0x72,0x48,0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90, + 0x07,0x7a,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc, + 0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81, + 0x1d,0xca,0xa1,0x0d,0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d, + 0xd8,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87, + 0x79,0x98,0x87,0x36,0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36, + 0x30,0x07,0x78,0x68,0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0, + 0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1, + 0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90, + 0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07, + 0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36, + 0x60,0x87,0x72,0x08,0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30, + 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8, + 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01, + 0x1e,0xda,0x80,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60, + 0x87,0x79,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c, + 0xc8,0xa1,0x0d,0xf4,0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda, + 0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77, + 0x78,0x87,0x36,0xa0,0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68, + 0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6, + 0x81,0x1e,0xc2,0x61,0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61, + 0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e, + 0xda,0x60,0x1e,0xd2,0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87, + 0x70,0x30,0x87,0x72,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74, + 0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e, + 0xde,0xc1,0x1c,0xe8,0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87, + 0x70,0x60,0x87,0x79,0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81, + 0x00,0x16,0xa0,0xda,0x80,0x10,0xff,0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5, + 0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,0x18,0x86,0x00,0x2c,0x40,0x05,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x86,0x40,0x18,0x26,0x0c,0x44,0x61,0x00,0x00,0x00, + 0x00,0x89,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04,0x70,0x90,0x34,0x45, + 0x94,0x30,0xf9,0x0c,0x80,0x34,0xf4,0xef,0x50,0x13,0x0a,0xc2,0x30,0x82,0x00,0x1c, + 0x25,0x4d,0x11,0x25,0x4c,0xfe,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0xff,0x34, + 0x46,0x00,0x0c,0x22,0x10,0xc1,0x45,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x12,0xc0,0x3c, + 0x0b,0x11,0xfd,0xd3,0x18,0x01,0x30,0x88,0x60,0x08,0xa5,0x10,0x23,0x94,0x43,0x68, + 0x8e,0x20,0x98,0x23,0x00,0x83,0x61,0x04,0x61,0x29,0x48,0x28,0x67,0x28,0xa6,0x00, + 0xb5,0x81,0x80,0x14,0x58,0x23,0x00,0x00,0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0, + 0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87, + 0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80,0x83,0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f, + 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9, + 0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0, + 0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07, + 0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72, + 0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0, + 0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06, + 0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6, + 0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20, + 0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78, + 0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07, + 0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72, + 0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60, + 0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07, + 0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a, + 0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10, + 0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07, + 0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74, + 0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x98, + 0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x21,0x8c,0x03,0x04,0x80,0x00,0x00, + 0x00,0x00,0x00,0x40,0x16,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98, + 0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x23,0x00,0x25, + 0x50,0x04,0x85,0x50,0x10,0x65,0x40,0x70,0x2c,0xa1,0x29,0x00,0x00,0x79,0x18,0x00, + 0x00,0xd9,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32, + 0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x42,0x3c,0x00,0x84,0x50,0xb9,0x1b,0x43,0x0b, + 0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x2c,0xc3,0x23,0x2c,0x05,0xd9,0x20,0x08, + 0x0e,0x8e,0xad,0x0c,0x84,0x89,0xc9,0xaa,0x09,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd, + 0x0d,0x64,0x26,0x07,0x46,0xc6,0xc5,0xe6,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd, + 0xac,0xac,0x65,0x26,0x07,0x46,0xc6,0xc5,0xe6,0x26,0x65,0x88,0xf0,0x10,0x43,0x8c, + 0x65,0x58,0x8c,0x45,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x79,0x8e,0x65,0x58, + 0x84,0x45,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42, + 0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44, + 0x78,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66, + 0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43, + 0x84,0x67,0x21,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9, + 0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d, + 0xa1,0x7d,0x95,0xb9,0x85,0x89,0xb1,0x95,0x0d,0x11,0x9e,0x86,0x61,0x10,0x96,0x26, + 0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0xe2,0x16,0x46,0x97,0x66,0x57,0xf6, + 0x45,0xf6,0x56,0x27,0xc6,0x56,0xf6,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44, + 0x78,0x1e,0x92,0x41,0x58,0x9a,0x9c,0xcb,0xd8,0x5b,0x1b,0x5c,0x1a,0x5b,0x99,0x8b, + 0x5b,0x18,0x5d,0x9a,0x5d,0xd9,0x17,0xdb,0x9b,0xdb,0xd9,0x17,0xdb,0x9b,0xdb,0xd9, + 0x17,0x59,0xda,0x5c,0x98,0x18,0x5b,0xd9,0x10,0xe1,0x89,0x78,0x06,0x61,0x69,0x72, + 0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x6e,0x61,0x74,0x69,0x76,0x65,0x5f, + 0x77,0x69,0x64,0x65,0x5f,0x76,0x65,0x63,0x74,0x6f,0x72,0x73,0x5f,0x64,0x69,0x73, + 0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x62,0x14,0x96,0x26,0xe7,0x22,0x57,0xe6,0x46, + 0x56,0x26,0xf7,0x45,0x17,0x26,0x77,0x56,0x46,0xc7,0x28,0x2c,0x4d,0xce,0x25,0x4c, + 0xee,0xec,0x8b,0x2e,0x0f,0xae,0xec,0xcb,0x2d,0xac,0xad,0x8c,0x86,0x19,0xdb,0x5b, + 0x18,0x1d,0x0d,0x99,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xb7,0xb0,0xb6,0x32, + 0x2a,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x43,0x98,0xa7,0x5a,0x84, + 0xc7,0x7a,0xae,0x07,0x7b,0xb2,0x21,0xc2,0xa3,0x51,0x0a,0x4b,0x93,0x73,0x31,0x93, + 0x0b,0x3b,0x6b,0x2b,0x73,0xa3,0xfb,0x4a,0x73,0x83,0xab,0xa3,0xe3,0x52,0x37,0x57, + 0x26,0x87,0xc2,0xf6,0x36,0xe6,0x06,0x93,0x42,0x25,0x2c,0x4d,0xce,0x65,0xac,0xcc, + 0x8d,0xae,0x4c,0x8e,0x4f,0x58,0x9a,0x9c,0x0b,0x5c,0x99,0xdc,0x1c,0x5c,0xd9,0x18, + 0x5d,0x9a,0x5d,0x19,0x0d,0x33,0xb6,0xb7,0x30,0x3a,0x19,0x0a,0x75,0x76,0x43,0xa4, + 0x45,0x78,0xb8,0xa7,0x7b,0xbc,0xe7,0x7b,0xac,0x07,0x0c,0x1e,0xec,0x09,0x03,0x2e, + 0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x2c,0xc6,0xde,0xd8,0xde, + 0xe4,0x86,0x48,0xcb,0xf0,0x70,0xcf,0x18,0x3c,0xde,0xf3,0x3d,0xd6,0x73,0x3d,0xd8, + 0x43,0x06,0x5c,0xc2,0xd2,0xe4,0x5c,0xe8,0xca,0xf0,0xe8,0xea,0xe4,0xca,0x28,0x85, + 0xa5,0xc9,0xb9,0xb0,0xbd,0x8d,0x85,0xd1,0xa5,0xbd,0xb9,0x7d,0xa5,0xb9,0x91,0x95, + 0xe1,0x51,0x09,0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83,0x63,0x2b,0x23,0x46,0x57,0x86, + 0x47,0x57,0x27,0x57,0x26,0x43,0xc6,0x63,0xc6,0xf6,0x16,0x46,0xc7,0x02,0x32,0x17, + 0xd6,0x06,0xc7,0x56,0xe6,0xc3,0x81,0xae,0x0c,0x6f,0x08,0xb5,0x10,0x8f,0x19,0x3c, + 0x67,0xb0,0x08,0xcb,0xf0,0xa0,0xc1,0x63,0x3d,0x69,0xf0,0x60,0x8f,0x1a,0x70,0x09, + 0x4b,0x93,0x73,0x99,0x0b,0x6b,0x83,0x63,0x2b,0x93,0xe3,0x31,0x17,0xd6,0x06,0xc7, + 0x56,0x26,0x47,0x84,0xae,0x0c,0x6f,0xaa,0x0d,0x8e,0x4d,0x6e,0x88,0xb4,0x1c,0x0f, + 0x1b,0x3c,0x67,0xb0,0x08,0xcb,0xf0,0x58,0x4f,0x1b,0x3c,0xd8,0xe3,0x06,0x43,0x90, + 0x47,0x0c,0x9e,0x32,0x78,0xd6,0xe0,0x79,0x83,0x21,0x46,0x02,0x3c,0xdb,0x03,0x07, + 0x23,0x22,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x77,0x20,0x87,0x7a,0x60, + 0x87,0x72,0x70,0x03,0x73,0x60,0x87,0x70,0x38,0x87,0x79,0x98,0x22,0x04,0xc3,0x08, + 0x85,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d,0xd2,0x81,0x1c,0xca,0xc1,0x1d,0xe8,0x61, + 0x4a,0x50,0x8c,0x58,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x61,0x1e, + 0xd2,0xe1,0x1d,0xdc,0x61,0x4a,0x60,0x8c,0xa0,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xd8, + 0x21,0x1c,0xdc,0xe1,0x1c,0xea,0x21,0x1c,0xce,0xa1,0x1c,0x7e,0xc1,0x1e,0xca,0x41, + 0x1e,0xe6,0x21,0x1d,0xde,0xc1,0x1d,0xa6,0x04,0xc8,0x88,0x29,0x1c,0xd2,0x41,0x1e, + 0xdc,0x60,0x1c,0xde,0xa1,0x1d,0xe0,0x21,0x1d,0xd8,0xa1,0x1c,0x7e,0xe1,0x1d,0xe0, + 0x81,0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x1e,0xa6,0x18,0x0a,0xe3,0x40,0x12,0x35,0x82, + 0x09,0x87,0x74,0x90,0x07,0x37,0x30,0x07,0x79,0x08,0x87,0x73,0x68,0x87,0x72,0x70, + 0x07,0x7a,0x98,0x12,0xc4,0x01,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x6d,0x00,0x00, + 0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84, + 0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed, + 0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66, + 0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c, + 0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70, + 0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90, + 0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4, + 0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83, + 0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14, + 0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70, + 0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80, + 0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0, + 0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1, + 0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d, + 0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39, + 0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc, + 0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70, + 0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53, + 0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e, + 0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c, + 0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38, + 0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37, + 0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33, + 0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4, + 0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0, + 0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3, + 0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07, + 0x72,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01, + 0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e, + 0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00, + 0x00,0x0c,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x04,0x00,0x00, + 0x00,0xc4,0x46,0x00,0x48,0x8d,0x00,0xd4,0x00,0x89,0x19,0x00,0x02,0x23,0x00,0x00, + 0x00,0x23,0x06,0x8a,0x10,0x44,0x87,0x91,0x0c,0x05,0x11,0x58,0x90,0xc8,0x67,0xb6, + 0x81,0x08,0x80,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const char _snk_vs_source_metal_sim[720] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x32,0x20,0x64,0x69,0x73,0x70,0x5f,0x73,0x69,0x7a,0x65,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x32,0x20,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63, + 0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c, + 0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20, + 0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b, + 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69, + 0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62, + 0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x5b, + 0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x32, + 0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31, + 0x35,0x20,0x22,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e, + 0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f, + 0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x33,0x20,0x5b,0x5b, + 0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74, + 0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x35,0x20, + 0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f, + 0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28, + 0x28,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20, + 0x5f,0x32,0x33,0x2e,0x64,0x69,0x73,0x70,0x5f,0x73,0x69,0x7a,0x65,0x29,0x20,0x2d, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30, + 0x29,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x23,0x6c, + 0x69,0x6e,0x65,0x20,0x31,0x36,0x20,0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75, + 0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,0x30,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22,0x22, + 0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d, + 0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _snk_fs_source_metal_sim[470] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d, + 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20, + 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20, + 0x31,0x31,0x20,0x22,0x22,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61, + 0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65, + 0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74,0x65,0x78,0x20,0x5b,0x5b, + 0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x20,0x5b, + 0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f, + 0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31, + 0x31,0x20,0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61, + 0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x28,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x69, + 0x6e,0x2e,0x75,0x76,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74, + 0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_D3D11) +static const uint8_t _snk_vs_bytecode_hlsl4[892] = { + 0x44,0x58,0x42,0x43,0x05,0xf8,0x0b,0x1e,0x7a,0x13,0x49,0x07,0x83,0x60,0x2e,0x88, + 0x06,0xfa,0x10,0x2e,0x01,0x00,0x00,0x00,0x7c,0x03,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0xd0,0x01,0x00,0x00, + 0x00,0x03,0x00,0x00,0x52,0x44,0x45,0x46,0xc0,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xfe,0xff, + 0x10,0x81,0x00,0x00,0x98,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x00,0xab,0xab,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x60,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x88,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x5f,0x32,0x33,0x5f,0x64,0x69,0x73,0x70,0x5f,0x73,0x69,0x7a, + 0x65,0x00,0xab,0xab,0x01,0x00,0x03,0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x28,0x52, + 0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64,0x65,0x72,0x20,0x43,0x6f, + 0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31,0x00,0x49,0x53,0x47,0x4e, + 0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x50,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x03,0x00,0x00,0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x50,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x68,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x0c,0x00,0x00,0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, + 0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44, + 0x00,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0xab,0xab,0xab, + 0x53,0x48,0x44,0x52,0x28,0x01,0x00,0x00,0x40,0x00,0x01,0x00,0x4a,0x00,0x00,0x00, + 0x59,0x00,0x00,0x04,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x5f,0x00,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x03, + 0x32,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00, + 0x02,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0x32,0x20,0x10,0x00,0x00,0x00,0x00,0x00, + 0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x67,0x00,0x00,0x04, + 0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x68,0x00,0x00,0x02, + 0x01,0x00,0x00,0x00,0x36,0x00,0x00,0x05,0x32,0x20,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x36,0x00,0x00,0x05,0xf2,0x20,0x10,0x00, + 0x01,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x02,0x00,0x00,0x00,0x0e,0x00,0x00,0x08, + 0x32,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x80,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a, + 0x32,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x00,0x10,0x00,0x00,0x00,0x00,0x00, + 0x02,0x40,0x00,0x00,0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x0a,0x32,0x20,0x10,0x00,0x02,0x00,0x00,0x00, + 0x46,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x40, + 0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x08, + 0xc2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x00,0x80,0x3f,0x3e,0x00,0x00,0x01, + 0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _snk_fs_bytecode_hlsl4[620] = { + 0x44,0x58,0x42,0x43,0xd1,0x93,0x1f,0x1b,0x9d,0x70,0x90,0xeb,0xc2,0x7c,0x26,0x07, + 0xdf,0x52,0xda,0x49,0x01,0x00,0x00,0x00,0x6c,0x02,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0x20,0x01,0x00,0x00,0x54,0x01,0x00,0x00, + 0xf0,0x01,0x00,0x00,0x52,0x44,0x45,0x46,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xff,0xff, + 0x10,0x81,0x00,0x00,0x6d,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x69,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x00,0x74,0x65,0x78,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f, + 0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64, + 0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31, + 0x00,0xab,0xab,0xab,0x49,0x53,0x47,0x4e,0x44,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x38,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x2c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65, + 0x74,0x00,0xab,0xab,0x53,0x48,0x44,0x52,0x94,0x00,0x00,0x00,0x40,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x5a,0x00,0x00,0x03,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x58,0x18,0x00,0x04,0x00,0x70,0x10,0x00,0x00,0x00,0x00,0x00,0x55,0x55,0x00,0x00, + 0x62,0x10,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x00,0x03, + 0xf2,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00, + 0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x02,0x01,0x00,0x00,0x00,0x45,0x00,0x00,0x09, + 0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x7e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x38,0x00,0x00,0x07,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x01,0x00,0x00,0x00,0x3e,0x00,0x00,0x01, + 0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const char _snk_fs_source_hlsl4[641] = { + 0x54,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x3e,0x20,0x74,0x65,0x78,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72, + 0x28,0x74,0x30,0x29,0x3b,0x0a,0x53,0x61,0x6d,0x70,0x6c,0x65,0x72,0x53,0x74,0x61, + 0x74,0x65,0x20,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20, + 0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x73,0x30,0x29,0x3b,0x0a, + 0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66, + 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69, + 0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61, + 0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72, + 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f, + 0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x3a,0x20,0x54,0x45, + 0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x54,0x45,0x58,0x43, + 0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63, + 0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75, + 0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x53, + 0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23, + 0x6c,0x69,0x6e,0x65,0x20,0x31,0x31,0x20,0x22,0x22,0x0a,0x76,0x6f,0x69,0x64,0x20, + 0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x23,0x6c, + 0x69,0x6e,0x65,0x20,0x31,0x31,0x20,0x22,0x22,0x0a,0x20,0x20,0x20,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x53, + 0x61,0x6d,0x70,0x6c,0x65,0x28,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c, + 0x65,0x72,0x2c,0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b, + 0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f, + 0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52, + 0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74, + 0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20, + 0x20,0x75,0x76,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75, + 0x74,0x2e,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20, + 0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61, + 0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f, + 0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61, + 0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73, + 0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a, + 0x00, +}; +#elif defined(SOKOL_WGPU) +static const uint8_t _snk_vs_bytecode_wgpu[1520] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x27,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x2a,0x00,0x00,0x00, + 0x2b,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x32,0x00,0x00,0x00, + 0x33,0x00,0x00,0x00,0x07,0x00,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x37,0x00,0x02,0x00,0x00,0x00,0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00, + 0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65, + 0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e, + 0x74,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f, + 0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64, + 0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b, + 0x61,0x6e,0x31,0x2e,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c, + 0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65, + 0x74,0x2d,0x65,0x6e,0x76,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20, + 0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65, + 0x64,0x20,0x65,0x6e,0x74,0x72,0x79,0x2d,0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61, + 0x69,0x6e,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00, + 0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,0x05,0x00,0x06,0x00, + 0x0c,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x65,0x72,0x56,0x65,0x72,0x74,0x65,0x78, + 0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x06,0x00,0x07,0x00, + 0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74, + 0x53,0x69,0x7a,0x65,0x00,0x00,0x00,0x00,0x06,0x00,0x07,0x00,0x0c,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x67,0x6c,0x5f,0x43,0x6c,0x69,0x70,0x44,0x69,0x73,0x74,0x61, + 0x6e,0x63,0x65,0x00,0x06,0x00,0x07,0x00,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x43,0x75,0x6c,0x6c,0x44,0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x00, + 0x05,0x00,0x03,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00, + 0x13,0x00,0x00,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x00,0x00, + 0x05,0x00,0x05,0x00,0x15,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x64,0x69,0x73,0x70,0x5f,0x73,0x69,0x7a,0x65,0x00,0x00,0x00,0x05,0x00,0x03,0x00, + 0x17,0x00,0x00,0x00,0x5f,0x32,0x33,0x00,0x05,0x00,0x03,0x00,0x2a,0x00,0x00,0x00, + 0x75,0x76,0x00,0x00,0x05,0x00,0x05,0x00,0x2b,0x00,0x00,0x00,0x74,0x65,0x78,0x63, + 0x6f,0x6f,0x72,0x64,0x30,0x00,0x00,0x00,0x05,0x00,0x04,0x00,0x2d,0x00,0x00,0x00, + 0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00,0x05,0x00,0x04,0x00,0x2f,0x00,0x00,0x00, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x00,0x00,0x05,0x00,0x05,0x00,0x32,0x00,0x00,0x00, + 0x67,0x6c,0x5f,0x56,0x65,0x72,0x74,0x65,0x78,0x49,0x44,0x00,0x05,0x00,0x06,0x00, + 0x33,0x00,0x00,0x00,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49, + 0x44,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x48,0x00,0x05,0x00, + 0x0c,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x48,0x00,0x05,0x00,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x47,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x13,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x48,0x00,0x05,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x47,0x00,0x03,0x00,0x15,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x2a,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x2b,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x2d,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x2f,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x32,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x05,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x33,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x06,0x00,0x00,0x00, + 0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x21,0x00,0x03,0x00,0x04,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x15,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x2b,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x1c,0x00,0x04,0x00,0x0b,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x0a,0x00,0x00,0x00, + 0x1e,0x00,0x06,0x00,0x0c,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x00, + 0x0b,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x0d,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x0d,0x00,0x00,0x00, + 0x0e,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x15,0x00,0x04,0x00,0x0f,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x0f,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x11,0x00,0x00,0x00, + 0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x12,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x12,0x00,0x00,0x00, + 0x13,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1e,0x00,0x03,0x00,0x15,0x00,0x00,0x00, + 0x11,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x15,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x18,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x11,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x1c,0x00,0x00,0x00, + 0x00,0x00,0x00,0x3f,0x2c,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x1d,0x00,0x00,0x00, + 0x1c,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00, + 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x2b,0x00,0x04,0x00,0x07,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x2c,0x00,0x05,0x00,0x11,0x00,0x00,0x00, + 0x21,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x2b,0x00,0x04,0x00, + 0x07,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x00,0x00,0x80,0x3f,0x20,0x00,0x04,0x00, + 0x27,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x04,0x00, + 0x29,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x29,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x12,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x27,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x20,0x00,0x04,0x00, + 0x2e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x2e,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x20,0x00,0x04,0x00, + 0x31,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x31,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x3b,0x00,0x04,0x00, + 0x31,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x36,0x00,0x05,0x00, + 0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x01,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x11,0x00,0x00,0x00, + 0x14,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x18,0x00,0x00,0x00, + 0x19,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x11,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x88,0x00,0x05,0x00, + 0x11,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x1a,0x00,0x00,0x00, + 0x83,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1b,0x00,0x00,0x00, + 0x1d,0x00,0x00,0x00,0x85,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x22,0x00,0x00,0x00, + 0x1e,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x51,0x00,0x05,0x00,0x07,0x00,0x00,0x00, + 0x24,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0x00,0x05,0x00, + 0x07,0x00,0x00,0x00,0x25,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x50,0x00,0x07,0x00,0x08,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x24,0x00,0x00,0x00, + 0x25,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x41,0x00,0x05,0x00, + 0x27,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x3e,0x00,0x03,0x00,0x28,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x11,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x3e,0x00,0x03,0x00, + 0x2a,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x01,0x00,0x00,0x00, + 0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x08,0x00,0x00,0x00, + 0x30,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x2d,0x00,0x00,0x00, + 0x30,0x00,0x00,0x00,0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +static const uint8_t _snk_fs_bytecode_wgpu[904] = { + 0x03,0x02,0x23,0x07,0x00,0x00,0x01,0x00,0x08,0x00,0x08,0x00,0x19,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00, + 0x02,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30, + 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x00,0x08,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x16,0x00,0x00,0x00, + 0x10,0x00,0x03,0x00,0x05,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x00,0x03,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x37,0x00,0x02,0x00,0x00,0x00, + 0xc2,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64, + 0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x63,0x6c,0x69, + 0x65,0x6e,0x74,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x30,0x30,0x0a,0x2f,0x2f, + 0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73, + 0x65,0x64,0x20,0x63,0x6c,0x69,0x65,0x6e,0x74,0x20,0x6f,0x70,0x65,0x6e,0x67,0x6c, + 0x31,0x30,0x30,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50, + 0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d, + 0x65,0x6e,0x76,0x20,0x76,0x75,0x6c,0x6b,0x61,0x6e,0x31,0x2e,0x30,0x0a,0x2f,0x2f, + 0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65,0x50,0x72,0x6f,0x63,0x65,0x73,0x73, + 0x65,0x64,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2d,0x65,0x6e,0x76,0x20,0x6f,0x70, + 0x65,0x6e,0x67,0x6c,0x0a,0x2f,0x2f,0x20,0x4f,0x70,0x4d,0x6f,0x64,0x75,0x6c,0x65, + 0x50,0x72,0x6f,0x63,0x65,0x73,0x73,0x65,0x64,0x20,0x65,0x6e,0x74,0x72,0x79,0x2d, + 0x70,0x6f,0x69,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x0a,0x23,0x6c,0x69,0x6e,0x65, + 0x20,0x31,0x0a,0x00,0x05,0x00,0x04,0x00,0x05,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e, + 0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x00,0x0a,0x00,0x00,0x00,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x05,0x00,0x03,0x00,0x0e,0x00,0x00,0x00, + 0x74,0x65,0x78,0x00,0x05,0x00,0x03,0x00,0x12,0x00,0x00,0x00,0x75,0x76,0x00,0x00, + 0x05,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0a,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x13,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x21,0x00,0x03,0x00,0x04,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x16,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x09,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x19,0x00,0x09,0x00,0x0b,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x1b,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x0d,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x17,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x20,0x00,0x04,0x00,0x15,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x00,0x04,0x00,0x15,0x00,0x00,0x00,0x16,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x36,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x04,0x00, + 0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x0c,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x3d,0x00,0x04,0x00, + 0x10,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x57,0x00,0x05,0x00, + 0x08,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x13,0x00,0x00,0x00, + 0x3d,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x16,0x00,0x00,0x00, + 0x85,0x00,0x05,0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x14,0x00,0x00,0x00, + 0x17,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x0a,0x00,0x00,0x00,0x18,0x00,0x00,0x00, + 0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00, +}; +#elif defined(SOKOL_DUMMY_BACKEND) +static const char* _snk_vs_source_dummy = ""; +static const char* _snk_fs_source_dummy = ""; +#else +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#endif + +#if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) +static void _snk_clipboard_copy(nk_handle usr, const char *text, int len) { + (void)usr; + if (len == 0) { + return; + } + sapp_set_clipboard_string(text); +} + +static void _snk_clipboard_paste(nk_handle usr, struct nk_text_edit *edit) { + const char *text = sapp_get_clipboard_string(); + if (text) { + nk_textedit_paste(edit, text, nk_strlen(text)); + } + (void)usr; +} + +#if defined(__EMSCRIPTEN__) && !defined(SOKOL_DUMMY_BACKEND) +EM_JS(int, snk_js_is_osx, (void), { + if (navigator.userAgent.includes('Macintosh')) { + return 1; + } + else { + return 0; + } +}); +#endif + +static bool _snk_is_osx(void) { + #if defined(SOKOL_DUMMY_BACKEND) + return false; + #elif defined(__EMSCRIPTEN__) + return snk_js_is_osx(); + #elif defined(__APPLE__) + return true; + #else + return false; + #endif +} +#endif // !SOKOL_NUKLEAR_NO_SOKOL_APP + +SOKOL_API_IMPL void snk_setup(const snk_desc_t* desc) { + SOKOL_ASSERT(desc); + memset(&_snuklear, 0, sizeof(_snuklear)); + _snuklear.desc = *desc; + _snuklear.desc.max_vertices = _snk_def(_snuklear.desc.max_vertices, 65536); + _snuklear.desc.dpi_scale = _snk_def(_snuklear.desc.dpi_scale, 1.0f); + #if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) + _snuklear.is_osx = _snk_is_osx(); + #endif + /* can keep color_format, depth_format and sample_count as is, + since sokol_gfx.h will do its own default-value handling + */ + + /* initialize Nuklear */ + nk_bool init_res = nk_init_default(&_snuklear.ctx, 0); + SOKOL_ASSERT(1 == init_res); (void)init_res; // silence unused warning in release mode +#if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) + _snuklear.ctx.clip.copy = _snk_clipboard_copy; + _snuklear.ctx.clip.paste = _snk_clipboard_paste; +#endif + + /* create sokol-gfx resources */ + sg_push_debug_group("sokol-nuklear"); + + /* Vertex Buffer */ + _snuklear.vertex_buffer_size = (size_t)_snuklear.desc.max_vertices * sizeof(_snk_vertex_t); + _snuklear.vbuf = sg_make_buffer(&(sg_buffer_desc){ + .usage = SG_USAGE_STREAM, + .size = _snuklear.vertex_buffer_size, + .label = "sokol-nuklear-vertices" + }); + + /* Index Buffer */ + _snuklear.index_buffer_size = (size_t)_snuklear.desc.max_vertices * 3 * sizeof(uint16_t); + _snuklear.ibuf = sg_make_buffer(&(sg_buffer_desc){ + .type = SG_BUFFERTYPE_INDEXBUFFER, + .usage = SG_USAGE_STREAM, + .size = _snuklear.index_buffer_size, + .label = "sokol-nuklear-indices" + }); + + /* Font Texture */ + if (!_snuklear.desc.no_default_font) { + nk_font_atlas_init_default(&_snuklear.atlas); + nk_font_atlas_begin(&_snuklear.atlas); + int font_width = 0, font_height = 0; + const void* pixels = nk_font_atlas_bake(&_snuklear.atlas, &font_width, &font_height, NK_FONT_ATLAS_RGBA32); + SOKOL_ASSERT((font_width > 0) && (font_height > 0)); + _snuklear.img = sg_make_image(&(sg_image_desc){ + .width = font_width, + .height = font_height, + .pixel_format = SG_PIXELFORMAT_RGBA8, + .wrap_u = SG_WRAP_CLAMP_TO_EDGE, + .wrap_v = SG_WRAP_CLAMP_TO_EDGE, + .min_filter = SG_FILTER_LINEAR, + .mag_filter = SG_FILTER_LINEAR, + .data.subimage[0][0] = { + .ptr = pixels, + .size = (size_t)(font_width * font_height) * sizeof(uint32_t) + }, + .label = "sokol-nuklear-font" + }); + nk_font_atlas_end(&_snuklear.atlas, nk_handle_id((int)_snuklear.img.id), 0); + nk_font_atlas_cleanup(&_snuklear.atlas); + if (_snuklear.atlas.default_font) { + nk_style_set_font(&_snuklear.ctx, &_snuklear.atlas.default_font->handle); + } + } + + /* Shader */ + #if defined SOKOL_METAL + const char* vs_entry = "main0"; + const char* fs_entry = "main0"; + #else + const char* vs_entry = "main"; + const char* fs_entry = "main"; + #endif + sg_range vs_bytecode = { .ptr = 0, .size = 0 }; + sg_range fs_bytecode = { .ptr = 0, .size = 0 }; + const char* vs_source = 0; + const char* fs_source = 0; + #if defined(SOKOL_GLCORE33) + vs_source = _snk_vs_source_glsl330; + fs_source = _snk_fs_source_glsl330; + #elif defined(SOKOL_GLES3) + vs_source = _snk_vs_source_glsl300es; + fs_source = _snk_fs_source_glsl300es; + #elif defined(SOKOL_METAL) + switch (sg_query_backend()) { + case SG_BACKEND_METAL_MACOS: + vs_bytecode = SG_RANGE(_snk_vs_bytecode_metal_macos); + fs_bytecode = SG_RANGE(_snk_fs_bytecode_metal_macos); + break; + case SG_BACKEND_METAL_IOS: + vs_bytecode = SG_RANGE(_snk_vs_bytecode_metal_ios); + fs_bytecode = SG_RANGE(_snk_fs_bytecode_metal_ios); + break; + default: + vs_source = _snk_vs_source_metal_sim; + fs_source = _snk_fs_source_metal_sim; + break; + } + #elif defined(SOKOL_D3D11) + vs_bytecode = SG_RANGE(_snk_vs_bytecode_hlsl4); + fs_bytecode = SG_RANGE(_snk_fs_bytecode_hlsl4); + #elif defined(SOKOL_WGPU) + vs_bytecode = SG_RANGE(_snk_vs_bytecode_wgpu); + fs_bytecode = SG_RANGE(_snk_fs_bytecode_wgpu); + #else + vs_source = _snk_vs_source_dummy; + fs_source = _snk_fs_source_dummy; + #endif + + /* Shader */ + _snuklear.shd = sg_make_shader(&(sg_shader_desc){ + .attrs = { + [0] = { .name = "position", .sem_name = "TEXCOORD", .sem_index = 0 }, + [1] = { .name = "texcoord0", .sem_name = "TEXCOORD", .sem_index = 1 }, + [2] = { .name = "color0", .sem_name = "TEXCOORD", .sem_index = 2 }, + }, + .vs = { + .source = vs_source, + .bytecode = vs_bytecode, + .entry = vs_entry, + .d3d11_target = "vs_4_0", + .uniform_blocks[0] = { + .size = sizeof(_snk_vs_params_t), + .uniforms[0] = { + .name = "vs_params", + .type = SG_UNIFORMTYPE_FLOAT4, + .array_count = 1, + } + }, + }, + .fs = { + .source = fs_source, + .bytecode = fs_bytecode, + .entry = fs_entry, + .d3d11_target = "ps_4_0", + .images[0] = { .name = "tex", .image_type = SG_IMAGETYPE_2D, .sampler_type = SG_SAMPLERTYPE_FLOAT }, + }, + .label = "sokol-nuklear-shader" + }); + + /* Pipeline */ + _snuklear.pip = sg_make_pipeline(&(sg_pipeline_desc){ + .layout = { + .attrs = { + [0] = { .offset = offsetof(_snk_vertex_t, pos), .format=SG_VERTEXFORMAT_FLOAT2 }, + [1] = { .offset = offsetof(_snk_vertex_t, uv), .format=SG_VERTEXFORMAT_FLOAT2 }, + [2] = { .offset = offsetof(_snk_vertex_t, col), .format=SG_VERTEXFORMAT_UBYTE4N } + } + }, + .shader = _snuklear.shd, + .index_type = SG_INDEXTYPE_UINT16, + .sample_count = _snuklear.desc.sample_count, + .depth.pixel_format = _snuklear.desc.depth_format, + .colors[0] = { + .pixel_format = _snuklear.desc.color_format, + .write_mask = SG_COLORMASK_RGB, + .blend = { + .enabled = true, + .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA, + .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + } + }, + .label = "sokol-nuklear-pipeline" + }); + + sg_pop_debug_group(); +} + +SOKOL_API_IMPL void snk_shutdown(void) { + nk_free(&_snuklear.ctx); + nk_font_atlas_clear(&_snuklear.atlas); + + /* NOTE: it's valid to call the destroy funcs with SG_INVALID_ID */ + sg_push_debug_group("sokol-nuklear"); + sg_destroy_pipeline(_snuklear.pip); + sg_destroy_shader(_snuklear.shd); + sg_destroy_image(_snuklear.img); + sg_destroy_buffer(_snuklear.ibuf); + sg_destroy_buffer(_snuklear.vbuf); + sg_pop_debug_group(); +} + +SOKOL_API_IMPL struct nk_context* snk_new_frame(void) { + #if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) + nk_input_begin(&_snuklear.ctx); + if (_snuklear.mouse_did_move) { + nk_input_motion(&_snuklear.ctx, _snuklear.mouse_pos[0], _snuklear.mouse_pos[1]); + _snuklear.mouse_did_move = false; + } + if (_snuklear.mouse_did_scroll) { + nk_input_scroll(&_snuklear.ctx, nk_vec2(_snuklear.mouse_scroll[0], _snuklear.mouse_scroll[1])); + _snuklear.mouse_did_scroll = false; + } + for (int i = 0; i < NK_BUTTON_MAX; i++) { + if (_snuklear.btn_down[i]) { + _snuklear.btn_down[i] = false; + nk_input_button(&_snuklear.ctx, (enum nk_buttons)i, _snuklear.mouse_pos[0], _snuklear.mouse_pos[1], 1); + } + else if (_snuklear.btn_up[i]) { + _snuklear.btn_up[i] = false; + nk_input_button(&_snuklear.ctx, (enum nk_buttons)i, _snuklear.mouse_pos[0], _snuklear.mouse_pos[1], 0); + } + } + const size_t char_buffer_len = strlen(_snuklear.char_buffer); + if (char_buffer_len > 0) { + for (size_t i = 0; i < char_buffer_len; i++) { + nk_input_char(&_snuklear.ctx, _snuklear.char_buffer[i]); + } + memset(_snuklear.char_buffer, 0, NK_INPUT_MAX); + } + for (int i = 0; i < NK_KEY_MAX; i++) { + if (_snuklear.keys_down[i]) { + nk_input_key(&_snuklear.ctx, (enum nk_keys)i, true); + _snuklear.keys_down[i] = 0; + } + if (_snuklear.keys_up[i]) { + nk_input_key(&_snuklear.ctx, (enum nk_keys)i, false); + _snuklear.keys_up[i] = 0; + } + } + nk_input_end(&_snuklear.ctx); + #endif + + nk_clear(&_snuklear.ctx); + return &_snuklear.ctx; +} + +SOKOL_API_IMPL void snk_render(int width, int height) { + static const struct nk_draw_vertex_layout_element vertex_layout[] = { + {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct _snk_vertex_t, pos)}, + {NK_VERTEX_TEXCOORD, NK_FORMAT_FLOAT, NK_OFFSETOF(struct _snk_vertex_t, uv)}, + {NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct _snk_vertex_t, col)}, + {NK_VERTEX_LAYOUT_END} + }; + struct nk_convert_config cfg = { + .shape_AA = NK_ANTI_ALIASING_ON, + .line_AA = NK_ANTI_ALIASING_ON, + .vertex_layout = vertex_layout, + .vertex_size = sizeof(_snk_vertex_t), + .vertex_alignment = 4, + .circle_segment_count = 22, + .curve_segment_count = 22, + .arc_segment_count = 22, + .global_alpha = 1.0f + }; + + _snuklear.vs_params.disp_size[0] = (float)width; + _snuklear.vs_params.disp_size[1] = (float)height; + + /* Setup vert/index buffers and convert */ + struct nk_buffer cmds, verts, idx; + nk_buffer_init_default(&cmds); + nk_buffer_init_default(&verts); + nk_buffer_init_default(&idx); + nk_convert(&_snuklear.ctx, &cmds, &verts, &idx, &cfg); + + /* Check for vertex- and index-buffer overflow, assert in debug-mode, + otherwise silently skip rendering + */ + const bool vertex_buffer_overflow = nk_buffer_total(&verts) > _snuklear.vertex_buffer_size; + const bool index_buffer_overflow = nk_buffer_total(&idx) > _snuklear.index_buffer_size; + SOKOL_ASSERT(!vertex_buffer_overflow && !index_buffer_overflow); + if (!vertex_buffer_overflow && !index_buffer_overflow) { + + /* Setup rendering */ + const float dpi_scale = _snuklear.desc.dpi_scale; + const int fb_width = (int)(_snuklear.vs_params.disp_size[0] * dpi_scale); + const int fb_height = (int)(_snuklear.vs_params.disp_size[1] * dpi_scale); + sg_apply_viewport(0, 0, fb_width, fb_height, true); + sg_apply_scissor_rect(0, 0, fb_width, fb_height, true); + sg_apply_pipeline(_snuklear.pip); + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(_snuklear.vs_params)); + sg_update_buffer(_snuklear.vbuf, &(sg_range){ nk_buffer_memory_const(&verts), nk_buffer_total(&verts) }); + sg_update_buffer(_snuklear.ibuf, &(sg_range){ nk_buffer_memory_const(&idx), nk_buffer_total(&idx) }); + + /* Iterate through the command list, rendering each one */ + const struct nk_draw_command* cmd = NULL; + int idx_offset = 0; + nk_draw_foreach(cmd, &_snuklear.ctx, &cmds) { + if (cmd->elem_count > 0) { + sg_image img; + if (cmd->texture.id != 0) { + img = (sg_image){ .id = (uint32_t) cmd->texture.id }; + } + else { + img = _snuklear.img; + } + sg_apply_bindings(&(sg_bindings){ + .fs_images[0] = img, + .vertex_buffers[0] = _snuklear.vbuf, + .index_buffer = _snuklear.ibuf, + .vertex_buffer_offsets[0] = 0, + .index_buffer_offset = idx_offset + }); + sg_apply_scissor_rectf(cmd->clip_rect.x * dpi_scale, + cmd->clip_rect.y * dpi_scale, + cmd->clip_rect.w * dpi_scale, + cmd->clip_rect.h * dpi_scale, + true); + sg_draw(0, (int)cmd->elem_count, 1); + idx_offset += (int)cmd->elem_count * (int)sizeof(uint16_t); + } + } + sg_apply_scissor_rect(0, 0, fb_width, fb_height, true); + } + + /* Cleanup */ + nk_buffer_free(&cmds); + nk_buffer_free(&verts); + nk_buffer_free(&idx); +} + +#if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) +_SOKOL_PRIVATE bool _snk_is_ctrl(uint32_t modifiers) { + if (_snuklear.is_osx) { + return 0 != (modifiers & SAPP_MODIFIER_SUPER); + } + else { + return 0 != (modifiers & SAPP_MODIFIER_CTRL); + } +} + +_SOKOL_PRIVATE void _snk_append_char(uint32_t char_code) { + size_t idx = strlen(_snuklear.char_buffer); + if (idxkey_code) { + case SAPP_KEYCODE_C: + if (_snk_is_ctrl(ev->modifiers)) { + return NK_KEY_COPY; + } else { + return NK_KEY_NONE; + } + break; + case SAPP_KEYCODE_X: + if (_snk_is_ctrl(ev->modifiers)) { + return NK_KEY_CUT; + } else { + return NK_KEY_NONE; + } + break; + case SAPP_KEYCODE_A: + if (_snk_is_ctrl(ev->modifiers)) { + return NK_KEY_TEXT_SELECT_ALL; + } else { + return NK_KEY_NONE; + } + break; + case SAPP_KEYCODE_Z: + if (_snk_is_ctrl(ev->modifiers)) { + if (ev->modifiers & SAPP_MODIFIER_SHIFT) { + return NK_KEY_TEXT_REDO; + } else { + return NK_KEY_TEXT_UNDO; + } + } else { + return NK_KEY_NONE; + } + break; + case SAPP_KEYCODE_DELETE: return NK_KEY_DEL; + case SAPP_KEYCODE_ENTER: return NK_KEY_ENTER; + case SAPP_KEYCODE_TAB: return NK_KEY_TAB; + case SAPP_KEYCODE_BACKSPACE: return NK_KEY_BACKSPACE; + case SAPP_KEYCODE_UP: return NK_KEY_UP; + case SAPP_KEYCODE_DOWN: return NK_KEY_DOWN; + case SAPP_KEYCODE_LEFT: return NK_KEY_LEFT; + case SAPP_KEYCODE_RIGHT: return NK_KEY_RIGHT; + case SAPP_KEYCODE_LEFT_SHIFT: return NK_KEY_SHIFT; + case SAPP_KEYCODE_RIGHT_SHIFT: return NK_KEY_SHIFT; + case SAPP_KEYCODE_LEFT_CONTROL: return NK_KEY_CTRL; + case SAPP_KEYCODE_RIGHT_CONTROL: return NK_KEY_CTRL; + default: + return NK_KEY_NONE; + } +} + +SOKOL_API_IMPL void snk_handle_event(const sapp_event* ev) { + const float dpi_scale = _snuklear.desc.dpi_scale; + switch (ev->type) { + case SAPP_EVENTTYPE_MOUSE_DOWN: + _snuklear.mouse_pos[0] = (int) (ev->mouse_x / dpi_scale); + _snuklear.mouse_pos[1] = (int) (ev->mouse_y / dpi_scale); + switch (ev->mouse_button) { + case SAPP_MOUSEBUTTON_LEFT: + _snuklear.btn_down[NK_BUTTON_LEFT] = true; + break; + case SAPP_MOUSEBUTTON_RIGHT: + _snuklear.btn_down[NK_BUTTON_RIGHT] = true; + break; + case SAPP_MOUSEBUTTON_MIDDLE: + _snuklear.btn_down[NK_BUTTON_MIDDLE] = true; + break; + default: + break; + } + break; + case SAPP_EVENTTYPE_MOUSE_UP: + _snuklear.mouse_pos[0] = (int) (ev->mouse_x / dpi_scale); + _snuklear.mouse_pos[1] = (int) (ev->mouse_y / dpi_scale); + switch (ev->mouse_button) { + case SAPP_MOUSEBUTTON_LEFT: + _snuklear.btn_up[NK_BUTTON_LEFT] = true; + break; + case SAPP_MOUSEBUTTON_RIGHT: + _snuklear.btn_up[NK_BUTTON_RIGHT] = true; + break; + case SAPP_MOUSEBUTTON_MIDDLE: + _snuklear.btn_up[NK_BUTTON_MIDDLE] = true; + break; + default: + break; + } + break; + case SAPP_EVENTTYPE_MOUSE_MOVE: + _snuklear.mouse_pos[0] = (int) (ev->mouse_x / dpi_scale); + _snuklear.mouse_pos[1] = (int) (ev->mouse_y / dpi_scale); + _snuklear.mouse_did_move = true; + break; + case SAPP_EVENTTYPE_MOUSE_ENTER: + case SAPP_EVENTTYPE_MOUSE_LEAVE: + for (int i = 0; i < NK_BUTTON_MAX; i++) { + _snuklear.btn_down[i] = false; + _snuklear.btn_up[i] = false; + } + break; + case SAPP_EVENTTYPE_MOUSE_SCROLL: + _snuklear.mouse_scroll[0] = ev->scroll_x; + _snuklear.mouse_scroll[1] = ev->scroll_y; + _snuklear.mouse_did_scroll = true; + break; + case SAPP_EVENTTYPE_TOUCHES_BEGAN: + _snuklear.btn_down[NK_BUTTON_LEFT] = true; + _snuklear.mouse_pos[0] = (int) (ev->touches[0].pos_x / dpi_scale); + _snuklear.mouse_pos[1] = (int) (ev->touches[0].pos_y / dpi_scale); + _snuklear.mouse_did_move = true; + break; + case SAPP_EVENTTYPE_TOUCHES_MOVED: + _snuklear.mouse_pos[0] = (int) (ev->touches[0].pos_x / dpi_scale); + _snuklear.mouse_pos[1] = (int) (ev->touches[0].pos_y / dpi_scale); + _snuklear.mouse_did_move = true; + break; + case SAPP_EVENTTYPE_TOUCHES_ENDED: + _snuklear.btn_up[NK_BUTTON_LEFT] = true; + _snuklear.mouse_pos[0] = (int) (ev->touches[0].pos_x / dpi_scale); + _snuklear.mouse_pos[1] = (int) (ev->touches[0].pos_y / dpi_scale); + _snuklear.mouse_did_move = true; + break; + case SAPP_EVENTTYPE_TOUCHES_CANCELLED: + _snuklear.btn_up[NK_BUTTON_LEFT] = false; + _snuklear.btn_down[NK_BUTTON_LEFT] = false; + break; + case SAPP_EVENTTYPE_KEY_DOWN: + /* intercept Ctrl-V, this is handled via EVENTTYPE_CLIPBOARD_PASTED */ + if (_snk_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_V)) { + break; + } + /* on web platform, don't forward Ctrl-X, Ctrl-V to the browser */ + if (_snk_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_X)) { + sapp_consume_event(); + } + if (_snk_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_C)) { + sapp_consume_event(); + } + _snuklear.keys_down[_snk_event_to_nuklearkey(ev)] = true; + break; + case SAPP_EVENTTYPE_KEY_UP: + /* intercept Ctrl-V, this is handled via EVENTTYPE_CLIPBOARD_PASTED */ + if (_snk_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_V)) { + break; + } + /* on web platform, don't forward Ctrl-X, Ctrl-V to the browser */ + if (_snk_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_X)) { + sapp_consume_event(); + } + if (_snk_is_ctrl(ev->modifiers) && (ev->key_code == SAPP_KEYCODE_C)) { + sapp_consume_event(); + } + _snuklear.keys_up[_snk_event_to_nuklearkey(ev)] = true; + break; + case SAPP_EVENTTYPE_CHAR: + if ((ev->char_code >= 32) && + (ev->char_code != 127) && + (0 == (ev->modifiers & (SAPP_MODIFIER_ALT|SAPP_MODIFIER_CTRL|SAPP_MODIFIER_SUPER)))) + { + _snk_append_char(ev->char_code); + } + break; + case SAPP_EVENTTYPE_CLIPBOARD_PASTED: + _snuklear.keys_down[NK_KEY_PASTE] = _snuklear.keys_up[NK_KEY_PASTE] = true; + break; + default: + break; + } +} + +SOKOL_API_IMPL nk_flags snk_edit_string(struct nk_context *ctx, nk_flags flags, char *memory, int *len, int max, nk_plugin_filter filter) { + nk_flags event = nk_edit_string(ctx, flags, memory, len, max, filter); + if ((event & NK_EDIT_ACTIVATED) && !sapp_keyboard_shown()) { + sapp_show_keyboard(true); + } + if ((event & NK_EDIT_DEACTIVATED) && sapp_keyboard_shown()) { + sapp_show_keyboard(false); + } + return event; +} +#endif // SOKOL_NUKLEAR_NO_SOKOL_APP + +#endif // SOKOL_IMPL diff --git a/source/engine/thirdparty/sokol/sokol_shape.h b/source/engine/thirdparty/sokol/sokol_shape.h new file mode 100644 index 0000000..419181f --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_shape.h @@ -0,0 +1,1437 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_SHAPE_IMPL) +#define SOKOL_SHAPE_IMPL +#endif +#ifndef SOKOL_SHAPE_INCLUDED +/* + sokol_shape.h -- create simple primitive shapes for sokol_gfx.h + + Project URL: https://github.com/floooh/sokol + + Do this: + #define SOKOL_IMPL or + #define SOKOL_SHAPE_IMPL + before you include this file in *one* C or C++ file to create the + implementation. + + Include the following headers before including sokol_shape.h: + + sokol_gfx.h + + ...optionally provide the following macros to override defaults: + + SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) + SOKOL_SHAPE_API_DECL- public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_SHAPE_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + + If sokol_shape.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + On Windows, SOKOL_DLL will define SOKOL_SHAPE_API_DECL as __declspec(dllexport) + or __declspec(dllimport) as needed. + + FEATURE OVERVIEW + ================ + sokol_shape.h creates vertices and indices for simple shapes and + builds structs which can be plugged into sokol-gfx resource + creation functions: + + The following shape types are supported: + + - plane + - cube + - sphere (with poles, not geodesic) + - cylinder + - torus (donut) + + Generated vertices look like this: + + typedef struct sshape_vertex_t { + float x, y, z; + uint32_t normal; // packed normal as BYTE4N + uint16_t u, v; // packed uv coords as USHORT2N + uint32_t color; // packed color as UBYTE4N (r,g,b,a); + } sshape_vertex_t; + + Indices are generally 16-bits wide (SG_INDEXTYPE_UINT16) and the indices + are written as triangle-lists (SG_PRIMITIVETYPE_TRIANGLES). + + EXAMPLES: + ========= + + Create multiple shapes into the same vertex- and index-buffer and + render with separate draw calls: + + https://github.com/floooh/sokol-samples/blob/master/sapp/shapes-sapp.c + + Same as the above, but pre-transform shapes and merge them into a single + shape that's rendered with a single draw call. + + https://github.com/floooh/sokol-samples/blob/master/sapp/shapes-transform-sapp.c + + STEP-BY-STEP: + ============= + + Setup an sshape_buffer_t struct with pointers to memory buffers where + generated vertices and indices will be written to: + + ```c + sshape_vertex_t vertices[512]; + uint16_t indices[4096]; + + sshape_buffer_t buf = { + .vertices = { + .buffer = SSHAPE_RANGE(vertices), + }, + .indices = { + .buffer = SSHAPE_RANGE(indices), + } + }; + ``` + + To find out how big those memory buffers must be (in case you want + to allocate dynamically) call the following functions: + + ```c + sshape_sizes_t sshape_plane_sizes(uint32_t tiles); + sshape_sizes_t sshape_box_sizes(uint32_t tiles); + sshape_sizes_t sshape_sphere_sizes(uint32_t slices, uint32_t stacks); + sshape_sizes_t sshape_cylinder_sizes(uint32_t slices, uint32_t stacks); + sshape_sizes_t sshape_torus_sizes(uint32_t sides, uint32_t rings); + ``` + + The returned sshape_sizes_t struct contains vertex- and index-counts + as well as the equivalent buffer sizes in bytes. For instance: + + ```c + sshape_sizes_t sizes = sshape_sphere_sizes(36, 12); + uint32_t num_vertices = sizes.vertices.num; + uint32_t num_indices = sizes.indices.num; + uint32_t vertex_buffer_size = sizes.vertices.size; + uint32_t index_buffer_size = sizes.indices.size; + ``` + + With the sshape_buffer_t struct that was setup earlier, call any + of the shape-builder functions: + + ```c + sshape_buffer_t sshape_build_plane(const sshape_buffer_t* buf, const sshape_plane_t* params); + sshape_buffer_t sshape_build_box(const sshape_buffer_t* buf, const sshape_box_t* params); + sshape_buffer_t sshape_build_sphere(const sshape_buffer_t* buf, const sshape_sphere_t* params); + sshape_buffer_t sshape_build_cylinder(const sshape_buffer_t* buf, const sshape_cylinder_t* params); + sshape_buffer_t sshape_build_torus(const sshape_buffer_t* buf, const sshape_torus_t* params); + ``` + + Note how the sshape_buffer_t struct is both an input value and the + return value. This can be used to append multiple shapes into the + same vertex- and index-buffers (more on this later). + + The second argument is a struct which holds creation parameters. + + For instance to build a sphere with radius 2, 36 "cake slices" and 12 stacks: + + ```c + sshape_buffer_t buf = ...; + buf = sshape_build_sphere(&buf, &(sshape_sphere_t){ + .radius = 2.0f, + .slices = 36, + .stacks = 12, + }); + ``` + + If the provided buffers are big enough to hold all generated vertices and + indices, the "valid" field in the result will be true: + + ```c + assert(buf.valid); + ``` + + The shape creation parameters have "useful defaults", refer to the + actual C struct declarations below to look up those defaults. + + You can also provide additional creation parameters, like a common vertex + color, a debug-helper to randomize colors, tell the shape builder function + to merge the new shape with the previous shape into the same draw-element-range, + or a 4x4 transform matrix to move, rotate and scale the generated vertices: + + ```c + sshape_buffer_t buf = ...; + buf = sshape_build_sphere(&buf, &(sshape_sphere_t){ + .radius = 2.0f, + .slices = 36, + .stacks = 12, + // merge with previous shape into a single element-range + .merge = true, + // set vertex color to red+opaque + .color = sshape_color_4f(1.0f, 0.0f, 0.0f, 1.0f), + // set position to y = 2.0 + .transform = { + .m = { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 2.0f, 0.0f, 1.0f }, + } + } + }); + assert(buf.valid); + ``` + + The following helper functions can be used to build a packed + color value or to convert from external matrix types: + + ```c + uint32_t sshape_color_4f(float r, float g, float b, float a); + uint32_t sshape_color_3f(float r, float g, float b); + uint32_t sshape_color_4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a); + uint32_t sshape_color_3b(uint8_t r, uint8_t g, uint8_t b); + sshape_mat4_t sshape_mat4(const float m[16]); + sshape_mat4_t sshape_mat4_transpose(const float m[16]); + ``` + + After the shape builder function has been called, the following functions + are used to extract the build result for plugging into sokol_gfx.h: + + ```c + sshape_element_range_t sshape_element_range(const sshape_buffer_t* buf); + sg_buffer_desc sshape_vertex_buffer_desc(const sshape_buffer_t* buf); + sg_buffer_desc sshape_index_buffer_desc(const sshape_buffer_t* buf); + sg_buffer_layout_desc sshape_buffer_layout_desc(void); + sg_vertex_attr_desc sshape_position_attr_desc(void); + sg_vertex_attr_desc sshape_normal_attr_desc(void); + sg_vertex_attr_desc sshape_texcoord_attr_desc(void); + sg_vertex_attr_desc sshape_color_attr_desc(void); + ``` + + The sshape_element_range_t struct contains the base-index and number of + indices which can be plugged into the sg_draw() call: + + ```c + sshape_element_range_t elms = sshape_element_range(&buf); + ... + sg_draw(elms.base_element, elms.num_elements, 1); + ``` + + To create sokol-gfx vertex- and index-buffers from the generated + shape data: + + ```c + // create sokol-gfx vertex buffer + sg_buffer_desc vbuf_desc = sshape_vertex_buffer_desc(&buf); + sg_buffer vbuf = sg_make_buffer(&vbuf_desc); + + // create sokol-gfx index buffer + sg_buffer_desc ibuf_desc = sshape_index_buffer_desc(&buf); + sg_buffer ibuf = sg_make_buffer(&ibuf_desc); + ``` + + The remaining functions are used to populate the vertex-layout item + in sg_pipeline_desc, note that these functions don't depend on the + created geometry, they always return the same result: + + ```c + sg_pipeline pip = sg_make_pipeline(&(sg_pipeline_desc){ + .layout = { + .buffers[0] = sshape_buffer_layout_desc(), + .attrs = { + [0] = sshape_position_attr_desc(), + [1] = ssape_normal_attr_desc(), + [2] = sshape_texcoord_attr_desc(), + [3] = sshape_color_attr_desc() + } + }, + ... + }); + ``` + + Note that you don't have to use all generated vertex attributes in the + pipeline's vertex layout, the sg_buffer_layout_desc struct returned + by sshape_buffer_layout_desc() contains the correct vertex stride + to skip vertex components. + + WRITING MULTIPLE SHAPES INTO THE SAME BUFFER + ============================================ + You can merge multiple shapes into the same vertex- and + index-buffers and either render them as a single shape, or + in separate draw calls. + + To build a single shape made of two cubes which can be rendered + in a single draw-call: + + ``` + sshape_vertex_t vertices[128]; + uint16_t indices[16]; + + sshape_buffer_t buf = { + .vertices.buffer = SSHAPE_RANGE(vertices), + .indices.buffer = SSHAPE_RANGE(indices) + }; + + // first cube at pos x=-2.0 (with default size of 1x1x1) + buf = sshape_build_cube(&buf, &(sshape_box_t){ + .transform = { + .m = { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + {-2.0f, 0.0f, 0.0f, 1.0f }, + } + } + }); + // ...and append another cube at pos pos=+1.0 + // NOTE the .merge = true, this tells the shape builder + // function to not advance the current shape start offset + buf = sshape_build_cube(&buf, &(sshape_box_t){ + .merge = true, + .transform = { + .m = { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + {-2.0f, 0.0f, 0.0f, 1.0f }, + } + } + }); + assert(buf.valid); + + // skipping buffer- and pipeline-creation... + + sshape_element_range_t elms = sshape_element_range(&buf); + sg_draw(elms.base_element, elms.num_elements, 1); + ``` + + To render the two cubes in separate draw-calls, the element-ranges used + in the sg_draw() calls must be captured right after calling the + builder-functions: + + ```c + sshape_vertex_t vertices[128]; + uint16_t indices[16]; + sshape_buffer_t buf = { + .vertices.buffer = SSHAPE_RANGE(vertices), + .indices.buffer = SSHAPE_RANGE(indices) + }; + + // build a red cube... + buf = sshape_build_cube(&buf, &(sshape_box_t){ + .color = sshape_color_3b(255, 0, 0) + }); + sshape_element_range_t red_cube = sshape_element_range(&buf); + + // append a green cube to the same vertex-/index-buffer: + buf = sshape_build_cube(&bud, &sshape_box_t){ + .color = sshape_color_3b(0, 255, 0); + }); + sshape_element_range_t green_cube = sshape_element_range(&buf); + + // skipping buffer- and pipeline-creation... + + sg_draw(red_cube.base_element, red_cube.num_elements, 1); + sg_draw(green_cube.base_element, green_cube.num_elements, 1); + ``` + + ...that's about all :) + + LICENSE + ======= + zlib/libpng license + + Copyright (c) 2020 Andre Weissflog + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_SHAPE_INCLUDED +#include // size_t, offsetof +#include +#include + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_shape.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_SHAPE_API_DECL) +#define SOKOL_SHAPE_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_SHAPE_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_SHAPE_IMPL) +#define SOKOL_SHAPE_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_SHAPE_API_DECL __declspec(dllimport) +#else +#define SOKOL_SHAPE_API_DECL extern +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + sshape_range is a pointer-size-pair struct used to pass memory + blobs into sokol-shape. When initialized from a value type + (array or struct), use the SSHAPE_RANGE() macro to build + an sshape_range struct. +*/ +typedef struct sshape_range { + const void* ptr; + size_t size; +} sshape_range; + +// disabling this for every includer isn't great, but the warning is also quite pointless +#if defined(_MSC_VER) +#pragma warning(disable:4221) /* /W4 only: nonstandard extension used: 'x': cannot be initialized using address of automatic variable 'y' */ +#endif +#if defined(__cplusplus) +#define SSHAPE_RANGE(x) sshape_range{ &x, sizeof(x) } +#else +#define SSHAPE_RANGE(x) (sshape_range){ &x, sizeof(x) } +#endif + +/* a 4x4 matrix wrapper struct */ +typedef struct sshape_mat4_t { float m[4][4]; } sshape_mat4_t; + +/* vertex layout of the generated geometry */ +typedef struct sshape_vertex_t { + float x, y, z; + uint32_t normal; // packed normal as BYTE4N + uint16_t u, v; // packed uv coords as USHORT2N + uint32_t color; // packed color as UBYTE4N (r,g,b,a); +} sshape_vertex_t; + +/* a range of draw-elements (sg_draw(int base_element, int num_element, ...)) */ +typedef struct sshape_element_range_t { + int base_element; + int num_elements; + #if defined(SOKOL_ZIG_BINDINGS) + uint32_t __pad[3]; + #endif +} sshape_element_range_t; + +/* number of elements and byte size of build actions */ +typedef struct sshape_sizes_item_t { + uint32_t num; // number of elements + uint32_t size; // the same as size in bytes + #if defined(SOKOL_ZIG_BINDINGS) + uint32_t __pad[3]; + #endif +} sshape_sizes_item_t; + +typedef struct sshape_sizes_t { + sshape_sizes_item_t vertices; + sshape_sizes_item_t indices; +} sshape_sizes_t; + +/* in/out struct to keep track of mesh-build state */ +typedef struct sshape_buffer_item_t { + sshape_range buffer; // pointer/size pair of output buffer + size_t data_size; // size in bytes of valid data in buffer + size_t shape_offset; // data offset of the most recent shape +} sshape_buffer_item_t; + +typedef struct sshape_buffer_t { + bool valid; + sshape_buffer_item_t vertices; + sshape_buffer_item_t indices; +} sshape_buffer_t; + +/* creation parameters for the different shape types */ +typedef struct sshape_plane_t { + float width, depth; // default: 1.0 + uint16_t tiles; // default: 1 + uint32_t color; // default: white + bool random_colors; // default: false + bool merge; // if true merge with previous shape (default: false) + sshape_mat4_t transform; // default: identity matrix +} sshape_plane_t; + +typedef struct sshape_box_t { + float width, height, depth; // default: 1.0 + uint16_t tiles; // default: 1 + uint32_t color; // default: white + bool random_colors; // default: false + bool merge; // if true merge with previous shape (default: false) + sshape_mat4_t transform; // default: identity matrix +} sshape_box_t; + +typedef struct sshape_sphere_t { + float radius; // default: 0.5 + uint16_t slices; // default: 5 + uint16_t stacks; // default: 4 + uint32_t color; // default: white + bool random_colors; // default: false + bool merge; // if true merge with previous shape (default: false) + sshape_mat4_t transform; // default: identity matrix +} sshape_sphere_t; + +typedef struct sshape_cylinder_t { + float radius; // default: 0.5 + float height; // default: 1.0 + uint16_t slices; // default: 5 + uint16_t stacks; // default: 1 + uint32_t color; // default: white + bool random_colors; // default: false + bool merge; // if true merge with previous shape (default: false) + sshape_mat4_t transform; // default: identity matrix +} sshape_cylinder_t; + +typedef struct sshape_torus_t { + float radius; // default: 0.5f + float ring_radius; // default: 0.2f + uint16_t sides; // default: 5 + uint16_t rings; // default: 5 + uint32_t color; // default: white + bool random_colors; // default: false + bool merge; // if true merge with previous shape (default: false) + sshape_mat4_t transform; // default: identity matrix +} sshape_torus_t; + +/* shape builder functions */ +SOKOL_SHAPE_API_DECL sshape_buffer_t sshape_build_plane(const sshape_buffer_t* buf, const sshape_plane_t* params); +SOKOL_SHAPE_API_DECL sshape_buffer_t sshape_build_box(const sshape_buffer_t* buf, const sshape_box_t* params); +SOKOL_SHAPE_API_DECL sshape_buffer_t sshape_build_sphere(const sshape_buffer_t* buf, const sshape_sphere_t* params); +SOKOL_SHAPE_API_DECL sshape_buffer_t sshape_build_cylinder(const sshape_buffer_t* buf, const sshape_cylinder_t* params); +SOKOL_SHAPE_API_DECL sshape_buffer_t sshape_build_torus(const sshape_buffer_t* buf, const sshape_torus_t* params); + +/* query required vertex- and index-buffer sizes in bytes */ +SOKOL_SHAPE_API_DECL sshape_sizes_t sshape_plane_sizes(uint32_t tiles); +SOKOL_SHAPE_API_DECL sshape_sizes_t sshape_box_sizes(uint32_t tiles); +SOKOL_SHAPE_API_DECL sshape_sizes_t sshape_sphere_sizes(uint32_t slices, uint32_t stacks); +SOKOL_SHAPE_API_DECL sshape_sizes_t sshape_cylinder_sizes(uint32_t slices, uint32_t stacks); +SOKOL_SHAPE_API_DECL sshape_sizes_t sshape_torus_sizes(uint32_t sides, uint32_t rings); + +/* extract sokol-gfx desc structs and primitive ranges from build state */ +SOKOL_SHAPE_API_DECL sshape_element_range_t sshape_element_range(const sshape_buffer_t* buf); +SOKOL_SHAPE_API_DECL sg_buffer_desc sshape_vertex_buffer_desc(const sshape_buffer_t* buf); +SOKOL_SHAPE_API_DECL sg_buffer_desc sshape_index_buffer_desc(const sshape_buffer_t* buf); +SOKOL_SHAPE_API_DECL sg_buffer_layout_desc sshape_buffer_layout_desc(void); +SOKOL_SHAPE_API_DECL sg_vertex_attr_desc sshape_position_attr_desc(void); +SOKOL_SHAPE_API_DECL sg_vertex_attr_desc sshape_normal_attr_desc(void); +SOKOL_SHAPE_API_DECL sg_vertex_attr_desc sshape_texcoord_attr_desc(void); +SOKOL_SHAPE_API_DECL sg_vertex_attr_desc sshape_color_attr_desc(void); + +/* helper functions to build packed color value from floats or bytes */ +SOKOL_SHAPE_API_DECL uint32_t sshape_color_4f(float r, float g, float b, float a); +SOKOL_SHAPE_API_DECL uint32_t sshape_color_3f(float r, float g, float b); +SOKOL_SHAPE_API_DECL uint32_t sshape_color_4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a); +SOKOL_SHAPE_API_DECL uint32_t sshape_color_3b(uint8_t r, uint8_t g, uint8_t b); + +/* adapter function for filling matrix struct from generic float[16] array */ +SOKOL_SHAPE_API_DECL sshape_mat4_t sshape_mat4(const float m[16]); +SOKOL_SHAPE_API_DECL sshape_mat4_t sshape_mat4_transpose(const float m[16]); + +#ifdef __cplusplus +} // extern "C" + +// FIXME: C++ helper functions + +#endif +#endif // SOKOL_SHAPE_INCLUDED + +/*-- IMPLEMENTATION ----------------------------------------------------------*/ +#ifdef SOKOL_SHAPE_IMPL +#define SOKOL_SHAPE_IMPL_INCLUDED (1) + +#include // memcpy +#include // sinf, cosf + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#endif + +#ifndef SOKOL_API_IMPL + #define SOKOL_API_IMPL +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif + +#define _sshape_def(val, def) (((val) == 0) ? (def) : (val)) +#define _sshape_def_flt(val, def) (((val) == 0.0f) ? (def) : (val)) +#define _sshape_white (0xFFFFFFFF) + +typedef struct { float x, y, z, w; } _sshape_vec4_t; +typedef struct { float x, y; } _sshape_vec2_t; + +static inline float _sshape_clamp(float v) { + if (v < 0.0f) return 0.0f; + else if (v > 1.0f) return 1.0f; + else return v; +} + +static inline uint32_t _sshape_pack_ub4_ubyte4n(uint8_t x, uint8_t y, uint8_t z, uint8_t w) { + return (uint32_t)(((uint32_t)w<<24)|((uint32_t)z<<16)|((uint32_t)y<<8)|x); +} + +static inline uint32_t _sshape_pack_f4_ubyte4n(float x, float y, float z, float w) { + uint8_t x8 = (uint8_t) (x * 255.0f); + uint8_t y8 = (uint8_t) (y * 255.0f); + uint8_t z8 = (uint8_t) (z * 255.0f); + uint8_t w8 = (uint8_t) (w * 255.0f); + return _sshape_pack_ub4_ubyte4n(x8, y8, z8, w8); +} + +static inline uint32_t _sshape_pack_f4_byte4n(float x, float y, float z, float w) { + int8_t x8 = (int8_t) (x * 127.0f); + int8_t y8 = (int8_t) (y * 127.0f); + int8_t z8 = (int8_t) (z * 127.0f); + int8_t w8 = (int8_t) (w * 127.0f); + return _sshape_pack_ub4_ubyte4n((uint8_t)x8, (uint8_t)y8, (uint8_t)z8, (uint8_t)w8); +} + +static inline uint16_t _sshape_pack_f_ushortn(float x) { + return (uint16_t) (x * 65535.0f); +} + +static inline _sshape_vec4_t _sshape_vec4(float x, float y, float z, float w) { + _sshape_vec4_t v = { x, y, z, w }; + return v; +} + +static inline _sshape_vec4_t _sshape_vec4_norm(_sshape_vec4_t v) { + float l = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w); + if (l != 0.0f) { + return _sshape_vec4(v.x/l, v.y/l, v.z/l, v.w/l); + } + else { + return _sshape_vec4(0.0f, 1.0f, 0.0f, 0.0f); + } +} + +static inline _sshape_vec2_t _sshape_vec2(float x, float y) { + _sshape_vec2_t v = { x, y }; + return v; +} + +static bool _sshape_mat4_isnull(const sshape_mat4_t* m) { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { + if (0.0f != m->m[y][x]) { + return false; + } + } + } + return true; +} + +static sshape_mat4_t _sshape_mat4_identity(void) { + sshape_mat4_t m = { + { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f } + } + }; + return m; +} + +static _sshape_vec4_t _sshape_mat4_mul(const sshape_mat4_t* m, _sshape_vec4_t v) { + _sshape_vec4_t res = { + m->m[0][0]*v.x + m->m[1][0]*v.y + m->m[2][0]*v.z + m->m[3][0]*v.w, + m->m[0][1]*v.x + m->m[1][1]*v.y + m->m[2][1]*v.z + m->m[3][1]*v.w, + m->m[0][2]*v.x + m->m[1][2]*v.y + m->m[2][2]*v.z + m->m[3][2]*v.w, + m->m[0][3]*v.x + m->m[1][3]*v.y + m->m[2][3]*v.z + m->m[3][3]*v.w + }; + return res; +} + +static uint32_t _sshape_plane_num_vertices(uint32_t tiles) { + return (tiles + 1) * (tiles + 1); +} + +static uint32_t _sshape_plane_num_indices(uint32_t tiles) { + return tiles * tiles * 2 * 3; +} + +static uint32_t _sshape_box_num_vertices(uint32_t tiles) { + return (tiles + 1) * (tiles + 1) * 6; +} + +static uint32_t _sshape_box_num_indices(uint32_t tiles) { + return tiles * tiles * 2 * 6 * 3; +} + +static uint32_t _sshape_sphere_num_vertices(uint32_t slices, uint32_t stacks) { + return (slices + 1) * (stacks + 1); +} + +static uint32_t _sshape_sphere_num_indices(uint32_t slices, uint32_t stacks) { + return ((2 * slices * stacks) - (2 * slices)) * 3; +} + +static uint32_t _sshape_cylinder_num_vertices(uint32_t slices, uint32_t stacks) { + return (slices + 1) * (stacks + 5); +} + +static uint32_t _sshape_cylinder_num_indices(uint32_t slices, uint32_t stacks) { + return ((2 * slices * stacks) + (2 * slices)) * 3; +} + +static uint32_t _sshape_torus_num_vertices(uint32_t sides, uint32_t rings) { + return (sides + 1) * (rings + 1); +} + +static uint32_t _sshape_torus_num_indices(uint32_t sides, uint32_t rings) { + return sides * rings * 2 * 3; +} + +static bool _sshape_validate_buffer_item(const sshape_buffer_item_t* item, uint32_t build_size) { + if (0 == item->buffer.ptr) { + return false; + } + if (0 == item->buffer.size) { + return false; + } + if ((item->data_size + build_size) > item->buffer.size) { + return false; + } + if (item->shape_offset > item->data_size) { + return false; + } + return true; +} + +static bool _sshape_validate_buffer(const sshape_buffer_t* buf, uint32_t num_vertices, uint32_t num_indices) { + if (!_sshape_validate_buffer_item(&buf->vertices, num_vertices * sizeof(sshape_vertex_t))) { + return false; + } + if (!_sshape_validate_buffer_item(&buf->indices, num_indices * sizeof(uint16_t))) { + return false; + } + return true; +} + +static void _sshape_advance_offset(sshape_buffer_item_t* item) { + item->shape_offset = item->data_size; +} + +static uint16_t _sshape_base_index(const sshape_buffer_t* buf) { + return (uint16_t) (buf->vertices.data_size / sizeof(sshape_vertex_t)); +} + +static sshape_plane_t _sshape_plane_defaults(const sshape_plane_t* params) { + sshape_plane_t res = *params; + res.width = _sshape_def_flt(res.width, 1.0f); + res.depth = _sshape_def_flt(res.depth, 1.0f); + res.tiles = _sshape_def(res.tiles, 1); + res.color = _sshape_def(res.color, _sshape_white); + res.transform = _sshape_mat4_isnull(&res.transform) ? _sshape_mat4_identity() : res.transform; + return res; +} + +static sshape_box_t _sshape_box_defaults(const sshape_box_t* params) { + sshape_box_t res = *params; + res.width = _sshape_def_flt(res.width, 1.0f); + res.height = _sshape_def_flt(res.height, 1.0f); + res.depth = _sshape_def_flt(res.depth, 1.0f); + res.tiles = _sshape_def(res.tiles, 1); + res.color = _sshape_def(res.color, _sshape_white); + res.transform = _sshape_mat4_isnull(&res.transform) ? _sshape_mat4_identity() : res.transform; + return res; +} + +static sshape_sphere_t _sshape_sphere_defaults(const sshape_sphere_t* params) { + sshape_sphere_t res = *params; + res.radius = _sshape_def_flt(res.radius, 0.5f); + res.slices = _sshape_def(res.slices, 5); + res.stacks = _sshape_def(res.stacks, 4); + res.color = _sshape_def(res.color, _sshape_white); + res.transform = _sshape_mat4_isnull(&res.transform) ? _sshape_mat4_identity() : res.transform; + return res; +} + +static sshape_cylinder_t _sshape_cylinder_defaults(const sshape_cylinder_t* params) { + sshape_cylinder_t res = *params; + res.radius = _sshape_def_flt(res.radius, 0.5f); + res.height = _sshape_def_flt(res.height, 1.0f); + res.slices = _sshape_def(res.slices, 5); + res.stacks = _sshape_def(res.stacks, 1); + res.color = _sshape_def(res.color, _sshape_white); + res.transform = _sshape_mat4_isnull(&res.transform) ? _sshape_mat4_identity() : res.transform; + return res; +} + +static sshape_torus_t _sshape_torus_defaults(const sshape_torus_t* params) { + sshape_torus_t res = *params; + res.radius = _sshape_def_flt(res.radius, 0.5f); + res.ring_radius = _sshape_def_flt(res.ring_radius, 0.2f); + res.sides = _sshape_def_flt(res.sides, 5); + res.rings = _sshape_def_flt(res.rings, 5); + res.color = _sshape_def(res.color, _sshape_white); + res.transform = _sshape_mat4_isnull(&res.transform) ? _sshape_mat4_identity() : res.transform; + return res; +} + +static void _sshape_add_vertex(sshape_buffer_t* buf, _sshape_vec4_t pos, _sshape_vec4_t norm, _sshape_vec2_t uv, uint32_t color) { + size_t offset = buf->vertices.data_size; + SOKOL_ASSERT((offset + sizeof(sshape_vertex_t)) <= buf->vertices.buffer.size); + buf->vertices.data_size += sizeof(sshape_vertex_t); + sshape_vertex_t* v_ptr = (sshape_vertex_t*) ((uint8_t*)buf->vertices.buffer.ptr + offset); + v_ptr->x = pos.x; + v_ptr->y = pos.y; + v_ptr->z = pos.z; + v_ptr->normal = _sshape_pack_f4_byte4n(norm.x, norm.y, norm.z, norm.w); + v_ptr->u = _sshape_pack_f_ushortn(uv.x); + v_ptr->v = _sshape_pack_f_ushortn(uv.y); + v_ptr->color = color; +} + +static void _sshape_add_triangle(sshape_buffer_t* buf, uint16_t i0, uint16_t i1, uint16_t i2) { + size_t offset = buf->indices.data_size; + SOKOL_ASSERT((offset + 3*sizeof(uint16_t)) <= buf->indices.buffer.size); + buf->indices.data_size += 3*sizeof(uint16_t); + uint16_t* i_ptr = (uint16_t*) ((uint8_t*)buf->indices.buffer.ptr + offset); + i_ptr[0] = i0; + i_ptr[1] = i1; + i_ptr[2] = i2; +} + +static uint32_t _sshape_rand_color(uint32_t* xorshift_state) { + // xorshift32 + uint32_t x = *xorshift_state; + x ^= x<<13; + x ^= x>>17; + x ^= x<<5; + *xorshift_state = x; + + // rand => bright color with alpha 1.0 + x |= 0xFF000000; + return x; + +} + +/*=== PUBLIC API FUNCTIONS ===================================================*/ +SOKOL_API_IMPL uint32_t sshape_color_4f(float r, float g, float b, float a) { + return _sshape_pack_f4_ubyte4n(_sshape_clamp(r), _sshape_clamp(g), _sshape_clamp(b), _sshape_clamp(a)); +} + +SOKOL_API_IMPL uint32_t sshape_color_3f(float r, float g, float b) { + return _sshape_pack_f4_ubyte4n(_sshape_clamp(r), _sshape_clamp(g), _sshape_clamp(b), 1.0f); +} + +SOKOL_API_IMPL uint32_t sshape_color_4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + return _sshape_pack_ub4_ubyte4n(r, g, b, a); +} + +SOKOL_API_IMPL uint32_t sshape_color_3b(uint8_t r, uint8_t g, uint8_t b) { + return _sshape_pack_ub4_ubyte4n(r, g, b, 255); +} + +SOKOL_API_IMPL sshape_mat4_t sshape_mat4(const float m[16]) { + sshape_mat4_t res; + memcpy(&res.m[0][0], &m[0], 64); + return res; +} + +SOKOL_API_IMPL sshape_mat4_t sshape_mat4_transpose(const float m[16]) { + sshape_mat4_t res; + for (int c = 0; c < 4; c++) { + for (int r = 0; r < 4; r++) { + res.m[r][c] = m[c*4 + r]; + } + } + return res; +} + +SOKOL_API_IMPL sshape_sizes_t sshape_plane_sizes(uint32_t tiles) { + SOKOL_ASSERT(tiles >= 1); + sshape_sizes_t res = { {0} }; + res.vertices.num = _sshape_plane_num_vertices(tiles); + res.indices.num = _sshape_plane_num_indices(tiles); + res.vertices.size = res.vertices.num * sizeof(sshape_vertex_t); + res.indices.size = res.indices.num * sizeof(uint16_t); + return res; +} + +SOKOL_API_IMPL sshape_sizes_t sshape_box_sizes(uint32_t tiles) { + SOKOL_ASSERT(tiles >= 1); + sshape_sizes_t res = { {0} }; + res.vertices.num = _sshape_box_num_vertices(tiles); + res.indices.num = _sshape_box_num_indices(tiles); + res.vertices.size = res.vertices.num * sizeof(sshape_vertex_t); + res.indices.size = res.indices.num * sizeof(uint16_t); + return res; +} + +SOKOL_API_IMPL sshape_sizes_t sshape_sphere_sizes(uint32_t slices, uint32_t stacks) { + SOKOL_ASSERT((slices >= 3) && (stacks >= 2)); + sshape_sizes_t res = { {0} }; + res.vertices.num = _sshape_sphere_num_vertices(slices, stacks); + res.indices.num = _sshape_sphere_num_indices(slices, stacks); + res.vertices.size = res.vertices.num * sizeof(sshape_vertex_t); + res.indices.size = res.indices.num * sizeof(uint16_t); + return res; +} + +SOKOL_API_IMPL sshape_sizes_t sshape_cylinder_sizes(uint32_t slices, uint32_t stacks) { + SOKOL_ASSERT((slices >= 3) && (stacks >= 1)); + sshape_sizes_t res = { {0} }; + res.vertices.num = _sshape_cylinder_num_vertices(slices, stacks); + res.indices.num = _sshape_cylinder_num_indices(slices, stacks); + res.vertices.size = res.vertices.num * sizeof(sshape_vertex_t); + res.indices.size = res.indices.num * sizeof(uint16_t); + return res; +} + +SOKOL_API_IMPL sshape_sizes_t sshape_torus_sizes(uint32_t sides, uint32_t rings) { + SOKOL_ASSERT((sides >= 3) && (rings >= 3)); + sshape_sizes_t res = { {0} }; + res.vertices.num = _sshape_torus_num_vertices(sides, rings); + res.indices.num = _sshape_torus_num_indices(sides, rings); + res.vertices.size = res.vertices.num * sizeof(sshape_vertex_t); + res.indices.size = res.indices.num * sizeof(uint16_t); + return res; +} + +/* + Geometry layout for plane (4 tiles): + +--+--+--+--+ + |\ |\ |\ |\ | + | \| \| \| \| + +--+--+--+--+ 25 vertices (tiles + 1) * (tiles + 1) + |\ |\ |\ |\ | 32 triangles (tiles + 1) * (tiles + 1) * 2 + | \| \| \| \| + +--+--+--+--+ + |\ |\ |\ |\ | + | \| \| \| \| + +--+--+--+--+ + |\ |\ |\ |\ | + | \| \| \| \| + +--+--+--+--+ +*/ +SOKOL_API_IMPL sshape_buffer_t sshape_build_plane(const sshape_buffer_t* in_buf, const sshape_plane_t* in_params) { + SOKOL_ASSERT(in_buf && in_params); + const sshape_plane_t params = _sshape_plane_defaults(in_params); + const uint32_t num_vertices = _sshape_plane_num_vertices(params.tiles); + const uint32_t num_indices = _sshape_plane_num_indices(params.tiles); + sshape_buffer_t buf = *in_buf; + if (!_sshape_validate_buffer(&buf, num_vertices, num_indices)) { + buf.valid = false; + return buf; + } + buf.valid = true; + const uint16_t start_index = _sshape_base_index(&buf); + if (!params.merge) { + _sshape_advance_offset(&buf.vertices); + _sshape_advance_offset(&buf.indices); + } + + // write vertices + uint32_t rand_seed = 0x12345678; + const float x0 = -params.width * 0.5f; + const float z0 = params.depth * 0.5f; + const float dx = params.width / params.tiles; + const float dz = -params.depth / params.tiles; + const float duv = 1.0f / params.tiles; + _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms.transform, _sshape_vec4(0.0f, 1.0f, 0.0f, 0.0f))); + for (uint32_t ix = 0; ix <= params.tiles; ix++) { + for (uint32_t iz = 0; iz <= params.tiles; iz++) { + const _sshape_vec4_t pos = _sshape_vec4(x0 + dx*ix, 0.0f, z0 + dz*iz, 1.0f); + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms.transform, pos); + const _sshape_vec2_t uv = _sshape_vec2(duv*ix, duv*iz); + const uint32_t color = params.random_colors ? _sshape_rand_color(&rand_seed) : params.color; + _sshape_add_vertex(&buf, tpos, tnorm, uv, color); + } + } + + // write indices + for (uint16_t j = 0; j < params.tiles; j++) { + for (uint16_t i = 0; i < params.tiles; i++) { + const uint16_t i0 = start_index + (j * (params.tiles + 1)) + i; + const uint16_t i1 = i0 + 1; + const uint16_t i2 = i0 + params.tiles + 1; + const uint16_t i3 = i2 + 1; + _sshape_add_triangle(&buf, i0, i1, i3); + _sshape_add_triangle(&buf, i0, i3, i2); + } + } + return buf; +} + +SOKOL_API_IMPL sshape_buffer_t sshape_build_box(const sshape_buffer_t* in_buf, const sshape_box_t* in_params) { + SOKOL_ASSERT(in_buf && in_params); + const sshape_box_t params = _sshape_box_defaults(in_params); + const uint32_t num_vertices = _sshape_box_num_vertices(params.tiles); + const uint32_t num_indices = _sshape_box_num_indices(params.tiles); + sshape_buffer_t buf = *in_buf; + if (!_sshape_validate_buffer(&buf, num_vertices, num_indices)) { + buf.valid = false; + return buf; + } + buf.valid = true; + const uint16_t start_index = _sshape_base_index(&buf); + if (!params.merge) { + _sshape_advance_offset(&buf.vertices); + _sshape_advance_offset(&buf.indices); + } + + // build vertices + uint32_t rand_seed = 0x12345678; + const float x0 = -params.width * 0.5f; + const float x1 = params.width * 0.5f; + const float y0 = -params.height * 0.5f; + const float y1 = params.height * 0.5f; + const float z0 = -params.depth * 0.5f; + const float z1 = params.depth * 0.5f; + const float dx = params.width / params.tiles; + const float dy = params.height / params.tiles; + const float dz = params.depth / params.tiles; + const float duv = 1.0f / params.tiles; + + // bottom/top vertices + for (uint32_t top_bottom = 0; top_bottom < 2; top_bottom++) { + _sshape_vec4_t pos = _sshape_vec4(0.0f, (0==top_bottom) ? y0:y1, 0.0f, 1.0f); + const _sshape_vec4_t norm = _sshape_vec4(0.0f, (0==top_bottom) ? -1.0f:1.0f, 0.0f, 0.0f); + const _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms.transform, norm)); + for (uint32_t ix = 0; ix <= params.tiles; ix++) { + pos.x = (0==top_bottom) ? (x0 + dx * ix) : (x1 - dx * ix); + for (uint32_t iz = 0; iz <= params.tiles; iz++) { + pos.z = z0 + dz * iz; + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms.transform, pos); + const _sshape_vec2_t uv = _sshape_vec2(ix * duv, iz * duv); + const uint32_t color = params.random_colors ? _sshape_rand_color(&rand_seed) : params.color; + _sshape_add_vertex(&buf, tpos, tnorm, uv, color); + } + } + } + + // left/right vertices + for (uint32_t left_right = 0; left_right < 2; left_right++) { + _sshape_vec4_t pos = _sshape_vec4((0==left_right) ? x0:x1, 0.0f, 0.0f, 1.0f); + const _sshape_vec4_t norm = _sshape_vec4((0==left_right) ? -1.0f:1.0f, 0.0f, 0.0f, 0.0f); + const _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms.transform, norm)); + for (uint32_t iy = 0; iy <= params.tiles; iy++) { + pos.y = (0==left_right) ? (y1 - dy * iy) : (y0 + dy * iy); + for (uint32_t iz = 0; iz <= params.tiles; iz++) { + pos.z = z0 + dz * iz; + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms.transform, pos); + const _sshape_vec2_t uv = _sshape_vec2(iy * duv, iz * duv); + const uint32_t color = params.random_colors ? _sshape_rand_color(&rand_seed) : params.color; + _sshape_add_vertex(&buf, tpos, tnorm, uv, color); + } + } + } + + // front/back vertices + for (uint32_t front_back = 0; front_back < 2; front_back++) { + _sshape_vec4_t pos = _sshape_vec4(0.0f, 0.0f, (0==front_back) ? z0:z1, 1.0f); + const _sshape_vec4_t norm = _sshape_vec4(0.0f, 0.0f, (0==front_back) ? -1.0f:1.0f, 0.0f); + const _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms.transform, norm)); + for (uint32_t ix = 0; ix <= params.tiles; ix++) { + pos.x = (0==front_back) ? (x1 - dx * ix) : (x0 + dx * ix); + for (uint32_t iy = 0; iy <= params.tiles; iy++) { + pos.y = y0 + dy * iy; + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms.transform, pos); + const _sshape_vec2_t uv = _sshape_vec2(ix * duv, iy * duv); + const uint32_t color = params.random_colors ? _sshape_rand_color(&rand_seed) : params.color; + _sshape_add_vertex(&buf, tpos, tnorm, uv, color); + } + } + } + + // build indices + const uint16_t verts_per_face = (params.tiles + 1) * (params.tiles + 1); + for (uint16_t face = 0; face < 6; face++) { + uint16_t face_start_index = start_index + face * verts_per_face; + for (uint16_t j = 0; j < params.tiles; j++) { + for (uint16_t i = 0; i < params.tiles; i++) { + const uint16_t i0 = face_start_index + (j * (params.tiles + 1)) + i; + const uint16_t i1 = i0 + 1; + const uint16_t i2 = i0 + params.tiles + 1; + const uint16_t i3 = i2 + 1; + _sshape_add_triangle(&buf, i0, i1, i3); + _sshape_add_triangle(&buf, i0, i3, i2); + } + } + } + return buf; +} + +/* + Geometry layout for spheres is as follows (for 5 slices, 4 stacks): + + + + + + + + north pole + |\ |\ |\ |\ |\ + | \| \| \| \| \ + +--+--+--+--+--+ 30 vertices (slices + 1) * (stacks + 1) + |\ |\ |\ |\ |\ | 30 triangles (2 * slices * stacks) - (2 * slices) + | \| \| \| \| \| 2 orphaned vertices + +--+--+--+--+--+ + |\ |\ |\ |\ |\ | + | \| \| \| \| \| + +--+--+--+--+--+ + \ |\ |\ |\ |\ | + \| \| \| \| \| + + + + + + + south pole +*/ +SOKOL_API_IMPL sshape_buffer_t sshape_build_sphere(const sshape_buffer_t* in_buf, const sshape_sphere_t* in_params) { + SOKOL_ASSERT(in_buf && in_params); + const sshape_sphere_t params = _sshape_sphere_defaults(in_params); + const uint32_t num_vertices = _sshape_sphere_num_vertices(params.slices, params.stacks); + const uint32_t num_indices = _sshape_sphere_num_indices(params.slices, params.stacks); + sshape_buffer_t buf = *in_buf; + if (!_sshape_validate_buffer(&buf, num_vertices, num_indices)) { + buf.valid = false; + return buf; + } + buf.valid = true; + const uint16_t start_index = _sshape_base_index(&buf); + if (!params.merge) { + _sshape_advance_offset(&buf.vertices); + _sshape_advance_offset(&buf.indices); + } + + uint32_t rand_seed = 0x12345678; + const float pi = 3.14159265358979323846f; + const float two_pi = 2.0f * pi; + const float du = 1.0f / params.slices; + const float dv = 1.0f / params.stacks; + + // generate vertices + for (uint32_t stack = 0; stack <= params.stacks; stack++) { + const float stack_angle = (pi * stack) / params.stacks; + const float sin_stack = sinf(stack_angle); + const float cos_stack = cosf(stack_angle); + for (uint32_t slice = 0; slice <= params.slices; slice++) { + const float slice_angle = (two_pi * slice) / params.slices; + const float sin_slice = sinf(slice_angle); + const float cos_slice = cosf(slice_angle); + const _sshape_vec4_t norm = _sshape_vec4(-sin_slice * sin_stack, cos_stack, cos_slice * sin_stack, 0.0f); + const _sshape_vec4_t pos = _sshape_vec4(norm.x * params.radius, norm.y * params.radius, norm.z * params.radius, 1.0f); + const _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms.transform, norm)); + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms.transform, pos); + const _sshape_vec2_t uv = _sshape_vec2(1.0f - slice * du, 1.0f - stack * dv); + const uint32_t color = params.random_colors ? _sshape_rand_color(&rand_seed) : params.color; + _sshape_add_vertex(&buf, tpos, tnorm, uv, color); + } + } + + // generate indices + { + // north-pole triangles + const uint16_t row_a = start_index; + const uint16_t row_b = row_a + params.slices + 1; + for (uint16_t slice = 0; slice < params.slices; slice++) { + _sshape_add_triangle(&buf, row_a + slice, row_b + slice, row_b + slice + 1); + } + } + // stack triangles + for (uint16_t stack = 1; stack < params.stacks - 1; stack++) { + const uint16_t row_a = start_index + stack * (params.slices + 1); + const uint16_t row_b = row_a + params.slices + 1; + for (uint16_t slice = 0; slice < params.slices; slice++) { + _sshape_add_triangle(&buf, row_a + slice, row_b + slice + 1, row_a + slice + 1); + _sshape_add_triangle(&buf, row_a + slice, row_b + slice, row_b + slice + 1); + } + } + { + // south-pole triangles + const uint16_t row_a = start_index + (params.stacks - 1) * (params.slices + 1); + const uint16_t row_b = row_a + params.slices + 1; + for (uint16_t slice = 0; slice < params.slices; slice++) { + _sshape_add_triangle(&buf, row_a + slice, row_b + slice + 1, row_a + slice + 1); + } + } + return buf; +} + +/* + Geometry for cylinders is as follows (2 stacks, 5 slices): + + + + + + + + + |\ |\ |\ |\ |\ + | \| \| \| \| \ + +--+--+--+--+--+ + +--+--+--+--+--+ 42 vertices (2 wasted) (slices + 1) * (stacks + 5) + |\ |\ |\ |\ |\ | 30 triangles (2 * slices * stacks) + (2 * slices) + | \| \| \| \| \| + +--+--+--+--+--+ + |\ |\ |\ |\ |\ | + | \| \| \| \| \| + +--+--+--+--+--+ + +--+--+--+--+--+ + \ |\ |\ |\ |\ | + \| \| \| \| \| + + + + + + + +*/ +static void _sshape_build_cylinder_cap_pole(sshape_buffer_t* buf, const sshape_cylinder_t* params, float pos_y, float norm_y, float du, float v, uint32_t* rand_seed) { + const _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms->transform, _sshape_vec4(0.0f, norm_y, 0.0f, 0.0f))); + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms->transform, _sshape_vec4(0.0f, pos_y, 0.0f, 1.0f)); + for (uint32_t slice = 0; slice <= params->slices; slice++) { + const _sshape_vec2_t uv = _sshape_vec2(slice * du, 1.0f - v); + const uint32_t color = params->random_colors ? _sshape_rand_color(rand_seed) : params->color; + _sshape_add_vertex(buf, tpos, tnorm, uv, color); + } +} + +static void _sshape_build_cylinder_cap_ring(sshape_buffer_t* buf, const sshape_cylinder_t* params, float pos_y, float norm_y, float du, float v, uint32_t* rand_seed) { + const float two_pi = 2.0f * 3.14159265358979323846f; + const _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms->transform, _sshape_vec4(0.0f, norm_y, 0.0f, 0.0f))); + for (uint32_t slice = 0; slice <= params->slices; slice++) { + const float slice_angle = (two_pi * slice) / params->slices; + const float sin_slice = sinf(slice_angle); + const float cos_slice = cosf(slice_angle); + const _sshape_vec4_t pos = _sshape_vec4(sin_slice * params->radius, pos_y, cos_slice * params->radius, 1.0f); + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms->transform, pos); + const _sshape_vec2_t uv = _sshape_vec2(slice * du, 1.0f - v); + const uint32_t color = params->random_colors ? _sshape_rand_color(rand_seed) : params->color; + _sshape_add_vertex(buf, tpos, tnorm, uv, color); + } +} + +SOKOL_SHAPE_API_DECL sshape_buffer_t sshape_build_cylinder(const sshape_buffer_t* in_buf, const sshape_cylinder_t* in_params) { + SOKOL_ASSERT(in_buf && in_params); + const sshape_cylinder_t params = _sshape_cylinder_defaults(in_params); + const uint32_t num_vertices = _sshape_cylinder_num_vertices(params.slices, params.stacks); + const uint32_t num_indices = _sshape_cylinder_num_indices(params.slices, params.stacks); + sshape_buffer_t buf = *in_buf; + if (!_sshape_validate_buffer(&buf, num_vertices, num_indices)) { + buf.valid = false; + return buf; + } + buf.valid = true; + const uint16_t start_index = _sshape_base_index(&buf); + if (!params.merge) { + _sshape_advance_offset(&buf.vertices); + _sshape_advance_offset(&buf.indices); + } + + uint32_t rand_seed = 0x12345678; + const float two_pi = 2.0f * 3.14159265358979323846f; + const float du = 1.0f / params.slices; + const float dv = 1.0f / (params.stacks + 2); + const float y0 = params.height * 0.5f; + const float y1 = -params.height * 0.5f; + const float dy = params.height / params.stacks; + + // generate vertices + _sshape_build_cylinder_cap_pole(&buf, ¶ms, y0, 1.0f, du, 0.0f, &rand_seed); + _sshape_build_cylinder_cap_ring(&buf, ¶ms, y0, 1.0f, du, dv, &rand_seed); + for (uint32_t stack = 0; stack <= params.stacks; stack++) { + const float y = y0 - dy * stack; + const float v = dv * stack + dv; + for (uint32_t slice = 0; slice <= params.slices; slice++) { + const float slice_angle = (two_pi * slice) / params.slices; + const float sin_slice = sinf(slice_angle); + const float cos_slice = cosf(slice_angle); + const _sshape_vec4_t pos = _sshape_vec4(sin_slice * params.radius, y, cos_slice * params.radius, 1.0f); + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms.transform, pos); + const _sshape_vec4_t norm = _sshape_vec4(sin_slice, 0.0f, cos_slice, 0.0f); + const _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms.transform, norm)); + const _sshape_vec2_t uv = _sshape_vec2(slice * du, 1.0f - v); + const uint32_t color = params.random_colors ? _sshape_rand_color(&rand_seed) : params.color; + _sshape_add_vertex(&buf, tpos, tnorm, uv, color); + } + } + _sshape_build_cylinder_cap_ring(&buf, ¶ms, y1, -1.0f, du, 1.0f - dv, &rand_seed); + _sshape_build_cylinder_cap_pole(&buf, ¶ms, y1, -1.0f, du, 1.0f, &rand_seed); + + // generate indices + { + // top-cap indices + const uint16_t row_a = start_index; + const uint16_t row_b = row_a + params.slices + 1; + for (uint16_t slice = 0; slice < params.slices; slice++) { + _sshape_add_triangle(&buf, row_a + slice, row_b + slice + 1, row_b + slice); + } + } + // shaft triangles + for (uint16_t stack = 0; stack < params.stacks; stack++) { + const uint16_t row_a = start_index + (stack + 2) * (params.slices + 1); + const uint16_t row_b = row_a + params.slices + 1; + for (uint16_t slice = 0; slice < params.slices; slice++) { + _sshape_add_triangle(&buf, row_a + slice, row_a + slice + 1, row_b + slice + 1); + _sshape_add_triangle(&buf, row_a + slice, row_b + slice + 1, row_b + slice); + } + } + { + // bottom-cap indices + const uint16_t row_a = start_index + (params.stacks + 3) * (params.slices + 1); + const uint16_t row_b = row_a + params.slices + 1; + for (uint16_t slice = 0; slice < params.slices; slice++) { + _sshape_add_triangle(&buf, row_a + slice, row_a + slice + 1, row_b + slice + 1); + } + } + return buf; +} + +/* + Geometry layout for torus (sides = 4, rings = 5): + + +--+--+--+--+--+ + |\ |\ |\ |\ |\ | + | \| \| \| \| \| + +--+--+--+--+--+ 30 vertices (sides + 1) * (rings + 1) + |\ |\ |\ |\ |\ | 40 triangles (2 * sides * rings) + | \| \| \| \| \| + +--+--+--+--+--+ + |\ |\ |\ |\ |\ | + | \| \| \| \| \| + +--+--+--+--+--+ + |\ |\ |\ |\ |\ | + | \| \| \| \| \| + +--+--+--+--+--+ +*/ +SOKOL_API_IMPL sshape_buffer_t sshape_build_torus(const sshape_buffer_t* in_buf, const sshape_torus_t* in_params) { + SOKOL_ASSERT(in_buf && in_params); + const sshape_torus_t params = _sshape_torus_defaults(in_params); + const uint32_t num_vertices = _sshape_torus_num_vertices(params.sides, params.rings); + const uint32_t num_indices = _sshape_torus_num_indices(params.sides, params.rings); + sshape_buffer_t buf = *in_buf; + if (!_sshape_validate_buffer(&buf, num_vertices, num_indices)) { + buf.valid = false; + return buf; + } + buf.valid = true; + const uint16_t start_index = _sshape_base_index(&buf); + if (!params.merge) { + _sshape_advance_offset(&buf.vertices); + _sshape_advance_offset(&buf.indices); + } + + uint32_t rand_seed = 0x12345678; + const float two_pi = 2.0f * 3.14159265358979323846f; + const float dv = 1.0f / params.sides; + const float du = 1.0f / params.rings; + + // generate vertices + for (uint32_t side = 0; side <= params.sides; side++) { + const float phi = (side * two_pi) / params.sides; + const float sin_phi = sinf(phi); + const float cos_phi = cosf(phi); + for (uint32_t ring = 0; ring <= params.rings; ring++) { + const float theta = (ring * two_pi) / params.rings; + const float sin_theta = sinf(theta); + const float cos_theta = cosf(theta); + + // torus surface position + const float spx = sin_theta * (params.radius - (params.ring_radius * cos_phi)); + const float spy = sin_phi * params.ring_radius; + const float spz = cos_theta * (params.radius - (params.ring_radius * cos_phi)); + + // torus position with ring-radius zero (for normal computation) + const float ipx = sin_theta * params.radius; + const float ipy = 0.0f; + const float ipz = cos_theta * params.radius; + + const _sshape_vec4_t pos = _sshape_vec4(spx, spy, spz, 1.0f); + const _sshape_vec4_t norm = _sshape_vec4(spx - ipx, spy - ipy, spz - ipz, 0.0f); + const _sshape_vec4_t tpos = _sshape_mat4_mul(¶ms.transform, pos); + const _sshape_vec4_t tnorm = _sshape_vec4_norm(_sshape_mat4_mul(¶ms.transform, norm)); + const _sshape_vec2_t uv = _sshape_vec2(ring * du, 1.0f - side * dv); + const uint32_t color = params.random_colors ? _sshape_rand_color(&rand_seed) : params.color; + _sshape_add_vertex(&buf, tpos, tnorm, uv, color); + } + } + + // generate indices + for (uint16_t side = 0; side < params.sides; side++) { + const uint16_t row_a = start_index + side * (params.rings + 1); + const uint16_t row_b = row_a + params.rings + 1; + for (uint16_t ring = 0; ring < params.rings; ring++) { + _sshape_add_triangle(&buf, row_a + ring, row_a + ring + 1, row_b + ring + 1); + _sshape_add_triangle(&buf, row_a + ring, row_b + ring + 1, row_b + ring); + } + } + return buf; +} + +SOKOL_API_IMPL sg_buffer_desc sshape_vertex_buffer_desc(const sshape_buffer_t* buf) { + SOKOL_ASSERT(buf && buf->valid); + sg_buffer_desc desc = { 0 }; + if (buf->valid) { + desc.type = SG_BUFFERTYPE_VERTEXBUFFER; + desc.usage = SG_USAGE_IMMUTABLE; + desc.data.ptr = buf->vertices.buffer.ptr; + desc.data.size = buf->vertices.data_size; + } + return desc; +} + +SOKOL_API_IMPL sg_buffer_desc sshape_index_buffer_desc(const sshape_buffer_t* buf) { + SOKOL_ASSERT(buf && buf->valid); + sg_buffer_desc desc = { 0 }; + if (buf->valid) { + desc.type = SG_BUFFERTYPE_INDEXBUFFER; + desc.usage = SG_USAGE_IMMUTABLE; + desc.data.ptr = buf->indices.buffer.ptr; + desc.data.size = buf->indices.data_size; + } + return desc; +} + +SOKOL_SHAPE_API_DECL sshape_element_range_t sshape_element_range(const sshape_buffer_t* buf) { + SOKOL_ASSERT(buf && buf->valid); + SOKOL_ASSERT(buf->indices.shape_offset < buf->indices.data_size); + SOKOL_ASSERT(0 == (buf->indices.shape_offset & (sizeof(uint16_t) - 1))); + SOKOL_ASSERT(0 == (buf->indices.data_size & (sizeof(uint16_t) - 1))); + sshape_element_range_t range = { 0 }; + range.base_element = (int) (buf->indices.shape_offset / sizeof(uint16_t)); + if (buf->valid) { + range.num_elements = (int) ((buf->indices.data_size - buf->indices.shape_offset) / sizeof(uint16_t)); + } + else { + range.num_elements = 0; + } + return range; +} + +SOKOL_API_IMPL sg_buffer_layout_desc sshape_buffer_layout_desc(void) { + sg_buffer_layout_desc desc = { 0 }; + desc.stride = sizeof(sshape_vertex_t); + return desc; +} + +SOKOL_API_IMPL sg_vertex_attr_desc sshape_position_attr_desc(void) { + sg_vertex_attr_desc desc = { 0 }; + desc.offset = offsetof(sshape_vertex_t, x); + desc.format = SG_VERTEXFORMAT_FLOAT3; + return desc; +} + +SOKOL_API_IMPL sg_vertex_attr_desc sshape_normal_attr_desc(void) { + sg_vertex_attr_desc desc = { 0 }; + desc.offset = offsetof(sshape_vertex_t, normal); + desc.format = SG_VERTEXFORMAT_BYTE4N; + return desc; +} + +SOKOL_API_IMPL sg_vertex_attr_desc sshape_texcoord_attr_desc(void) { + sg_vertex_attr_desc desc = { 0 }; + desc.offset = offsetof(sshape_vertex_t, u); + desc.format = SG_VERTEXFORMAT_USHORT2N; + return desc; +} + +SOKOL_API_IMPL sg_vertex_attr_desc sshape_color_attr_desc(void) { + sg_vertex_attr_desc desc = { 0 }; + desc.offset = offsetof(sshape_vertex_t, color); + desc.format = SG_VERTEXFORMAT_UBYTE4N; + return desc; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#endif // SOKOL_SHAPE_IMPL diff --git a/source/engine/thirdparty/sokol/sokol_spine.h b/source/engine/thirdparty/sokol/sokol_spine.h new file mode 100644 index 0000000..2fd62c8 --- /dev/null +++ b/source/engine/thirdparty/sokol/sokol_spine.h @@ -0,0 +1,5759 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_SPINE_IMPL) +#define SOKOL_SPINE_IMPL +#endif +#ifndef SOKOL_SPINE_INCLUDED +/* + sokol_spine.h -- a sokol-gfx renderer for the spine-c runtime + (see https://github.com/EsotericSoftware/spine-runtimes/tree/4.1/spine-c) + + Project URL: https://github.com/floooh/sokol + + Do this: + #define SOKOL_IMPL or + #define SOKOL_SPINE_IMPL + + before you include this file in *one* C or C++ file to create the + implementation. + + The following defines are used by the implementation to select the + platform-specific embedded shader code (these are the same defines as + used by sokol_gfx.h and sokol_app.h): + + SOKOL_GLCORE33 + SOKOL_GLES3 + SOKOL_D3D11 + SOKOL_METAL + + ...optionally provide the following macros to override defaults: + + SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) + SOKOL_SPINE_API_DECL - public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_SPINE_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) + + If sokol_spine.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + On Windows, SOKOL_DLL will define SOKOL_SPINE_API_DECL as __declspec(dllexport) + or __declspec(dllimport) as needed. + + Include the following headers before including sokol_spine.h: + + sokol_gfx.h + + Include the following headers before include the sokol_spine.h *IMPLEMENTATION*: + + spine/spine.h + + You'll also need to compile and link with the spine-c runtime: + + https://github.com/EsotericSoftware/spine-runtimes/tree/4.1/spine-c/spine-c + + + FEATURE OVERVIEW + ================ + sokol_spine.h is a sokol-gfx renderer and 'handle wrapper' for Spine + (http://en.esotericsoftware.com/spine-in-depth) on top of the + spine-c runtime: http://en.esotericsoftware.com/spine-c (source code: + https://github.com/EsotericSoftware/spine-runtimes/tree/4.1/spine-c/spine-c). + + The sokol-gfx renderer allows to manage multiple contexts for rendering + Spine scenes into different sokol-gfx render passes (similar to sokol-gl and + sokol-debugtext), allows to split rendering into layers to mix Spine + rendering with other rendering operations, and it automatically batches + adjacent draw calls for Spine objects that use the same texture and in the + same layer. + + Sokol-spine wraps 'raw' spine-c objects with tagged index handles. This + eliminates the risk of memory corruption via dangling pointers. Any + API calls involving invalid objects either result in a no-op, or + in a proper error. + + The sokol-spine API exposes four 'base object types', and a number of + 'subobject types' which are owned by base objects. + + Base object types are: + + - sspine_atlas: A wrapper around a spine-c spAtlas object, each spAtlas + object owns at least one spAtlasPage object, and each spAtlasPage object + owns exactly one sokol-gfx image object. + + - sspine_skeleton: A skeleton object requires an atlas object for creation, + and is a wrapper around one spine-c spSkeletonData and one + spAnimationStateData object. both contain the shared static data for + individual spine instances + + - sspine_instance: Instance objects are created from skeleton objects. + Instances are the objects that are actually getting rendered. Each instance + tracks its own transformation and animation state, but otherwise just + references shared data of the skeleton object it was created from. An + sspine_instance object is a wrapper around one spine-c spSkeleton, + spAnimationState and spSkeletonClipping object each. + + - sspine_skinset: Skin-set objects are collections of skins which define + the look of an instance. Some Spine scenes consist of combinable skins + (for instance a human character could offer different skins for different + types of clothing, hats, scarfs, shirts, pants, and so on..., and a skin + set would represent a specific outfit). + + Subobject types allow to inspect and manipulate Spine objects in more detail: + + - sspine_anim: Each skeleton object usually offers animations which can + then be scheduled and mixed on an instance. + + - sspine_bone: Bone objects are the hierarchical transform nodes of + a skeleton. The sokol-spine API allows both to inspect the shared + static bone attributes of an sspine_skeleton object, as well as + inspecting and manipulating the per-instance bone attributes + on an sspine_instance object. + + - sspine_event: A running Spine animation may fire 'events' at certain + positions in time (for instance a 'footstep' event whenever a foot + hits the ground). Events can be used to play sound effects (or visual + effects) at the right time. + + - sspine_iktarget: Allows to set the target position for a group of + bones controlled by inverse kinematics. + + There's a couple of other subobject types which are mostly useful to + inspect the interior structure of skeletons. Those will be explained + in detail further down. + + MINIMAL API USAGE OVERVIEW + ========================== + During initialization: + + - call sspine_setup() after initializating sokol-gfx + - create an atlas object from a Spine atlas file with sspine_make_atlas() + - load and initialize the sokol-gfx image objects referenced by the atlas + - create a skeleton object from a Spine skeleton file with sspine_make_skeleton() + - create at least one instance object with sspine_make_instance() + + In the frame loop, outside of sokol-gfx render passes: + + - if needed, move instances around with sspine_set_position() + - if needed, schedule new animations with sspine_set_animation() and sspine_add_animation() + - each frame, advance the current instance animation state with sspine_update_instance() + - each frame, render instances with sspine_draw_instance_in_layer(), this just records + vertices, indices and draw commands into internal buffers, but does no actual + sokol-gfx rendering + + In the frame loop, inside a sokol-gfx render pass: + + - call sspine_draw_layer() to draw all previously recorded instances in a specific layer + + On shutdown: + + - call sspine_shutdown(), ideally before shutting down sokol-gfx + + QUICKSTART STEP BY STEP + ======================= + For a simple demo program using sokol_app.h, sokol_gfx.h and sokol_fetch.h, + see here: [TODO: add link to spine-simple-sapp wasm demo]. + + - sokol_spine.h must be included after sokol_gfx.h (this is true both + for the declaration and implementation): + + #include "sokol_gfx.h" + #include "sokol_spine.h" + + - ...and sokol_gfx.h must be initialized before sokol_spine.h: + + sg_setup(&(sg_desc){ ... }); + sspine_setup(&(sspine_desc){ ... }); + + - You should always provide a logging callback to sokol-spine, otherwise + no warning or errors will be logged. The easiest way is to use sokol_log.h + for this: + + #include "sokol_log.h" + + sspine_setup(&(sspine_desc){ + .logger = { + .func = slog_func + } + }); + + - You can tweak the memory usage of sokol-spine by limiting or expanding the + maximum number of vertices, draw commands and pool sizes: + + sspine_setup(&(sspine_desc){ + .max_vertices = 1024, // default: (1<<16) = 65536 + .max_commands = 128, // default: (1<<14) = 16384 + .context_pool_size = 1, // default: 4 + .atlas_pool_size = 1, // default: 64 + .skeleton_pool_size = 1, // default: 64 + .skinset_pool_size = 1, // default: 64 + .instance_pool_size = 16, // default: 1024 + .logger = { + .func = slog_func, + } + }); + + Sokol-spine uses 32-bit vertex-indices for rendering + (SG_INDEXTYPE_UINT32), so that the maximum number of Spine vertices + in a frame isn't limited to (1<<16). + + - You can override memory allocation and logging with your own + functions, this is explained in detail further down: + + sspine_setup(&(sspine_desc){ + .allocator = { + .alloc = my_alloc, + .free = my_free, + .user_data = ..., + }, + .logger = { + .log_func = my_log_func, + .user_data = ..., + } + }); + + - After initialization, the first thing you need is an sspine_atlas object. + Sokol-spine doesn't concern itself with file IO, it expects all external + data to be provided as pointer/size pairs: + + sspine_atlas atlas = sspine_make_atlas(&(sspine_atlas_desc){ + .data = { + .ptr = ..., // pointer to Spine atlas file data in memory + .size = ..., // atlas file data size in bytes + } + }); + assert(sspine_atlas_valid(atlas)); + + If you load the atlas data asynchronously, you can still run your + per-frame rendering code without waiting for the atlas data to be loaded + and the atlas to be created. This works because calling sokol-spine + functions with 'invalid' object handles is a valid no-op. + + - Optionally you can override some or all of the atlas texture creation parameters: + + sspine_atlas atlas = sspine_make_atlas(&(sspine_atlas_desc){ + .data = { ... }, + .overrides = { + .min_filter = SG_FILTER_NEAREST, + .mag_filter = SG_FILTER_NEAREST, + .wrap_u = SG_WRAP_MIRROR, + .wrap_v = SG_WRAP_MIRROR, + .premul_alpha_enabled = ..., + .premul_alpha_disabled = ..., + } + }); + + - The atlas file itself doesn't contain any texture data, it only contains + filenames of the required textures. Sokol-spine has already allocated + a sokol-gfx sg_image handle for each required texture, but the actual + texture loading and initialization must be performed by user code: + + // iterate over atlas textures and initialize sokol-gfx image objects + // with existing handles + const int num = sspine_num_images(atlas); + for (int i = 0; i < num; i++) { + const sspine_image img = sspine_image_by_index(atlas, i); + const sspine_image_info img_info = sspine_get_image_info(img); + assert(img_info.valid); + assert(!img_info.filename.truncated); + + // the filename is now in img_info.filename.cstr, 'somehow' + // load and decode the image data into memory, and then + // initialize the sokol-gfx image from the existing sg_image handle + // in img_info.sgimage: + sg_init_image(img_info.sgimage, &(sg_image_desc){ + .width = ..., + .height = ..., + .pixel_format = ..., + .min_filter = img_info.min_filter, + .mag_filter = img_info.mag_filter, + .wrap_u = img_info.wrap_u, + .wrap_v = img_info.wrap_v, + .data.subimage[0][0] = { + .ptr = ..., // pointer to decoded image pixel data + .size = ..., // size of decoded image pixel data in bytes + } + }); + } + + If you load the image data asynchronously, you can still simply start rendering + before the image data is loaded. This works because sokol-gfx will silently drop + any rendering operations that involve 'incomplete' objects. + + - Once an atlas object has been created (independently from loading any image data), + an sspine_skeleton object is needed next. This requires a valid atlas object + handle as input, and a pointer to the Spine skeleton file data loaded into memory. + + Spine skeleton files come in two flavours: binary or json, for binary data, + a ptr/size pair must be provided: + + sspine_skeleton skeleton = sspine_make_skeleton(&(sspine_skeleton_desc){ + .atlas = atlas, // atlas must be a valid sspine_atlas handle + .binary_data = { + .ptr = ..., // pointer to binary skeleton data in memory + .size = ..., // size of binary skeleton data in bytes + } + }); + assert(sspine_skeleton_valid(skeleton)); + + For JSON skeleton file data, the data must be provided as a zero-terminated C string: + + sspine_skeleton skeleton = sspine_make_skeleton(&(sspine_skeleton_desc){ + .atlas = atlas, + .json_data = ..., // JSON skeleton data as zero-terminated(!) C-string + }); + + Like with all sokol-spine objects, if you load the skeleton data asynchronously + and only then create a skeleton object, you can already start rendering before + the data is loaded and the Spine objects have been created. Any operations + involving 'incomplete' handles will be dropped. + + - You can pre-scale the Spine scene size, and you can provide a default cross-fade + duration for animation mixing: + + sspine_skeleton skeleton = sspine_make_skeleton(&(sspine_skeleton_desc){ + .atlas = atlas, + .binary_data = { ... }, + .prescale = 0.5f, // scale to half-size + .anim_default_mix = 0.2f, // default anim mixing cross-fade duration 0.2 seconds + }); + + - Once the skeleton object has been created, it's finally time to create one or many instance objects. + If you want to independently render and animate the 'same' Spine object many times in a frame, + you should only create one sspine_skeleton object, and then as many sspine_instance object + as needed from the shared skeleton object: + + sspine_instance instance = sspine_make_instance(&(sspine_instance_desc){ + .skeleton = skeleton, // must be a valid skeleton handle + }); + assert(sspine_instance_valid(instance)); + + After creation, the sspine_instance will have a 'default skin' set as its appearance. + + - To set the position of an instance: + + sspine_set_position(inst, (sspine_vec2){ .x=..., .y=... }); + + Sokol-spine doesn't define a specific unit (like pixels or meters), instead the + rendering coordinate system is defined later at 'render time'. + + - To schedule an initial looping animation by its name: + + // first lookup up the animation by name on the skeleton: + sspine_anim anim = sspine_anim_by_name(skeleton, "walk"); + assert(sspine_anim_valid(anim)); + + // then schedule the animation on the instance, on mixer track 0, as looping: + sspine_set_animation(instance, anim, 0, true); + + Scheduling and mixing animations will be explained in more detail further down. + + - To advance and mix instance animations: + + sspine_update_instance(instance, delta_time_in_seconds); + + Usually you'd call this each frame for each active instance with the + frame duration in seconds. + + - Now it's finally time to 'render' the instance at its current position and + animation state: + + sspine_draw_instance_in_layer(instance, 0); + + Instances are generally rendered into numbered virtual 'render layers' (in this + case, layer 0). Layers are useful for interleaving sokol-spine rendering + with other rendering commands (like background and foreground tile maps, + sprites or text). + + - It's important to note that no actual sokol-gfx rendering happens in + sspine_draw_instance_in_layer(), instead only vertices, indices and + draw commands are recorded into internal memory buffes. + + - The only sokol-spine function which *must* (and should) be called inside + a sokol-gfx rendering pass is sspine_draw_layer(). + + This renders all draw commands that have been recorded previously in a + specific layer via sspine_draw_instance_in_layer(). + + const sspine_layer_transform tform = { ... }; + + sg_begin_default_pass(...); + sspine_draw_layer(0, tform); + sg_end_pass(); + sg_commit(); + + IMPORTANT: DO *NOT* MIX any calls to sspine_draw_instance_in_layer() + with sspine_draw_layer(), as this will confuse the internal draw command + recording. Ideally, move all sokol-gfx pass rendering (including all + sspine_draw_layer() calls) towards the end of the frame, separate from + any other sokol-spine calls. + + The sspine_layer_transform struct defines the layer's screen space coordinate + system. For instance to map Spine coordinates to framebuffer pixels, with the + origin in the screen center, you'd setup the layer transform like this: + + const float width = sapp_widthf(); + const float height = sapp_heightf(); + const sspine_layer_transform tform = { + .size = { .x = width, .y = height }, + .origin = { .x = width * 0.5f, .y = height * 0.5f }, + }; + + With this pixel mapping, the Spine scene would *not* scale with window size, + which often is not very useful. Instead it might make more sense to render + to a fixed 'virtual' resolution, for instance 1024 * 768: + + const sspine_layer_transform tform = { + .size = { .x = 1024.0f, .y = 768.0f }, + .origin = { .x = 512.0f, .y = 384.0f }, + }; + + How to configure a virtual resolution with a fixed aspect ratio is + left as an exercise to the reader ;) + + - That's it for basic sokol-spine setup and rendering. Any existing objects + will automatically be cleaned up when calling sspine_shutdown(), this + should be called before shutting down sokol-gfx, but this is not required: + + sspine_shutdown(); + sg_shutdown(); + + - You can explicitely destroy the base object types if you don't need them + any longer. This will cause the underlying spine-c objects to be + freed and the memory to be returned to the operating system: + + sspine_destroy_instance(instance); + sspine_destroy_skinset(skinset); + sspine_destroy_skeleton(skeleton); + sspine_destroy_atlas(atlas); + + You can destroy these objects in any order without causing memory corruption + issues. Instead any dependent object handles will simply become invalid (e.g. + if you destroy an atlas object, all skeletons and instances created from + this atlas will 'technically' still exist, but their handles will resolve to + 'invalid' and all sokol-spine calls involving these handles will silently fail). + + For instance: + + // create an atlas, skeleton and instance + sspine_atlas atlas = sspine_make_atlas(&(sspine_atlas_desc){ ... }); + assert(sspine_atlas_valid(atlas)); + + sspine_skeleton skeleton = sspine_make_skeleton(&(sspine_skeleton_desc){ + .atlas = atlas, + ... + }); + assert(sspine_skeleton_valid(skeleton)); + + sspine_instance instance = sspine_make_instance(&(sspine_instance_desc){ + .skeleton = skeleton, + }); + assert(sspine_instance_valid(instance)); + + // destroy the atlas object: + sspine_destroy_atlas(atlas); + + // the skeleton and instance handle should now be invalid, but + // otherwise, nothing bad will happen: + if (!sspine_skeleton_valid(skeleton)) { + ... + } + if (!sspine_instance_valid(instance)) { + ... + } + + RENDERER DETAILS + ================ + Any rendering related work happens in the functions sspine_draw_instance_in_layer() and + sspine_draw_layer(). + + sspine_draw_instance_in_layer() will result in vertices, indices and internal + draw commands which will be recorded into internal memory buffers (e.g. + no sokol-gfx functions will be called here). + + If possible, batching will be performed by merging a new draw command with + the previously recorded draw command. For two draw commands to be merged, + the following conditions must be tru: + + - rendering needs to go into the same layer + - the same atlas texture must be used + - the blend mode must be compatible (the Spine blending modes + 'normal' and 'additive' can be merged, but not 'multiply') + - the same premultiplied alpha mode must be used + + To make the most out of batching: + + - use Spine objects which only have a single atlas texture + and blend mode across all slots + - group sspine_draw_instance_in_layer() calls by layer + + After all instances have been 'rendered' (or rather: recorded) into layers, + the actually rendering happens inside a sokol-gfx pass by calling the + function sspine_draw_layer() for each layer in 'z order' (e.g. the layer + index doesn't matter for z-ordering, only the order how sspine_draw_layer() is + called). + + Only the first call to sspine_draw_layer() in a frame will copy the recorded + vertices and indices into sokol-gfx buffers. + + Each call to sspine_draw_layer() will iterate over all recorded (and + hopefully well-batched) draw commands, skip any draw commands with a + non-matching layer index, and draw only those with a matching layer by + calling: + + - if the pipeline object has changed: + - sg_apply_pipeline() + - sg_apply_uniforms() for the vertex stage + - if the atlas texture has changed: + - sg_apply_bindings() + - if the premultiplied-alpha mode has changed: + - sg_apply_uniforms() for the fragment stage + - and finally sg_draw() + + The main purpose of render layers is to mix Spine rendering with other + render operations. In the not too distant future, the same render layer idea + will also be implemented at least for sokol-gl and sokol-debugtext. + + FIXME: does this section need more details about layer transforms? + + RENDERING WITH CONTEXTS + ======================= + At first glance, render contexts may look like more heavy-weight + render layers, but they serve a different purpose: they are useful + if Spine rendering needs to happen in different sokol-gfx render passes + with different pixel formats and MSAA sample counts. + + All Spine rendering happens within a context, even you don't call any + of the context API functions, in this case, an internal 'default context' + will be used. + + Each context has its own internal vertex-, index- and command buffer and + all context state is completely independent from any other contexts. + + To create a new context object, call: + + sspine_context ctx = sspine_make_context(&(sspine_context_desc){ + .max_vertices = ..., + .max_commands = ..., + .color_format = SG_PIXELFORMAT_..., + .depth_format = SG_PIXELFORMAT_..., + .sample_count = ..., + .color_write_mask = SG_COLORMASK_..., + }); + + The color_format, depth_format and sample_count items must be compatible + with the sokol-gfx render pass you're going to render into. + + If you omit the color_format, depth_format and sample_count designators, + the new context will be compatible with the sokol-gfx default pass + (which is most likely not what you want, unless your offscreen render passes + exactly match the default pass attributes). + + Once a context has been created, it can be made active with: + + sspine_set_context(ctx); + + To set the default context again: + + sspine_set_contxt(sspine_default_context()); + + ...and to get the currently active context: + + sspine_context cur_ctx = sspine_get_context(); + + The currently active context only matter for two functions: + + - sspine_draw_instance_in_layer() + - sspine_draw_layer() + + Alternatively you can bypass the currently set context with these + alternative functions: + + - sspine_context_draw_layer_in_instance(ctx, ...) + - sspine_context_draw_layer(ctx, ...) + + These explicitely take a context argument, completely ignore + and don't change the active context. + + You can query some information about the a context with the function: + + sspine_context_info info = ssgpine_get_context_info(ctx); + + This returns the current number of recorded vertices, indices + and draw commands. + + RESOURCE STATES: + ================ + Similar to sokol-gfx, you can query the current 'resource state' of Spine + objects: + + sspine_resource_state sspine_get_atlas_resource_state(sspine_atlas atlas); + sspine_resource_state sspine_get_skeleton_resource_state(sspine_atlas atlas); + sspine_resource_state sspine_get_instance_resource_state(sspine_atlas atlas); + sspine_resource_state sspine_get_skinset_resource_state(sspine_atlas atlas); + sspine_resource_state sspine_get_context_resource_state(sspine_atlas atlas); + + This returns one of + + - SSPINE_RESOURCE_VALID: the object is valid and ready to use + - SSPINE_RESOURCE_FAILED: the object creation has failed + - SSPINE_RESOURCE_INVALID: the object or one of its dependencies is + invalid, it either no longer exists, or the the handle hasn't been + initialized with a call to one of the object creation functions + + MISC HELPER FUNCTIONS: + ====================== + There's a couple of helper functions which don't fit into a big enough category + of their own: + + You can ask a skeleton for the atlas it has been created from: + + sspine_atlas atlas = sspine_get_skeleton_atlas(skeleton); + + ...and likewise, ask an instance for the skeleton it has been created from: + + sspine_skeleton skeleton = sspine_get_instance_skeleton(instance); + + ...and finally you can convert a layer transform struct into a 4x4 projection + matrix that's memory-layout compatible with sokol-gl: + + const sspine_layer_transform tform = { ... }; + const sspine_mat4 proj = sspine_layer_transform_to_mat4(&tform); + sgl_matrix_mode_projection(); + sgl_load_matrix(proj.m); + + ANIMATIONS + ========== + Animations have their own handle type sspine_anim. A valid sspine_anim + handle is either obtained by looking up an animation by name from a skeleton: + + sspine_anim anim = sspine_anim_by_name(skeleton, "walk"); + + ...or by index: + + sspine_anim anim = sspine_anim_by_index(skeleton, 0); + + The returned anim handle will be invalid if an animation of that name doesn't + exist, or the provided index is out-of-range: + + if (!sspine_anim_is_valid(anim)) { + // animation handle is not valid + } + + An animation handle will also become invalid when the skeleton object it was + created is destroyed, or otherwise becomes invalid. + + You can iterate over all animations in a skeleton: + + const int num_anims = sspine_num_anims(skeleton); + for (int anim_index = 0; anim_index < num_anims; anim_index++) { + sspine_anim anim = sspine_anim_by_index(skeleton, anim_index); + ... + } + + Since sspine_anim is a 'fat handle' (it houses a skeleton handle and an index), + there's a helper function which checks if two anim handles are equal: + + if (sspine_anim_equal(anim0, anim1)) { + ... + } + + To query information about an animation: + + const sspine_anim_info info = sspine_get_anim_info(anim); + if (info.valid) { + printf("index: %d, duration: %f, name: %s", info.index, info.duration, info.name.cstr); + } + + Scheduling and mixing animations is controlled through the following functions: + + void sspine_clear_animation_tracks(sspine_instance instance); + void sspine_clear_animation_track(sspine_instance instance, int track_index); + void sspine_set_animation(sspine_instance instance, sspine_anim anim, int track_index, bool loop); + void sspine_add_animation(sspine_instance instance, sspine_anim anim, int track_index, bool loop, float delay); + void sspine_set_empty_animation(sspine_instance instance, int track_index, float mix_duration); + void sspine_add_empty_animation(sspine_instance instance, int track_index, float mix_duration, float delay); + + Please refer to the spine-c documentation to get an idea what these functions do: + + http://en.esotericsoftware.com/spine-c#Applying-animations + + EVENTS + ====== + For a general idea of Spine events, see here: http://esotericsoftware.com/spine-events + + After calling sspine_update_instance() to advance the currently configured animations, + you can poll for triggered events like this: + + const int num_triggered_events = sspine_num_triggered_events(instance); + for (int i = 0; i < num_triggered_events; i++) { + const sspine_triggered_event_info info = sspine_get_triggered_event_info(instance, i); + if (info.valid) { + ... + } + } + + The returned sspine_triggered_event_info struct gives you the current runtime properties + of the event (in case the event has keyed properties). For the actual list of event + properties please see the actual sspine_triggered_event_info struct declaration. + + It's also possible to inspect the static event definition on a skeleton, this works + the same as iterating through animations. You can lookup an event by name, + get the number of events, lookup an event by its index, and get detailed + information about an event: + + int sspine_num_events(sspine_skeleton skeleton); + sspine_event sspine_event_by_name(sspine_skeleton skeleton, const char* name); + sspine_event sspine_event_by_index(sspine_skeleton skeleton, int index); + bool sspine_event_valid(sspine_event event); + bool sspine_event_equal(sspine_event first, sspine_event second); + sspine_event_info sspine_get_event_info(sspine_event event); + + (FIXME: shouldn't the event info struct contains an sspine_anim handle?) + + IK TARGETS + ========== + The IK target function group allows to iterate over the IK targets that have been + defined on a skeleton, find an IK target by name, get detailed information about + an IK target, and most importantly, set the world space position of an IK target + which updates the position of all bones influenced by the IK target: + + int sspine_num_iktargets(sspine_skeleton skeleton); + sspine_iktarget sspine_iktarget_by_name(sspine_skeleton skeleton, const char* name); + sspine_iktarget sspine_iktarget_by_index(sspine_skeleton skeleton, int index); + bool sspine_iktarget_valid(sspine_iktarget iktarget); + bool sspine_iktarget_equal(sspine_iktarget first, sspine_iktarget second); + sspine_iktarget_info sspine_get_iktarget_info(sspine_iktarget iktarget); + void sspine_set_iktarget_world_pos(sspine_instance instance, sspine_iktarget iktarget, sspine_vec2 world_pos); + + BONES + ===== + Skeleton bones are wrapped with an sspine_bone handle which can be created from + a skeleton handle, and either a bone name: + + sspine_bone bone = sspine_bone_by_name(skeleton, "root"); + assert(sspine_bone_valid(bone)); + + ...or a bone index: + + sspine_bone bone = sspine_bone_by_index(skeleton, 0); + assert(sspine_bone_valid(bone)); + + ...to iterate over all bones of a skeleton and query information about each + bone: + + const int num_bones = sspine_num_bones(skeleton); + for (int bone_index = 0; bone_index < num_bones; bone_index++) { + sspine_bone bone = sspine_bone_by_index(skeleton, bone_index); + const sspine_bone_info info = sspine_get_bone_info(skeleton, bone); + if (info.valid) { + ... + } + } + + The sspine_bone_info struct provides the shared, static bone state in the skeleton (like + the name, a parent bone handle, bone length, pose transform and a color attribute), + but doesn't contain any dynamic information of per-instance bones. + + To manipulate the per-instance bone attributes use the following setter functions: + + void sspine_set_bone_transform(sspine_instance instance, sspine_bone bone, const sspine_bone_transform* transform); + void sspine_set_bone_position(sspine_instance instance, sspine_bone bone, sspine_vec2 position); + void sspine_set_bone_rotation(sspine_instance instance, sspine_bone bone, float rotation); + void sspine_set_bone_scale(sspine_instance instance, sspine_bone bone, sspine_vec2 scale); + void sspine_set_bone_shear(sspine_instance instance, sspine_bone bone, sspine_vec2 shear); + + ...and to query the per-instance bone attributes, the following getters: + + sspine_bone_transform sspine_get_bone_transform(sspine_instance instance, sspine_bone bone); + sspine_vec2 sspine_get_bone_position(sspine_instance instance, sspine_bone bone); + float sspine_get_bone_rotation(sspine_instance instance, sspine_bone bone); + sspine_vec2 sspine_get_bone_scale(sspine_instance instance, sspine_bone bone); + sspine_vec2 sspine_get_bone_shear(sspine_instance instance, sspine_bone bone); + + These functions all work in the local bone coordinate system (relative to a bone's parent bone). + + To transform positions between bone-local and global space use the following helper functions: + + sspine_vec2 sspine_bone_local_to_world(sspine_instance instance, sspine_bone bone, sspine_vec2 local_pos); + sspine_vec2 sspine_bone_world_to_local(sspine_instance instance, sspine_bone bone, sspine_vec2 world_pos); + + ...and as a convenience, there's a helper function which obtains the bone position in global space + directly: + + sspine_vec2 sspine_get_bone_world_position(sspine_instance instance, sspine_bone bone); + + SKINS AND SKINSETS + ================== + Skins are named pieces of geometry which can be turned on and off, what makes Spine skins a bit + confusing is that they are hierarchical. A skin can itself be a collection of other skins. Setting + the 'root skin' will also make all 'child skins' visible. In sokol-spine collections of skins are + managed through dedicated 'skin set' objects. Under the hood they create a 'root skin' where the + skins of the skin set are attached to, but from the outside it just looks like a 'flat' collection + of skins without the tricky hierarchical management. + + Like other 'subobjects', skin handles can be obtained by the skin name from a skeleton handle: + + sspine_skin skin = sspine_skin_by_name(skeleton, "jacket"); + assert(sspine_skin_valid(skin)); + + ...or by a skin index: + + sspine_skin skin = sspine_skin_by_index(skeleton, 0); + assert(sspine_skin_valid(skin)); + + ...you can iterate over all skins of a skeleton and query some information about the skin: + + const int num_skins = sspine_num_skins(skeleton); + for (int skin_index = 0; skin_index < num_skins; skin_index++) { + sspine_skin skin = sspine_skin_by_index(skin_index); + sspine_skin_info info = sspine_get_skin_info(skin); + if (info.valid) { + ... + } + } + + Currently, the only useful query item is the skin name though. + + To make a skin visible on an instance, just call: + + sspine_set_skin(instance, skin); + + ...this will first deactivate the previous skin before setting a new skin. + + A more powerful way to configure the skin visibility is through 'skin sets'. Skin + sets are simply flat collections of skins which should be made visible at once. + A new skin set is created like this: + + sspine_skinset skinset = sspine_make_skinset(&(sspine_skinset_desc){ + .skeleton = skeleton, + .skins = { + sspine_skin_by_name(skeleton, "blue-jacket"), + sspine_skin_by_name(skeleton, "green-pants"), + sspine_skin_by_name(skeleton, "blonde-hair"), + ... + } + }); + assert(sspine_skinset_valid(skinset)) + + ...then simply set the skinset on an instance to reconfigure the appearance + of the instance: + + sspine_set_skinset(instance, skinset); + + The functions sspine_set_skinset() and sspine_set_skin() will cancel each other. + Calling sspine_set_skinset() deactivates the effect of sspine_set_skin() and + vice versa. + + + ERROR REPORTING AND LOGGING + =========================== + To get any logging information at all you need to provide a logging callback in the setup call, + the easiest way is to use sokol_log.h: + + #include "sokol_log.h" + + sspine_setup(&(sspine_desc){ .logger.func = slog_func }); + + To override logging with your own callback, first write a logging function like this: + + void my_log(const char* tag, // e.g. 'sspine' + uint32_t log_level, // 0=panic, 1=error, 2=warn, 3=info + uint32_t log_item_id, // SSPINE_LOGITEM_* + const char* message_or_null, // a message string, may be nullptr in release mode + uint32_t line_nr, // line number in sokol_spine.h + const char* filename_or_null, // source filename, may be nullptr in release mode + void* user_data) + { + ... + } + + ...and then setup sokol-spine like this: + + sspine_setup(&(sspine_desc){ + .logger = { + .func = my_log, + .user_data = my_user_data, + } + }); + + The provided logging function must be reentrant (e.g. be callable from + different threads). + + If you don't want to provide your own custom logger it is highly recommended to use + the standard logger in sokol_log.h instead, otherwise you won't see any warnings or + errors. + + + MEMORY ALLOCATION OVERRIDE + ========================== + You can override the memory allocation functions at initialization time + like this: + + void* my_alloc(size_t size, void* user_data) { + return malloc(size); + } + + void my_free(void* ptr, void* user_data) { + free(ptr); + } + + ... + sspine_setup(&(sspine_desc){ + // ... + .allocator = { + .alloc = my_alloc, + .free = my_free, + .user_data = ...; + } + }); + ... + + If no overrides are provided, malloc and free will be used. + + This only affects memory allocation calls done by sokol_gfx.h + itself though, not any allocations in OS libraries. + + + LICENSE + ======= + zlib/libpng license + + Copyright (c) 2022 Andre Weissflog + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the + use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#define SOKOL_SPINE_INCLUDED (1) +#include +#include +#include // size_t + +#if !defined(SOKOL_GFX_INCLUDED) +#error "Please include sokol_gfx.h before sokol_spine.h" +#endif + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_SPINE_API_DECL) +#define SOKOL_SPINE_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_SPINE_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_SPINE_IMPL) +#define SOKOL_SPINE_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_SPINE_API_DECL __declspec(dllimport) +#else +#define SOKOL_SPINE_API_DECL extern +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + SSPINE_INVALID_ID = 0, + SSPINE_MAX_SKINSET_SKINS = 32, + SSPINE_MAX_STRING_SIZE = 61, // see sspine_string struct +}; + +typedef struct sspine_context { uint32_t id; } sspine_context; +typedef struct sspine_atlas { uint32_t id; } sspine_atlas; +typedef struct sspine_skeleton { uint32_t id; } sspine_skeleton; +typedef struct sspine_instance { uint32_t id; } sspine_instance; +typedef struct sspine_skinset { uint32_t id; } sspine_skinset; + +typedef struct sspine_image { uint32_t atlas_id; int index; } sspine_image; +typedef struct sspine_atlas_page { uint32_t atlas_id; int index; } sspine_atlas_page; +typedef struct sspine_anim { uint32_t skeleton_id; int index; } sspine_anim; +typedef struct sspine_bone { uint32_t skeleton_id; int index; } sspine_bone; +typedef struct sspine_slot { uint32_t skeleton_id; int index; } sspine_slot; +typedef struct sspine_event { uint32_t skeleton_id; int index; } sspine_event; +typedef struct sspine_iktarget { uint32_t skeleton_id; int index; } sspine_iktarget; +typedef struct sspine_skin { uint32_t skeleton_id; int index; } sspine_skin; + +typedef struct sspine_range { const void* ptr; size_t size; } sspine_range; +typedef struct sspine_vec2 { float x, y; } sspine_vec2; +typedef struct sspine_mat4 { float m[16]; } sspine_mat4; +typedef sg_color sspine_color; + +typedef struct sspine_string { + bool valid; + bool truncated; + uint8_t len; + char cstr[SSPINE_MAX_STRING_SIZE]; +} sspine_string; + +typedef enum sspine_resource_state { + SSPINE_RESOURCESTATE_INITIAL, + SSPINE_RESOURCESTATE_ALLOC, + SSPINE_RESOURCESTATE_VALID, + SSPINE_RESOURCESTATE_FAILED, + SSPINE_RESOURCESTATE_INVALID, + _SSPINE_RESOURCESTATE_FORCE_U32 = 0x7FFFFFFF +} sspine_resource_state; + +// log item codes via x-macro magic +#define _SSPINE_LOG_ITEMS \ + _SSPINE_LOGITEM_XMACRO(OK, "Ok")\ + _SSPINE_LOGITEM_XMACRO(MALLOC_FAILED, "memory allocation failed")\ + _SSPINE_LOGITEM_XMACRO(CONTEXT_POOL_EXHAUSTED, "context pool exhausted (adjust via sspine_desc.context_pool_size)")\ + _SSPINE_LOGITEM_XMACRO(ATLAS_POOL_EXHAUSTED, "atlas pool exhausted (adjust via sspine_desc.atlas_pool_size)")\ + _SSPINE_LOGITEM_XMACRO(SKELETON_POOL_EXHAUSTED, "skeleton pool exhausted (adjust via sspine_desc.skeleton_pool_size)")\ + _SSPINE_LOGITEM_XMACRO(SKINSET_POOL_EXHAUSTED, "skinset pool exhausted (adjust via sspine_desc.skinset_pool_size)")\ + _SSPINE_LOGITEM_XMACRO(INSTANCE_POOL_EXHAUSTED, "instance pool exhausted (adjust via sspine_desc.instance_pool_size)")\ + _SSPINE_LOGITEM_XMACRO(CANNOT_DESTROY_DEFAULT_CONTEXT, "cannot destroy default context")\ + _SSPINE_LOGITEM_XMACRO(ATLAS_DESC_NO_DATA, "no data provided in sspine_atlas_desc.data")\ + _SSPINE_LOGITEM_XMACRO(SPINE_ATLAS_CREATION_FAILED, "spAtlas_create() failed")\ + _SSPINE_LOGITEM_XMACRO(SG_ALLOC_IMAGE_FAILED, "sg_alloc_image() failed")\ + _SSPINE_LOGITEM_XMACRO(SKELETON_DESC_NO_DATA, "no data provided in sspine_skeleton_desc.json_data or .binary_data")\ + _SSPINE_LOGITEM_XMACRO(SKELETON_DESC_NO_ATLAS, "no atlas object provided in sspine_skeleton_desc.atlas")\ + _SSPINE_LOGITEM_XMACRO(SKELETON_ATLAS_NOT_VALID, "sspine_skeleton_desc.atlas is not in valid state")\ + _SSPINE_LOGITEM_XMACRO(CREATE_SKELETON_DATA_FROM_JSON_FAILED, "spSkeletonJson_readSkeletonData() failed")\ + _SSPINE_LOGITEM_XMACRO(CREATE_SKELETON_DATA_FROM_BINARY_FAILED, "spSkeletonBinary_readSkeletonData() failed")\ + _SSPINE_LOGITEM_XMACRO(SKINSET_DESC_NO_SKELETON, "no skeleton object provided in sspine_skinset_desc.skeleton")\ + _SSPINE_LOGITEM_XMACRO(SKINSET_SKELETON_NOT_VALID, "sspine_skinset_desc.skeleton is not in valid state")\ + _SSPINE_LOGITEM_XMACRO(SKINSET_INVALID_SKIN_HANDLE, "invalid skin handle in sspine_skinset_desc.skins[]")\ + _SSPINE_LOGITEM_XMACRO(INSTANCE_DESC_NO_SKELETON, "no skeleton object provided in sspine_instance_desc.skeleton")\ + _SSPINE_LOGITEM_XMACRO(INSTANCE_SKELETON_NOT_VALID, "sspine_instance_desc.skeleton is not in valid state")\ + _SSPINE_LOGITEM_XMACRO(INSTANCE_ATLAS_NOT_VALID, "skeleton's atlas object no longer valid via sspine_instance_desc.skeleton")\ + _SSPINE_LOGITEM_XMACRO(SPINE_SKELETON_CREATION_FAILED, "spSkeleton_create() failed")\ + _SSPINE_LOGITEM_XMACRO(SPINE_ANIMATIONSTATE_CREATION_FAILED, "spAnimationState_create() failed")\ + _SSPINE_LOGITEM_XMACRO(SPINE_SKELETONCLIPPING_CREATION_FAILED, "spSkeletonClipping_create() failed")\ + _SSPINE_LOGITEM_XMACRO(COMMAND_BUFFER_FULL, "command buffer full (adjust via sspine_desc.max_commands)")\ + _SSPINE_LOGITEM_XMACRO(VERTEX_BUFFER_FULL, "vertex buffer (adjust via sspine_desc.max_vertices)")\ + _SSPINE_LOGITEM_XMACRO(INDEX_BUFFER_FULL, "index buffer full (adjust via sspine_desc.max_vertices)")\ + _SSPINE_LOGITEM_XMACRO(STRING_TRUNCATED, "a string has been truncated")\ + _SSPINE_LOGITEM_XMACRO(ADD_COMMIT_LISTENER_FAILED, "sg_add_commit_listener() failed")\ + +#define _SSPINE_LOGITEM_XMACRO(item,msg) SSPINE_LOGITEM_##item, +typedef enum sspine_log_item { + _SSPINE_LOG_ITEMS +} sspine_log_item; +#undef _SSPINE_LOGITEM_XMACRO + +typedef struct sspine_layer_transform { + sspine_vec2 size; + sspine_vec2 origin; +} sspine_layer_transform; + +typedef struct sspine_bone_transform { + sspine_vec2 position; + float rotation; // in degrees + sspine_vec2 scale; + sspine_vec2 shear; // in degrees +} sspine_bone_transform; + +typedef struct sspine_context_desc { + int max_vertices; + int max_commands; + sg_pixel_format color_format; + sg_pixel_format depth_format; + int sample_count; + sg_color_mask color_write_mask; +} sspine_context_desc; + +typedef struct sspine_context_info { + int num_vertices; // current number of vertices + int num_indices; // current number of indices + int num_commands; // current number of commands +} sspine_context_info; + +typedef struct sspine_image_info { + bool valid; + sg_image sgimage; + sg_filter min_filter; + sg_filter mag_filter; + sg_wrap wrap_u; + sg_wrap wrap_v; + int width; + int height; + bool premul_alpha; + sspine_string filename; +} sspine_image_info; + +typedef struct sspine_atlas_overrides { + sg_filter min_filter; + sg_filter mag_filter; + sg_wrap wrap_u; + sg_wrap wrap_v; + bool premul_alpha_enabled; + bool premul_alpha_disabled; +} sspine_atlas_overrides; + +typedef struct sspine_atlas_desc { + sspine_range data; + sspine_atlas_overrides override; +} sspine_atlas_desc; + +typedef struct sspine_atlas_page_info { + bool valid; + sspine_atlas atlas; + sspine_image_info image; + sspine_atlas_overrides overrides; +} sspine_atlas_page_info; + +typedef struct sspine_skeleton_desc { + sspine_atlas atlas; + float prescale; + float anim_default_mix; + const char* json_data; + sspine_range binary_data; +} sspine_skeleton_desc; + +typedef struct sspine_skinset_desc { + sspine_skeleton skeleton; + sspine_skin skins[SSPINE_MAX_SKINSET_SKINS]; +} sspine_skinset_desc; + +typedef struct sspine_anim_info { + bool valid; + int index; + float duration; + sspine_string name; +} sspine_anim_info; + +typedef struct sspine_bone_info { + bool valid; + int index; + sspine_bone parent_bone; + float length; + sspine_bone_transform pose; + sspine_color color; + sspine_string name; +} sspine_bone_info; + +typedef struct sspine_slot_info { + bool valid; + int index; + sspine_bone bone; + sspine_color color; + sspine_string attachment_name; + sspine_string name; +} sspine_slot_info; + +typedef struct sspine_iktarget_info { + bool valid; + int index; + sspine_bone target_bone; + sspine_string name; +} sspine_iktarget_info; + +typedef struct sspine_skin_info { + bool valid; + int index; + sspine_string name; +} sspine_skin_info; + +typedef struct sspine_event_info { + bool valid; + int index; + int int_value; + float float_value; + float volume; + float balance; + sspine_string name; + sspine_string string_value; + sspine_string audio_path; +} sspine_event_info; + +typedef struct sspine_triggered_event_info { + bool valid; + sspine_event event; + float time; + int int_value; + float float_value; + float volume; + float balance; + sspine_string string_value; +} sspine_triggered_event_info; + +typedef struct sspine_instance_desc { + sspine_skeleton skeleton; +} sspine_instance_desc; + +typedef struct sspine_allocator { + void* (*alloc)(size_t size, void* user_data); + void (*free)(void* ptr, void* user_data); + void* user_data; +} sspine_allocator; + +typedef struct sspine_logger { + void (*func)( + const char* tag, // always "sspine" + uint32_t log_level, // 0=panic, 1=error, 2=warning, 3=info + uint32_t log_item_id, // SSPINE_LOGITEM_* + const char* message_or_null, // a message string, may be nullptr in release mode + uint32_t line_nr, // line number in sokol_spine.h + const char* filename_or_null, // the source filename, may be nullptr in release mode + void* user_data); + void* user_data; +} sspine_logger; + +typedef struct sspine_desc { + int max_vertices; + int max_commands; + int context_pool_size; + int atlas_pool_size; + int skeleton_pool_size; + int skinset_pool_size; + int instance_pool_size; + sg_pixel_format color_format; + sg_pixel_format depth_format; + int sample_count; + sg_color_mask color_write_mask; + sspine_allocator allocator; // optional allocation override functions (default: malloc/free) + sspine_logger logger; // optional logging function (default: NO LOGGING!) +} sspine_desc; + +// setup/shutdown +SOKOL_SPINE_API_DECL void sspine_setup(const sspine_desc* desc); +SOKOL_SPINE_API_DECL void sspine_shutdown(void); + +// context functions +SOKOL_SPINE_API_DECL sspine_context sspine_make_context(const sspine_context_desc* desc); +SOKOL_SPINE_API_DECL void sspine_destroy_context(sspine_context ctx); +SOKOL_SPINE_API_DECL void sspine_set_context(sspine_context ctx); +SOKOL_SPINE_API_DECL sspine_context sspine_get_context(void); +SOKOL_SPINE_API_DECL sspine_context sspine_default_context(void); +SOKOL_SPINE_API_DECL sspine_context_info sspine_get_context_info(sspine_context ctx); + +// create and destroy spine objects +SOKOL_SPINE_API_DECL sspine_atlas sspine_make_atlas(const sspine_atlas_desc* desc); +SOKOL_SPINE_API_DECL sspine_skeleton sspine_make_skeleton(const sspine_skeleton_desc* desc); +SOKOL_SPINE_API_DECL sspine_skinset sspine_make_skinset(const sspine_skinset_desc* desc); +SOKOL_SPINE_API_DECL sspine_instance sspine_make_instance(const sspine_instance_desc* desc); +SOKOL_SPINE_API_DECL void sspine_destroy_atlas(sspine_atlas atlas); +SOKOL_SPINE_API_DECL void sspine_destroy_skeleton(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL void sspine_destroy_skinset(sspine_skinset skinset); +SOKOL_SPINE_API_DECL void sspine_destroy_instance(sspine_instance instance); + +// configure instance appearance via skinsets +SOKOL_SPINE_API_DECL void sspine_set_skinset(sspine_instance instance, sspine_skinset skinset); + +// update instance animations before drawing +SOKOL_SPINE_API_DECL void sspine_update_instance(sspine_instance instance, float delta_time); + +// iterate over triggered events after updating an instance +SOKOL_SPINE_API_DECL int sspine_num_triggered_events(sspine_instance instance); +SOKOL_SPINE_API_DECL sspine_triggered_event_info sspine_get_triggered_event_info(sspine_instance instance, int triggered_event_index); + +// draw instance into current or explicit context +SOKOL_SPINE_API_DECL void sspine_draw_instance_in_layer(sspine_instance instance, int layer); +SOKOL_SPINE_API_DECL void sspine_context_draw_instance_in_layer(sspine_context ctx, sspine_instance instance, int layer); + +// helper function to convert sspine_layer_transform into projection matrix +SOKOL_SPINE_API_DECL sspine_mat4 sspine_layer_transform_to_mat4(const sspine_layer_transform* tform); + +// draw a layer in current context or explicit context (call once per context and frame in sokol-gfx pass) +SOKOL_SPINE_API_DECL void sspine_draw_layer(int layer, const sspine_layer_transform* tform); +SOKOL_SPINE_API_DECL void sspine_context_draw_layer(sspine_context ctx, int layer, const sspine_layer_transform* tform); + +// get current resource state (INITIAL, ALLOC, VALID, FAILED, INVALID) +SOKOL_SPINE_API_DECL sspine_resource_state sspine_get_context_resource_state(sspine_context context); +SOKOL_SPINE_API_DECL sspine_resource_state sspine_get_atlas_resource_state(sspine_atlas atlas); +SOKOL_SPINE_API_DECL sspine_resource_state sspine_get_skeleton_resource_state(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL sspine_resource_state sspine_get_skinset_resource_state(sspine_skinset skinset); +SOKOL_SPINE_API_DECL sspine_resource_state sspine_get_instance_resource_state(sspine_instance instance); + +// shortcut for sspine_get_*_state() == SSPINE_RESOURCESTATE_VALID +SOKOL_SPINE_API_DECL bool sspine_context_valid(sspine_context context); +SOKOL_SPINE_API_DECL bool sspine_atlas_valid(sspine_atlas atlas); +SOKOL_SPINE_API_DECL bool sspine_skeleton_valid(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL bool sspine_instance_valid(sspine_instance instance); +SOKOL_SPINE_API_DECL bool sspine_skinset_valid(sspine_skinset skinset); + +// get dependency objects +SOKOL_SPINE_API_DECL sspine_atlas sspine_get_skeleton_atlas(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL sspine_skeleton sspine_get_instance_skeleton(sspine_instance instance); + +// atlas images +SOKOL_SPINE_API_DECL int sspine_num_images(sspine_atlas atlas); +SOKOL_SPINE_API_DECL sspine_image sspine_image_by_index(sspine_atlas atlas, int index); +SOKOL_SPINE_API_DECL bool sspine_image_valid(sspine_image image); +SOKOL_SPINE_API_DECL bool sspine_image_equal(sspine_image first, sspine_image second); +SOKOL_SPINE_API_DECL sspine_image_info sspine_get_image_info(sspine_image image); + +// atlas page functions +SOKOL_SPINE_API_DECL int sspine_num_atlas_pages(sspine_atlas atlas); +SOKOL_SPINE_API_DECL sspine_atlas_page sspine_atlas_page_by_index(sspine_atlas atlas, int index); +SOKOL_SPINE_API_DECL bool sspine_atlas_page_valid(sspine_atlas_page page); +SOKOL_SPINE_API_DECL bool sspine_atlas_page_equal(sspine_atlas_page first, sspine_atlas_page second); +SOKOL_SPINE_API_DECL sspine_atlas_page_info sspine_get_atlas_page_info(sspine_atlas_page page); + +// instance transform functions +SOKOL_SPINE_API_DECL void sspine_set_position(sspine_instance instance, sspine_vec2 position); +SOKOL_SPINE_API_DECL void sspine_set_scale(sspine_instance instance, sspine_vec2 scale); +SOKOL_SPINE_API_DECL void sspine_set_color(sspine_instance instance, sspine_color color); +SOKOL_SPINE_API_DECL sspine_vec2 sspine_get_position(sspine_instance instance); +SOKOL_SPINE_API_DECL sspine_vec2 sspine_get_scale(sspine_instance instance); +SOKOL_SPINE_API_DECL sspine_color sspine_get_color(sspine_instance instance); + +// instance animation functions +SOKOL_SPINE_API_DECL int sspine_num_anims(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL sspine_anim sspine_anim_by_name(sspine_skeleton skeleton, const char* name); +SOKOL_SPINE_API_DECL sspine_anim sspine_anim_by_index(sspine_skeleton skeleton, int index); +SOKOL_SPINE_API_DECL bool sspine_anim_valid(sspine_anim anim); +SOKOL_SPINE_API_DECL bool sspine_anim_equal(sspine_anim first, sspine_anim second); +SOKOL_SPINE_API_DECL sspine_anim_info sspine_get_anim_info(sspine_anim anim); +SOKOL_SPINE_API_DECL void sspine_clear_animation_tracks(sspine_instance instance); +SOKOL_SPINE_API_DECL void sspine_clear_animation_track(sspine_instance instance, int track_index); +SOKOL_SPINE_API_DECL void sspine_set_animation(sspine_instance instance, sspine_anim anim, int track_index, bool loop); +SOKOL_SPINE_API_DECL void sspine_add_animation(sspine_instance instance, sspine_anim anim, int track_index, bool loop, float delay); +SOKOL_SPINE_API_DECL void sspine_set_empty_animation(sspine_instance instance, int track_index, float mix_duration); +SOKOL_SPINE_API_DECL void sspine_add_empty_animation(sspine_instance instance, int track_index, float mix_duration, float delay); + +// bone functions +SOKOL_SPINE_API_DECL int sspine_num_bones(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL sspine_bone sspine_bone_by_name(sspine_skeleton skeleton, const char* name); +SOKOL_SPINE_API_DECL sspine_bone sspine_bone_by_index(sspine_skeleton skeleton, int index); +SOKOL_SPINE_API_DECL bool sspine_bone_valid(sspine_bone bone); +SOKOL_SPINE_API_DECL bool sspine_bone_equal(sspine_bone first, sspine_bone second); +SOKOL_SPINE_API_DECL sspine_bone_info sspine_get_bone_info(sspine_bone bone); +SOKOL_SPINE_API_DECL void sspine_set_bone_transform(sspine_instance instance, sspine_bone bone, const sspine_bone_transform* transform); +SOKOL_SPINE_API_DECL void sspine_set_bone_position(sspine_instance instance, sspine_bone bone, sspine_vec2 position); +SOKOL_SPINE_API_DECL void sspine_set_bone_rotation(sspine_instance instance, sspine_bone bone, float rotation); +SOKOL_SPINE_API_DECL void sspine_set_bone_scale(sspine_instance instance, sspine_bone bone, sspine_vec2 scale); +SOKOL_SPINE_API_DECL void sspine_set_bone_shear(sspine_instance instance, sspine_bone bone, sspine_vec2 shear); +SOKOL_SPINE_API_DECL sspine_bone_transform sspine_get_bone_transform(sspine_instance instance, sspine_bone bone); +SOKOL_SPINE_API_DECL sspine_vec2 sspine_get_bone_position(sspine_instance instance, sspine_bone bone); +SOKOL_SPINE_API_DECL float sspine_get_bone_rotation(sspine_instance instance, sspine_bone bone); +SOKOL_SPINE_API_DECL sspine_vec2 sspine_get_bone_scale(sspine_instance instance, sspine_bone bone); +SOKOL_SPINE_API_DECL sspine_vec2 sspine_get_bone_shear(sspine_instance instance, sspine_bone bone); +SOKOL_SPINE_API_DECL sspine_vec2 sspine_get_bone_world_position(sspine_instance instance, sspine_bone bone); +SOKOL_SPINE_API_DECL sspine_vec2 sspine_bone_local_to_world(sspine_instance instance, sspine_bone bone, sspine_vec2 local_pos); +SOKOL_SPINE_API_DECL sspine_vec2 sspine_bone_world_to_local(sspine_instance instance, sspine_bone bone, sspine_vec2 world_pos); + +// slot functions +SOKOL_SPINE_API_DECL int sspine_num_slots(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL sspine_slot sspine_slot_by_name(sspine_skeleton skeleton, const char* name); +SOKOL_SPINE_API_DECL sspine_slot sspine_slot_by_index(sspine_skeleton skeleton, int index); +SOKOL_SPINE_API_DECL bool sspine_slot_valid(sspine_slot slot); +SOKOL_SPINE_API_DECL bool sspine_slot_equal(sspine_slot first, sspine_slot second); +SOKOL_SPINE_API_DECL sspine_slot_info sspine_get_slot_info(sspine_slot slot); +SOKOL_SPINE_API_DECL void sspine_set_slot_color(sspine_instance instance, sspine_slot slot, sspine_color color); +SOKOL_SPINE_API_DECL sspine_color sspine_get_slot_color(sspine_instance instance, sspine_slot slot); + +// event functions +SOKOL_SPINE_API_DECL int sspine_num_events(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL sspine_event sspine_event_by_name(sspine_skeleton skeleton, const char* name); +SOKOL_SPINE_API_DECL sspine_event sspine_event_by_index(sspine_skeleton skeleton, int index); +SOKOL_SPINE_API_DECL bool sspine_event_valid(sspine_event event); +SOKOL_SPINE_API_DECL bool sspine_event_equal(sspine_event first, sspine_event second); +SOKOL_SPINE_API_DECL sspine_event_info sspine_get_event_info(sspine_event event); + +// ik target functions +SOKOL_SPINE_API_DECL int sspine_num_iktargets(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL sspine_iktarget sspine_iktarget_by_name(sspine_skeleton skeleton, const char* name); +SOKOL_SPINE_API_DECL sspine_iktarget sspine_iktarget_by_index(sspine_skeleton skeleton, int index); +SOKOL_SPINE_API_DECL bool sspine_iktarget_valid(sspine_iktarget iktarget); +SOKOL_SPINE_API_DECL bool sspine_iktarget_equal(sspine_iktarget first, sspine_iktarget second); +SOKOL_SPINE_API_DECL sspine_iktarget_info sspine_get_iktarget_info(sspine_iktarget iktarget); +SOKOL_SPINE_API_DECL void sspine_set_iktarget_world_pos(sspine_instance instance, sspine_iktarget iktarget, sspine_vec2 world_pos); + +// skin functions +SOKOL_SPINE_API_DECL int sspine_num_skins(sspine_skeleton skeleton); +SOKOL_SPINE_API_DECL sspine_skin sspine_skin_by_name(sspine_skeleton skeleton, const char* name); +SOKOL_SPINE_API_DECL sspine_skin sspine_skin_by_index(sspine_skeleton skeleton, int index); +SOKOL_SPINE_API_DECL bool sspine_skin_valid(sspine_skin skin); +SOKOL_SPINE_API_DECL bool sspine_skin_equal(sspine_skin first, sspine_skin second); +SOKOL_SPINE_API_DECL sspine_skin_info sspine_get_skin_info(sspine_skin skin); +SOKOL_SPINE_API_DECL void sspine_set_skin(sspine_instance instance, sspine_skin skin); + +#ifdef __cplusplus +} // extern "C" +#endif + +// ██ ███ ███ ██████ ██ ███████ ███ ███ ███████ ███ ██ ████████ █████ ████████ ██ ██████ ███ ██ +// ██ ████ ████ ██ ██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ +// ██ ██ ████ ██ ██████ ██ █████ ██ ████ ██ █████ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ████ ██ ██ ██ ██ ██ ██████ ██ ████ +// +// >>implementation +#ifdef SOKOL_SPINE_IMPL +#define SOKOL_SPINE_IMPL_INCLUDED (1) + +#if !defined(SPINE_SPINE_H_) +#error "Please include spine/spine.h before the sokol_spine.h implementation" +#endif + +#ifndef SOKOL_API_IMPL + #define SOKOL_API_IMPL +#endif +#ifndef SOKOL_DEBUG + #ifndef NDEBUG + #define SOKOL_DEBUG (1) + #endif +#endif +#ifndef SOKOL_ASSERT + #include + #define SOKOL_ASSERT(c) assert(c) +#endif +#ifndef SOKOL_UNREACHABLE + #define SOKOL_UNREACHABLE SOKOL_ASSERT(false) +#endif +#ifndef SOKOL_UNUSED + #define SOKOL_UNUSED(x) (void)(x) +#endif + +#include // malloc/free +#include // memset, strcmp + +// ███████╗██╗ ██╗ █████╗ ██████╗ ███████╗██████╗ ███████╗ +// ██╔════╝██║ ██║██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔════╝ +// ███████╗███████║███████║██║ ██║█████╗ ██████╔╝███████╗ +// ╚════██║██╔══██║██╔══██║██║ ██║██╔══╝ ██╔══██╗╚════██║ +// ███████║██║ ██║██║ ██║██████╔╝███████╗██║ ██║███████║ +// ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚══════╝╚═╝ ╚═╝╚══════╝ +// +// >>shaders +/* + Embedded source compiled with: + + sokol-shdc -i sspine.glsl -o sspine.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + + @vs vs + uniform vs_params { + mat4 mvp; + }; + in vec2 position; + in vec2 texcoord0; + in vec4 color0; + out vec2 uv; + out vec4 color; + void main() { + gl_Position = mvp * vec4(position, 0.0, 1.0); + uv = texcoord0; + color = color0; + } + @end + + @fs fs + uniform sampler2D tex; + uniform fs_params { + float pma; + }; + in vec2 uv; + in vec4 color; + out vec4 frag_color; + void main() { + vec4 c0 = texture(tex, uv) * color; + vec4 c1 = vec4(c0.rgb * c0.a, c0.a) * color; + frag_color = mix(c0, c1, pma); + } + @end + + @program sspine vs fs +*/ +#if defined(SOKOL_GLCORE33) +static const char _sspine_vs_source_glsl330[352] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e, + 0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f, + 0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20, + 0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f, + 0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70, + 0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72, + 0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _sspine_fs_source_glsl330[300] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d, + 0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a, + 0x0a,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69,0x6e,0x20, + 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63, + 0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e, + 0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x32, + 0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x34,0x20,0x3d,0x20,0x5f,0x32, + 0x35,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x32,0x35,0x2c,0x20,0x76, + 0x65,0x63,0x34,0x28,0x5f,0x32,0x35,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x5f,0x33, + 0x34,0x2c,0x20,0x5f,0x33,0x34,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2c, + 0x20,0x76,0x65,0x63,0x34,0x28,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x30,0x5d,0x2e,0x78,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_GLES3) +static const char _sspine_vs_source_glsl300es[355] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c, + 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20, + 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f, + 0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61, + 0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c, + 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f, + 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63, + 0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c, + 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20, + 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x00, +}; +static const char _sspine_fs_source_glsl300es[391] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63, + 0x34,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a, + 0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x69,0x6e, + 0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69, + 0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28, + 0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65, + 0x63,0x34,0x20,0x5f,0x32,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65, + 0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x5f,0x33,0x34,0x20,0x3d,0x20,0x5f,0x32,0x35,0x2e,0x77,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d, + 0x20,0x6d,0x69,0x78,0x28,0x5f,0x32,0x35,0x2c,0x20,0x76,0x65,0x63,0x34,0x28,0x5f, + 0x32,0x35,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x5f,0x33,0x34,0x2c,0x20,0x5f,0x33, + 0x34,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x76,0x65,0x63,0x34, + 0x28,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x29, + 0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +#elif defined(SOKOL_D3D11) +static const uint8_t _sspine_vs_bytecode_hlsl4[844] = { + 0x44,0x58,0x42,0x43,0xb2,0xdb,0x57,0x6f,0x29,0xa5,0x26,0x49,0xa3,0x0e,0xb4,0x9e, + 0x0f,0x0d,0x7f,0xcd,0x01,0x00,0x00,0x00,0x4c,0x03,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0xf4,0x00,0x00,0x00,0x58,0x01,0x00,0x00,0xc8,0x01,0x00,0x00, + 0xd0,0x02,0x00,0x00,0x52,0x44,0x45,0x46,0xb8,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xfe,0xff, + 0x10,0x81,0x00,0x00,0x90,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x00,0xab,0xab,0x3c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x60,0x00,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x80,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x5f,0x32,0x31,0x5f,0x6d,0x76,0x70,0x00,0x02,0x00,0x03,0x00, + 0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4d,0x69,0x63,0x72, + 0x6f,0x73,0x6f,0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53, + 0x68,0x61,0x64,0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31, + 0x30,0x2e,0x31,0x00,0x49,0x53,0x47,0x4e,0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x50,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x03,0x03,0x00,0x00,0x50,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43, + 0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab,0x4f,0x53,0x47,0x4e,0x68,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0c,0x00,0x00, + 0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, + 0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x00,0xab,0xab,0xab,0x53,0x48,0x44,0x52,0x00,0x01,0x00,0x00, + 0x40,0x00,0x01,0x00,0x40,0x00,0x00,0x00,0x59,0x00,0x00,0x04,0x46,0x8e,0x20,0x00, + 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,0x32,0x10,0x10,0x00, + 0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,0x32,0x10,0x10,0x00,0x01,0x00,0x00,0x00, + 0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00,0x02,0x00,0x00,0x00,0x65,0x00,0x00,0x03, + 0x32,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00, + 0x01,0x00,0x00,0x00,0x67,0x00,0x00,0x04,0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x68,0x00,0x00,0x02,0x01,0x00,0x00,0x00,0x36,0x00,0x00,0x05, + 0x32,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x01,0x00,0x00,0x00, + 0x36,0x00,0x00,0x05,0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x1e,0x10,0x00, + 0x02,0x00,0x00,0x00,0x38,0x00,0x00,0x08,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00, + 0x56,0x15,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00, + 0x06,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08, + 0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x3e,0x00,0x00,0x01, + 0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sspine_fs_bytecode_hlsl4[876] = { + 0x44,0x58,0x42,0x43,0xd8,0xf3,0x35,0x5e,0xf6,0xd6,0x61,0x80,0x71,0x85,0x56,0x46, + 0x08,0x09,0x74,0xcd,0x01,0x00,0x00,0x00,0x6c,0x03,0x00,0x00,0x05,0x00,0x00,0x00, + 0x34,0x00,0x00,0x00,0x44,0x01,0x00,0x00,0x90,0x01,0x00,0x00,0xc4,0x01,0x00,0x00, + 0xf0,0x02,0x00,0x00,0x52,0x44,0x45,0x46,0x08,0x01,0x00,0x00,0x01,0x00,0x00,0x00, + 0x98,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xff,0xff, + 0x10,0x81,0x00,0x00,0xe0,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x89,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x8d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x00,0x74,0x65,0x78,0x00,0x66,0x73,0x5f,0x70,0x61,0x72,0x61, + 0x6d,0x73,0x00,0xab,0x8d,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xb0,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xd0,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x5f,0x35,0x30,0x5f,0x70,0x6d,0x61,0x00,0x00,0x00,0x03,0x00, + 0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4d,0x69,0x63,0x72, + 0x6f,0x73,0x6f,0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53, + 0x68,0x61,0x64,0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31, + 0x30,0x2e,0x31,0x00,0x49,0x53,0x47,0x4e,0x44,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x38,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab, + 0x4f,0x53,0x47,0x4e,0x2c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65, + 0x74,0x00,0xab,0xab,0x53,0x48,0x44,0x52,0x24,0x01,0x00,0x00,0x40,0x00,0x00,0x00, + 0x49,0x00,0x00,0x00,0x59,0x00,0x00,0x04,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x5a,0x00,0x00,0x03,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x58,0x18,0x00,0x04,0x00,0x70,0x10,0x00,0x00,0x00,0x00,0x00,0x55,0x55,0x00,0x00, + 0x62,0x10,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x00,0x03, + 0xf2,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00, + 0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x02,0x02,0x00,0x00,0x00,0x45,0x00,0x00,0x09, + 0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x7e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00, + 0x38,0x00,0x00,0x07,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00, + 0x00,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x07, + 0x72,0x00,0x10,0x00,0x01,0x00,0x00,0x00,0xf6,0x0f,0x10,0x00,0x00,0x00,0x00,0x00, + 0x46,0x02,0x10,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x05,0x82,0x00,0x10,0x00, + 0x01,0x00,0x00,0x00,0x3a,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x0a, + 0xf2,0x00,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x01,0x00,0x00,0x00, + 0x46,0x1e,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x0e,0x10,0x80,0x41,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x0a,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00, + 0x06,0x80,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00, + 0x01,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x01, + 0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +#elif defined(SOKOL_METAL) +static const uint8_t _sspine_vs_bytecode_metal_macos[3068] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xfc,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0xf0,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0x00,0x1c,0x82,0xf4,0xbb,0x79,0xa7, + 0x30,0x7f,0x4a,0xbc,0xb6,0x93,0x11,0x29,0xf6,0x24,0x44,0x87,0xfa,0x98,0x7e,0xd3, + 0x73,0xca,0x18,0xc6,0xe1,0x22,0x50,0x45,0x09,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x37,0x00,0x00,0x00,0x56,0x41,0x54, + 0x54,0x22,0x00,0x03,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x80, + 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x00,0x02,0x80,0x56,0x41,0x54,0x59,0x05,0x00,0x03,0x00,0x04,0x04,0x06, + 0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b, + 0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0xdc,0x0a,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0xb4,0x02,0x00,0x00,0x0b,0x82,0x20,0x00, + 0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49, + 0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62, + 0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49, + 0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72, + 0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00, + 0x51,0x18,0x00,0x00,0x81,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8,0xff,0xff,0xff,0xff, + 0x01,0x90,0x80,0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87,0x71,0xa0,0x07,0x76, + 0xc8,0x87,0x36,0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72,0x20,0x87,0x36,0x20, + 0x87,0x74,0xb0,0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88,0x07,0x79,0xa0,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0xc0,0x1c,0xc2,0x81, + 0x1d,0xe6,0xa1,0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c, + 0xda,0x80,0x1e,0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c,0xd8,0x81,0x1d,0xe6, + 0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87,0x72,0x98,0x87,0x79, + 0x68,0x03,0x78,0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72,0x68,0x03,0x73,0x80, + 0x87,0x76,0x08,0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xdc, + 0xe1,0x1d,0xda,0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda,0x00,0x1e,0xde,0x21, + 0x1d,0xdc,0x81,0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21,0x1d,0xda,0x01,0xa0, + 0x07,0x79,0xa8,0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30,0x07,0x79,0x08,0x87, + 0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87,0x72,0x90,0x87,0x36, + 0x28,0x07,0x76,0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77,0x68,0x03,0x76,0x28, + 0x87,0x70,0x30,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70,0x07,0x73,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1,0x1d,0xe0,0xa1,0x0d, + 0xe8,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87, + 0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87,0x79,0x68,0x03,0x73, + 0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d,0xca,0x81,0x1c,0xda, + 0x40,0x1f,0xca,0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21, + 0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,0x77,0x68, + 0x03,0x7a,0x90,0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38,0x87,0x36,0x68,0x87, + 0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0x62,0x1e,0xe8,0x21, + 0x1c,0xc6,0x61,0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1,0x1c,0xc6,0x81,0x1e, + 0xde,0x41,0x1e,0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x0d,0xe6, + 0x21,0x1d,0xf4,0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87,0x79,0x08,0x07,0x73, + 0x28,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e, + 0xe4,0xa1,0x1e,0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d,0xe6,0xe1,0x1d,0xcc, + 0x81,0x1e,0xda,0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00,0x73,0x08,0x07,0x76, + 0x98,0x87,0x72,0x00,0x36,0x18,0x02,0x01,0x2c,0x40,0x05,0x00,0x49,0x18,0x00,0x00, + 0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,0x00,0x1f,0x00,0x00,0x00, + 0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3, + 0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x44,0x33,0x00, + 0xc3,0x08,0x02,0x30,0x8c,0x40,0x00,0x76,0x08,0x42,0x24,0x81,0x98,0x89,0x9a,0x07, + 0x7a,0x90,0x87,0x7a,0x18,0x07,0x7a,0x70,0x83,0x76,0x28,0x07,0x7a,0x08,0x07,0x76, + 0xd0,0x03,0x3d,0x68,0x87,0x70,0xa0,0x07,0x79,0x48,0x07,0x7c,0x40,0x01,0x39,0x48, + 0x9a,0x22,0x4a,0x98,0xfc,0x4a,0xfa,0x1f,0x20,0x02,0x18,0x09,0x05,0x65,0x10,0xc1, + 0x10,0x4a,0x31,0x42,0x10,0x87,0xd0,0x40,0xc0,0x1c,0x01,0x18,0xa4,0xc0,0x9a,0x23, + 0x00,0x85,0x41,0x04,0x41,0x18,0x46,0x20,0x96,0x11,0x00,0x00,0x13,0xb2,0x70,0x48, + 0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83, + 0x76,0x08,0x87,0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83,0x38, + 0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07,0x7a, + 0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78,0xa0, + 0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e, + 0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e,0x73, + 0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76,0x40, + 0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20,0x07, + 0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07,0x7a, + 0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a,0x10, + 0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07,0x72, + 0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74,0xa0, + 0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07, + 0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a, + 0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20, + 0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20,0x07, + 0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x72, + 0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0, + 0x06,0xf6,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07, + 0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70, + 0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78,0xa0, + 0x07,0x71,0x60,0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x49,0x00,0x00,0x08,0x00,0x00, + 0x00,0x00,0x00,0xc8,0x02,0x01,0x00,0x00,0x0a,0x00,0x00,0x00,0x32,0x1e,0x98,0x10, + 0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50, + 0x04,0x05,0x18,0x50,0x08,0x05,0x51,0x06,0x05,0x42,0x6d,0x04,0x80,0xd8,0x58,0x02, + 0x33,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0xea,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10, + 0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x32,0x28, + 0x00,0xa3,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x2c, + 0x81,0x22,0x2c,0x05,0xe3,0x20,0x08,0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e,0x8c, + 0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26,0x06,0x06,0x26,0xc6,0xa5, + 0x46,0x46,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x26,0x06,0x06, + 0x26,0xc6,0xa5,0x46,0x46,0x26,0x65,0x88,0xa0,0x10,0x43,0x8c,0x25,0x58,0x8c,0x45, + 0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x51,0x8e,0x25,0x58,0x82,0x45,0xe0,0x16, + 0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26, + 0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x50,0x12,0x72,0x61, + 0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f, + 0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04,0x65,0x61,0x19, + 0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5, + 0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x91,0xa5, + 0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11,0x94,0x86,0x51,0x58,0x9a,0x9c,0x8b,0x5d,0x99, + 0x1c,0x5d,0x19,0xde,0xd7,0x5b,0x1d,0x1d,0x5c,0x1d,0x1d,0x97,0xba,0xb9,0x32,0x39, + 0x14,0xb6,0xb7,0x31,0x37,0x98,0x14,0x46,0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f, + 0x74,0x79,0x70,0x65,0x5f,0x6e,0x61,0x6d,0x65,0x34,0xcc,0xd8,0xde,0xc2,0xe8,0x64, + 0xc8,0x84,0xa5,0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xb9,0x85,0xb5,0x95,0x51,0xa8,0xb3, + 0x1b,0xc2,0x28,0x8f,0x02,0x29,0x91,0x22,0x29,0x93,0x42,0x71,0xa9,0x9b,0x2b,0x93, + 0x43,0x61,0x7b,0x1b,0x73,0x8b,0x49,0xa1,0x61,0xc6,0xf6,0x16,0x46,0x47,0xc3,0x62, + 0xec,0x8d,0xed,0x4d,0x6e,0x08,0xa3,0x3c,0x8a,0xa5,0x44,0xca,0xa5,0x4c,0x0a,0x46, + 0x26,0x2c,0x4d,0xce,0x05,0xee,0x6d,0x2e,0x8d,0x2e,0xed,0xcd,0x8d,0xcb,0x19,0xdb, + 0x17,0xd4,0xdb,0x5c,0x1a,0x5d,0xda,0x9b,0xdb,0x10,0x45,0xd1,0x94,0x48,0xb9,0x94, + 0x49,0xd9,0x86,0x18,0x4a,0xa5,0x64,0x0a,0x47,0x28,0x2c,0x4d,0xce,0xc5,0xae,0x4c, + 0x8e,0xae,0x0c,0xef,0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x52,0x58,0x9a,0x9c,0x0b,0xdb, + 0xdb,0x58,0x18,0x5d,0xda,0x9b,0xdb,0x57,0x9a,0x1b,0x59,0x19,0x1e,0xbd,0xb3,0x32, + 0xb7,0x32,0xb9,0x30,0xba,0x32,0x32,0x94,0xaf,0xaf,0xb0,0x34,0xb9,0x2f,0x38,0xb6, + 0xb0,0xb1,0x32,0xb4,0x37,0x36,0xb2,0x32,0xb9,0xaf,0xaf,0x14,0x22,0x70,0x6f,0x73, + 0x69,0x74,0x69,0x6f,0x6e,0x43,0xa8,0x45,0x50,0x3c,0xe5,0x5b,0x84,0x25,0x50,0xc0, + 0x40,0x89,0x14,0x49,0x99,0x94,0x30,0x60,0x42,0x57,0x86,0x37,0xf6,0xf6,0x26,0x47, + 0x06,0x33,0x84,0x5a,0x02,0xc5,0x53,0xbe,0x25,0x58,0x02,0x05,0x0c,0x94,0x48,0x91, + 0x94,0x49,0x19,0x03,0x1a,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x43,0xa8,0x65,0x50,0x3c, + 0xe5,0x5b,0x86,0x25,0x50,0xc0,0x40,0x89,0x94,0x4b,0x99,0x94,0x32,0xa0,0x12,0x96, + 0x26,0xe7,0x22,0x56,0x67,0x66,0x56,0x26,0xc7,0x27,0x2c,0x4d,0xce,0x45,0xac,0xce, + 0xcc,0xac,0x4c,0xee,0x6b,0x2e,0x4d,0xaf,0x8c,0x48,0x58,0x9a,0x9c,0x8b,0x5c,0x59, + 0x18,0x19,0xa9,0xb0,0x34,0x39,0x97,0x39,0x3a,0xb9,0xba,0x31,0xba,0x2f,0xba,0x3c, + 0xb8,0xb2,0xaf,0x34,0x37,0xb3,0x37,0x22,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34, + 0x1c,0xda,0xec,0xe0,0x86,0x28,0x8b,0xb0,0x10,0x8b,0xa0,0xac,0x81,0xc2,0x06,0x8c, + 0xc2,0xd2,0xe4,0x5c,0xc2,0xe4,0xce,0xbe,0xe8,0xf2,0xe0,0xca,0xbe,0xe6,0xd2,0xf4, + 0xca,0x78,0x85,0xa5,0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xd1,0xe5,0xc1,0x95,0x7d,0x85, + 0xb1,0xa5,0x9d,0xb9,0x7d,0xcd,0xa5,0xe9,0x95,0x31,0xb1,0x9b,0xfb,0x82,0x0b,0x93, + 0x0b,0x6b,0x9b,0xe3,0xf0,0x25,0x13,0x33,0x84,0x0c,0x96,0x43,0x39,0x03,0x05,0x0d, + 0x16,0x42,0xf9,0x16,0x61,0x09,0x94,0x34,0x50,0xd4,0x40,0x69,0x03,0xc5,0x0d,0x16, + 0x42,0x79,0x83,0x05,0x51,0x22,0x05,0x0e,0x94,0x49,0x89,0x83,0x21,0x88,0x22,0x06, + 0x0a,0x19,0x28,0x66,0xa0,0xc8,0xc1,0x10,0x23,0x01,0x94,0x4e,0x99,0x03,0x3e,0x6f, + 0x6d,0x6e,0x69,0x70,0x6f,0x74,0x65,0x6e,0x74,0x20,0x63,0x68,0x61,0x72,0x7c,0xa6, + 0xd2,0xda,0xe0,0xd8,0xca,0x40,0x86,0x56,0x56,0x40,0xa8,0x84,0x82,0x82,0x86,0x08, + 0x8a,0x1d,0x0c,0x31,0x94,0x3a,0x50,0xee,0xa0,0x49,0x86,0x18,0x0a,0x1e,0x28,0x78, + 0xd0,0x24,0x23,0x22,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x77,0x20,0x87, + 0x7a,0x60,0x87,0x72,0x70,0x03,0x73,0x60,0x87,0x70,0x38,0x87,0x79,0x98,0x22,0x04, + 0xc3,0x08,0x85,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d,0xd2,0x81,0x1c,0xca,0xc1,0x1d, + 0xe8,0x61,0x4a,0x50,0x8c,0x58,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4, + 0x61,0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x4a,0x60,0x8c,0xa0,0xc2,0x21,0x1d,0xe4,0xc1, + 0x0d,0xd8,0x21,0x1c,0xdc,0xe1,0x1c,0xea,0x21,0x1c,0xce,0xa1,0x1c,0x7e,0xc1,0x1e, + 0xca,0x41,0x1e,0xe6,0x21,0x1d,0xde,0xc1,0x1d,0xa6,0x04,0xc8,0x88,0x29,0x1c,0xd2, + 0x41,0x1e,0xdc,0x60,0x1c,0xde,0xa1,0x1d,0xe0,0x21,0x1d,0xd8,0xa1,0x1c,0x7e,0xe1, + 0x1d,0xe0,0x81,0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x1e,0xa6,0x0c,0x0a,0xe3,0x8c,0x50, + 0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x81,0x1e,0xca,0x01,0x1f,0xa6, + 0x04,0x74,0x00,0x00,0x79,0x18,0x00,0x00,0x7b,0x00,0x00,0x00,0x33,0x08,0x80,0x1c, + 0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07, + 0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e, + 0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43, + 0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c, + 0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76, + 0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e, + 0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8, + 0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4, + 0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68, + 0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07, + 0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71, + 0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5, + 0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4, + 0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90, + 0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43, + 0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b, + 0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78, + 0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2, + 0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20, + 0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0, + 0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83, + 0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07, + 0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61, + 0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d, + 0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39, + 0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79, + 0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c,0xe3, + 0x10,0x0e,0xec,0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e,0xe4, + 0xe1,0x17,0xd8,0xe1,0x1d,0xde,0x01,0x1e,0x66,0x50,0x59,0x38,0xa4,0x83,0x3c,0xb8, + 0x81,0x39,0xd4,0x83,0x3b,0x8c,0x03,0x3d,0xa4,0xc3,0x3b,0xb8,0xc3,0x2f,0x9c,0x83, + 0x3c,0xbc,0x43,0x3d,0xc0,0xc3,0x3c,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00, + 0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x1e,0x00,0x00,0x00, + 0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xf4,0xc6,0x22,0x82, + 0x20,0x08,0x46,0x00,0xa8,0x95,0x40,0x19,0xd0,0x98,0x01,0xa0,0x30,0x03,0x00,0x00, + 0xe3,0x15,0x07,0x33,0x4d,0x0c,0x05,0x65,0x90,0x81,0x19,0x0e,0x13,0x02,0xf9,0x8c, + 0x57,0x2c,0xd0,0x75,0x21,0x14,0x94,0x41,0x06,0xe8,0x60,0x4c,0x08,0xe4,0x63,0x41, + 0x01,0x9f,0xf1,0x0a,0xa8,0xe2,0x38,0x86,0x82,0x62,0x43,0x00,0x9f,0xd9,0x06,0xa7, + 0x02,0x66,0x1b,0x82,0x2a,0x98,0x6d,0x08,0x06,0x21,0x83,0x80,0x18,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x5b,0x86,0x20,0xc8,0x83,0x2d,0x43,0x11,0xe4,0xc1,0x96,0x41, + 0x09,0xf2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sspine_fs_bytecode_metal_macos[3257] = { + 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xb9,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd1,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd9,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe0,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0xeb,0x62,0x74,0xda,0xdc,0xfb,0x51, + 0x12,0x89,0xbd,0xc2,0xa1,0xdc,0x89,0x67,0x5f,0x96,0x17,0x50,0xd6,0x8b,0xbc,0x5d, + 0xa9,0xe9,0x5d,0xef,0xeb,0x59,0xe4,0x51,0x64,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44, + 0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00, + 0x00,0x14,0x00,0x00,0x00,0xc8,0x0b,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0, + 0xde,0x21,0x0c,0x00,0x00,0xef,0x02,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00, + 0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32, + 0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45, + 0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44, + 0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8, + 0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00, + 0x00,0x8e,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff,0xff,0x01,0x60,0x00, + 0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07,0x7a,0x60,0x87,0x7c, + 0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72,0x68,0x03,0x72,0x48, + 0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90,0x07,0x7a,0x68,0x03, + 0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc,0x21,0x1c,0xd8,0x61, + 0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81,0x1d,0xca,0xa1,0x0d, + 0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d,0xd8,0x61,0x1e,0x00, + 0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87,0x79,0x98,0x87,0x36, + 0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36,0x30,0x07,0x78,0x68, + 0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x00,0xc2,0x1d,0xde, + 0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0,0xe1,0x1d,0xd2,0xc1, + 0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1,0x1d,0x00,0x7a,0x90, + 0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90,0x87,0x70,0x68,0x87, + 0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07,0x79,0x68,0x83,0x72, + 0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36,0x60,0x87,0x72,0x08, + 0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30,0x87,0x79,0x68,0x03, + 0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1, + 0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01,0x1e,0xda,0x80,0x1e, + 0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07, + 0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87,0x36,0x30,0x07,0x78, + 0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20, + 0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c,0xc8,0xa1,0x0d,0xf4, + 0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda,0xa0,0x1d,0xc2,0x81, + 0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0xa0, + 0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68,0x83,0x76,0x08,0x07, + 0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6,0x81,0x1e,0xc2,0x61, + 0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61,0x1c,0xe8,0xe1,0x1d, + 0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e,0xda,0x60,0x1e,0xd2, + 0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87,0x70,0x30,0x87,0x72, + 0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e, + 0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e,0xde,0xc1,0x1c,0xe8, + 0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87,0x70,0x60,0x87,0x79, + 0x28,0x07,0x60,0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81,0x00,0x16,0xa0,0xda, + 0x60,0x10,0x05,0xb0,0x00,0xd5,0x06,0xa3,0xf8,0xff,0xff,0xff,0xff,0x01,0x90,0x00, + 0x6a,0x03,0x62,0xfc,0xff,0xff,0xff,0xff,0x00,0x30,0x80,0x04,0x54,0x1b,0x8c,0x23, + 0x00,0x16,0xa0,0xda,0x60,0x20,0x02,0xb0,0x00,0x15,0x00,0x00,0x00,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x88,0x40,0x18,0x88,0x09,0x41,0x31,0x61,0x30,0x0e, + 0x04,0x89,0x20,0x00,0x00,0x27,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x6c,0x33,0x00,0xc3,0x08,0x04,0x60,0x83,0x30,0x8c, + 0x20,0x00,0x07,0x49,0x53,0x44,0x09,0x93,0x5f,0x48,0xff,0x03,0x44,0x00,0x23,0xa1, + 0x00,0x0c,0x22,0x10,0xc2,0x51,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x13,0x71,0x4d,0x54, + 0x44,0xfc,0xf6,0xf0,0x4f,0x63,0x04,0xc0,0x20,0x82,0x11,0x5c,0x24,0x4d,0x11,0x25, + 0x4c,0xfe,0x2f,0x01,0xcc,0xb3,0x10,0xd1,0x3f,0x8d,0x11,0x00,0x83,0x08,0x88,0x50, + 0x0c,0x31,0x42,0x39,0x89,0x54,0x21,0x42,0x08,0x81,0xd8,0x1c,0x41,0x30,0x47,0x00, + 0x06,0xc3,0x08,0xc2,0x53,0x90,0x70,0xd2,0x70,0xd0,0x01,0x8a,0x03,0x01,0x29,0xf0, + 0x86,0x11,0x86,0x67,0x18,0x61,0x00,0x86,0x11,0x88,0x67,0x8e,0x00,0x14,0x06,0x11, + 0x00,0x61,0x04,0x00,0x00,0x13,0xb2,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83, + 0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79, + 0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83,0x38,0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5, + 0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40, + 0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07, + 0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76, + 0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0, + 0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07, + 0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73, + 0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40, + 0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07, + 0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d, + 0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60, + 0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f, + 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79, + 0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60, + 0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07, + 0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a, + 0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50, + 0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07, + 0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71, + 0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00, + 0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07, + 0x72,0x30,0x84,0x59,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x18,0xc2,0x34,0x40, + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x0c,0x61,0x24,0x20,0x00,0x06,0x00,0x00,0x00, + 0x00,0x00,0xb2,0x40,0x00,0x09,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c, + 0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x7a,0x23,0x00,0x25,0x50,0x08,0x45,0x50, + 0x10,0x65,0x40,0x78,0x04,0x80,0xe8,0x58,0x02,0x33,0x00,0x00,0x00,0x79,0x18,0x00, + 0x00,0xfa,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32, + 0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x63,0x4c,0x00,0xa5,0x50,0xb9,0x1b,0x43,0x0b, + 0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x3c,0xc4,0x24,0x3c,0x05,0xe3,0x20,0x08, + 0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e,0x8c,0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed, + 0xcd,0x0d,0x64,0x26,0x06,0x06,0x26,0xc6,0xa5,0x46,0x46,0x06,0x04,0xa5,0xad,0x8c, + 0x2e,0x8c,0xcd,0xac,0xac,0x65,0x26,0x06,0x06,0x26,0xc6,0xa5,0x46,0x46,0x26,0x65, + 0x88,0x30,0x11,0x43,0x8c,0x87,0x78,0x8e,0x67,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36, + 0x04,0x99,0x8e,0x87,0x78,0x88,0x67,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06, + 0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17, + 0x26,0xc6,0x56,0x36,0x44,0x98,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70, + 0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e, + 0x61,0x62,0x6c,0x65,0x43,0x84,0x69,0x61,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5, + 0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9, + 0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x91,0xa5,0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11, + 0xa6,0x86,0x51,0x58,0x9a,0x9c,0x8b,0x5c,0x99,0x1b,0x59,0x99,0xdc,0x17,0x5d,0x98, + 0xdc,0x59,0x19,0x1d,0xa3,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xba,0x3c,0xb8, + 0xb2,0x2f,0xb7,0xb0,0xb6,0x32,0x1a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x64,0xc2,0xd2, + 0xe4,0x5c,0xc2,0xe4,0xce,0xbe,0xdc,0xc2,0xda,0xca,0xa8,0x98,0xc9,0x85,0x9d,0x7d, + 0x8d,0xbd,0xb1,0xbd,0xc9,0x0d,0x61,0xa6,0xe7,0x19,0x26,0x68,0x8a,0x26,0x69,0x9a, + 0x86,0x08,0x13,0x45,0x29,0x2c,0x4d,0xce,0xc5,0x4c,0x2e,0xec,0xac,0xad,0xcc,0x8d, + 0xee,0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x4b,0xdd,0x5c,0x99,0x1c,0x0a,0xdb,0xdb,0x98, + 0x1b,0x4c,0x0a,0x95,0xb0,0x34,0x39,0x97,0xb1,0x32,0x37,0xba,0x32,0x39,0x3e,0x61, + 0x69,0x72,0x2e,0x70,0x65,0x72,0x73,0x70,0x65,0x63,0x74,0x69,0x76,0x65,0x34,0xcc, + 0xd8,0xde,0xc2,0xe8,0x64,0x28,0xd4,0xd9,0x0d,0x91,0x9e,0x61,0xb2,0xa6,0x6b,0xc2, + 0xa6,0x6c,0x82,0x26,0x6d,0x92,0xa6,0x8d,0x4b,0xdd,0x5c,0x99,0x1c,0x0a,0xdb,0xdb, + 0x98,0x5b,0x4c,0x0a,0x8b,0xb1,0x37,0xb6,0x37,0xb9,0x21,0xd2,0x43,0x4c,0xd6,0xd4, + 0x4d,0xd8,0x94,0x4d,0xd0,0x14,0x4d,0xd2,0xe4,0x51,0x09,0x4b,0x93,0x73,0x11,0xab, + 0x33,0x33,0x2b,0x93,0xe3,0x13,0x96,0x26,0xe7,0x22,0x56,0x67,0x66,0x56,0x26,0xf7, + 0x35,0x97,0xa6,0x57,0x46,0x29,0x2c,0x4d,0xce,0x85,0xed,0x6d,0x2c,0x8c,0x2e,0xed, + 0xcd,0xed,0x2b,0xcd,0x8d,0xac,0x0c,0x8f,0x48,0x58,0x9a,0x9c,0x8b,0x5c,0x59,0x18, + 0x19,0xa9,0xb0,0x34,0x39,0x97,0x39,0x3a,0xb9,0xba,0x31,0xba,0x2f,0xba,0x3c,0xb8, + 0xb2,0xaf,0x34,0x37,0xb3,0x37,0x16,0x66,0x6c,0x6f,0x61,0x74,0x1c,0xe0,0xda,0xc2, + 0x86,0x28,0xcf,0xf0,0x14,0xcf,0x30,0x95,0xc1,0x64,0x06,0x8c,0xc2,0xd2,0xe4,0x5c, + 0xc2,0xe4,0xce,0xbe,0xe8,0xf2,0xe0,0xca,0xbe,0xe6,0xd2,0xf4,0xca,0x78,0x85,0xa5, + 0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xd1,0xe5,0xc1,0x95,0x7d,0x85,0xb1,0xa5,0x9d,0xb9, + 0x7d,0xcd,0xa5,0xe9,0x95,0x31,0x31,0x9b,0xfb,0x82,0x0b,0x93,0x0b,0x6b,0x9b,0xe3, + 0xf0,0x55,0x03,0x33,0x84,0x0c,0x1e,0x63,0x02,0x83,0x29,0x0c,0x9e,0x62,0x12,0x83, + 0x67,0x78,0x88,0x69,0x0c,0x26,0x32,0x98,0xce,0x60,0x42,0x83,0xa7,0x98,0xd2,0xe0, + 0x29,0x26,0x68,0x52,0x83,0x49,0x9a,0xd6,0x80,0x4b,0x58,0x9a,0x9c,0x0b,0x5d,0x19, + 0x1e,0x5d,0x9d,0x5c,0x19,0x95,0xb0,0x34,0x39,0x97,0xb9,0xb0,0x36,0x38,0xb6,0x32, + 0x62,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74, + 0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x3e,0x1c,0xe8,0xca,0xf0,0x86,0x50,0x0f, + 0x32,0xb5,0xc1,0x24,0x06,0xcf,0xf0,0x10,0x93,0x1b,0x4c,0xd0,0xf4,0x06,0x93,0x34, + 0xc1,0x01,0x97,0xb0,0x34,0x39,0x97,0xb9,0xb0,0x36,0x38,0xb6,0x32,0x39,0x1e,0x73, + 0x61,0x6d,0x70,0x6c,0x65,0x72,0x44,0xe8,0xca,0xf0,0xa6,0xda,0xe0,0xd8,0xe4,0x86, + 0x48,0x4f,0x31,0xc9,0xc1,0x24,0x06,0xcf,0xf0,0x10,0x13,0x34,0xcd,0xc1,0x24,0x4d, + 0x74,0x30,0x44,0x99,0xb8,0xe9,0x9b,0xd8,0x60,0x8a,0x83,0xa9,0x0e,0x86,0x18,0x0b, + 0x30,0x55,0x93,0x1d,0xd0,0xf9,0xd2,0xa2,0x9a,0xca,0x31,0x9b,0xfb,0x82,0x0b,0x93, + 0x0b,0x6b,0x9b,0xe3,0xf3,0xd6,0xe6,0x96,0x06,0xf7,0x46,0x57,0xe6,0x46,0x07,0x32, + 0x86,0x16,0x26,0xc7,0x67,0x2a,0xad,0x0d,0x8e,0xad,0x0c,0x64,0x68,0x65,0x05,0x84, + 0x4a,0x28,0x28,0x68,0x88,0x30,0xe9,0xc1,0x10,0x63,0xca,0x83,0x69,0x0f,0xb0,0x64, + 0x88,0x31,0x95,0xc1,0xc4,0x07,0x58,0x32,0xc4,0x98,0xf0,0x60,0xea,0x03,0x2c,0x19, + 0x62,0x4c,0x7e,0x30,0xf5,0x01,0x96,0x8c,0x88,0xd8,0x81,0x1d,0xec,0xa1,0x1d,0xdc, + 0xa0,0x1d,0xde,0x81,0x1c,0xea,0x81,0x1d,0xca,0xc1,0x0d,0xcc,0x81,0x1d,0xc2,0xe1, + 0x1c,0xe6,0x61,0x8a,0x10,0x0c,0x23,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x48, + 0x07,0x72,0x28,0x07,0x77,0xa0,0x87,0x29,0x41,0x31,0x62,0x09,0x87,0x74,0x90,0x07, + 0x37,0xb0,0x87,0x72,0x90,0x87,0x79,0x48,0x87,0x77,0x70,0x87,0x29,0x81,0x31,0x82, + 0x0a,0x87,0x74,0x90,0x07,0x37,0x60,0x87,0x70,0x70,0x87,0x73,0xa8,0x87,0x70,0x38, + 0x87,0x72,0xf8,0x05,0x7b,0x28,0x07,0x79,0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12, + 0x20,0x23,0xa6,0x70,0x48,0x07,0x79,0x70,0x83,0x71,0x78,0x87,0x76,0x80,0x87,0x74, + 0x60,0x87,0x72,0xf8,0x85,0x77,0x80,0x07,0x7a,0x48,0x87,0x77,0x70,0x87,0x79,0x98, + 0x32,0x28,0x8c,0x33,0x82,0x09,0x87,0x74,0x90,0x07,0x37,0x30,0x07,0x79,0x08,0x87, + 0x73,0x68,0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0xdc,0x01,0x00,0x00,0x79,0x18,0x00, + 0x00,0x7b,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d, + 0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c, + 0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d, + 0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d, + 0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79, + 0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc, + 0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50, + 0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30, + 0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03, + 0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07, + 0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76, + 0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98, + 0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8, + 0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21, + 0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43, + 0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f, + 0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70, + 0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0, + 0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40, + 0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41, + 0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e, + 0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07, + 0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f, + 0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d, + 0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38, + 0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88, + 0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08, + 0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c,0xe3,0x10,0x0e,0xec,0xc0,0x0e,0xe5,0x50, + 0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e,0xe4,0xe1,0x17,0xd8,0xe1,0x1d,0xde,0x01, + 0x1e,0x66,0x50,0x59,0x38,0xa4,0x83,0x3c,0xb8,0x81,0x39,0xd4,0x83,0x3b,0x8c,0x03, + 0x3d,0xa4,0xc3,0x3b,0xb8,0xc3,0x2f,0x9c,0x83,0x3c,0xbc,0x43,0x3d,0xc0,0xc3,0x3c, + 0x00,0x71,0x20,0x00,0x00,0x0b,0x00,0x00,0x00,0x26,0xb0,0x01,0x48,0xe4,0x4b,0x00, + 0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d, + 0x00,0x05,0x03,0x20,0x0d,0x6d,0x01,0x0d,0x80,0x44,0x3e,0x83,0x5c,0x7e,0x85,0x17, + 0xb7,0x0d,0x00,0x00,0x00,0x61,0x20,0x00,0x00,0x25,0x00,0x00,0x00,0x13,0x04,0x41, + 0x2c,0x10,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x74,0x47,0x00,0xc6,0x22,0x80,0x40, + 0x38,0xe6,0x20,0x06,0xc2,0xa8,0xc8,0xd5,0xc0,0x08,0x00,0xbd,0x19,0x00,0x82,0x23, + 0x00,0x54,0xc7,0x1a,0x80,0x40,0x18,0x6b,0x18,0x86,0x81,0xec,0x0c,0x00,0x89,0x19, + 0x00,0x0a,0x33,0x00,0x04,0x46,0x00,0x00,0x00,0x23,0x06,0xca,0x10,0x6c,0x8f,0x23, + 0x29,0x47,0x12,0x58,0x20,0xc9,0x67,0x90,0x21,0x20,0x90,0x41,0x06,0xa1,0x40,0x4c, + 0x08,0xe4,0x33,0xc8,0x10,0x24,0xd0,0x20,0x43,0x50,0x48,0x16,0x60,0xf2,0x19,0x6f, + 0xc0,0x38,0x31,0xa0,0x60,0xcc,0x31,0x30,0x01,0x19,0x0c,0x32,0x04,0x0d,0x36,0x62, + 0x60,0x08,0x01,0x1a,0x2c,0x45,0x30,0xdb,0x00,0x05,0x40,0x06,0x01,0x31,0x00,0x00, + 0x00,0x02,0x00,0x00,0x00,0x5b,0x86,0x24,0xf8,0x03,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sspine_vs_bytecode_metal_ios[3068] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xfc,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0xf0,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0x0e,0xe2,0x38,0x0e,0x18,0xad,0x5b, + 0x54,0x49,0xaf,0x95,0xc9,0xab,0xf7,0xda,0x83,0x18,0xe7,0x3c,0xff,0xd0,0x8d,0x85, + 0x65,0x82,0x6c,0xdb,0x0b,0x02,0x06,0x0c,0x04,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x37,0x00,0x00,0x00,0x56,0x41,0x54, + 0x54,0x22,0x00,0x03,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x80, + 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x00,0x02,0x80,0x56,0x41,0x54,0x59,0x05,0x00,0x03,0x00,0x04,0x04,0x06, + 0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b, + 0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0xd8,0x0a,0x00,0x00,0xff,0xff,0xff,0xff, + 0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,0xb3,0x02,0x00,0x00,0x0b,0x82,0x20,0x00, + 0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49, + 0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62, + 0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49, + 0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72, + 0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00, + 0x51,0x18,0x00,0x00,0x82,0x00,0x00,0x00,0x1b,0xc8,0x25,0xf8,0xff,0xff,0xff,0xff, + 0x01,0x90,0x80,0x8a,0x18,0x87,0x77,0x90,0x07,0x79,0x28,0x87,0x71,0xa0,0x07,0x76, + 0xc8,0x87,0x36,0x90,0x87,0x77,0xa8,0x07,0x77,0x20,0x87,0x72,0x20,0x87,0x36,0x20, + 0x87,0x74,0xb0,0x87,0x74,0x20,0x87,0x72,0x68,0x83,0x79,0x88,0x07,0x79,0xa0,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0xc0,0x1c,0xc2,0x81, + 0x1d,0xe6,0xa1,0x1c,0x00,0x82,0x1c,0xd2,0x61,0x1e,0xc2,0x41,0x1c,0xd8,0xa1,0x1c, + 0xda,0x80,0x1e,0xc2,0x21,0x1d,0xd8,0xa1,0x0d,0xc6,0x21,0x1c,0xd8,0x81,0x1d,0xe6, + 0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07,0x80,0x60,0x87,0x72,0x98,0x87,0x79, + 0x68,0x03,0x78,0x90,0x87,0x72,0x18,0x87,0x74,0x98,0x87,0x72,0x68,0x03,0x73,0x80, + 0x87,0x76,0x08,0x07,0x72,0x00,0xcc,0x21,0x1c,0xd8,0x61,0x1e,0xca,0x01,0x20,0xdc, + 0xe1,0x1d,0xda,0xc0,0x1c,0xe4,0x21,0x1c,0xda,0xa1,0x1c,0xda,0x00,0x1e,0xde,0x21, + 0x1d,0xdc,0x81,0x1e,0xca,0x41,0x1e,0xda,0xa0,0x1c,0xd8,0x21,0x1d,0xda,0x01,0xa0, + 0x07,0x79,0xa8,0x87,0x72,0x00,0x06,0x77,0x78,0x87,0x36,0x30,0x07,0x79,0x08,0x87, + 0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,0x87,0x72,0x90,0x87,0x36, + 0x28,0x07,0x76,0x48,0x87,0x76,0x68,0x03,0x77,0x78,0x07,0x77,0x68,0x03,0x76,0x28, + 0x87,0x70,0x30,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x74,0x70,0x07,0x73,0x98,0x87, + 0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1, + 0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0x40,0x1d,0xea,0xa1,0x1d,0xe0,0xa1,0x0d, + 0xe8,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x1e,0x00,0x73,0x08,0x07,0x76,0x98,0x87, + 0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x70,0x87,0x70,0x70,0x87,0x79,0x68,0x03,0x73, + 0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c, + 0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe6,0x21,0x1d,0xce,0xc1,0x1d,0xca,0x81,0x1c,0xda, + 0x40,0x1f,0xca,0x41,0x1e,0xde,0x61,0x1e,0xda,0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21, + 0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,0x77,0x68, + 0x03,0x7a,0x90,0x87,0x70,0x80,0x07,0x78,0x48,0x07,0x77,0x38,0x87,0x36,0x68,0x87, + 0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0x62,0x1e,0xe8,0x21, + 0x1c,0xc6,0x61,0x1d,0xda,0x00,0x1e,0xe4,0xe1,0x1d,0xe8,0xa1,0x1c,0xc6,0x81,0x1e, + 0xde,0x41,0x1e,0xda,0x40,0x1c,0xea,0xc1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x0d,0xe6, + 0x21,0x1d,0xf4,0xa1,0x1c,0x00,0x3c,0x00,0x88,0x7a,0x70,0x87,0x79,0x08,0x07,0x73, + 0x28,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e, + 0xe4,0xa1,0x1e,0xca,0x01,0x20,0xea,0x61,0x1e,0xca,0xa1,0x0d,0xe6,0xe1,0x1d,0xcc, + 0x81,0x1e,0xda,0xc0,0x1c,0xd8,0xe1,0x1d,0xc2,0x81,0x1e,0x00,0x73,0x08,0x07,0x76, + 0x98,0x87,0x72,0x00,0x36,0x20,0x02,0x01,0x24,0xc0,0x02,0x54,0x00,0x00,0x00,0x00, + 0x49,0x18,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,0x00, + 0x1f,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84, + 0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c, + 0x10,0x44,0x33,0x00,0xc3,0x08,0x02,0x30,0x8c,0x40,0x00,0x76,0x08,0x42,0x24,0x81, + 0x98,0x89,0x9a,0x07,0x7a,0x90,0x87,0x7a,0x18,0x07,0x7a,0x70,0x83,0x76,0x28,0x07, + 0x7a,0x08,0x07,0x76,0xd0,0x03,0x3d,0x68,0x87,0x70,0xa0,0x07,0x79,0x48,0x07,0x7c, + 0x40,0x01,0x39,0x48,0x9a,0x22,0x4a,0x98,0xfc,0x4a,0xfa,0x1f,0x20,0x02,0x18,0x09, + 0x05,0x65,0x10,0xc1,0x10,0x4a,0x31,0x42,0x10,0x87,0xd0,0x40,0xc0,0x1c,0x01,0x18, + 0xa4,0xc0,0x9a,0x23,0x00,0x85,0x41,0x04,0x41,0x18,0x46,0x20,0x96,0x11,0x00,0x00, + 0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60, + 0x87,0x72,0x68,0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80,0x83, + 0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d, + 0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0, + 0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07, + 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76, + 0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20, + 0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a, + 0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30, + 0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07, + 0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74, + 0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0, + 0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07, + 0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a, + 0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72,0x50, + 0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60,0x07, + 0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x75, + 0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xd0, + 0x06,0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07, + 0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07,0x76, + 0xa0,0x07,0x73,0x20,0x07,0x43,0x98,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80, + 0x2c,0x10,0x00,0x00,0x0a,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90, + 0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50,0x04,0x05,0x18,0x50, + 0x08,0x05,0x51,0x06,0x05,0x42,0x6d,0x04,0x80,0xd8,0x58,0x02,0x04,0x00,0x00,0x00, + 0x79,0x18,0x00,0x00,0xea,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25, + 0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x32,0x28,0x00,0xa3,0x50,0xb9, + 0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x2c,0x81,0x22,0x2c,0x05, + 0xe7,0x20,0x08,0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e,0x8c,0x0d,0xc4,0xae,0x4c, + 0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26,0x06,0x06,0x26,0xc6,0xc5,0x86,0x66,0x06,0x04, + 0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x26,0x06,0x06,0x26,0xc6,0xc5,0x86, + 0x66,0xc6,0x85,0x26,0x65,0x88,0xa0,0x10,0x43,0x8c,0x25,0x58,0x8c,0x45,0x60,0xd1, + 0x54,0x46,0x17,0xc6,0x36,0x04,0x51,0x8e,0x25,0x58,0x84,0x45,0xe0,0x16,0x96,0x26, + 0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36, + 0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x50,0x12,0x72,0x61,0x69,0x72, + 0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61, + 0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04,0x65,0x21,0x19,0x84,0xa5, + 0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89, + 0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x95,0xb9,0x85,0x89, + 0xb1,0x95,0x0d,0x11,0x94,0x86,0x51,0x58,0x9a,0x9c,0x8b,0x5d,0x99,0x1c,0x5d,0x19, + 0xde,0xd7,0x5b,0x1d,0x1d,0x5c,0x1d,0x1d,0x97,0xba,0xb9,0x32,0x39,0x14,0xb6,0xb7, + 0x31,0x37,0x98,0x14,0x46,0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x74,0x79,0x70, + 0x65,0x5f,0x6e,0x61,0x6d,0x65,0x34,0xcc,0xd8,0xde,0xc2,0xe8,0x64,0xc8,0x84,0xa5, + 0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xb9,0x85,0xb5,0x95,0x51,0xa8,0xb3,0x1b,0xc2,0x28, + 0x8f,0x02,0x29,0x91,0x22,0x29,0x93,0x42,0x71,0xa9,0x9b,0x2b,0x93,0x43,0x61,0x7b, + 0x1b,0x73,0x8b,0x49,0xa1,0x61,0xc6,0xf6,0x16,0x46,0x47,0xc3,0x62,0xec,0x8d,0xed, + 0x4d,0x6e,0x08,0xa3,0x3c,0x8a,0xa5,0x44,0xca,0xa5,0x4c,0x0a,0x46,0x26,0x2c,0x4d, + 0xce,0x05,0xee,0x6d,0x2e,0x8d,0x2e,0xed,0xcd,0x8d,0xcb,0x19,0xdb,0x17,0xd4,0xdb, + 0x5c,0x1a,0x5d,0xda,0x9b,0xdb,0x10,0x45,0xd1,0x94,0x48,0xb9,0x94,0x49,0xd9,0x86, + 0x18,0x4a,0xa5,0x64,0x0a,0x47,0x28,0x2c,0x4d,0xce,0xc5,0xae,0x4c,0x8e,0xae,0x0c, + 0xef,0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x52,0x58,0x9a,0x9c,0x0b,0xdb,0xdb,0x58,0x18, + 0x5d,0xda,0x9b,0xdb,0x57,0x9a,0x1b,0x59,0x19,0x1e,0xbd,0xb3,0x32,0xb7,0x32,0xb9, + 0x30,0xba,0x32,0x32,0x94,0xaf,0xaf,0xb0,0x34,0xb9,0x2f,0x38,0xb6,0xb0,0xb1,0x32, + 0xb4,0x37,0x36,0xb2,0x32,0xb9,0xaf,0xaf,0x14,0x22,0x70,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x43,0xa8,0x45,0x50,0x3c,0xe5,0x5b,0x84,0x25,0x50,0xc0,0x40,0x89,0x14, + 0x49,0x99,0x94,0x30,0x60,0x42,0x57,0x86,0x37,0xf6,0xf6,0x26,0x47,0x06,0x33,0x84, + 0x5a,0x02,0xc5,0x53,0xbe,0x25,0x58,0x02,0x05,0x0c,0x94,0x48,0x91,0x94,0x49,0x19, + 0x03,0x1a,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x43,0xa8,0x65,0x50,0x3c,0xe5,0x5b,0x86, + 0x25,0x50,0xc0,0x40,0x89,0x94,0x4b,0x99,0x94,0x32,0xa0,0x12,0x96,0x26,0xe7,0x22, + 0x56,0x67,0x66,0x56,0x26,0xc7,0x27,0x2c,0x4d,0xce,0x45,0xac,0xce,0xcc,0xac,0x4c, + 0xee,0x6b,0x2e,0x4d,0xaf,0x8c,0x48,0x58,0x9a,0x9c,0x8b,0x5c,0x59,0x18,0x19,0xa9, + 0xb0,0x34,0x39,0x97,0x39,0x3a,0xb9,0xba,0x31,0xba,0x2f,0xba,0x3c,0xb8,0xb2,0xaf, + 0x34,0x37,0xb3,0x37,0x22,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x1c,0xda,0xec, + 0xe0,0x86,0x28,0x8b,0xb0,0x10,0x8b,0xa0,0xac,0x81,0xc2,0x06,0x8c,0xc2,0xd2,0xe4, + 0x5c,0xc2,0xe4,0xce,0xbe,0xe8,0xf2,0xe0,0xca,0xbe,0xe6,0xd2,0xf4,0xca,0x78,0x85, + 0xa5,0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xd1,0xe5,0xc1,0x95,0x7d,0x85,0xb1,0xa5,0x9d, + 0xb9,0x7d,0xcd,0xa5,0xe9,0x95,0x31,0xb1,0x9b,0xfb,0x82,0x0b,0x93,0x0b,0x6b,0x9b, + 0xe3,0xf0,0x25,0x13,0x33,0x84,0x0c,0x96,0x43,0x39,0x03,0x05,0x0d,0x16,0x42,0xf9, + 0x16,0x61,0x09,0x94,0x34,0x50,0xd4,0x40,0x69,0x03,0xc5,0x0d,0x16,0x42,0x79,0x83, + 0x05,0x51,0x22,0x05,0x0e,0x94,0x49,0x89,0x83,0x21,0x88,0x22,0x06,0x0a,0x19,0x28, + 0x66,0xa0,0xc8,0xc1,0x10,0x23,0x01,0x94,0x4e,0x99,0x03,0x3e,0x6f,0x6d,0x6e,0x69, + 0x70,0x6f,0x74,0x65,0x6e,0x74,0x20,0x63,0x68,0x61,0x72,0x7c,0xa6,0xd2,0xda,0xe0, + 0xd8,0xca,0x40,0x86,0x56,0x56,0x40,0xa8,0x84,0x82,0x82,0x86,0x08,0x8a,0x1d,0x0c, + 0x31,0x94,0x3a,0x50,0xee,0xa0,0x49,0x86,0x18,0x0a,0x1e,0x28,0x78,0xd0,0x24,0x23, + 0x22,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x77,0x20,0x87,0x7a,0x60,0x87, + 0x72,0x70,0x03,0x73,0x60,0x87,0x70,0x38,0x87,0x79,0x98,0x22,0x04,0xc3,0x08,0x85, + 0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d,0xd2,0x81,0x1c,0xca,0xc1,0x1d,0xe8,0x61,0x4a, + 0x50,0x8c,0x58,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x61,0x1e,0xd2, + 0xe1,0x1d,0xdc,0x61,0x4a,0x60,0x8c,0xa0,0xc2,0x21,0x1d,0xe4,0xc1,0x0d,0xd8,0x21, + 0x1c,0xdc,0xe1,0x1c,0xea,0x21,0x1c,0xce,0xa1,0x1c,0x7e,0xc1,0x1e,0xca,0x41,0x1e, + 0xe6,0x21,0x1d,0xde,0xc1,0x1d,0xa6,0x04,0xc8,0x88,0x29,0x1c,0xd2,0x41,0x1e,0xdc, + 0x60,0x1c,0xde,0xa1,0x1d,0xe0,0x21,0x1d,0xd8,0xa1,0x1c,0x7e,0xe1,0x1d,0xe0,0x81, + 0x1e,0xd2,0xe1,0x1d,0xdc,0x61,0x1e,0xa6,0x0c,0x0a,0xe3,0x8c,0x50,0xc2,0x21,0x1d, + 0xe4,0xc1,0x0d,0xec,0xa1,0x1c,0xe4,0x81,0x1e,0xca,0x01,0x1f,0xa6,0x04,0x74,0x00, + 0x79,0x18,0x00,0x00,0x7b,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66, + 0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73, + 0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e, + 0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b, + 0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b, + 0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20, + 0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0, + 0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61, + 0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83, + 0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87, + 0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76, + 0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98, + 0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30, + 0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61, + 0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43, + 0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b, + 0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7, + 0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18, + 0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90, + 0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1, + 0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d, + 0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24, + 0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c, + 0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d, + 0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54, + 0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4, + 0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18, + 0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c,0xe3,0x10,0x0e,0xec,0xc0, + 0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e,0xe4,0xe1,0x17,0xd8,0xe1, + 0x1d,0xde,0x01,0x1e,0x66,0x50,0x59,0x38,0xa4,0x83,0x3c,0xb8,0x81,0x39,0xd4,0x83, + 0x3b,0x8c,0x03,0x3d,0xa4,0xc3,0x3b,0xb8,0xc3,0x2f,0x9c,0x83,0x3c,0xbc,0x43,0x3d, + 0xc0,0xc3,0x3c,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x50,0x30,0x00, + 0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x1e,0x00,0x00,0x00,0x13,0x04,0x41,0x2c, + 0x10,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xf4,0xc6,0x22,0x82,0x20,0x08,0x46,0x00, + 0xa8,0x95,0x40,0x19,0xd0,0x98,0x01,0xa0,0x30,0x03,0x00,0x00,0xe3,0x15,0x07,0x33, + 0x4d,0x0c,0x05,0x65,0x90,0x81,0x19,0x0e,0x13,0x02,0xf9,0x8c,0x57,0x2c,0xd0,0x75, + 0x21,0x14,0x94,0x41,0x06,0xe8,0x60,0x4c,0x08,0xe4,0x63,0x41,0x01,0x9f,0xf1,0x0a, + 0xa8,0xe2,0x38,0x86,0x82,0x62,0x43,0x00,0x9f,0xd9,0x06,0xa7,0x02,0x66,0x1b,0x82, + 0x2a,0x98,0x6d,0x08,0x06,0x21,0x83,0x80,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00, + 0x5b,0x86,0x20,0xc8,0x83,0x2d,0x43,0x11,0xe4,0xc1,0x96,0x41,0x09,0xf2,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const uint8_t _sspine_fs_bytecode_metal_ios[3257] = { + 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xb9,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd1,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd9,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe0,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00, + 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45, + 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0xf9,0x30,0x1b,0xe4,0xb2,0x62,0xda, + 0x23,0x88,0x1d,0xd4,0x13,0xb5,0x57,0x53,0xb9,0x44,0x7f,0x7f,0xe5,0xf3,0xc1,0xe4, + 0x19,0x37,0x0b,0xd8,0xef,0xc5,0x9b,0xf1,0x0b,0x4f,0x46,0x46,0x54,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08, + 0x00,0x01,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44, + 0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00, + 0x00,0x14,0x00,0x00,0x00,0xc0,0x0b,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0, + 0xde,0x21,0x0c,0x00,0x00,0xed,0x02,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00, + 0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32, + 0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45, + 0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44, + 0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8, + 0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00, + 0x00,0x8e,0x00,0x00,0x00,0x1b,0xcc,0x25,0xf8,0xff,0xff,0xff,0xff,0x01,0x60,0x00, + 0x09,0xa8,0x88,0x71,0x78,0x07,0x79,0x90,0x87,0x72,0x18,0x07,0x7a,0x60,0x87,0x7c, + 0x68,0x03,0x79,0x78,0x87,0x7a,0x70,0x07,0x72,0x28,0x07,0x72,0x68,0x03,0x72,0x48, + 0x07,0x7b,0x48,0x07,0x72,0x28,0x87,0x36,0x98,0x87,0x78,0x90,0x07,0x7a,0x68,0x03, + 0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xcc,0x21,0x1c,0xd8,0x61, + 0x1e,0xca,0x01,0x20,0xc8,0x21,0x1d,0xe6,0x21,0x1c,0xc4,0x81,0x1d,0xca,0xa1,0x0d, + 0xe8,0x21,0x1c,0xd2,0x81,0x1d,0xda,0x60,0x1c,0xc2,0x81,0x1d,0xd8,0x61,0x1e,0x00, + 0x73,0x08,0x07,0x76,0x98,0x87,0x72,0x00,0x08,0x76,0x28,0x87,0x79,0x98,0x87,0x36, + 0x80,0x07,0x79,0x28,0x87,0x71,0x48,0x87,0x79,0x28,0x87,0x36,0x30,0x07,0x78,0x68, + 0x87,0x70,0x20,0x07,0xc0,0x1c,0xc2,0x81,0x1d,0xe6,0xa1,0x1c,0x00,0xc2,0x1d,0xde, + 0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,0x0d,0xe0,0xe1,0x1d,0xd2,0xc1, + 0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,0xd2,0xa1,0x1d,0x00,0x7a,0x90, + 0x87,0x7a,0x28,0x07,0x60,0x70,0x87,0x77,0x68,0x03,0x73,0x90,0x87,0x70,0x68,0x87, + 0x72,0x68,0x03,0x78,0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07,0x79,0x68,0x83,0x72, + 0x60,0x87,0x74,0x68,0x87,0x36,0x70,0x87,0x77,0x70,0x87,0x36,0x60,0x87,0x72,0x08, + 0x07,0x73,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,0x30,0x87,0x79,0x68,0x03, + 0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e,0xea,0xa1, + 0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xd4,0xa1,0x1e,0xda,0x01,0x1e,0xda,0x80,0x1e, + 0xc2,0x41,0x1c,0xd8,0xa1,0x1c,0xe6,0x01,0x30,0x87,0x70,0x60,0x87,0x79,0x28,0x07, + 0x80,0x70,0x87,0x77,0x68,0x03,0x77,0x08,0x07,0x77,0x98,0x87,0x36,0x30,0x07,0x78, + 0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20, + 0xdc,0xe1,0x1d,0xda,0x60,0x1e,0xd2,0xe1,0x1c,0xdc,0xa1,0x1c,0xc8,0xa1,0x0d,0xf4, + 0xa1,0x1c,0xe4,0xe1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda,0xa0,0x1d,0xc2,0x81, + 0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0xa0, + 0x07,0x79,0x08,0x07,0x78,0x80,0x87,0x74,0x70,0x87,0x73,0x68,0x83,0x76,0x08,0x07, + 0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xe6,0x81,0x1e,0xc2,0x61, + 0x1c,0xd6,0xa1,0x0d,0xe0,0x41,0x1e,0xde,0x81,0x1e,0xca,0x61,0x1c,0xe8,0xe1,0x1d, + 0xe4,0xa1,0x0d,0xc4,0xa1,0x1e,0xcc,0xc1,0x1c,0xca,0x41,0x1e,0xda,0x60,0x1e,0xd2, + 0x41,0x1f,0xca,0x01,0xc0,0x03,0x80,0xa8,0x07,0x77,0x98,0x87,0x70,0x30,0x87,0x72, + 0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,0x41,0x1e, + 0xea,0xa1,0x1c,0x00,0xa2,0x1e,0xe6,0xa1,0x1c,0xda,0x60,0x1e,0xde,0xc1,0x1c,0xe8, + 0xa1,0x0d,0xcc,0x81,0x1d,0xde,0x21,0x1c,0xe8,0x01,0x30,0x87,0x70,0x60,0x87,0x79, + 0x28,0x07,0x60,0x03,0x22,0x0c,0x40,0x02,0x2c,0x40,0xb5,0xc1,0x18,0x08,0x60,0x01, + 0xaa,0x0d,0x06,0x51,0x00,0x0b,0x50,0x6d,0x30,0x8a,0xff,0xff,0xff,0xff,0x1f,0x00, + 0x09,0xa0,0x36,0x20,0xc6,0xff,0xff,0xff,0xff,0x0f,0x00,0x03,0x48,0x40,0xb5,0xc1, + 0x38,0x02,0x60,0x01,0xaa,0x0d,0x06,0x22,0x00,0x0b,0x50,0x01,0x00,0x49,0x18,0x00, + 0x00,0x03,0x00,0x00,0x00,0x13,0x88,0x40,0x18,0x88,0x09,0x41,0x31,0x61,0x30,0x0e, + 0x04,0x89,0x20,0x00,0x00,0x27,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85, + 0x04,0x93,0x22,0xa4,0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a, + 0x8c,0x0b,0x84,0xa4,0x4c,0x10,0x6c,0x33,0x00,0xc3,0x08,0x04,0x60,0x83,0x30,0x8c, + 0x20,0x00,0x07,0x49,0x53,0x44,0x09,0x93,0x5f,0x48,0xff,0x03,0x44,0x00,0x23,0xa1, + 0x00,0x0c,0x22,0x10,0xc2,0x51,0xd2,0x14,0x51,0xc2,0xe4,0xff,0x13,0x71,0x4d,0x54, + 0x44,0xfc,0xf6,0xf0,0x4f,0x63,0x04,0xc0,0x20,0x82,0x11,0x5c,0x24,0x4d,0x11,0x25, + 0x4c,0xfe,0x2f,0x01,0xcc,0xb3,0x10,0xd1,0x3f,0x8d,0x11,0x00,0x83,0x08,0x88,0x50, + 0x0c,0x31,0x42,0x39,0x89,0x54,0x21,0x42,0x08,0x81,0xd8,0x1c,0x41,0x30,0x47,0x00, + 0x06,0xc3,0x08,0xc2,0x53,0x90,0x70,0xd2,0x70,0xd0,0x01,0x8a,0x03,0x01,0x29,0xf0, + 0x86,0x11,0x86,0x67,0x18,0x61,0x00,0x86,0x11,0x88,0x67,0x8e,0x00,0x14,0x06,0x11, + 0x00,0x61,0x04,0x00,0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83, + 0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37, + 0x80,0x03,0x37,0x80,0x83,0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80, + 0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06, + 0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9, + 0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60, + 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07, + 0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74, + 0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0, + 0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07, + 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73, + 0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40, + 0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07, + 0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78, + 0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10, + 0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07, + 0x72,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6, + 0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60, + 0x07,0x6d,0x60,0x0f,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07, + 0x75,0x10,0x07,0x72,0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71, + 0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80, + 0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x98,0x05,0x00,0x80,0x00, + 0x00,0x00,0x00,0x00,0x80,0x21,0x4c,0x03,0x04,0x80,0x00,0x00,0x00,0x00,0x00,0xc0, + 0x10,0x46,0x02,0x02,0x60,0x00,0x00,0x00,0x00,0x00,0x20,0x0b,0x04,0x09,0x00,0x00, + 0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43, + 0x7a,0x23,0x00,0x25,0x50,0x08,0x45,0x50,0x10,0x65,0x40,0x78,0x04,0x80,0xe8,0x58, + 0x02,0x04,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0xfa,0x00,0x00,0x00,0x1a,0x03,0x4c, + 0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x63, + 0x4c,0x00,0xa5,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62, + 0x3c,0xc4,0x24,0x3c,0x05,0xe7,0x20,0x08,0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e, + 0x8c,0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x26,0x06,0x06,0x26,0xc6, + 0xc5,0x86,0x66,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x26,0x06, + 0x06,0x26,0xc6,0xc5,0x86,0x66,0xc6,0x85,0x26,0x65,0x88,0x30,0x11,0x43,0x8c,0x87, + 0x78,0x8e,0x67,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x99,0x8e,0x87,0x78,0x86, + 0x67,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56, + 0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x98, + 0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61, + 0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x84, + 0x69,0x21,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98, + 0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1, + 0x7d,0x95,0xb9,0x85,0x89,0xb1,0x95,0x0d,0x11,0xa6,0x86,0x51,0x58,0x9a,0x9c,0x8b, + 0x5c,0x99,0x1b,0x59,0x99,0xdc,0x17,0x5d,0x98,0xdc,0x59,0x19,0x1d,0xa3,0xb0,0x34, + 0x39,0x97,0x30,0xb9,0xb3,0x2f,0xba,0x3c,0xb8,0xb2,0x2f,0xb7,0xb0,0xb6,0x32,0x1a, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x64,0xc2,0xd2,0xe4,0x5c,0xc2,0xe4,0xce,0xbe,0xdc, + 0xc2,0xda,0xca,0xa8,0x98,0xc9,0x85,0x9d,0x7d,0x8d,0xbd,0xb1,0xbd,0xc9,0x0d,0x61, + 0xa6,0xe7,0x19,0x26,0x68,0x8a,0x26,0x69,0x9a,0x86,0x08,0x13,0x45,0x29,0x2c,0x4d, + 0xce,0xc5,0x4c,0x2e,0xec,0xac,0xad,0xcc,0x8d,0xee,0x2b,0xcd,0x0d,0xae,0x8e,0x8e, + 0x4b,0xdd,0x5c,0x99,0x1c,0x0a,0xdb,0xdb,0x98,0x1b,0x4c,0x0a,0x95,0xb0,0x34,0x39, + 0x97,0xb1,0x32,0x37,0xba,0x32,0x39,0x3e,0x61,0x69,0x72,0x2e,0x70,0x65,0x72,0x73, + 0x70,0x65,0x63,0x74,0x69,0x76,0x65,0x34,0xcc,0xd8,0xde,0xc2,0xe8,0x64,0x28,0xd4, + 0xd9,0x0d,0x91,0x9e,0x61,0xb2,0xa6,0x6b,0xc2,0xa6,0x6c,0x82,0x26,0x6d,0x92,0xa6, + 0x8d,0x4b,0xdd,0x5c,0x99,0x1c,0x0a,0xdb,0xdb,0x98,0x5b,0x4c,0x0a,0x8b,0xb1,0x37, + 0xb6,0x37,0xb9,0x21,0xd2,0x43,0x4c,0xd6,0xd4,0x4d,0xd8,0x94,0x4d,0xd0,0x14,0x4d, + 0xd2,0xe4,0x51,0x09,0x4b,0x93,0x73,0x11,0xab,0x33,0x33,0x2b,0x93,0xe3,0x13,0x96, + 0x26,0xe7,0x22,0x56,0x67,0x66,0x56,0x26,0xf7,0x35,0x97,0xa6,0x57,0x46,0x29,0x2c, + 0x4d,0xce,0x85,0xed,0x6d,0x2c,0x8c,0x2e,0xed,0xcd,0xed,0x2b,0xcd,0x8d,0xac,0x0c, + 0x8f,0x48,0x58,0x9a,0x9c,0x8b,0x5c,0x59,0x18,0x19,0xa9,0xb0,0x34,0x39,0x97,0x39, + 0x3a,0xb9,0xba,0x31,0xba,0x2f,0xba,0x3c,0xb8,0xb2,0xaf,0x34,0x37,0xb3,0x37,0x16, + 0x66,0x6c,0x6f,0x61,0x74,0x1c,0xe0,0xda,0xc2,0x86,0x28,0xcf,0xf0,0x14,0xcf,0x30, + 0x95,0xc1,0x64,0x06,0x8c,0xc2,0xd2,0xe4,0x5c,0xc2,0xe4,0xce,0xbe,0xe8,0xf2,0xe0, + 0xca,0xbe,0xe6,0xd2,0xf4,0xca,0x78,0x85,0xa5,0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xd1, + 0xe5,0xc1,0x95,0x7d,0x85,0xb1,0xa5,0x9d,0xb9,0x7d,0xcd,0xa5,0xe9,0x95,0x31,0x31, + 0x9b,0xfb,0x82,0x0b,0x93,0x0b,0x6b,0x9b,0xe3,0xf0,0x55,0x03,0x33,0x84,0x0c,0x1e, + 0x63,0x02,0x83,0x29,0x0c,0x9e,0x62,0x12,0x83,0x67,0x78,0x88,0x69,0x0c,0x26,0x32, + 0x98,0xce,0x60,0x42,0x83,0xa7,0x98,0xd2,0xe0,0x29,0x26,0x68,0x52,0x83,0x49,0x9a, + 0xd6,0x80,0x4b,0x58,0x9a,0x9c,0x0b,0x5d,0x19,0x1e,0x5d,0x9d,0x5c,0x19,0x95,0xb0, + 0x34,0x39,0x97,0xb9,0xb0,0x36,0x38,0xb6,0x32,0x62,0x74,0x65,0x78,0x74,0x75,0x72, + 0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c, + 0x65,0x3e,0x1c,0xe8,0xca,0xf0,0x86,0x50,0x0f,0x32,0xb5,0xc1,0x24,0x06,0xcf,0xf0, + 0x10,0x93,0x1b,0x4c,0xd0,0xf4,0x06,0x93,0x34,0xc1,0x01,0x97,0xb0,0x34,0x39,0x97, + 0xb9,0xb0,0x36,0x38,0xb6,0x32,0x39,0x1e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x44, + 0xe8,0xca,0xf0,0xa6,0xda,0xe0,0xd8,0xe4,0x86,0x48,0x4f,0x31,0xc9,0xc1,0x24,0x06, + 0xcf,0xf0,0x10,0x13,0x34,0xcd,0xc1,0x24,0x4d,0x74,0x30,0x44,0x99,0xb8,0xe9,0x9b, + 0xd8,0x60,0x8a,0x83,0xa9,0x0e,0x86,0x18,0x0b,0x30,0x55,0x93,0x1d,0xd0,0xf9,0xd2, + 0xa2,0x9a,0xca,0x31,0x9b,0xfb,0x82,0x0b,0x93,0x0b,0x6b,0x9b,0xe3,0xf3,0xd6,0xe6, + 0x96,0x06,0xf7,0x46,0x57,0xe6,0x46,0x07,0x32,0x86,0x16,0x26,0xc7,0x67,0x2a,0xad, + 0x0d,0x8e,0xad,0x0c,0x64,0x68,0x65,0x05,0x84,0x4a,0x28,0x28,0x68,0x88,0x30,0xe9, + 0xc1,0x10,0x63,0xca,0x83,0x69,0x0f,0xb0,0x64,0x88,0x31,0x95,0xc1,0xc4,0x07,0x58, + 0x32,0xc4,0x98,0xf0,0x60,0xea,0x03,0x2c,0x19,0x62,0x4c,0x7e,0x30,0xf5,0x01,0x96, + 0x8c,0x88,0xd8,0x81,0x1d,0xec,0xa1,0x1d,0xdc,0xa0,0x1d,0xde,0x81,0x1c,0xea,0x81, + 0x1d,0xca,0xc1,0x0d,0xcc,0x81,0x1d,0xc2,0xe1,0x1c,0xe6,0x61,0x8a,0x10,0x0c,0x23, + 0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x48,0x07,0x72,0x28,0x07,0x77,0xa0,0x87, + 0x29,0x41,0x31,0x62,0x09,0x87,0x74,0x90,0x07,0x37,0xb0,0x87,0x72,0x90,0x87,0x79, + 0x48,0x87,0x77,0x70,0x87,0x29,0x81,0x31,0x82,0x0a,0x87,0x74,0x90,0x07,0x37,0x60, + 0x87,0x70,0x70,0x87,0x73,0xa8,0x87,0x70,0x38,0x87,0x72,0xf8,0x05,0x7b,0x28,0x07, + 0x79,0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12,0x20,0x23,0xa6,0x70,0x48,0x07,0x79, + 0x70,0x83,0x71,0x78,0x87,0x76,0x80,0x87,0x74,0x60,0x87,0x72,0xf8,0x85,0x77,0x80, + 0x07,0x7a,0x48,0x87,0x77,0x70,0x87,0x79,0x98,0x32,0x28,0x8c,0x33,0x82,0x09,0x87, + 0x74,0x90,0x07,0x37,0x30,0x07,0x79,0x08,0x87,0x73,0x68,0x87,0x72,0x70,0x07,0x7a, + 0x98,0x12,0xdc,0x01,0x00,0x79,0x18,0x00,0x00,0x7b,0x00,0x00,0x00,0x33,0x08,0x80, + 0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80, + 0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80, + 0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88, + 0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78, + 0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03, + 0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f, + 0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c, + 0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39, + 0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b, + 0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60, + 0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87, + 0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e, + 0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c, + 0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6, + 0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94, + 0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03, + 0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07, + 0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f, + 0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33, + 0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc, + 0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c, + 0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78, + 0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca, + 0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21, + 0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43, + 0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87, + 0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c, + 0xe3,0x10,0x0e,0xec,0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e, + 0xe4,0xe1,0x17,0xd8,0xe1,0x1d,0xde,0x01,0x1e,0x66,0x50,0x59,0x38,0xa4,0x83,0x3c, + 0xb8,0x81,0x39,0xd4,0x83,0x3b,0x8c,0x03,0x3d,0xa4,0xc3,0x3b,0xb8,0xc3,0x2f,0x9c, + 0x83,0x3c,0xbc,0x43,0x3d,0xc0,0xc3,0x3c,0x00,0x71,0x20,0x00,0x00,0x0b,0x00,0x00, + 0x00,0x26,0xb0,0x01,0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45, + 0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20,0x0d,0x6d,0x01,0x0d, + 0x80,0x44,0x3e,0x83,0x5c,0x7e,0x85,0x17,0xb7,0x0d,0x00,0x00,0x00,0x61,0x20,0x00, + 0x00,0x25,0x00,0x00,0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x0c,0x00,0x00, + 0x00,0x74,0x47,0x00,0xc6,0x22,0x80,0x40,0x38,0xe6,0x20,0x06,0xc2,0xa8,0xc8,0xd5, + 0xc0,0x08,0x00,0xbd,0x19,0x00,0x82,0x23,0x00,0x54,0xc7,0x1a,0x80,0x40,0x18,0x6b, + 0x18,0x86,0x81,0xec,0x0c,0x00,0x89,0x19,0x00,0x0a,0x33,0x00,0x04,0x46,0x00,0x00, + 0x00,0x23,0x06,0xca,0x10,0x6c,0x8f,0x23,0x29,0x47,0x12,0x58,0x20,0xc9,0x67,0x90, + 0x21,0x20,0x90,0x41,0x06,0xa1,0x40,0x4c,0x08,0xe4,0x33,0xc8,0x10,0x24,0xd0,0x20, + 0x43,0x50,0x48,0x16,0x60,0xf2,0x19,0x6f,0xc0,0x38,0x31,0xa0,0x60,0xcc,0x31,0x30, + 0x01,0x19,0x0c,0x32,0x04,0x0d,0x36,0x62,0x60,0x08,0x01,0x1a,0x2c,0x45,0x30,0xdb, + 0x00,0x05,0x40,0x06,0x01,0x31,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x5b,0x86,0x24, + 0xf8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; +static const char _sspine_vs_source_metal_sim[716] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x7d,0x3b,0x0a, + 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75, + 0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75, + 0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d, + 0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31, + 0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f, + 0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74, + 0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28, + 0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32, + 0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74, + 0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x5b, + 0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x35,0x20,0x22,0x73, + 0x73,0x70,0x69,0x6e,0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x76,0x65,0x72,0x74, + 0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69, + 0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b, + 0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e, + 0x73,0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26, + 0x20,0x5f,0x32,0x31,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29, + 0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c, + 0x69,0x6e,0x65,0x20,0x31,0x35,0x20,0x22,0x73,0x73,0x70,0x69,0x6e,0x65,0x2e,0x67, + 0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f, + 0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x32,0x31,0x2e,0x6d, + 0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e, + 0x30,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x36,0x20,0x22,0x73,0x73, + 0x70,0x69,0x6e,0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f, + 0x75,0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f, + 0x6f,0x72,0x64,0x30,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22, + 0x73,0x73,0x70,0x69,0x6e,0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20, + 0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e, + 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75, + 0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +static const char _sspine_fs_source_metal_sim[721] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x66, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x70,0x6d,0x61,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74, + 0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30, + 0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20, + 0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28, + 0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65, + 0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a, + 0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x34,0x20,0x22,0x73,0x73,0x70,0x69,0x6e,0x65, + 0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20, + 0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28, + 0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74, + 0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61, + 0x6e,0x74,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x35, + 0x30,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c, + 0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74, + 0x3e,0x20,0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28, + 0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x65, + 0x78,0x53,0x6d,0x70,0x6c,0x72,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72, + 0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69, + 0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b, + 0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x34,0x20,0x22,0x73,0x73,0x70,0x69,0x6e, + 0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x34,0x20,0x5f,0x32,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x28,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x69,0x6e, + 0x2e,0x75,0x76,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x3b, + 0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x35,0x20,0x22,0x73,0x73,0x70,0x69,0x6e, + 0x65,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x20,0x5f,0x33,0x34,0x20,0x3d,0x20,0x5f,0x32,0x35,0x2e,0x77,0x3b,0x0a,0x23, + 0x6c,0x69,0x6e,0x65,0x20,0x31,0x36,0x20,0x22,0x73,0x73,0x70,0x69,0x6e,0x65,0x2e, + 0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f, + 0x32,0x35,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x32,0x35,0x2e,0x78, + 0x79,0x7a,0x20,0x2a,0x20,0x5f,0x33,0x34,0x2c,0x20,0x5f,0x33,0x34,0x29,0x20,0x2a, + 0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x34,0x28,0x5f,0x35,0x30,0x2e,0x70,0x6d,0x61,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a, + 0x00, +}; +#elif defined(SOKOL_WGPU) +#error "FIXME: wgpu shaders" +#elif defined(SOKOL_DUMMY_BACKEND) +static const char* _sspine_vs_source_dummy = ""; +static const char* _sspine_fs_source_dummy = ""; +#else +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#endif + +// ███████ ████████ ██████ ██ ██ ██████ ████████ ███████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██ ██████ ██ ██ ██ ██ ███████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██ ██ ██ ██████ ██████ ██ ███████ +// +// >>structs + +#define _sspine_def(val, def) (((val) == 0) ? (def) : (val)) +#define _SSPINE_INIT_COOKIE (0xABBAABBA) +#define _SSPINE_INVALID_SLOT_INDEX (0) +#define _SSPINE_DEFAULT_CONTEXT_POOL_SIZE (4) +#define _SSPINE_DEFAULT_ATLAS_POOL_SIZE (64) +#define _SSPINE_DEFAULT_SKELETON_POOL_SIZE (64) +#define _SSPINE_DEFAULT_SKINSET_POOL_SIZE (64) +#define _SSPINE_DEFAULT_INSTANCE_POOL_SIZE (1024) +#define _SSPINE_DEFAULT_MAX_VERTICES (1<<16) +#define _SSPINE_DEFAULT_MAX_COMMANDS (1<<14) +#define _SSPINE_MAX_TRIGGERED_EVENTS (16) +#define _SSPINE_SLOT_SHIFT (16) +#define _SSPINE_MAX_POOL_SIZE (1<<_SSPINE_SLOT_SHIFT) +#define _SSPINE_SLOT_MASK (_SSPINE_MAX_POOL_SIZE-1) + +typedef struct { + float mvp[16]; +} _sspine_vsparams_t; + +typedef struct { + float pma; + uint8_t _pad[12]; +} _sspine_fsparams_t; + +typedef struct { + uint32_t id; + sspine_resource_state state; +} _sspine_slot_t; + +typedef struct { + int size; + int queue_top; + uint32_t* gen_ctrs; + int* free_queue; +} _sspine_pool_t; + +typedef struct { + _sspine_slot_t slot; + sspine_atlas_overrides overrides; + spAtlas* sp_atlas; + int num_pages; +} _sspine_atlas_t; + +typedef struct { + _sspine_pool_t pool; + _sspine_atlas_t* items; +} _sspine_atlas_pool_t; + +typedef struct { + uint32_t id; + _sspine_atlas_t* ptr; +} _sspine_atlas_ref_t; + +typedef struct { + _sspine_slot_t slot; + _sspine_atlas_ref_t atlas; + spSkeletonData* sp_skel_data; + spAnimationStateData* sp_anim_data; + struct { + int cap; + sspine_vec2* ptr; + } tform_buf; +} _sspine_skeleton_t; + +typedef struct { + _sspine_pool_t pool; + _sspine_skeleton_t* items; +} _sspine_skeleton_pool_t; + +typedef struct { + uint32_t id; + _sspine_skeleton_t* ptr; +} _sspine_skeleton_ref_t; + +typedef struct { + _sspine_slot_t slot; + _sspine_skeleton_ref_t skel; + spSkin* sp_skin; +} _sspine_skinset_t; + +typedef struct { + _sspine_pool_t pool; + _sspine_skinset_t* items; +} _sspine_skinset_pool_t; + +typedef struct { + uint32_t id; + _sspine_skinset_t* ptr; +} _sspine_skinset_ref_t; + +typedef struct { + _sspine_slot_t slot; + _sspine_atlas_ref_t atlas; + _sspine_skeleton_ref_t skel; + _sspine_skinset_ref_t skinset; + spSkeleton* sp_skel; + spAnimationState* sp_anim_state; + spSkeletonClipping* sp_clip; + int cur_triggered_event_index; + sspine_triggered_event_info triggered_events[_SSPINE_MAX_TRIGGERED_EVENTS]; +} _sspine_instance_t; + +typedef struct { + _sspine_pool_t pool; + _sspine_instance_t* items; +} _sspine_instance_pool_t; + +typedef struct { + sspine_vec2 pos; + sspine_vec2 uv; + uint32_t color; +} _sspine_vertex_t; + +typedef struct { + _sspine_vertex_t* ptr; + int index; +} _sspine_alloc_vertices_result_t; + +typedef struct { + uint32_t* ptr; + int index; +} _sspine_alloc_indices_result_t; + +typedef struct { + int layer; + sg_pipeline pip; + sg_image img; + float pma; // pma = 0.0: use texture color as is, pma = 1.0: multiply texture rgb by texture alpha in fragment shader + int base_element; + int num_elements; +} _sspine_command_t; + +typedef struct { + _sspine_slot_t slot; + float transform[16]; + struct { + int cap; + int next; + uint32_t rewind_frame_id; + _sspine_vertex_t* ptr; + } vertices; + struct { + int cap; + int next; + uint32_t rewind_frame_id; + uint32_t* ptr; + } indices; + struct { + int cap; + int next; + uint32_t rewind_frame_id; + _sspine_command_t* ptr; + } commands; + uint32_t update_frame_id; + sg_buffer vbuf; + sg_buffer ibuf; + struct { + sg_pipeline normal_additive; + sg_pipeline multiply; + } pip; + sg_bindings bind; +} _sspine_context_t; + +typedef struct { + _sspine_pool_t pool; + _sspine_context_t* items; +} _sspine_context_pool_t; + +typedef struct { + uint32_t init_cookie; + uint32_t frame_id; + sspine_desc desc; + sspine_context def_ctx_id; + sspine_context cur_ctx_id; + _sspine_context_t* cur_ctx; // may be 0! + sg_shader shd; + _sspine_context_pool_t context_pool; + _sspine_atlas_pool_t atlas_pool; + _sspine_skeleton_pool_t skeleton_pool; + _sspine_skinset_pool_t skinset_pool; + _sspine_instance_pool_t instance_pool; +} _sspine_t; +static _sspine_t _sspine; + +// dummy spine-c platform implementation functions +#if defined(__cplusplus) +extern "C" { +#endif +void _spAtlasPage_createTexture(spAtlasPage* self, const char* path) { + // nothing to do here + (void)self; (void)path; +} + +void _spAtlasPage_disposeTexture(spAtlasPage* self) { + if (self->rendererObject != 0) { + const sg_image img = { (uint32_t)(uintptr_t)self->rendererObject }; + sg_destroy_image(img); + } +} + +char* _spUtil_readFile(const char* path, int* length) { + (void)path; + *length = 0; + return 0; +} +#if defined(__cplusplus) +} // extern "C" +#endif + +// ██ ██████ ██████ ██████ ██ ███ ██ ██████ +// ██ ██ ██ ██ ██ ██ ████ ██ ██ +// ██ ██ ██ ██ ███ ██ ███ ██ ██ ██ ██ ██ ███ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██████ ██████ ██████ ██ ██ ████ ██████ +// +// >>logging +#if defined(SOKOL_DEBUG) +#define _SSPINE_LOGITEM_XMACRO(item,msg) #item ": " msg, +static const char* _sspine_log_messages[] = { + _SSPINE_LOG_ITEMS +}; +#undef _SSPINE_LOGITEM_XMACRO +#endif // SOKOL_DEBUG + +#define _SSPINE_PANIC(code) _sspine_log(SSPINE_LOGITEM_ ##code, 0, __LINE__) +#define _SSPINE_ERROR(code) _sspine_log(SSPINE_LOGITEM_ ##code, 1, __LINE__) +#define _SSPINE_WARN(code) _sspine_log(SSPINE_LOGITEM_ ##code, 2, __LINE__) +#define _SSPINE_INFO(code) _sspine_log(SSPINE_LOGITEM_ ##code, 3, __LINE__) + +static void _sspine_log(sspine_log_item log_item, uint32_t log_level, uint32_t line_nr) { + if (_sspine.desc.logger.func) { + #if defined(SOKOL_DEBUG) + const char* filename = __FILE__; + const char* message = _sspine_log_messages[log_item]; + #else + const char* filename = 0; + const char* message = 0; + #endif + _sspine.desc.logger.func("sspine", log_level, log_item, message, line_nr, filename, _sspine.desc.logger.user_data); + } + else { + // for log level PANIC it would be 'undefined behaviour' to continue + if (log_level == 0) { + abort(); + } + } +} + +// ███ ███ ███████ ███ ███ ██████ ██████ ██ ██ +// ████ ████ ██ ████ ████ ██ ██ ██ ██ ██ ██ +// ██ ████ ██ █████ ██ ████ ██ ██ ██ ██████ ████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ███████ ██ ██ ██████ ██ ██ ██ +// +// >>memory +static void _sspine_clear(void* ptr, size_t size) { + SOKOL_ASSERT(ptr && (size > 0)); + memset(ptr, 0, size); +} + +/* Copy a string into a fixed size buffer with guaranteed zero- + termination. + + Return false if the string didn't fit into the buffer and had to be clamped. + + FIXME: Currently UTF-8 strings might become invalid if the string + is clamped, because the last zero-byte might be written into + the middle of a multi-byte sequence. +*/ +static bool _sspine_strcpy(const char* src, char* dst, int max_len) { + SOKOL_ASSERT(src && dst && (max_len > 0)); + char* const end = &(dst[max_len-1]); + char c = 0; + for (int i = 0; i < max_len; i++) { + c = *src; + if (c != 0) { + src++; + } + *dst++ = c; + } + // truncated? + if (c != 0) { + *end = 0; + return false; + } + else { + return true; + } +} + +static sspine_string _sspine_string(const char* cstr) { + sspine_string res; + _sspine_clear(&res, sizeof(res)); + if (cstr) { + res.valid = true; + res.truncated = !_sspine_strcpy(cstr, res.cstr, sizeof(res.cstr)); + res.len = (uint8_t)strlen(res.cstr); + } + return res; +} + +static void* _sspine_malloc(size_t size) { + SOKOL_ASSERT(size > 0); + void* ptr; + if (_sspine.desc.allocator.alloc) { + ptr = _sspine.desc.allocator.alloc(size, _sspine.desc.allocator.user_data); + } + else { + ptr = malloc(size); + } + if (0 == ptr) { + _SSPINE_PANIC(MALLOC_FAILED); + } + return ptr; +} + +static void* _sspine_malloc_clear(size_t size) { + void* ptr = _sspine_malloc(size); + _sspine_clear(ptr, size); + return ptr; +} + +static void _sspine_free(void* ptr) { + if (_sspine.desc.allocator.free) { + _sspine.desc.allocator.free(ptr, _sspine.desc.allocator.user_data); + } + else { + free(ptr); + } +} + +// ██████ ███████ ███████ ███████ +// ██ ██ ██ ██ ██ +// ██████ █████ █████ ███████ +// ██ ██ ██ ██ ██ +// ██ ██ ███████ ██ ███████ +// +// >>refs +static bool _sspine_atlas_ref_valid(const _sspine_atlas_ref_t* ref) { + return ref->ptr && (ref->ptr->slot.id == ref->id); +} + +static bool _sspine_skeleton_ref_valid(const _sspine_skeleton_ref_t* ref) { + return ref->ptr && (ref->ptr->slot.id == ref->id); +} + +static bool _sspine_skinset_ref_valid(const _sspine_skinset_ref_t* ref) { + return ref->ptr && (ref->ptr->slot.id == ref->id); +} + +static bool _sspine_skeleton_and_deps_valid(_sspine_skeleton_t* skeleton) { + return skeleton && _sspine_atlas_ref_valid(&skeleton->atlas); +} + +static bool _sspine_skinset_and_deps_valid(_sspine_skinset_t* skinset) { + return skinset && _sspine_skeleton_ref_valid(&skinset->skel); +} + +static bool _sspine_instance_and_deps_valid(_sspine_instance_t* instance) { + return instance && + _sspine_atlas_ref_valid(&instance->atlas) && + _sspine_skeleton_ref_valid(&instance->skel) && + ((instance->skinset.id == SSPINE_INVALID_ID) || _sspine_skinset_ref_valid(&instance->skinset)); +} + +static sspine_image _sspine_image(uint32_t atlas_id, int index) { + sspine_image img = { atlas_id, index }; + return img; +} + +static sspine_atlas_page _sspine_atlas_page(uint32_t atlas_id, int index) { + sspine_atlas_page page = { atlas_id, index }; + return page; +} + +static sspine_anim _sspine_anim(uint32_t skeleton_id, int index) { + sspine_anim anim = { skeleton_id, index }; + return anim; +} + +static sspine_bone _sspine_bone(uint32_t skeleton_id, int index) { + sspine_bone bone = { skeleton_id, index }; + return bone; +} + +static sspine_slot _sspine_slot(uint32_t skeleton_id, int index) { + sspine_slot slot = { skeleton_id, index }; + return slot; +} + +static sspine_event _sspine_event(uint32_t skeleton_id, int index) { + sspine_event event = { skeleton_id, index }; + return event; +} + +static sspine_iktarget _sspine_iktarget(uint32_t skeleton_id, int index) { + sspine_iktarget iktarget = { skeleton_id, index }; + return iktarget; +} + +static sspine_skin _sspine_skin(uint32_t skeleton_id, int index) { + sspine_skin skin = { skeleton_id, index }; + return skin; +} + +// ██████ ██████ ██████ ██ +// ██ ██ ██ ██ ██ ██ ██ +// ██████ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ +// ██ ██████ ██████ ███████ +// +// >>pool +static void _sspine_init_pool(_sspine_pool_t* pool, int num) { + SOKOL_ASSERT(pool && (num >= 1)); + // slot 0 is reserved for the 'invalid id', so bump the pool size by 1 + pool->size = num + 1; + pool->queue_top = 0; + // generation counters indexable by pool slot index, slot 0 is reserved + size_t gen_ctrs_size = sizeof(uint32_t) * (size_t)pool->size; + pool->gen_ctrs = (uint32_t*) _sspine_malloc_clear(gen_ctrs_size); + // it's not a bug to only reserve 'num' here + pool->free_queue = (int*) _sspine_malloc_clear(sizeof(int) * (size_t)num); + // never allocate the zero-th pool item since the invalid id is 0 + for (int i = pool->size-1; i >= 1; i--) { + pool->free_queue[pool->queue_top++] = i; + } +} + +static void _sspine_discard_pool(_sspine_pool_t* pool) { + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + _sspine_free(pool->free_queue); + pool->free_queue = 0; + SOKOL_ASSERT(pool->gen_ctrs); + _sspine_free(pool->gen_ctrs); + pool->gen_ctrs = 0; + pool->size = 0; + pool->queue_top = 0; +} + +static int _sspine_pool_alloc_index(_sspine_pool_t* pool) { + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + if (pool->queue_top > 0) { + int slot_index = pool->free_queue[--pool->queue_top]; + SOKOL_ASSERT((slot_index > 0) && (slot_index < pool->size)); + return slot_index; + } + else { + // pool exhausted + return _SSPINE_INVALID_SLOT_INDEX; + } +} + +static void _sspine_pool_free_index(_sspine_pool_t* pool, int slot_index) { + SOKOL_ASSERT((slot_index > _SSPINE_INVALID_SLOT_INDEX) && (slot_index < pool->size)); + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + SOKOL_ASSERT(pool->queue_top < pool->size); + #ifdef SOKOL_DEBUG + // debug check against double-free + for (int i = 0; i < pool->queue_top; i++) { + SOKOL_ASSERT(pool->free_queue[i] != slot_index); + } + #endif + pool->free_queue[pool->queue_top++] = slot_index; + SOKOL_ASSERT(pool->queue_top <= (pool->size-1)); +} + +/* initiailize a pool slot: + - bump the slot's generation counter + - create a resource id from the generation counter and slot index + - set the slot's id to this id + - set the slot's state to ALLOC + - return the handle id +*/ +static uint32_t _sspine_slot_init(_sspine_pool_t* pool, _sspine_slot_t* slot, int slot_index) { + /* FIXME: add handling for an overflowing generation counter, + for now, just overflow (another option is to disable + the slot) + */ + SOKOL_ASSERT(pool && pool->gen_ctrs); + SOKOL_ASSERT((slot_index > _SSPINE_INVALID_SLOT_INDEX) && (slot_index < pool->size)); + SOKOL_ASSERT((slot->state == SSPINE_RESOURCESTATE_INITIAL) && (slot->id == SSPINE_INVALID_ID)); + uint32_t ctr = ++pool->gen_ctrs[slot_index]; + slot->id = (ctr<<_SSPINE_SLOT_SHIFT)|(slot_index & _SSPINE_SLOT_MASK); + slot->state = SSPINE_RESOURCESTATE_ALLOC; + return slot->id; +} + +// extract slot index from id +static int _sspine_slot_index(uint32_t id) { + int slot_index = (int) (id & _SSPINE_SLOT_MASK); + SOKOL_ASSERT(_SSPINE_INVALID_SLOT_INDEX != slot_index); + return slot_index; +} + +static void _sspine_init_item_pool(_sspine_pool_t* pool, int pool_size, void** items_ptr, size_t item_size_bytes) { + // NOTE: the pools will have an additional item, since slot 0 is reserved + SOKOL_ASSERT(pool && (pool->size == 0)); + SOKOL_ASSERT((pool_size > 0) && (pool_size < _SSPINE_MAX_POOL_SIZE)); + SOKOL_ASSERT(items_ptr && (*items_ptr == 0)); + SOKOL_ASSERT(item_size_bytes > 0); + _sspine_init_pool(pool, pool_size); + const size_t pool_size_bytes = item_size_bytes * (size_t)pool->size; + *items_ptr = _sspine_malloc_clear(pool_size_bytes); +} + +static void _sspine_discard_item_pool(_sspine_pool_t* pool, void** items_ptr) { + SOKOL_ASSERT(pool && (pool->size != 0)); + SOKOL_ASSERT(items_ptr && (*items_ptr != 0)); + _sspine_free(*items_ptr); *items_ptr = 0; + _sspine_discard_pool(pool); +} + +// ██████ ██████ ███ ██ ████████ ███████ ██ ██ ████████ +// ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ █████ ███ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██████ ██████ ██ ████ ██ ███████ ██ ██ ██ +// +// >>context +static void _sspine_setup_context_pool(int pool_size) { + _sspine_context_pool_t* p = &_sspine.context_pool; + _sspine_init_item_pool(&p->pool, pool_size, (void**)&p->items, sizeof(_sspine_context_t)); +} + +static void _sspine_discard_context_pool(void) { + _sspine_context_pool_t* p = &_sspine.context_pool; + _sspine_discard_item_pool(&p->pool, (void**)&p->items); +} + +static sspine_context _sspine_make_context_handle(uint32_t id) { + sspine_context handle = { id }; + return handle; +} + +static _sspine_context_t* _sspine_context_at(uint32_t id) { + SOKOL_ASSERT(SSPINE_INVALID_ID != id); + const _sspine_context_pool_t* p = &_sspine.context_pool; + int slot_index = _sspine_slot_index(id); + SOKOL_ASSERT((slot_index > _SSPINE_INVALID_SLOT_INDEX) && (slot_index < p->pool.size)); + return &p->items[slot_index]; +} + +static _sspine_context_t* _sspine_lookup_context(uint32_t id) { + if (SSPINE_INVALID_ID != id) { + _sspine_context_t* ctx = _sspine_context_at(id); + if (ctx->slot.id == id) { + return ctx; + } + } + return 0; +} + +static sspine_context _sspine_alloc_context(void) { + _sspine_context_pool_t* p = &_sspine.context_pool; + int slot_index = _sspine_pool_alloc_index(&p->pool); + if (_SSPINE_INVALID_SLOT_INDEX != slot_index) { + uint32_t id = _sspine_slot_init(&p->pool, &p->items[slot_index].slot, slot_index); + return _sspine_make_context_handle(id); + } + else { + // pool exhausted + return _sspine_make_context_handle(SSPINE_INVALID_ID); + } +} + +static sspine_resource_state _sspine_init_context(_sspine_context_t* ctx, const sspine_context_desc* desc) { + SOKOL_ASSERT(ctx && (ctx->slot.state == SSPINE_RESOURCESTATE_ALLOC)); + SOKOL_ASSERT(desc); + + // setup vertex, index and command storage + ctx->vertices.cap = desc->max_vertices; + ctx->indices.cap = ctx->vertices.cap * 3; + ctx->commands.cap = desc->max_commands; + + const size_t vbuf_size = (size_t)ctx->vertices.cap * sizeof(_sspine_vertex_t); + const size_t ibuf_size = (size_t)ctx->indices.cap * sizeof(uint32_t); + const size_t cbuf_size = (size_t)ctx->commands.cap * sizeof(_sspine_command_t); + + ctx->vertices.ptr = (_sspine_vertex_t*) _sspine_malloc(vbuf_size); + ctx->indices.ptr = (uint32_t*) _sspine_malloc(ibuf_size); + ctx->commands.ptr = (_sspine_command_t*) _sspine_malloc(cbuf_size); + + sg_buffer_desc vbuf_desc; + _sspine_clear(&vbuf_desc, sizeof(vbuf_desc)); + vbuf_desc.type = SG_BUFFERTYPE_VERTEXBUFFER; + vbuf_desc.usage = SG_USAGE_STREAM; + vbuf_desc.size = vbuf_size; + vbuf_desc.label = "sspine-vbuf"; + ctx->vbuf = sg_make_buffer(&vbuf_desc); + ctx->bind.vertex_buffers[0] = ctx->vbuf; + + sg_buffer_desc ibuf_desc; + _sspine_clear(&ibuf_desc, sizeof(ibuf_desc)); + ibuf_desc.type = SG_BUFFERTYPE_INDEXBUFFER; + ibuf_desc.usage = SG_USAGE_STREAM; + ibuf_desc.size = ibuf_size; + ibuf_desc.label = "sspine-ibuf"; + ctx->ibuf = sg_make_buffer(&ibuf_desc); + ctx->bind.index_buffer = ctx->ibuf; + + // for blend modes, see: https://wiki.libsdl.org/SDL_BlendMode + // + // NOTE: we're configuring the blend mode for premultiplied alpha, + // and then do the premultiplication in the fragment shader + // if needed + sg_pipeline_desc pip_desc; + _sspine_clear(&pip_desc, sizeof(pip_desc)); + pip_desc.shader = _sspine.shd; + pip_desc.layout.buffers[0].stride = sizeof(_sspine_vertex_t); + pip_desc.layout.attrs[0].format = SG_VERTEXFORMAT_FLOAT2; + pip_desc.layout.attrs[1].format = SG_VERTEXFORMAT_FLOAT2; + pip_desc.layout.attrs[2].format = SG_VERTEXFORMAT_UBYTE4N; + pip_desc.index_type = SG_INDEXTYPE_UINT32; + pip_desc.sample_count = desc->sample_count; + pip_desc.depth.pixel_format = desc->depth_format; + pip_desc.colors[0].pixel_format = desc->color_format; + pip_desc.colors[0].write_mask = desc->color_write_mask; + pip_desc.colors[0].blend.enabled = true; + pip_desc.colors[0].blend.src_factor_rgb = SG_BLENDFACTOR_ONE; + pip_desc.colors[0].blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + pip_desc.colors[0].blend.src_factor_alpha = SG_BLENDFACTOR_ONE; + pip_desc.colors[0].blend.dst_factor_alpha = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + pip_desc.label = "sspine-pip-normal/additive"; + ctx->pip.normal_additive = sg_make_pipeline(&pip_desc); + + pip_desc.colors[0].blend.src_factor_rgb = SG_BLENDFACTOR_ZERO; + pip_desc.colors[0].blend.dst_factor_rgb = SG_BLENDFACTOR_SRC_COLOR; + pip_desc.colors[0].blend.src_factor_alpha = SG_BLENDFACTOR_ZERO; + pip_desc.colors[0].blend.dst_factor_alpha = SG_BLENDFACTOR_ONE; + pip_desc.label = "sspine-pip-multiply"; + ctx->pip.multiply = sg_make_pipeline(&pip_desc); + + return SSPINE_RESOURCESTATE_VALID; +} + +static void _sspine_deinit_context(_sspine_context_t* ctx) { + // NOTE: it's ok to call sg_destroy functions with invalid handles + sg_destroy_pipeline(ctx->pip.normal_additive); + sg_destroy_pipeline(ctx->pip.multiply); + sg_destroy_buffer(ctx->ibuf); + sg_destroy_buffer(ctx->vbuf); + if (ctx->commands.ptr) { + _sspine_free(ctx->commands.ptr); + ctx->commands.ptr = 0; + } + if (ctx->indices.ptr) { + _sspine_free(ctx->indices.ptr); + ctx->indices.ptr = 0; + } + if (ctx->vertices.ptr) { + _sspine_free(ctx->vertices.ptr); + ctx->vertices.ptr = 0; + } +} + +static void _sspine_destroy_context(sspine_context ctx_id) { + _sspine_context_t* ctx = _sspine_lookup_context(ctx_id.id); + if (ctx) { + _sspine_deinit_context(ctx); + _sspine_context_pool_t* p = &_sspine.context_pool; + _sspine_clear(ctx, sizeof(_sspine_context_t)); + _sspine_pool_free_index(&p->pool, _sspine_slot_index(ctx_id.id)); + } +} + +static void _sspine_destroy_all_contexts(void) { + _sspine_context_pool_t* p = &_sspine.context_pool; + for (int i = 0; i < p->pool.size; i++) { + _sspine_context_t* ctx = &p->items[i]; + _sspine_destroy_context(_sspine_make_context_handle(ctx->slot.id)); + } +} + +static sspine_context_desc _sspine_context_desc_defaults(const sspine_context_desc* desc) { + sspine_context_desc res = *desc; + res.max_vertices = _sspine_def(desc->max_vertices, _SSPINE_DEFAULT_MAX_VERTICES); + res.max_commands = _sspine_def(desc->max_commands, _SSPINE_DEFAULT_MAX_COMMANDS); + return res; +} + +static bool _sspine_is_default_context(sspine_context ctx_id) { + return ctx_id.id == 0x00010001; +} + +// █████ ████████ ██ █████ ███████ +// ██ ██ ██ ██ ██ ██ ██ +// ███████ ██ ██ ███████ ███████ +// ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ███████ ██ ██ ███████ +// +// >>atlas +static void _sspine_setup_atlas_pool(int pool_size) { + _sspine_atlas_pool_t* p = &_sspine.atlas_pool; + _sspine_init_item_pool(&p->pool, pool_size, (void**)&p->items, sizeof(_sspine_atlas_t)); +} + +static void _sspine_discard_atlas_pool(void) { + _sspine_atlas_pool_t* p = &_sspine.atlas_pool; + _sspine_discard_item_pool(&p->pool, (void**)&p->items); +} + +static sspine_atlas _sspine_make_atlas_handle(uint32_t id) { + sspine_atlas handle = { id }; + return handle; +} + +static _sspine_atlas_t* _sspine_atlas_at(uint32_t id) { + SOKOL_ASSERT(SSPINE_INVALID_ID != id); + const _sspine_atlas_pool_t* p = &_sspine.atlas_pool; + int slot_index = _sspine_slot_index(id); + SOKOL_ASSERT((slot_index > _SSPINE_INVALID_SLOT_INDEX) && (slot_index < p->pool.size)); + return &p->items[slot_index]; +} + +static _sspine_atlas_t* _sspine_lookup_atlas(uint32_t id) { + if (SSPINE_INVALID_ID != id) { + _sspine_atlas_t* atlas = _sspine_atlas_at(id); + if (atlas->slot.id == id) { + return atlas; + } + } + return 0; +} + +static sspine_atlas _sspine_alloc_atlas(void) { + _sspine_atlas_pool_t* p = &_sspine.atlas_pool; + int slot_index = _sspine_pool_alloc_index(&p->pool); + if (_SSPINE_INVALID_SLOT_INDEX != slot_index) { + uint32_t id = _sspine_slot_init(&p->pool, &p->items[slot_index].slot, slot_index); + return _sspine_make_atlas_handle(id); + } + else { + // pool exhausted + return _sspine_make_atlas_handle(SSPINE_INVALID_ID); + } +} + +static sspine_resource_state _sspine_init_atlas(_sspine_atlas_t* atlas, const sspine_atlas_desc* desc) { + SOKOL_ASSERT(atlas && (atlas->slot.state == SSPINE_RESOURCESTATE_ALLOC)); + SOKOL_ASSERT(desc); + SOKOL_ASSERT(atlas->sp_atlas == 0); + + if ((0 == desc->data.ptr) || (0 == desc->data.size)) { + _SSPINE_ERROR(ATLAS_DESC_NO_DATA); + return SSPINE_RESOURCESTATE_FAILED; + } + atlas->overrides = desc->override; + + // NOTE: Spine doesn't detect when invalid or corrupt data is passed here, + // not much we can do about this... + atlas->sp_atlas = spAtlas_create((const char*)desc->data.ptr, (int)desc->data.size, "", 0); + if (0 == atlas->sp_atlas) { + _SSPINE_ERROR(SPINE_ATLAS_CREATION_FAILED); + return SSPINE_RESOURCESTATE_FAILED; + } + + // allocate a sokol-gfx image handle for each page, but the actual image initialization + // needs to be delegated to the application + for (spAtlasPage* page = atlas->sp_atlas->pages; page != 0; page = page->next) { + atlas->num_pages++; + const sg_image img = sg_alloc_image(); + if (sg_query_image_state(img) != SG_RESOURCESTATE_ALLOC) { + _SSPINE_ERROR(SG_ALLOC_IMAGE_FAILED); + return SSPINE_RESOURCESTATE_FAILED; + } + page->rendererObject = (void*)(uintptr_t)img.id; + if (desc->override.premul_alpha_enabled) { + // NOTE: -1 is spine-c convention for 'true' + page->pma = -1; + } + else if (desc->override.premul_alpha_disabled) { + page->pma = 0; + } + } + return SSPINE_RESOURCESTATE_VALID; +} + +static void _sspine_deinit_atlas(_sspine_atlas_t* atlas) { + if (atlas->sp_atlas) { + spAtlas_dispose(atlas->sp_atlas); + atlas->sp_atlas = 0; + } +} + +static void _sspine_destroy_atlas(sspine_atlas atlas_id) { + _sspine_atlas_t* atlas = _sspine_lookup_atlas(atlas_id.id); + if (atlas) { + _sspine_deinit_atlas(atlas); + _sspine_atlas_pool_t* p = &_sspine.atlas_pool; + _sspine_clear(atlas, sizeof(_sspine_atlas_t)); + _sspine_pool_free_index(&p->pool, _sspine_slot_index(atlas_id.id)); + } +} + +static void _sspine_destroy_all_atlases(void) { + _sspine_atlas_pool_t* p = &_sspine.atlas_pool; + for (int i = 0; i < p->pool.size; i++) { + _sspine_atlas_t* atlas = &p->items[i]; + _sspine_destroy_atlas(_sspine_make_atlas_handle(atlas->slot.id)); + } +} + +static sspine_atlas_desc _sspine_atlas_desc_defaults(const sspine_atlas_desc* desc) { + sspine_atlas_desc res = *desc; + return res; +} + +static spAtlasPage* _sspine_lookup_atlas_page(uint32_t atlas_id, int page_index) { + _sspine_atlas_t* atlas = _sspine_lookup_atlas(atlas_id); + if (atlas) { + if ((page_index >= 0) && (page_index < atlas->num_pages)) { + int i = 0; + for (spAtlasPage* page = atlas->sp_atlas->pages; page != 0; page = page->next, i++) { + if (i == page_index) { + return page; + } + } + } + } + return 0; +} + +// ███████ ██ ██ ███████ ██ ███████ ████████ ██████ ███ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ +// ███████ █████ █████ ██ █████ ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██ ██ ███████ ███████ ███████ ██ ██████ ██ ████ +// +// >>skeleton +static void _sspine_setup_skeleton_pool(int pool_size) { + _sspine_skeleton_pool_t* p = &_sspine.skeleton_pool; + _sspine_init_item_pool(&p->pool, pool_size, (void**)&p->items, sizeof(_sspine_skeleton_t)); +} + +static void _sspine_discard_skeleton_pool(void) { + _sspine_skeleton_pool_t* p = &_sspine.skeleton_pool; + _sspine_discard_item_pool(&p->pool, (void**)&p->items); +} + +static sspine_skeleton _sspine_make_skeleton_handle(uint32_t id) { + sspine_skeleton handle = { id }; + return handle; +} + +static _sspine_skeleton_t* _sspine_skeleton_at(uint32_t id) { + SOKOL_ASSERT(SSPINE_INVALID_ID != id); + const _sspine_skeleton_pool_t* p = &_sspine.skeleton_pool; + int slot_index = _sspine_slot_index(id); + SOKOL_ASSERT((slot_index > _SSPINE_INVALID_SLOT_INDEX) && (slot_index < p->pool.size)); + return &p->items[slot_index]; +} + +static _sspine_skeleton_t* _sspine_lookup_skeleton(uint32_t id) { + if (SSPINE_INVALID_ID != id) { + _sspine_skeleton_t* skeleton = _sspine_skeleton_at(id); + if (skeleton->slot.id == id) { + return skeleton; + } + } + return 0; +} + +static sspine_skeleton _sspine_alloc_skeleton(void) { + _sspine_skeleton_pool_t* p = &_sspine.skeleton_pool; + int slot_index = _sspine_pool_alloc_index(&p->pool); + if (_SSPINE_INVALID_SLOT_INDEX != slot_index) { + uint32_t id = _sspine_slot_init(&p->pool, &p->items[slot_index].slot, slot_index); + return _sspine_make_skeleton_handle(id); + } + else { + // pool exhausted + return _sspine_make_skeleton_handle(SSPINE_INVALID_ID); + } +} + +static sspine_resource_state _sspine_init_skeleton(_sspine_skeleton_t* skeleton, const sspine_skeleton_desc* desc) { + SOKOL_ASSERT(skeleton && (skeleton->slot.state == SSPINE_RESOURCESTATE_ALLOC)); + SOKOL_ASSERT(desc); + + if ((0 == desc->json_data) && ((0 == desc->binary_data.ptr) || (0 == desc->binary_data.size))) { + _SSPINE_ERROR(SKELETON_DESC_NO_DATA); + return SSPINE_RESOURCESTATE_FAILED; + } + if (desc->atlas.id == SSPINE_INVALID_ID) { + _SSPINE_ERROR(SKELETON_DESC_NO_ATLAS); + return SSPINE_RESOURCESTATE_FAILED; + } + + skeleton->atlas.id = desc->atlas.id; + skeleton->atlas.ptr = _sspine_lookup_atlas(skeleton->atlas.id); + if (!_sspine_atlas_ref_valid(&skeleton->atlas)) { + _SSPINE_ERROR(SKELETON_ATLAS_NOT_VALID); + return SSPINE_RESOURCESTATE_FAILED; + } + _sspine_atlas_t* atlas = skeleton->atlas.ptr; + if (SSPINE_RESOURCESTATE_VALID != atlas->slot.state) { + _SSPINE_ERROR(SKELETON_ATLAS_NOT_VALID); + return SSPINE_RESOURCESTATE_FAILED; + } + SOKOL_ASSERT(atlas->sp_atlas); + + if (desc->json_data) { + spSkeletonJson* skel_json = spSkeletonJson_create(atlas->sp_atlas); + SOKOL_ASSERT(skel_json); + skel_json->scale = desc->prescale; + skeleton->sp_skel_data = spSkeletonJson_readSkeletonData(skel_json, desc->json_data); + spSkeletonJson_dispose(skel_json); skel_json = 0; + if (0 == skeleton->sp_skel_data) { + _SSPINE_ERROR(CREATE_SKELETON_DATA_FROM_JSON_FAILED); + return SSPINE_RESOURCESTATE_FAILED; + } + } + else { + spSkeletonBinary* skel_bin = spSkeletonBinary_create(atlas->sp_atlas); + SOKOL_ASSERT(skel_bin); + skel_bin->scale = desc->prescale; + skeleton->sp_skel_data = spSkeletonBinary_readSkeletonData(skel_bin, (const unsigned char*)desc->binary_data.ptr, (int)desc->binary_data.size); + spSkeletonBinary_dispose(skel_bin); skel_bin = 0; + if (0 == skeleton->sp_skel_data) { + _SSPINE_ERROR(CREATE_SKELETON_DATA_FROM_BINARY_FAILED); + return SSPINE_RESOURCESTATE_FAILED; + } + } + SOKOL_ASSERT(skeleton->sp_skel_data); + + skeleton->sp_anim_data = spAnimationStateData_create(skeleton->sp_skel_data); + SOKOL_ASSERT(skeleton->sp_anim_data); + skeleton->sp_anim_data->defaultMix = desc->anim_default_mix; + + // get the max number of vertices in any mesh attachment + int max_vertex_count = 4; // number of vertices in a 'region attachment' (a 2-triangle quad) + const spSkeletonData* sp_skel_data = skeleton->sp_skel_data; + for (int skinIndex = 0; skinIndex < sp_skel_data->skinsCount; skinIndex++) { + const spSkin* sp_skin = sp_skel_data->skins[skinIndex]; + const spSkinEntry* skin_entry = spSkin_getAttachments(sp_skin); + if (skin_entry) do { + if (skin_entry->attachment) { + if (skin_entry->attachment->type == SP_ATTACHMENT_MESH) { + const spMeshAttachment* mesh_attachment = (spMeshAttachment*)skin_entry->attachment; + // worldVerticesLength is number of floats + SOKOL_ASSERT((mesh_attachment->super.worldVerticesLength & 1) == 0); + const int num_vertices = mesh_attachment->super.worldVerticesLength / 2; + if (num_vertices > max_vertex_count) { + max_vertex_count = num_vertices; + } + } + } + } while ((skin_entry = skin_entry->next) != 0); + } + + // allocate a shared vertex transform buffer (big enough to hold vertices for biggest mesh attachment) + skeleton->tform_buf.cap = max_vertex_count; + skeleton->tform_buf.ptr = (sspine_vec2*) _sspine_malloc((size_t)skeleton->tform_buf.cap * sizeof(sspine_vec2)); + + return SSPINE_RESOURCESTATE_VALID; +} + +static void _sspine_deinit_skeleton(_sspine_skeleton_t* skeleton) { + if (skeleton->tform_buf.ptr) { + _sspine_free(skeleton->tform_buf.ptr); + skeleton->tform_buf.ptr = 0; + } + if (skeleton->sp_anim_data) { + spAnimationStateData_dispose(skeleton->sp_anim_data); + skeleton->sp_anim_data = 0; + } + if (skeleton->sp_skel_data) { + spSkeletonData_dispose(skeleton->sp_skel_data); + skeleton->sp_skel_data = 0; + } +} + +static void _sspine_destroy_skeleton(sspine_skeleton skeleton_id) { + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (skeleton) { + _sspine_deinit_skeleton(skeleton); + _sspine_skeleton_pool_t* p = &_sspine.skeleton_pool; + _sspine_clear(skeleton, sizeof(_sspine_skeleton_t)); + _sspine_pool_free_index(&p->pool, _sspine_slot_index(skeleton_id.id)); + } +} + +static void _sspine_destroy_all_skeletons(void) { + _sspine_skeleton_pool_t* p = &_sspine.skeleton_pool; + for (int i = 0; i < p->pool.size; i++) { + _sspine_skeleton_t* skeleton = &p->items[i]; + _sspine_destroy_skeleton(_sspine_make_skeleton_handle(skeleton->slot.id)); + } +} + +static sspine_skeleton_desc _sspine_skeleton_desc_defaults(const sspine_skeleton_desc* desc) { + sspine_skeleton_desc res = *desc; + res.prescale = _sspine_def(desc->prescale, 1.0f); + res.anim_default_mix = _sspine_def(desc->anim_default_mix, 0.2f); + return res; +} + +static spBoneData* _sspine_lookup_bone_data(uint32_t skeleton_id, int bone_index) { + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data && skeleton->sp_skel_data->bones); + if ((bone_index >= 0) && (bone_index <= skeleton->sp_skel_data->bonesCount)) { + return skeleton->sp_skel_data->bones[bone_index]; + } + } + return 0; +} + +static spSlotData* _sspine_lookup_slot_data(uint32_t skeleton_id, int slot_index) { + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data && skeleton->sp_skel_data->slots); + if ((slot_index >= 0) && (slot_index <= skeleton->sp_skel_data->slotsCount)) { + return skeleton->sp_skel_data->slots[slot_index]; + } + } + return 0; +} + +static spEventData* _sspine_lookup_event_data(uint32_t skeleton_id, int event_index) { + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data && skeleton->sp_skel_data->events); + if ((event_index >= 0) && (event_index < skeleton->sp_skel_data->eventsCount)) { + return skeleton->sp_skel_data->events[event_index]; + } + } + return 0; +} + +static spIkConstraintData* _sspine_lookup_ikconstraint_data(uint32_t skeleton_id, int iktarget_index) { + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data && skeleton->sp_skel_data->ikConstraints); + if ((iktarget_index >= 0) && (iktarget_index < skeleton->sp_skel_data->ikConstraintsCount)) { + return skeleton->sp_skel_data->ikConstraints[iktarget_index]; + } + } + return 0; +} + +static spSkin* _sspine_lookup_skin(uint32_t skeleton_id, int skin_index) { + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data && skeleton->sp_skel_data->skins); + if ((skin_index >= 0) && (skin_index < skeleton->sp_skel_data->skinsCount)) { + return skeleton->sp_skel_data->skins[skin_index]; + } + } + return 0; +} + +// ███████ ██ ██ ██ ███ ██ ███████ ███████ ████████ +// ██ ██ ██ ██ ████ ██ ██ ██ ██ +// ███████ █████ ██ ██ ██ ██ ███████ █████ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ███████ ██ ██ ██ ██ ████ ███████ ███████ ██ +// +// >>skinset +static void _sspine_setup_skinset_pool(int pool_size) { + _sspine_skinset_pool_t* p = &_sspine.skinset_pool; + _sspine_init_item_pool(&p->pool, pool_size, (void**)&p->items, sizeof(_sspine_skinset_t)); +} + +static void _sspine_discard_skinset_pool(void) { + _sspine_skinset_pool_t* p = &_sspine.skinset_pool; + _sspine_discard_item_pool(&p->pool, (void**)&p->items); +} + +static sspine_skinset _sspine_make_skinset_handle(uint32_t id) { + sspine_skinset handle = { id }; + return handle; +} + +static _sspine_skinset_t* _sspine_skinset_at(uint32_t id) { + SOKOL_ASSERT(SSPINE_INVALID_ID != id); + const _sspine_skinset_pool_t* p = &_sspine.skinset_pool; + int slot_index = _sspine_slot_index(id); + SOKOL_ASSERT((slot_index > _SSPINE_INVALID_SLOT_INDEX) && (slot_index < p->pool.size)); + return &p->items[slot_index]; +} + +static _sspine_skinset_t* _sspine_lookup_skinset(uint32_t id) { + if (SSPINE_INVALID_ID != id) { + _sspine_skinset_t* skinset = _sspine_skinset_at(id); + if (skinset->slot.id == id) { + return skinset; + } + } + return 0; +} + +static sspine_skinset _sspine_alloc_skinset(void) { + _sspine_skinset_pool_t* p = &_sspine.skinset_pool; + int slot_index = _sspine_pool_alloc_index(&p->pool); + if (_SSPINE_INVALID_SLOT_INDEX != slot_index) { + uint32_t id = _sspine_slot_init(&p->pool, &p->items[slot_index].slot, slot_index); + return _sspine_make_skinset_handle(id); + } + else { + // pool exhausted + return _sspine_make_skinset_handle(SSPINE_INVALID_ID); + } +} + +static sspine_resource_state _sspine_init_skinset(_sspine_skinset_t* skinset, const sspine_skinset_desc* desc) { + SOKOL_ASSERT(skinset && (skinset->slot.state == SSPINE_RESOURCESTATE_ALLOC)); + SOKOL_ASSERT(desc); + + if (desc->skeleton.id == SSPINE_INVALID_ID) { + _SSPINE_ERROR(SKINSET_DESC_NO_SKELETON); + return SSPINE_RESOURCESTATE_FAILED; + } + skinset->skel.id = desc->skeleton.id; + skinset->skel.ptr = _sspine_lookup_skeleton(desc->skeleton.id); + if (!_sspine_skeleton_ref_valid(&skinset->skel)) { + _SSPINE_ERROR(SKINSET_SKELETON_NOT_VALID); + return SSPINE_RESOURCESTATE_FAILED; + } + _sspine_skeleton_t* skel = skinset->skel.ptr; + if (SSPINE_RESOURCESTATE_VALID != skel->slot.state) { + _SSPINE_ERROR(SKINSET_SKELETON_NOT_VALID); + return SSPINE_RESOURCESTATE_FAILED; + } + SOKOL_ASSERT(skel->sp_skel_data); + skinset->sp_skin = spSkin_create("skinset"); + for (int i = 0; i < SSPINE_MAX_SKINSET_SKINS; i++) { + if (desc->skins[i].skeleton_id != SSPINE_INVALID_ID) { + spSkin* skin = _sspine_lookup_skin(desc->skins[i].skeleton_id, desc->skins[i].index); + if (0 == skin) { + _SSPINE_ERROR(SKINSET_INVALID_SKIN_HANDLE); + return SSPINE_RESOURCESTATE_FAILED; + } + spSkin_addSkin(skinset->sp_skin, skin); + } + } + return SSPINE_RESOURCESTATE_VALID; +} + +static void _sspine_deinit_skinset(_sspine_skinset_t* skinset) { + if (skinset->sp_skin) { + spSkin_clear(skinset->sp_skin); + spSkin_dispose(skinset->sp_skin); + skinset->sp_skin = 0; + } +} + +static void _sspine_destroy_skinset(sspine_skinset skinset_id) { + _sspine_skinset_t* skinset = _sspine_lookup_skinset(skinset_id.id); + if (skinset) { + _sspine_deinit_skinset(skinset); + _sspine_skinset_pool_t* p = &_sspine.skinset_pool; + _sspine_clear(skinset, sizeof(_sspine_skinset_t)); + _sspine_pool_free_index(&p->pool, _sspine_slot_index(skinset_id.id)); + } +} + +static void _sspine_destroy_all_skinsets(void) { + _sspine_skinset_pool_t* p = &_sspine.skinset_pool; + for (int i = 0; i < p->pool.size; i++) { + _sspine_skinset_t* skinset = &p->items[i]; + _sspine_destroy_skinset(_sspine_make_skinset_handle(skinset->slot.id)); + } +} + +static sspine_skinset_desc _sspine_skinset_desc_defaults(const sspine_skinset_desc* desc) { + sspine_skinset_desc res = *desc; + return res; +} + +// ██ ███ ██ ███████ ████████ █████ ███ ██ ██████ ███████ +// ██ ████ ██ ██ ██ ██ ██ ████ ██ ██ ██ +// ██ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ ██ █████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ████ ███████ ██ ██ ██ ██ ████ ██████ ███████ +// +// >>instance +static void _sspine_setup_instance_pool(int pool_size) { + _sspine_instance_pool_t* p = &_sspine.instance_pool; + _sspine_init_item_pool(&p->pool, pool_size, (void**)&p->items, sizeof(_sspine_instance_t)); +} + +static void _sspine_discard_instance_pool(void) { + _sspine_instance_pool_t* p = &_sspine.instance_pool; + _sspine_discard_item_pool(&p->pool, (void**)&p->items); +} + +static sspine_instance _sspine_make_instance_handle(uint32_t id) { + sspine_instance handle = { id }; + return handle; +} + +static _sspine_instance_t* _sspine_instance_at(uint32_t id) { + SOKOL_ASSERT(SSPINE_INVALID_ID != id); + const _sspine_instance_pool_t* p = &_sspine.instance_pool; + int slot_index = _sspine_slot_index(id); + SOKOL_ASSERT((slot_index > _SSPINE_INVALID_SLOT_INDEX) && (slot_index < p->pool.size)); + return &p->items[slot_index]; +} + +static _sspine_instance_t* _sspine_lookup_instance(uint32_t id) { + if (SSPINE_INVALID_ID != id) { + _sspine_instance_t* instance = _sspine_instance_at(id); + if (instance->slot.id == id) { + return instance; + } + } + return 0; +} + +static sspine_instance _sspine_alloc_instance(void) { + _sspine_instance_pool_t* p = &_sspine.instance_pool; + sspine_instance res; + int slot_index = _sspine_pool_alloc_index(&p->pool); + if (_SSPINE_INVALID_SLOT_INDEX != slot_index) { + uint32_t id = _sspine_slot_init(&p->pool, &p->items[slot_index].slot, slot_index); + res = _sspine_make_instance_handle(id); + } + else { + // pool exhausted + res = _sspine_make_instance_handle(SSPINE_INVALID_ID); + } + return res; +} + +static void _sspine_rewind_triggered_events(_sspine_instance_t* instance) { + instance->cur_triggered_event_index = 0; + _sspine_clear(instance->triggered_events, sizeof(instance->triggered_events)); +} + +static sspine_triggered_event_info* _sspine_next_triggered_event_info(_sspine_instance_t* instance) { + if (instance->cur_triggered_event_index < _SSPINE_MAX_TRIGGERED_EVENTS) { + return &instance->triggered_events[instance->cur_triggered_event_index++]; + } + else { + return 0; + } +} + +static void _sspine_event_listener(spAnimationState* sp_anim_state, spEventType sp_event_type, spTrackEntry* sp_track_entry, spEvent* sp_event) { + if (sp_event_type == SP_ANIMATION_EVENT) { + SOKOL_ASSERT(sp_anim_state && sp_track_entry && sp_event); (void)sp_track_entry; + SOKOL_ASSERT(sp_event->data && sp_event->data->name); + _sspine_instance_t* instance = _sspine_lookup_instance((uint32_t)(uintptr_t)sp_anim_state->userData); + if (_sspine_instance_and_deps_valid(instance)) { + sspine_triggered_event_info* info = _sspine_next_triggered_event_info(instance); + if (info) { + // FIXME: this sucks, but we really need the event index + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(instance->skel.id); + SOKOL_ASSERT(skeleton && skeleton->sp_skel_data->events); + const spEventData* sp_event_data = sp_event->data; + for (int i = 0; i < skeleton->sp_skel_data->eventsCount; i++) { + if (sp_event_data == skeleton->sp_skel_data->events[i]) { + info->event = _sspine_event(skeleton->slot.id, i); + break; + } + } + SOKOL_ASSERT(info->event.skeleton_id != SSPINE_INVALID_ID); + info->valid = true; + info->time = sp_event->time; + info->int_value = sp_event->intValue; + info->float_value = sp_event->floatValue; + info->volume = sp_event->volume; + info->balance = sp_event->balance; + info->string_value = _sspine_string(sp_event->stringValue); + if (info->string_value.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + } + } + } +} + +static sspine_resource_state _sspine_init_instance(_sspine_instance_t* instance, const sspine_instance_desc* desc) { + SOKOL_ASSERT(instance && (instance->slot.state == SSPINE_RESOURCESTATE_ALLOC)); + SOKOL_ASSERT(desc); + + if (desc->skeleton.id == SSPINE_INVALID_ID) { + _SSPINE_ERROR(INSTANCE_DESC_NO_SKELETON); + return SSPINE_RESOURCESTATE_FAILED; + } + instance->skel.id = desc->skeleton.id; + instance->skel.ptr = _sspine_lookup_skeleton(instance->skel.id); + if (!_sspine_skeleton_ref_valid(&instance->skel)) { + _SSPINE_ERROR(INSTANCE_SKELETON_NOT_VALID); + return SSPINE_RESOURCESTATE_FAILED; + } + _sspine_skeleton_t* skel = instance->skel.ptr; + if (SSPINE_RESOURCESTATE_VALID != skel->slot.state) { + _SSPINE_ERROR(INSTANCE_SKELETON_NOT_VALID); + return SSPINE_RESOURCESTATE_FAILED; + } + instance->atlas = skel->atlas; + if (!_sspine_atlas_ref_valid(&instance->atlas)) { + _SSPINE_ERROR(INSTANCE_ATLAS_NOT_VALID); + return SSPINE_RESOURCESTATE_FAILED; + } + if (SSPINE_RESOURCESTATE_VALID != instance->atlas.ptr->slot.state) { + _SSPINE_ERROR(INSTANCE_ATLAS_NOT_VALID); + return SSPINE_RESOURCESTATE_FAILED; + } + SOKOL_ASSERT(skel->sp_skel_data); + SOKOL_ASSERT(skel->sp_anim_data); + + instance->sp_skel = spSkeleton_create(skel->sp_skel_data); + if (0 == instance->sp_skel) { + _SSPINE_ERROR(SPINE_SKELETON_CREATION_FAILED); + return SSPINE_RESOURCESTATE_FAILED; + } + instance->sp_anim_state = spAnimationState_create(skel->sp_anim_data); + if (0 == instance->sp_anim_state) { + _SSPINE_ERROR(SPINE_ANIMATIONSTATE_CREATION_FAILED); + return SSPINE_RESOURCESTATE_FAILED; + } + instance->sp_clip = spSkeletonClipping_create(); + if (0 == instance->sp_clip) { + _SSPINE_ERROR(SPINE_SKELETONCLIPPING_CREATION_FAILED); + return SSPINE_RESOURCESTATE_FAILED; + } + + instance->sp_anim_state->userData = (void*)(uintptr_t)instance->slot.id; + instance->sp_anim_state->listener = _sspine_event_listener; + + spSkeleton_setToSetupPose(instance->sp_skel); + spAnimationState_update(instance->sp_anim_state, 0.0f); + spAnimationState_apply(instance->sp_anim_state, instance->sp_skel); + spSkeleton_updateWorldTransform(instance->sp_skel); + + return SSPINE_RESOURCESTATE_VALID; +} + +static void _sspine_deinit_instance(_sspine_instance_t* instance) { + if (instance->sp_clip) { + spSkeletonClipping_dispose(instance->sp_clip); + instance->sp_clip = 0; + } + if (instance->sp_anim_state) { + spAnimationState_dispose(instance->sp_anim_state); + instance->sp_anim_state = 0; + } + if (instance->sp_skel) { + spSkeleton_dispose(instance->sp_skel); + instance->sp_skel = 0; + } +} + +static void _sspine_destroy_instance(sspine_instance instance_id) { + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (instance) { + _sspine_deinit_instance(instance); + _sspine_instance_pool_t* p = &_sspine.instance_pool; + _sspine_clear(instance, sizeof(_sspine_instance_t)); + _sspine_pool_free_index(&p->pool, _sspine_slot_index(instance_id.id)); + } +} + +static void _sspine_destroy_all_instances(void) { + _sspine_instance_pool_t* p = &_sspine.instance_pool; + for (int i = 0; i < p->pool.size; i++) { + _sspine_instance_t* instance = &p->items[i]; + _sspine_destroy_instance(_sspine_make_instance_handle(instance->slot.id)); + } +} + +static spAnimation* _sspine_lookup_skeleton_anim(uint32_t skeleton_id, int anim_index) { + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + if ((anim_index >= 0) && (anim_index < skeleton->sp_skel_data->animationsCount)) { + return skeleton->sp_skel_data->animations[anim_index]; + } + } + return 0; +} + +static spAnimation* _sspine_lookup_instance_anim(uint32_t instance_id, uint32_t skeleton_id, int anim_index) { + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id); + if (_sspine_instance_and_deps_valid(instance) && (instance->skel.id == skeleton_id)) { + SOKOL_ASSERT(instance->sp_skel && instance->sp_skel->data); + if ((anim_index >= 0) && (anim_index < instance->sp_skel->data->animationsCount)) { + return instance->sp_skel->data->animations[anim_index]; + } + } + return 0; +} + +static spBone* _sspine_lookup_bone(uint32_t instance_id, uint32_t skeleton_id, int bone_index) { + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id); + if (_sspine_instance_and_deps_valid(instance) && (instance->skel.id == skeleton_id)) { + SOKOL_ASSERT(instance->sp_skel && instance->sp_skel->bones); + if ((bone_index >= 0) && (bone_index <= instance->sp_skel->bonesCount)) { + return instance->sp_skel->bones[bone_index]; + } + } + return 0; +} + +static spSlot* _sspine_lookup_slot(uint32_t instance_id, uint32_t skeleton_id, int slot_index) { + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id); + if (_sspine_instance_and_deps_valid(instance) && (instance->skel.id == skeleton_id)) { + SOKOL_ASSERT(instance->sp_skel && instance->sp_skel->slots); + if ((slot_index >= 0) && (slot_index <= instance->sp_skel->slotsCount)) { + return instance->sp_skel->slots[slot_index]; + } + } + return 0; +} + +static spIkConstraint* _sspine_lookup_ikconstraint(uint32_t instance_id, uint32_t skeleton_id, int iktarget_index) { + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id); + if (_sspine_instance_and_deps_valid(instance) && (instance->skel.id == skeleton_id)) { + SOKOL_ASSERT(instance->sp_skel && instance->sp_skel->ikConstraints); + if ((iktarget_index >= 0) && (iktarget_index < instance->sp_skel->ikConstraintsCount)) { + return instance->sp_skel->ikConstraints[iktarget_index]; + } + } + return 0; +} + +static sspine_instance_desc _sspine_instance_desc_defaults(const sspine_instance_desc* desc) { + sspine_instance_desc res = *desc; + return res; +} + +// ██████ ██████ █████ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██ ██████ ███████ ██ █ ██ +// ██ ██ ██ ██ ██ ██ ██ ███ ██ +// ██████ ██ ██ ██ ██ ███ ███ +// +// >>draw +static void _sspine_check_rewind_commands(_sspine_context_t* ctx) { + if (_sspine.frame_id != ctx->commands.rewind_frame_id) { + ctx->commands.next = 0; + ctx->commands.rewind_frame_id = _sspine.frame_id; + } +} + +static _sspine_command_t* _sspine_next_command(_sspine_context_t* ctx) { + _sspine_check_rewind_commands(ctx); + if (ctx->commands.next < ctx->commands.cap) { + return &(ctx->commands.ptr[ctx->commands.next++]); + } + else { + _SSPINE_ERROR(COMMAND_BUFFER_FULL); + return 0; + } +} + +static _sspine_command_t* _sspine_cur_command(_sspine_context_t* ctx) { + _sspine_check_rewind_commands(ctx); + if (ctx->commands.next > 0) { + return &ctx->commands.ptr[ctx->commands.next - 1]; + } + else { + return 0; + } +} + +static void _sspine_check_rewind_vertices(_sspine_context_t* ctx) { + if (_sspine.frame_id != ctx->vertices.rewind_frame_id) { + ctx->vertices.next = 0; + ctx->vertices.rewind_frame_id = _sspine.frame_id; + } +} + +static _sspine_alloc_vertices_result_t _sspine_alloc_vertices(_sspine_context_t* ctx, int num) { + _sspine_check_rewind_vertices(ctx); + _sspine_alloc_vertices_result_t res; + _sspine_clear(&res, sizeof(res)); + if ((ctx->vertices.next + num) <= ctx->vertices.cap) { + res.ptr = &(ctx->vertices.ptr[ctx->vertices.next]); + res.index = ctx->vertices.next; + ctx->vertices.next += num; + } + else { + _SSPINE_ERROR(VERTEX_BUFFER_FULL); + } + return res; +} + +static void _sspine_check_rewind_indices(_sspine_context_t* ctx) { + if (_sspine.frame_id != ctx->indices.rewind_frame_id) { + ctx->indices.next = 0; + ctx->indices.rewind_frame_id = _sspine.frame_id; + } +} + +static _sspine_alloc_indices_result_t _sspine_alloc_indices(_sspine_context_t* ctx, int num) { + _sspine_check_rewind_indices(ctx); + _sspine_alloc_indices_result_t res; + _sspine_clear(&res, sizeof(res)); + if ((ctx->indices.next + num) <= ctx->indices.cap) { + res.ptr = &(ctx->indices.ptr[ctx->indices.next]); + res.index = ctx->indices.next; + ctx->indices.next += num; + } + else { + _SSPINE_ERROR(INDEX_BUFFER_FULL); + } + return res; +} + +static void _sspine_draw_instance(_sspine_context_t* ctx, _sspine_instance_t* instance, int layer) { + SOKOL_ASSERT(_sspine_instance_and_deps_valid(instance)); + SOKOL_ASSERT(instance->sp_skel); + SOKOL_ASSERT(instance->sp_anim_state); + SOKOL_ASSERT(instance->sp_clip); + + // see: https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/spine-sdl/src/spine-sdl-c.c + const spSkeleton* sp_skel = instance->sp_skel; + float* tform_buf = (float*)instance->skel.ptr->tform_buf.ptr; + const int max_tform_buf_verts = instance->skel.ptr->tform_buf.cap; + SOKOL_UNUSED(max_tform_buf_verts); // only used in asserts + const int tform_buf_stride = 2; // each element is 2 floats + spSkeletonClipping* sp_clip = instance->sp_clip; + for (int slot_index = 0; slot_index < sp_skel->slotsCount; slot_index++) { + spSlot* sp_slot = sp_skel->drawOrder[slot_index]; + if (!sp_slot->attachment) { + spSkeletonClipping_clipEnd(sp_clip, sp_slot); + continue; + } + + // early out if the slot alpha is 0 or the bone is not active + // FIXME: does alpha 0 actually mean 'invisible' for all blend modes? + if ((sp_slot->color.a == 0) || (!sp_slot->bone->active)) { + spSkeletonClipping_clipEnd(sp_clip, sp_slot); + continue; + } + + int num_vertices = 0; + float* uvs = 0; + float* vertices = 0; + int num_indices = 0; + const uint16_t* indices = 0; + const spColor* att_color = 0; + sg_image img = { SG_INVALID_ID }; + bool premul_alpha = false; + if (sp_slot->attachment->type == SP_ATTACHMENT_REGION) { + static const uint16_t quad_indices[] = { 0, 1, 2, 2, 3, 0 }; + spRegionAttachment* region = (spRegionAttachment*)sp_slot->attachment; + att_color = ®ion->color; + // FIXME(?) early out if the slot alpha is 0 + if (att_color->a == 0) { + spSkeletonClipping_clipEnd(sp_clip, sp_slot); + continue; + } + spRegionAttachment_computeWorldVertices(region, sp_slot, tform_buf, 0, tform_buf_stride); + vertices = tform_buf; + num_vertices = 4; + indices = &quad_indices[0]; + num_indices = 6; + uvs = region->uvs; + const spAtlasPage* sp_page = ((spAtlasRegion*)region->rendererObject)->page; + img.id = (uint32_t)(uintptr_t)sp_page->rendererObject; + premul_alpha = sp_page->pma != 0; + } + else if (sp_slot->attachment->type == SP_ATTACHMENT_MESH) { + spMeshAttachment* mesh = (spMeshAttachment*)sp_slot->attachment; + att_color = &mesh->color; + // FIXME(?) early out if the slot alpha is 0 + if (att_color->a == 0) { + spSkeletonClipping_clipEnd(sp_clip, sp_slot); + continue; + } + + const int num_floats = mesh->super.worldVerticesLength; + num_vertices = num_floats / 2; + SOKOL_ASSERT(num_vertices <= max_tform_buf_verts); + spVertexAttachment_computeWorldVertices(&mesh->super, sp_slot, 0, num_floats, tform_buf, 0, tform_buf_stride); + vertices = tform_buf; + indices = mesh->triangles; + num_indices = mesh->trianglesCount; // actually indicesCount??? + uvs = mesh->uvs; + const spAtlasPage* sp_page = ((spAtlasRegion*)mesh->rendererObject)->page; + img.id = (uint32_t)(uintptr_t)sp_page->rendererObject; + premul_alpha = sp_page->pma != 0; + } + else if (sp_slot->attachment->type == SP_ATTACHMENT_CLIPPING) { + spClippingAttachment* clip_attachment = (spClippingAttachment*) sp_slot->attachment; + spSkeletonClipping_clipStart(sp_clip, sp_slot, clip_attachment); + continue; + } + else { + spSkeletonClipping_clipEnd(sp_clip, sp_slot); + continue; + } + SOKOL_ASSERT(vertices && (num_vertices > 0)); + SOKOL_ASSERT(indices && (num_indices > 0)); + SOKOL_ASSERT(uvs); + SOKOL_ASSERT(img.id != SG_INVALID_ID); + + if (spSkeletonClipping_isClipping(sp_clip)) { + spSkeletonClipping_clipTriangles(sp_clip, tform_buf, num_vertices * 2, (uint16_t*)indices, num_indices, uvs, tform_buf_stride); + vertices = sp_clip->clippedVertices->items; + num_vertices = sp_clip->clippedVertices->size / 2; + uvs = sp_clip->clippedUVs->items; + indices = sp_clip->clippedTriangles->items; + num_indices = sp_clip->clippedTriangles->size; + } + SOKOL_ASSERT(vertices); + SOKOL_ASSERT(indices); + SOKOL_ASSERT(uvs); + SOKOL_ASSERT(img.id != SG_INVALID_ID); + + // there might be no geometry to render after clipping + if ((0 == num_vertices) || (0 == num_indices)) { + spSkeletonClipping_clipEnd(sp_clip, sp_slot); + continue; + } + + const _sspine_alloc_vertices_result_t dst_vertices = _sspine_alloc_vertices(ctx, num_vertices); + const _sspine_alloc_indices_result_t dst_indices = _sspine_alloc_indices(ctx, num_indices); + if ((0 == dst_vertices.ptr) || (0 == dst_indices.ptr)) { + spSkeletonClipping_clipEnd(sp_clip, sp_slot); + continue; + } + + // write transformed and potentially clipped vertices and indices + const uint8_t r = (uint8_t)(sp_skel->color.r * sp_slot->color.r * att_color->r * 255.0f); + const uint8_t g = (uint8_t)(sp_skel->color.g * sp_slot->color.g * att_color->g * 255.0f); + const uint8_t b = (uint8_t)(sp_skel->color.b * sp_slot->color.b * att_color->b * 255.0f); + const uint8_t a = (uint8_t)(sp_skel->color.a * sp_slot->color.a * att_color->a * 255.0f); + const uint32_t color = (((uint32_t)a<<24) | ((uint32_t)b<<16) | ((uint32_t)g<<8) | (uint32_t)r); + for (int vi = 0; vi < num_vertices; vi++) { + dst_vertices.ptr[vi].pos.x = vertices[vi*2]; + dst_vertices.ptr[vi].pos.y = vertices[vi*2 + 1]; + dst_vertices.ptr[vi].color = color; + dst_vertices.ptr[vi].uv.x = uvs[vi*2]; + dst_vertices.ptr[vi].uv.y = uvs[vi*2 + 1]; + } + for (int ii = 0; ii < num_indices; ii++) { + dst_indices.ptr[ii] = (uint32_t)indices[ii] + (uint32_t)dst_vertices.index; + } + + sg_pipeline pip = { SG_INVALID_ID }; + // NOTE: pma == 0.0: use color from texture as is + // pma == 1.0: multiply texture rgb by texture alpha in fragment shader + float pma = 0.0f; + switch (sp_slot->data->blendMode) { + case SP_BLEND_MODE_NORMAL: + case SP_BLEND_MODE_ADDITIVE: + case SP_BLEND_MODE_SCREEN: + pip = ctx->pip.normal_additive; + pma = premul_alpha ? 0.0f : 1.0f; // NOT A BUG + break; + case SP_BLEND_MODE_MULTIPLY: + pip = ctx->pip.multiply; + pma = 0.0f; // always use texture color as is + break; + } + + // write new draw command, or merge with current draw command + _sspine_command_t* cur_cmd = _sspine_cur_command(ctx); + if (cur_cmd && (cur_cmd->layer == layer) && (cur_cmd->pip.id == pip.id) && (cur_cmd->img.id == img.id) && (cur_cmd->pma == pma)) { + // merge with current command + cur_cmd->num_elements += num_indices; + } + else { + // record a new command + _sspine_command_t* cmd_ptr = _sspine_next_command(ctx); + if (cmd_ptr) { + cmd_ptr->layer = layer; + cmd_ptr->pip = pip; + cmd_ptr->img = img; + cmd_ptr->pma = pma; + cmd_ptr->base_element = dst_indices.index; + cmd_ptr->num_elements = num_indices; + } + } + spSkeletonClipping_clipEnd(sp_clip, sp_slot); + } + spSkeletonClipping_clipEnd2(sp_clip); +} + +// compute orthographic projection matrix +static void _sspine_layer_transform_to_proj(const sspine_layer_transform* tform, float* res) { + const float left = -tform->origin.x; + const float right = tform->size.x - tform->origin.x; + const float top = -tform->origin.y; + const float bottom = tform->size.y - tform->origin.y; + const float znear = -1.0f; + const float zfar = 1.0f; + res[0] = 2.0f / (right - left); + res[1] = 0.0f; + res[2] = 0.0f; + res[3] = 0.0f; + res[4] = 0.0f; + res[5] = 2.0f / (top - bottom); + res[6] = 0.0f; + res[7] = 0.0f; + res[8] = 0.0f; + res[9] = 0.0f; + res[10] = -2.0f / (zfar - znear); + res[11] = 0.0f; + res[12] = -(right + left) / (right - left); + res[13] = -(top + bottom) / (top - bottom); + res[14] = -(zfar + znear) / (zfar - znear); + res[15] = 1.0f; +} + +static _sspine_vsparams_t _sspine_compute_vsparams(const sspine_layer_transform* tform) { + _sspine_vsparams_t p; + _sspine_clear(&p, sizeof(p)); + _sspine_layer_transform_to_proj(tform, p.mvp); + return p; +} + +static void _sspine_draw_layer(_sspine_context_t* ctx, int layer, const sspine_layer_transform* tform) { + if ((ctx->vertices.next > 0) && (ctx->commands.next > 0)) { + sg_push_debug_group("sokol-spine"); + + if (ctx->update_frame_id != _sspine.frame_id) { + ctx->update_frame_id = _sspine.frame_id; + const sg_range vtx_range = { ctx->vertices.ptr, (size_t)ctx->vertices.next * sizeof(_sspine_vertex_t) }; + sg_update_buffer(ctx->vbuf, &vtx_range); + const sg_range idx_range = { ctx->indices.ptr, (size_t)ctx->indices.next * sizeof(uint32_t) }; + sg_update_buffer(ctx->ibuf, &idx_range); + } + + _sspine_vsparams_t vsparams = _sspine_compute_vsparams(tform); + const sg_range vsparams_range = { &vsparams, sizeof(vsparams) }; + _sspine_fsparams_t fsparams; + _sspine_clear(&fsparams, sizeof(fsparams)); + const sg_range fsparams_range = { &fsparams, sizeof(fsparams) }; + + uint32_t cur_pip_id = SG_INVALID_ID; + uint32_t cur_img_id = SG_INVALID_ID; + float cur_pma = -1.0f; + for (int i = 0; i < ctx->commands.next; i++) { + const _sspine_command_t* cmd = &ctx->commands.ptr[i]; + if ((layer == cmd->layer) && (sg_query_image_state(cmd->img) == SG_RESOURCESTATE_VALID)) { + if (cur_pip_id != cmd->pip.id) { + sg_apply_pipeline(cmd->pip); + cur_pip_id = cmd->pip.id; + sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &vsparams_range); + cur_img_id = SG_INVALID_ID; + } + if (cur_img_id != cmd->img.id) { + ctx->bind.fs_images[0] = cmd->img; + sg_apply_bindings(&ctx->bind); + cur_img_id = cmd->img.id; + } + if (cur_pma != cmd->pma) { + fsparams.pma = cmd->pma; + sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, &fsparams_range); + cur_pma = cmd->pma; + } + if (cmd->num_elements > 0) { + sg_draw(cmd->base_element, cmd->num_elements, 1); + } + } + } + sg_pop_debug_group(); + } +} + +// ███ ███ ██ ███████ ██████ +// ████ ████ ██ ██ ██ +// ██ ████ ██ ██ ███████ ██ +// ██ ██ ██ ██ ██ ██ +// ██ ██ ██ ███████ ██████ +// +// >>misc + +// return sspine_desc with patched defaults +static sspine_desc _sspine_desc_defaults(const sspine_desc* desc) { + SOKOL_ASSERT((desc->allocator.alloc && desc->allocator.free) || (!desc->allocator.alloc && !desc->allocator.free)); + sspine_desc res = *desc; + res.max_vertices = _sspine_def(desc->max_vertices, _SSPINE_DEFAULT_MAX_VERTICES); + res.max_commands = _sspine_def(desc->max_commands, _SSPINE_DEFAULT_MAX_COMMANDS); + res.context_pool_size = _sspine_def(desc->context_pool_size, _SSPINE_DEFAULT_CONTEXT_POOL_SIZE); + res.atlas_pool_size = _sspine_def(desc->atlas_pool_size, _SSPINE_DEFAULT_ATLAS_POOL_SIZE); + res.skeleton_pool_size = _sspine_def(desc->skeleton_pool_size, _SSPINE_DEFAULT_SKELETON_POOL_SIZE); + res.skinset_pool_size = _sspine_def(desc->skinset_pool_size, _SSPINE_DEFAULT_SKINSET_POOL_SIZE); + res.instance_pool_size = _sspine_def(desc->instance_pool_size, _SSPINE_DEFAULT_INSTANCE_POOL_SIZE); + return res; +} + +static sspine_context_desc _sspine_as_context_desc(const sspine_desc* desc) { + sspine_context_desc ctx_desc; + _sspine_clear(&ctx_desc, sizeof(ctx_desc)); + ctx_desc.max_vertices = desc->max_vertices; + ctx_desc.max_commands = desc->max_commands; + ctx_desc.color_format = desc->color_format; + ctx_desc.depth_format = desc->depth_format; + ctx_desc.sample_count = desc->sample_count; + ctx_desc.color_write_mask = desc->color_write_mask; + return ctx_desc; +} + +static sg_filter _sspine_as_image_filter(spAtlasFilter filter) { + switch (filter) { + case SP_ATLAS_UNKNOWN_FILTER: return _SG_FILTER_DEFAULT; + case SP_ATLAS_NEAREST: return SG_FILTER_NEAREST; + case SP_ATLAS_LINEAR: return SG_FILTER_LINEAR; + case SP_ATLAS_MIPMAP: return SG_FILTER_LINEAR_MIPMAP_NEAREST; + case SP_ATLAS_MIPMAP_NEAREST_NEAREST: return SG_FILTER_NEAREST_MIPMAP_NEAREST; + case SP_ATLAS_MIPMAP_LINEAR_NEAREST: return SG_FILTER_LINEAR_MIPMAP_NEAREST; + case SP_ATLAS_MIPMAP_NEAREST_LINEAR: return SG_FILTER_NEAREST_MIPMAP_LINEAR; + case SP_ATLAS_MIPMAP_LINEAR_LINEAR: return SG_FILTER_LINEAR_MIPMAP_LINEAR; + default: return _SG_FILTER_DEFAULT; + } +} + +static sg_wrap _sspine_as_image_wrap(spAtlasWrap wrap) { + switch (wrap) { + case SP_ATLAS_MIRROREDREPEAT: return SG_WRAP_MIRRORED_REPEAT; + case SP_ATLAS_CLAMPTOEDGE: return SG_WRAP_CLAMP_TO_EDGE; + case SP_ATLAS_REPEAT: return SG_WRAP_REPEAT; + default: return _SG_WRAP_DEFAULT; + } +} + +static void _sspine_init_image_info(const _sspine_atlas_t* atlas, int index, sspine_image_info* info, bool with_overrides) { + spAtlasPage* page = _sspine_lookup_atlas_page(atlas->slot.id, index); + SOKOL_ASSERT(page); + SOKOL_ASSERT(page->name); + info->valid = true; + info->sgimage.id = (uint32_t)(uintptr_t)page->rendererObject; + if (with_overrides && (atlas->overrides.min_filter != _SG_FILTER_DEFAULT)) { + info->min_filter = atlas->overrides.min_filter; + } + else { + info->min_filter = _sspine_as_image_filter(page->minFilter); + } + if (with_overrides && (atlas->overrides.mag_filter != _SG_FILTER_DEFAULT)) { + info->mag_filter = atlas->overrides.mag_filter; + } + else { + info->mag_filter = _sspine_as_image_filter(page->magFilter); + } + if (with_overrides && (atlas->overrides.wrap_u != _SG_WRAP_DEFAULT)) { + info->wrap_u = atlas->overrides.wrap_u; + } + else { + info->wrap_u = _sspine_as_image_wrap(page->uWrap); + } + if (with_overrides && (atlas->overrides.wrap_v != _SG_WRAP_DEFAULT)) { + info->wrap_v = atlas->overrides.wrap_v; + } + else { + info->wrap_v = _sspine_as_image_wrap(page->vWrap); + } + info->width = page->width; + info->height = page->height; + // NOTE: override already happened in atlas init + info->premul_alpha = page->pma != 0; + info->filename = _sspine_string(page->name); + if (info->filename.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } +} + +static void _sspine_init_shared(void) { + sg_shader_desc shd_desc; + _sspine_clear(&shd_desc, sizeof(shd_desc)); + shd_desc.attrs[0].name = "position"; + shd_desc.attrs[1].name = "texcoord0"; + shd_desc.attrs[2].name = "color0"; + shd_desc.attrs[0].sem_name = "TEXCOORD"; + shd_desc.attrs[0].sem_index = 0; + shd_desc.attrs[1].sem_name = "TEXCOORD"; + shd_desc.attrs[1].sem_index = 1; + shd_desc.attrs[2].sem_name = "TEXCOORD"; + shd_desc.attrs[2].sem_index = 2; + shd_desc.vs.uniform_blocks[0].size = sizeof(_sspine_vsparams_t); + shd_desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140; + shd_desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params"; + shd_desc.vs.uniform_blocks[0].uniforms[0].type = SG_UNIFORMTYPE_FLOAT4; + shd_desc.vs.uniform_blocks[0].uniforms[0].array_count = 4; + shd_desc.fs.uniform_blocks[0].size = 16; + shd_desc.fs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140; + shd_desc.fs.uniform_blocks[0].uniforms[0].name = "fs_params"; + shd_desc.fs.uniform_blocks[0].uniforms[0].type = SG_UNIFORMTYPE_FLOAT4; + shd_desc.fs.uniform_blocks[0].uniforms[0].array_count = 1; + shd_desc.fs.images[0].name = "tex"; + shd_desc.fs.images[0].image_type = SG_IMAGETYPE_2D; + shd_desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; + shd_desc.label = "sspine-shader"; + #if defined(SOKOL_GLCORE33) + shd_desc.vs.source = _sspine_vs_source_glsl330; + shd_desc.fs.source = _sspine_fs_source_glsl330; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _sspine_vs_source_glsl300es; + shd_desc.fs.source = _sspine_fs_source_glsl300es; + #elif defined(SOKOL_METAL) + shd_desc.vs.entry = "main0"; + shd_desc.fs.entry = "main0"; + switch (sg_query_backend()) { + case SG_BACKEND_METAL_MACOS: + shd_desc.vs.bytecode = SG_RANGE(_sspine_vs_bytecode_metal_macos); + shd_desc.fs.bytecode = SG_RANGE(_sspine_fs_bytecode_metal_macos); + break; + case SG_BACKEND_METAL_IOS: + shd_desc.vs.bytecode = SG_RANGE(_sspine_vs_bytecode_metal_ios); + shd_desc.fs.bytecode = SG_RANGE(_sspine_fs_bytecode_metal_ios); + break; + default: + shd_desc.vs.source = _sspine_vs_source_metal_sim; + shd_desc.fs.source = _sspine_fs_source_metal_sim; + break; + } + #elif defined(SOKOL_D3D11) + shd_desc.vs.bytecode = SG_RANGE(_sspine_vs_bytecode_hlsl4); + shd_desc.fs.bytecode = SG_RANGE(_sspine_fs_bytecode_hlsl4); + #elif defined(SOKOL_WGPU) + shd_desc.vs.bytecode = SG_RANGE(_sspine_vs_bytecode_wgpu); + shd_desc.fs.bytecode = SG_RANGE(_sspine_fs_bytecode_wgpu); + #else + shd_desc.vs.source = _sspine_vs_source_dummy; + shd_desc.fs.source = _sspine_fs_source_dummy; + #endif + _sspine.shd = sg_make_shader(&shd_desc); +} + +static void _sspine_destroy_shared(void) { + sg_destroy_shader(_sspine.shd); +} + +// called from inside sokol-gfx sg_commit() +static void _sspine_commit_listener_func(void* userdata) { + (void)userdata; + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine.frame_id++; +} + +static sg_commit_listener _sspine_make_commit_listener(void) { + sg_commit_listener commit_listener = { _sspine_commit_listener_func, 0 }; + return commit_listener; +} + +// ██████ ██ ██ ██████ ██ ██ ██████ +// ██ ██ ██ ██ ██ ██ ██ ██ ██ +// ██████ ██ ██ ██████ ██ ██ ██ +// ██ ██ ██ ██ ██ ██ ██ ██ +// ██ ██████ ██████ ███████ ██ ██████ +// +// >>public +SOKOL_API_IMPL void sspine_setup(const sspine_desc* desc) { + SOKOL_ASSERT(desc); + spBone_setYDown(1); + _sspine_clear(&_sspine, sizeof(_sspine)); + _sspine.init_cookie = _SSPINE_INIT_COOKIE; + _sspine.desc = _sspine_desc_defaults(desc); + _sspine_init_shared(); + // important, need to setup the frame id with a non-zero value, + // otherwise updates won't trigger in the first frame + _sspine.frame_id = 1; + _sspine_setup_context_pool(_sspine.desc.context_pool_size); + _sspine_setup_atlas_pool(_sspine.desc.atlas_pool_size); + _sspine_setup_skeleton_pool(_sspine.desc.skeleton_pool_size); + _sspine_setup_skinset_pool(_sspine.desc.skinset_pool_size); + _sspine_setup_instance_pool(_sspine.desc.instance_pool_size); + const sspine_context_desc ctx_desc = _sspine_as_context_desc(&_sspine.desc); + _sspine.def_ctx_id = sspine_make_context(&ctx_desc); + SOKOL_ASSERT(_sspine_is_default_context(_sspine.def_ctx_id)); + sspine_set_context(_sspine.def_ctx_id); + if (!sg_add_commit_listener(_sspine_make_commit_listener())) { + _SSPINE_ERROR(ADD_COMMIT_LISTENER_FAILED); + } +} + +SOKOL_API_IMPL void sspine_shutdown(void) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sg_remove_commit_listener(_sspine_make_commit_listener()); + _sspine_destroy_all_instances(); + _sspine_destroy_all_skinsets(); + _sspine_destroy_all_skeletons(); + _sspine_destroy_all_atlases(); + _sspine_destroy_all_contexts(); + _sspine_discard_instance_pool(); + _sspine_discard_skinset_pool(); + _sspine_discard_skeleton_pool(); + _sspine_discard_atlas_pool(); + _sspine_discard_context_pool(); + _sspine_destroy_shared(); + _sspine.init_cookie = 0; +} + +SOKOL_API_IMPL sspine_context sspine_make_context(const sspine_context_desc* desc) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(desc); + const sspine_context_desc desc_def = _sspine_context_desc_defaults(desc); + sspine_context ctx_id = _sspine_alloc_context(); + _sspine_context_t* ctx = _sspine_lookup_context(ctx_id.id); + if (ctx) { + ctx->slot.state = _sspine_init_context(ctx, &desc_def); + SOKOL_ASSERT((ctx->slot.state == SSPINE_RESOURCESTATE_VALID) || (ctx->slot.state == SSPINE_RESOURCESTATE_FAILED)); + if (ctx->slot.state == SSPINE_RESOURCESTATE_FAILED) { + _sspine_deinit_context(ctx); + } + } + else { + ctx->slot.state = SSPINE_RESOURCESTATE_FAILED; + _SSPINE_ERROR(CONTEXT_POOL_EXHAUSTED); + } + return ctx_id; +} + +SOKOL_API_IMPL void sspine_destroy_context(sspine_context ctx_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + if (_sspine_is_default_context(ctx_id)) { + _SSPINE_ERROR(CANNOT_DESTROY_DEFAULT_CONTEXT); + return; + } + _sspine_destroy_context(ctx_id); + // re-validate the current context pointer (this will return a nullptr + // if we just destroyed the current context) + _sspine.cur_ctx = _sspine_lookup_context(_sspine.cur_ctx_id.id); +} + +SOKOL_API_IMPL void sspine_set_context(sspine_context ctx_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + if (_sspine_is_default_context(ctx_id)) { + _sspine.cur_ctx_id = _sspine.def_ctx_id; + } + else { + _sspine.cur_ctx_id = ctx_id; + } + // this will return null if the handle isn't valid + _sspine.cur_ctx = _sspine_lookup_context(_sspine.cur_ctx_id.id); +} + +SOKOL_API_IMPL sspine_context sspine_get_context(void) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + return _sspine.cur_ctx_id; +} + +SOKOL_API_IMPL sspine_context sspine_default_context(void) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + return _sspine_make_context_handle(0x00010001); +} + +SOKOL_API_IMPL sspine_context_info sspine_get_context_info(sspine_context ctx_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_context_info res; + _sspine_clear(&res, sizeof(res)); + const _sspine_context_t* ctx = _sspine_lookup_context(ctx_id.id); + if (ctx) { + res.num_vertices = ctx->vertices.next; + res.num_indices = ctx->indices.next; + res.num_commands = ctx->commands.next; + } + return res; +} + +SOKOL_API_IMPL void sspine_set_skinset(sspine_instance instance_id, sspine_skinset skinset_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + _sspine_skinset_t* skinset = _sspine_lookup_skinset(skinset_id.id); + if (_sspine_instance_and_deps_valid(instance) && _sspine_skinset_and_deps_valid(skinset) && (instance->skel.id == skinset->skel.id)) { + SOKOL_ASSERT(instance->sp_skel); + SOKOL_ASSERT(instance->sp_anim_state); + SOKOL_ASSERT(skinset->sp_skin); + spSkeleton_setSkin(instance->sp_skel, 0); + spSkeleton_setSkin(instance->sp_skel, skinset->sp_skin); + spSkeleton_setSlotsToSetupPose(instance->sp_skel); + spAnimationState_apply(instance->sp_anim_state, instance->sp_skel); + } +} + +SOKOL_API_IMPL void sspine_update_instance(sspine_instance instance_id, float delta_time) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (_sspine_instance_and_deps_valid(instance)) { + SOKOL_ASSERT(instance->sp_skel); + SOKOL_ASSERT(instance->sp_anim_state); + _sspine_rewind_triggered_events(instance); + spAnimationState_update(instance->sp_anim_state, delta_time); + spAnimationState_apply(instance->sp_anim_state, instance->sp_skel); + spSkeleton_updateWorldTransform(instance->sp_skel); + } +} + +SOKOL_API_IMPL int sspine_num_triggered_events(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (_sspine_instance_and_deps_valid(instance)) { + SOKOL_ASSERT((instance->cur_triggered_event_index >= 0) && (instance->cur_triggered_event_index <= _SSPINE_MAX_TRIGGERED_EVENTS)); + return instance->cur_triggered_event_index; + } + return 0; +} + +SOKOL_API_IMPL sspine_triggered_event_info sspine_get_triggered_event_info(sspine_instance instance_id, int triggered_event_index) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + sspine_triggered_event_info res; + _sspine_clear(&res, sizeof(res)); + if (_sspine_instance_and_deps_valid(instance)) { + if ((triggered_event_index >= 0) && (triggered_event_index < instance->cur_triggered_event_index)) { + res = instance->triggered_events[triggered_event_index]; + } + } + return res; +} + +SOKOL_API_IMPL void sspine_draw_instance_in_layer(sspine_instance instance_id, int layer) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_context_t* ctx = _sspine.cur_ctx; + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (ctx && _sspine_instance_and_deps_valid(instance)) { + _sspine_draw_instance(ctx, instance, layer); + } +} + +SOKOL_API_IMPL sspine_mat4 sspine_layer_transform_to_mat4(const sspine_layer_transform* tform) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_mat4 res; + _sspine_layer_transform_to_proj(tform, res.m); + return res; +} + +SOKOL_API_IMPL void sspine_context_draw_instance_in_layer(sspine_context ctx_id, sspine_instance instance_id, int layer) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_context_t* ctx = _sspine_lookup_context(ctx_id.id); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (ctx && _sspine_instance_and_deps_valid(instance)) { + _sspine_draw_instance(ctx, instance, layer); + } +} + +SOKOL_API_IMPL void sspine_draw_layer(int layer, const sspine_layer_transform* tform) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(tform); + _sspine_context_t* ctx = _sspine.cur_ctx; + if (ctx) { + _sspine_draw_layer(ctx, layer, tform); + } +} + +SOKOL_API_IMPL void sspine_context_draw_layer(sspine_context ctx_id, int layer, const sspine_layer_transform* tform) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(tform); + _sspine_context_t* ctx = _sspine_lookup_context(ctx_id.id); + if (ctx) { + _sspine_draw_layer(ctx, layer, tform); + } +} + +SOKOL_API_IMPL sspine_atlas sspine_make_atlas(const sspine_atlas_desc* desc) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(desc); + const sspine_atlas_desc desc_def = _sspine_atlas_desc_defaults(desc); + sspine_atlas atlas_id = _sspine_alloc_atlas(); + _sspine_atlas_t* atlas = _sspine_lookup_atlas(atlas_id.id); + if (atlas) { + atlas->slot.state = _sspine_init_atlas(atlas, &desc_def); + SOKOL_ASSERT((atlas->slot.state == SSPINE_RESOURCESTATE_VALID) || (atlas->slot.state == SSPINE_RESOURCESTATE_FAILED)); + if (atlas->slot.state == SSPINE_RESOURCESTATE_FAILED) { + _sspine_deinit_atlas(atlas); + } + } + else { + _SSPINE_ERROR(ATLAS_POOL_EXHAUSTED); + } + return atlas_id; +} + +SOKOL_API_IMPL void sspine_destroy_atlas(sspine_atlas atlas_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_destroy_atlas(atlas_id); +} + +SOKOL_API_IMPL sspine_skeleton sspine_make_skeleton(const sspine_skeleton_desc* desc) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(desc); + const sspine_skeleton_desc desc_def = _sspine_skeleton_desc_defaults(desc); + sspine_skeleton skeleton_id = _sspine_alloc_skeleton(); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (skeleton) { + skeleton->slot.state = _sspine_init_skeleton(skeleton, &desc_def); + SOKOL_ASSERT((skeleton->slot.state == SSPINE_RESOURCESTATE_VALID) || (skeleton->slot.state == SSPINE_RESOURCESTATE_FAILED)); + if (skeleton->slot.state == SSPINE_RESOURCESTATE_FAILED) { + _sspine_deinit_skeleton(skeleton); + } + } + else { + _SSPINE_ERROR(SKELETON_POOL_EXHAUSTED); + } + return skeleton_id; +} + +SOKOL_API_IMPL void sspine_destroy_skeleton(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_destroy_skeleton(skeleton_id); +} + +SOKOL_API_IMPL sspine_skinset sspine_make_skinset(const sspine_skinset_desc* desc) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(desc); + const sspine_skinset_desc desc_def = _sspine_skinset_desc_defaults(desc); + sspine_skinset skinset_id = _sspine_alloc_skinset(); + _sspine_skinset_t* skinset = _sspine_lookup_skinset(skinset_id.id); + if (skinset) { + skinset->slot.state = _sspine_init_skinset(skinset, &desc_def); + SOKOL_ASSERT((skinset->slot.state == SSPINE_RESOURCESTATE_VALID) || (skinset->slot.state == SSPINE_RESOURCESTATE_FAILED)); + if (skinset->slot.state == SSPINE_RESOURCESTATE_FAILED) { + _sspine_deinit_skinset(skinset); + } + } + else { + _SSPINE_ERROR(SKINSET_POOL_EXHAUSTED); + } + return skinset_id; +} + +SOKOL_API_IMPL void sspine_destroy_skinset(sspine_skinset skinset_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_destroy_skinset(skinset_id); +} + +SOKOL_API_IMPL sspine_instance sspine_make_instance(const sspine_instance_desc* desc) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(desc); + const sspine_instance_desc desc_def = _sspine_instance_desc_defaults(desc); + sspine_instance instance_id = _sspine_alloc_instance(); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (instance) { + instance->slot.state = _sspine_init_instance(instance, &desc_def); + SOKOL_ASSERT((instance->slot.state == SSPINE_RESOURCESTATE_VALID) || (instance->slot.state == SSPINE_RESOURCESTATE_FAILED)); + if (instance->slot.state == SSPINE_RESOURCESTATE_FAILED) { + _sspine_deinit_instance(instance); + } + } + else { + _SSPINE_ERROR(INSTANCE_POOL_EXHAUSTED); + } + return instance_id; +} + +SOKOL_API_IMPL void sspine_destroy_instance(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_destroy_instance(instance_id); +} + +SOKOL_API_IMPL sspine_resource_state sspine_get_context_resource_state(sspine_context ctx_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + const _sspine_context_t* ctx = _sspine_lookup_context(ctx_id.id); + if (ctx) { + return ctx->slot.state; + } + else { + return SSPINE_RESOURCESTATE_INVALID; + } +} + +SOKOL_API_IMPL sspine_resource_state sspine_get_atlas_resource_state(sspine_atlas atlas_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + const _sspine_atlas_t* atlas = _sspine_lookup_atlas(atlas_id.id); + if (atlas) { + return atlas->slot.state; + } + else { + return SSPINE_RESOURCESTATE_INVALID; + } +} + +SOKOL_API_IMPL sspine_resource_state sspine_get_skeleton_resource_state(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + const _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (skeleton) { + return skeleton->slot.state; + } + else { + return SSPINE_RESOURCESTATE_INVALID; + } +} + +SOKOL_API_IMPL sspine_resource_state sspine_get_skinset_resource_state(sspine_skinset skinset_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + const _sspine_skinset_t* skinset = _sspine_lookup_skinset(skinset_id.id); + if (skinset) { + return skinset->slot.state; + } + else { + return SSPINE_RESOURCESTATE_INVALID; + } +} + +SOKOL_API_IMPL sspine_resource_state sspine_get_instance_resource_state(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + const _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (instance) { + return instance->slot.state; + } + else { + return SSPINE_RESOURCESTATE_INVALID; + } +} + +SOKOL_API_IMPL bool sspine_context_valid(sspine_context ctx_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + return sspine_get_context_resource_state(ctx_id) == SSPINE_RESOURCESTATE_VALID; +} + +SOKOL_API_IMPL bool sspine_atlas_valid(sspine_atlas atlas_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + return sspine_get_atlas_resource_state(atlas_id) == SSPINE_RESOURCESTATE_VALID; +} + +SOKOL_API_IMPL bool sspine_skeleton_valid(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + return sspine_get_skeleton_resource_state(skeleton_id) == SSPINE_RESOURCESTATE_VALID; +} + +SOKOL_API_IMPL bool sspine_skinset_valid(sspine_skinset skinset_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + return sspine_get_skinset_resource_state(skinset_id) == SSPINE_RESOURCESTATE_VALID; +} + +SOKOL_API_IMPL bool sspine_instance_valid(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + return sspine_get_instance_resource_state(instance_id) == SSPINE_RESOURCESTATE_VALID; +} + +SOKOL_API_IMPL sspine_atlas sspine_get_skeleton_atlas(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + sspine_atlas res; + _sspine_clear(&res, sizeof(res)); + if (skeleton) { + res.id = skeleton->atlas.id; + } + return res; +} + +SOKOL_API_IMPL sspine_skeleton sspine_get_instance_skeleton(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + sspine_skeleton res; + _sspine_clear(&res, sizeof(res)); + if (instance) { + res.id = instance->skel.id; + } + return res; +} + +SOKOL_API_IMPL int sspine_num_images(sspine_atlas atlas_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_atlas_t* atlas = _sspine_lookup_atlas(atlas_id.id); + if (atlas) { + return atlas->num_pages; + } + return 0; +} + +SOKOL_API_IMPL sspine_image sspine_image_by_index(sspine_atlas atlas_id, int index) { + return _sspine_image(atlas_id.id, index); +} + +SOKOL_API_IMPL bool sspine_image_valid(sspine_image image) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_atlas_t* atlas = _sspine_lookup_atlas(image.atlas_id); + return atlas && (image.index >= 0) && (image.index < atlas->num_pages); +} + +SOKOL_API_IMPL bool sspine_image_equal(sspine_image first, sspine_image second) { + return (first.atlas_id == second.atlas_id) && (first.index == second.index); +} + +SOKOL_API_IMPL sspine_image_info sspine_get_image_info(sspine_image image) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_atlas_t* atlas = _sspine_lookup_atlas(image.atlas_id); + sspine_image_info img_info; + _sspine_clear(&img_info, sizeof(img_info)); + if (atlas && (image.index >= 0) && (image.index < atlas->num_pages)) { + _sspine_init_image_info(atlas, image.index, &img_info, true); + } + return img_info; +} + +SOKOL_API_IMPL int sspine_num_atlas_pages(sspine_atlas atlas_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_atlas_t* atlas = _sspine_lookup_atlas(atlas_id.id); + if (atlas) { + return atlas->num_pages; + } + else { + return 0; + } +} + +SOKOL_API_IMPL sspine_atlas_page sspine_atlas_page_by_index(sspine_atlas atlas_id, int index) { + return _sspine_atlas_page(atlas_id.id, index); +} + +SOKOL_API_IMPL bool sspine_atlas_page_valid(sspine_atlas_page page) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_atlas_t* atlas = _sspine_lookup_atlas(page.atlas_id); + if (atlas) { + return (page.index >= 0) && (page.index < atlas->num_pages); + } + return false; +} + +SOKOL_API_IMPL bool sspine_atlas_page_equal(sspine_atlas_page first, sspine_atlas_page second) { + return (first.atlas_id == second.atlas_id) && (first.index == second.index); +} + +SOKOL_API_IMPL sspine_atlas_page_info sspine_get_atlas_page_info(sspine_atlas_page page) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_atlas_page_info res; + _sspine_clear(&res, sizeof(res)); + const spAtlasPage* sp_page = _sspine_lookup_atlas_page(page.atlas_id, page.index); + if (sp_page) { + // at this point, atlas is guaranteed to be valid + const _sspine_atlas_t* atlas = _sspine_lookup_atlas(page.atlas_id); + res.valid = true; + res.atlas.id = page.atlas_id; + // write image info without overrides + _sspine_init_image_info(atlas, page.index, &res.image, false); + // ...and provide the overrides separately + res.overrides = atlas->overrides; + } + return res; +} + +SOKOL_API_IMPL void sspine_set_position(sspine_instance instance_id, sspine_vec2 position) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (_sspine_instance_and_deps_valid(instance)) { + SOKOL_ASSERT(instance->sp_skel); + instance->sp_skel->x = position.x; + instance->sp_skel->y = position.y; + } +} + +SOKOL_API_IMPL void sspine_set_scale(sspine_instance instance_id, sspine_vec2 scale) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (instance) { + SOKOL_ASSERT(instance->sp_skel); + instance->sp_skel->scaleX = scale.x; + instance->sp_skel->scaleY = scale.y; + } +} + +SOKOL_API_IMPL void sspine_set_color(sspine_instance instance_id, sspine_color color) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (instance) { + SOKOL_ASSERT(instance->sp_skel); + instance->sp_skel->color.r = color.r; + instance->sp_skel->color.g = color.g; + instance->sp_skel->color.b = color.b; + instance->sp_skel->color.a = color.a; + } +} + +SOKOL_API_IMPL sspine_vec2 sspine_get_position(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + sspine_vec2 v = { 0.0f, 0.0f }; + if (instance) { + SOKOL_ASSERT(instance->sp_skel); + v.x = instance->sp_skel->x; + v.y = instance->sp_skel->y; + } + return v; +} + +SOKOL_API_IMPL sspine_vec2 sspine_get_scale(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + sspine_vec2 v = { 0.0f, 0.0f }; + if (instance) { + SOKOL_ASSERT(instance->sp_skel); + v.x = instance->sp_skel->scaleX; + v.y = instance->sp_skel->scaleY; + } + return v; +} + +SOKOL_API_IMPL sspine_color sspine_get_color(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + sspine_color c = { 0.0f, 0.0f, 0.0f, 0.0f }; + if (instance) { + SOKOL_ASSERT(instance->sp_skel); + c.r = instance->sp_skel->color.r; + c.g = instance->sp_skel->color.g; + c.b = instance->sp_skel->color.b; + c.a = instance->sp_skel->color.a; + } + return c; +} + +SOKOL_API_IMPL int sspine_num_anims(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return skeleton->sp_skel_data->animationsCount; + } + return 0; +} + +SOKOL_API_IMPL sspine_anim sspine_anim_by_name(sspine_skeleton skeleton_id, const char* name) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(name); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + // NOTE: there's a spSkeletonData_findAnimation function, but that doesn't + // give us access to the index, so we'll need to do the loop ourselves + SOKOL_ASSERT(skeleton->sp_skel_data); + const spSkeletonData* sp_skel_data = skeleton->sp_skel_data; + const int num_anims = sp_skel_data->animationsCount; + SOKOL_ASSERT(sp_skel_data->animations); + for (int i = 0; i < num_anims; i++) { + SOKOL_ASSERT(sp_skel_data->animations[i]); + SOKOL_ASSERT(sp_skel_data->animations[i]->name); + if (0 == strcmp(sp_skel_data->animations[i]->name, name)) { + return _sspine_anim(skeleton_id.id, i); + } + } + } + return _sspine_anim(0, 0); +} + +SOKOL_API_IMPL sspine_anim sspine_anim_by_index(sspine_skeleton skeleton_id, int index) { + return _sspine_anim(skeleton_id.id, index); +} + +SOKOL_API_IMPL bool sspine_anim_valid(sspine_anim anim) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(anim.skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return (anim.index >= 0) && (anim.index < skeleton->sp_skel_data->animationsCount); + } + return false; +} + +SOKOL_API_IMPL bool sspine_anim_equal(sspine_anim first, sspine_anim second) { + return (first.skeleton_id == second.skeleton_id) && (first.index == second.index); +} + +SOKOL_API_IMPL sspine_anim_info sspine_get_anim_info(sspine_anim anim) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_anim_info res; + _sspine_clear(&res, sizeof(res)); + const spAnimation* sp_anim = _sspine_lookup_skeleton_anim(anim.skeleton_id, anim.index); + if (sp_anim) { + res.valid = true; + res.index = anim.index; + res.duration = sp_anim->duration; + res.name = _sspine_string(sp_anim->name); + if (res.name.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + } + return res; +} + +SOKOL_API_IMPL void sspine_clear_animation_tracks(sspine_instance instance_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (_sspine_instance_and_deps_valid(instance)) { + SOKOL_ASSERT(instance->sp_anim_state); + spAnimationState_clearTracks(instance->sp_anim_state); + } +} + +SOKOL_API_IMPL void sspine_clear_animation_track(sspine_instance instance_id, int track_index) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (_sspine_instance_and_deps_valid(instance)) { + SOKOL_ASSERT(instance->sp_anim_state); + spAnimationState_clearTrack(instance->sp_anim_state, track_index); + } +} + +SOKOL_API_IMPL void sspine_set_animation(sspine_instance instance_id, sspine_anim anim, int track_index, bool loop) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spAnimation* sp_anim = _sspine_lookup_instance_anim(instance_id.id, anim.skeleton_id, anim.index); + if (sp_anim) { + // NOTE: at this point, instance is guaranteed to be valid + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + SOKOL_ASSERT(instance); + spAnimationState_setAnimation(instance->sp_anim_state, track_index, sp_anim, loop?1:0); + } +} + +SOKOL_API_IMPL void sspine_add_animation(sspine_instance instance_id, sspine_anim anim, int track_index, bool loop, float delay) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spAnimation* sp_anim = _sspine_lookup_instance_anim(instance_id.id, anim.skeleton_id, anim.index); + if (sp_anim) { + // NOTE: at this point, instance is guaranteed to be valid + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + SOKOL_ASSERT(instance); + SOKOL_ASSERT(instance->sp_anim_state); + spAnimationState_addAnimation(instance->sp_anim_state, track_index, sp_anim, loop?1:0, delay); + } +} + +SOKOL_API_IMPL void sspine_set_empty_animation(sspine_instance instance_id, int track_index, float mix_duration) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (_sspine_instance_and_deps_valid(instance)) { + SOKOL_ASSERT(instance->sp_anim_state); + spAnimationState_setEmptyAnimation(instance->sp_anim_state, track_index, mix_duration); + } +} + +SOKOL_API_IMPL void sspine_add_empty_animation(sspine_instance instance_id, int track_index, float mix_duration, float delay) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (_sspine_instance_and_deps_valid(instance)) { + SOKOL_ASSERT(instance->sp_anim_state); + spAnimationState_addEmptyAnimation(instance->sp_anim_state, track_index, mix_duration, delay); + } +} + +SOKOL_API_IMPL int sspine_num_bones(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return skeleton->sp_skel_data->bonesCount; + } + return 0; +} + +SOKOL_API_IMPL sspine_bone sspine_bone_by_name(sspine_skeleton skeleton_id, const char* name) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(name); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + spBoneData* sp_bone_data = spSkeletonData_findBone(skeleton->sp_skel_data, name); + if (sp_bone_data) { + return _sspine_bone(skeleton_id.id, sp_bone_data->index); + } + } + return _sspine_bone(0, 0); +} + +SOKOL_API_IMPL sspine_bone sspine_bone_by_index(sspine_skeleton skeleton_id, int index) { + return _sspine_bone(skeleton_id.id, index); +} + +SOKOL_API_IMPL bool sspine_bone_valid(sspine_bone bone) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(bone.skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return (bone.index >= 0) && (bone.index < skeleton->sp_skel_data->bonesCount); + } + return false; +} + +SOKOL_API_IMPL bool sspine_bone_equal(sspine_bone first, sspine_bone second) { + return (first.skeleton_id == second.skeleton_id) && (first.index == second.index); +} + +SOKOL_API_IMPL sspine_bone_info sspine_get_bone_info(sspine_bone bone) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_bone_info res; + _sspine_clear(&res, sizeof(res)); + const spBoneData* sp_bone_data = _sspine_lookup_bone_data(bone.skeleton_id, bone.index); + if (sp_bone_data) { + SOKOL_ASSERT(sp_bone_data->index == bone.index); + SOKOL_ASSERT(sp_bone_data->name); + res.valid = true; + res.index = sp_bone_data->index; + if (sp_bone_data->parent) { + res.parent_bone = _sspine_bone(bone.skeleton_id, sp_bone_data->parent->index); + } + res.length = sp_bone_data->length; + res.pose.position.x = sp_bone_data->x; + res.pose.position.y = sp_bone_data->y; + res.pose.rotation = sp_bone_data->rotation; + res.pose.scale.x = sp_bone_data->scaleX; + res.pose.scale.y = sp_bone_data->scaleY; + res.pose.shear.x = sp_bone_data->shearX; + res.pose.shear.y = sp_bone_data->shearY; + res.color.r = sp_bone_data->color.r; + res.color.g = sp_bone_data->color.g; + res.color.b = sp_bone_data->color.b; + res.color.a = sp_bone_data->color.a; + res.name = _sspine_string(sp_bone_data->name); + if (res.name.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + } + return res; +} + +SOKOL_API_IMPL void sspine_set_bone_transform(sspine_instance instance_id, sspine_bone bone, const sspine_bone_transform* transform) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(transform); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + sp_bone->x = transform->position.x; + sp_bone->y = transform->position.y; + sp_bone->rotation = transform->rotation; + sp_bone->scaleX = transform->scale.x; + sp_bone->scaleY = transform->scale.y; + sp_bone->shearX = transform->shear.x; + sp_bone->shearY = transform->shear.y; + } +} + +SOKOL_API_IMPL void sspine_set_bone_position(sspine_instance instance_id, sspine_bone bone, sspine_vec2 position) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + sp_bone->x = position.x; + sp_bone->y = position.y; + } +} + +SOKOL_API_IMPL void sspine_set_bone_rotation(sspine_instance instance_id, sspine_bone bone, float rotation) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + sp_bone->rotation = rotation; + } +} + +SOKOL_API_IMPL void sspine_set_bone_scale(sspine_instance instance_id, sspine_bone bone, sspine_vec2 scale) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + sp_bone->scaleX = scale.x; + sp_bone->scaleY = scale.y; + } +} + +SOKOL_API_IMPL void sspine_set_bone_shear(sspine_instance instance_id, sspine_bone bone, sspine_vec2 shear) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + sp_bone->shearX = shear.x; + sp_bone->shearY = shear.y; + } +} + +SOKOL_API_IMPL sspine_bone_transform sspine_get_bone_transform(sspine_instance instance_id, sspine_bone bone) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_bone_transform res; + _sspine_clear(&res, sizeof(res)); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + res.position.x = sp_bone->x; + res.position.y = sp_bone->y; + res.rotation = sp_bone->rotation; + res.scale.x = sp_bone->scaleX; + res.scale.y = sp_bone->scaleY; + res.shear.x = sp_bone->shearX; + res.shear.y = sp_bone->shearY; + } + return res; +} + +SOKOL_API_IMPL sspine_vec2 sspine_get_bone_position(sspine_instance instance_id, sspine_bone bone) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_vec2 res; + _sspine_clear(&res, sizeof(res)); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + res.x = sp_bone->x; + res.y = sp_bone->y; + } + return res; +} + +SOKOL_API_IMPL float sspine_get_bone_rotation(sspine_instance instance_id, sspine_bone bone) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + return sp_bone->rotation; + } + else { + return 0.0f; + } +} + +SOKOL_API_IMPL sspine_vec2 sspine_get_bone_scale(sspine_instance instance_id, sspine_bone bone) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_vec2 res; + _sspine_clear(&res, sizeof(res)); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + res.x = sp_bone->scaleX; + res.y = sp_bone->scaleY; + } + return res; +} + +SOKOL_API_IMPL sspine_vec2 sspine_get_bone_shear(sspine_instance instance_id, sspine_bone bone) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_vec2 res; + _sspine_clear(&res, sizeof(res)); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + res.x = sp_bone->shearX; + res.y = sp_bone->shearY; + } + return res; +} + +SOKOL_API_IMPL sspine_vec2 sspine_get_bone_world_position(sspine_instance instance_id, sspine_bone bone) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_vec2 res; + _sspine_clear(&res, sizeof(res)); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + res.x = sp_bone->worldX; + res.y = sp_bone->worldY; + } + return res; +} + +SOKOL_API_IMPL sspine_vec2 sspine_bone_local_to_world(sspine_instance instance_id, sspine_bone bone, sspine_vec2 local_pos) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_vec2 res; + _sspine_clear(&res, sizeof(res)); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + spBone_localToWorld(sp_bone, local_pos.x, local_pos.y, &res.x, &res.y); + } + return res; +} + +SOKOL_API_IMPL sspine_vec2 sspine_bone_world_to_local(sspine_instance instance_id, sspine_bone bone, sspine_vec2 world_pos) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_vec2 res; + _sspine_clear(&res, sizeof(res)); + spBone* sp_bone = _sspine_lookup_bone(instance_id.id, bone.skeleton_id, bone.index); + if (sp_bone) { + spBone_worldToLocal(sp_bone, world_pos.x, world_pos.y, &res.x, &res.y); + } + return res; +} + +SOKOL_API_IMPL int sspine_num_slots(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return skeleton->sp_skel_data->slotsCount; + } + return 0; +} + +SOKOL_API_IMPL sspine_slot sspine_slot_by_name(sspine_skeleton skeleton_id, const char* name) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(name); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + spSlotData* sp_slot_data = spSkeletonData_findSlot(skeleton->sp_skel_data, name); + if (sp_slot_data) { + return _sspine_slot(skeleton_id.id, sp_slot_data->index); + } + } + return _sspine_slot(0, 0); +} + +SOKOL_API_IMPL sspine_slot sspine_slot_by_index(sspine_skeleton skeleton_id, int index) { + return _sspine_slot(skeleton_id.id, index); +} + +SOKOL_API_IMPL bool sspine_slot_valid(sspine_slot slot) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(slot.skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return (slot.index >= 0) && (slot.index < skeleton->sp_skel_data->slotsCount); + } + return false; +} + +SOKOL_API_IMPL bool sspine_slot_equal(sspine_slot first, sspine_slot second) { + return (first.skeleton_id == second.skeleton_id) && (first.index == second.index); +} + +SOKOL_API_IMPL sspine_slot_info sspine_get_slot_info(sspine_slot slot) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_slot_info res; + _sspine_clear(&res, sizeof(res)); + const spSlotData* sp_slot_data = _sspine_lookup_slot_data(slot.skeleton_id, slot.index); + if (sp_slot_data) { + SOKOL_ASSERT(sp_slot_data->index == slot.index); + SOKOL_ASSERT(sp_slot_data->name); + SOKOL_ASSERT(sp_slot_data->boneData); + res.valid = true; + res.index = sp_slot_data->index; + res.bone = _sspine_bone(slot.skeleton_id, sp_slot_data->boneData->index); + res.color.r = sp_slot_data->color.r; + res.color.g = sp_slot_data->color.g; + res.color.b = sp_slot_data->color.b; + res.color.a = sp_slot_data->color.a; + res.attachment_name = _sspine_string(sp_slot_data->attachmentName); + if (res.attachment_name.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + res.name = _sspine_string(sp_slot_data->name); + if (res.name.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + } + return res; +} + +SOKOL_API_IMPL void sspine_set_slot_color(sspine_instance instance_id, sspine_slot slot, sspine_color color) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spSlot* sp_slot = _sspine_lookup_slot(instance_id.id, slot.skeleton_id, slot.index); + if (sp_slot) { + sp_slot->color.r = color.r; + sp_slot->color.g = color.g; + sp_slot->color.b = color.b; + sp_slot->color.a = color.a; + } +} + +SOKOL_API_IMPL sspine_color sspine_get_slot_color(sspine_instance instance_id, sspine_slot slot) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_color color; + _sspine_clear(&color, sizeof(color)); + spSlot* sp_slot = _sspine_lookup_slot(instance_id.id, slot.skeleton_id, slot.index); + if (sp_slot) { + color.r = sp_slot->color.r; + color.g = sp_slot->color.g; + color.b = sp_slot->color.b; + color.a = sp_slot->color.a; + } + return color; +} + +SOKOL_API_IMPL int sspine_num_events(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return skeleton->sp_skel_data->eventsCount; + } + return 0; +} + +SOKOL_API_IMPL sspine_event sspine_event_by_name(sspine_skeleton skeleton_id, const char* name) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(name); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + SOKOL_ASSERT(skeleton->sp_skel_data->events); + // spEventData has no embedded index, so we need to loop over the events + for (int i = 0; i < skeleton->sp_skel_data->eventsCount; i++) { + SOKOL_ASSERT(skeleton->sp_skel_data->events[i]); + SOKOL_ASSERT(skeleton->sp_skel_data->events[i]->name); + if (0 == strcmp(skeleton->sp_skel_data->events[i]->name, name)) { + return _sspine_event(skeleton_id.id, i); + } + } + } + return _sspine_event(0, 0); +} + +SOKOL_API_IMPL sspine_event sspine_event_by_index(sspine_skeleton skeleton_id, int index) { + return _sspine_event(skeleton_id.id, index); +} + +SOKOL_API_IMPL bool sspine_event_valid(sspine_event event) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(event.skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return (event.index >= 0) && (event.index < skeleton->sp_skel_data->eventsCount); + } + return false; +} + +SOKOL_API_IMPL bool sspine_event_equal(sspine_event first, sspine_event second) { + return (first.skeleton_id == second.skeleton_id) && (first.index == second.index); +} + +SOKOL_API_IMPL sspine_event_info sspine_get_event_info(sspine_event event) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_event_info res; + _sspine_clear(&res, sizeof(res)); + const spEventData* sp_event_data = _sspine_lookup_event_data(event.skeleton_id, event.index); + if (sp_event_data) { + res.valid = true; + res.index = event.index; + res.int_value = sp_event_data->intValue; + res.float_value = sp_event_data->floatValue; + res.volume = sp_event_data->volume; + res.balance = sp_event_data->balance; + res.name = _sspine_string(sp_event_data->name); + if (res.name.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + res.string_value = _sspine_string(sp_event_data->stringValue); + if (res.string_value.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + res.audio_path = _sspine_string(sp_event_data->audioPath); + if (res.audio_path.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + } + return res; +} + +SOKOL_API_IMPL int sspine_num_iktargets(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return skeleton->sp_skel_data->ikConstraintsCount; + } + return 0; +} + +SOKOL_API_IMPL sspine_iktarget sspine_iktarget_by_name(sspine_skeleton skeleton_id, const char* name) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(name); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + SOKOL_ASSERT(skeleton->sp_skel_data->ikConstraints); + // spIkConstraintData has no embedded index, so we need to loop over the events + for (int i = 0; i < skeleton->sp_skel_data->ikConstraintsCount; i++) { + SOKOL_ASSERT(skeleton->sp_skel_data->ikConstraints[i]); + SOKOL_ASSERT(skeleton->sp_skel_data->ikConstraints[i]->name); + if (0 == strcmp(skeleton->sp_skel_data->ikConstraints[i]->name, name)) { + return _sspine_iktarget(skeleton_id.id, i); + } + } + } + return _sspine_iktarget(0, 0); +} + +SOKOL_API_IMPL sspine_iktarget sspine_iktarget_by_index(sspine_skeleton skeleton_id, int index) { + return _sspine_iktarget(skeleton_id.id, index); +} + +SOKOL_API_IMPL bool sspine_iktarget_valid(sspine_iktarget iktarget) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(iktarget.skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return (iktarget.index >= 0) && (iktarget.index < skeleton->sp_skel_data->ikConstraintsCount); + } + return false; +} + +SOKOL_API_IMPL bool sspine_iktarget_equal(sspine_iktarget first, sspine_iktarget second) { + return (first.skeleton_id == second.skeleton_id) && (first.index == second.index); +} + +SOKOL_API_IMPL sspine_iktarget_info sspine_get_iktarget_info(sspine_iktarget iktarget) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_iktarget_info res; + _sspine_clear(&res, sizeof(res)); + const spIkConstraintData* ik_data = _sspine_lookup_ikconstraint_data(iktarget.skeleton_id, iktarget.index); + if (ik_data) { + res.valid = true; + res.index = iktarget.index; + res.target_bone = _sspine_bone(iktarget.skeleton_id, ik_data->target->index); + res.name = _sspine_string(ik_data->name); + if (res.name.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + } + return res; +} + +SOKOL_API_IMPL void sspine_set_iktarget_world_pos(sspine_instance instance_id, sspine_iktarget iktarget, sspine_vec2 world_pos) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + spIkConstraint* ik_data = _sspine_lookup_ikconstraint(instance_id.id, iktarget.skeleton_id, iktarget.index); + if (ik_data) { + spBone* bone = ik_data->target; + spBone* parent_bone = bone->parent; + if (parent_bone) { + spBone_worldToLocal(parent_bone, world_pos.x, world_pos.y, &bone->x, &bone->y); + } + } +} + +SOKOL_API_IMPL int sspine_num_skins(sspine_skeleton skeleton_id) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return skeleton->sp_skel_data->skinsCount; + } + return 0; +} + +SOKOL_API_IMPL sspine_skin sspine_skin_by_name(sspine_skeleton skeleton_id, const char* name) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + SOKOL_ASSERT(name); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skeleton_id.id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + SOKOL_ASSERT(skeleton->sp_skel_data->skins); + // spSkin has no embedded index, so we need to loop over the skins + for (int i = 0; i < skeleton->sp_skel_data->skinsCount; i++) { + SOKOL_ASSERT(skeleton->sp_skel_data->skins[i]); + SOKOL_ASSERT(skeleton->sp_skel_data->skins[i]->name); + if (0 == strcmp(skeleton->sp_skel_data->skins[i]->name, name)) { + return _sspine_skin(skeleton_id.id, i); + } + } + } + return _sspine_skin(0, 0); +} + +SOKOL_API_IMPL sspine_skin sspine_skin_by_index(sspine_skeleton skeleton_id, int index) { + return _sspine_skin(skeleton_id.id, index); +} + +SOKOL_API_IMPL bool sspine_skin_valid(sspine_skin skin) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_skeleton_t* skeleton = _sspine_lookup_skeleton(skin.skeleton_id); + if (_sspine_skeleton_and_deps_valid(skeleton)) { + SOKOL_ASSERT(skeleton->sp_skel_data); + return (skin.index >= 0) && (skin.index < skeleton->sp_skel_data->skinsCount); + } + return false; +} + +SOKOL_API_IMPL bool sspine_skin_equal(sspine_skin first, sspine_skin second) { + return (first.skeleton_id == second.skeleton_id) && (first.index == second.index); +} + +SOKOL_API_IMPL sspine_skin_info sspine_get_skin_info(sspine_skin skin) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + sspine_skin_info res; + _sspine_clear(&res, sizeof(res)); + const spSkin* sp_skin = _sspine_lookup_skin(skin.skeleton_id, skin.index); + if (sp_skin) { + res.valid = true; + res.index = skin.index; + res.name = _sspine_string(sp_skin->name); + if (res.name.truncated) { + _SSPINE_WARN(STRING_TRUNCATED); + } + } + return res; +} + +SOKOL_SPINE_API_DECL void sspine_set_skin(sspine_instance instance_id, sspine_skin skin) { + SOKOL_ASSERT(_SSPINE_INIT_COOKIE == _sspine.init_cookie); + _sspine_instance_t* instance = _sspine_lookup_instance(instance_id.id); + if (_sspine_instance_and_deps_valid(instance) && (instance->skel.id == skin.skeleton_id)) { + SOKOL_ASSERT(instance->sp_skel); + SOKOL_ASSERT(instance->sp_anim_state); + // clear any currently set skinset + instance->skinset.id = SSPINE_INVALID_ID; + instance->skinset.ptr = 0; + spSkin* sp_skin = _sspine_lookup_skin(skin.skeleton_id, skin.index); + if (sp_skin) { + spSkeleton_setSkin(instance->sp_skel, 0); + spSkeleton_setSkin(instance->sp_skel, sp_skin); + spSkeleton_setSlotsToSetupPose(instance->sp_skel); + spAnimationState_apply(instance->sp_anim_state, instance->sp_skel); + } + } +} + +#endif // SOKOL_SPINE_IMPL +#endif // SOKOL_SPINE_INCLUDED diff --git a/source/engine/timer.c b/source/engine/timer.c index ac3ccfa..482307d 100644 --- a/source/engine/timer.c +++ b/source/engine/timer.c @@ -1,88 +1,86 @@ #include "timer.h" -#include #include "log.h" +#include #include struct timer *timers; static int first = -1; -void check_timer(struct timer *t, double dt) -{ - if (!t->on) - return; +void check_timer(struct timer *t, double dt) { + if (!t->on) + return; - t->remain_time -= dt; + t->remain_time -= dt; - if (t->remain_time <= 0) { - t->cb(t->data); - if (t->repeat) { - t->remain_time = t->interval; - return; - } - - timer_pause(t); - return; + if (t->remain_time <= 0) { + t->cb(t->data); + if (t->repeat) { + t->remain_time = t->interval; + return; } + + timer_pause(t); + return; + } } void timer_update(double dt) { - for (int i = 0; i < arrlen(timers); i++) - check_timer(&timers[i], dt); + for (int i = 0; i < arrlen(timers); i++) + check_timer(&timers[i], dt); } int timer_make(double interval, void (*callback)(void *param), void *param, int own) { - struct timer new; - new.remain_time = interval; - new.interval = interval; - new.cb = callback; - new.data = param; - new.repeat = 1; - new.owndata = own; - new.next = -1; - - if (first < 0) { - timer_start(&new); - arrput(timers, new); - return arrlen(timers)-1; - } else { - int retid = first; - first = id2timer(first)->next; - *id2timer(retid) = new; - timer_start(id2timer(retid)); - return retid; - } + struct timer new; + new.remain_time = interval; + new.interval = interval; + new.cb = callback; + new.data = param; + new.repeat = 1; + new.owndata = own; + new.next = -1; + + if (first < 0) { + timer_start(&new); + arrput(timers, new); + return arrlen(timers) - 1; + } else { + int retid = first; + first = id2timer(first)->next; + *id2timer(retid) = new; + timer_start(id2timer(retid)); + return retid; + } } void timer_pause(struct timer *t) { - if (!t->on) return; - t->on = 0; + if (!t->on) return; + t->on = 0; } void timer_stop(struct timer *t) { - if (!t->on) return; - t->on = 0; - t->remain_time = t->interval; + if (!t->on) return; + t->on = 0; + t->remain_time = t->interval; } void timer_start(struct timer *t) { - if (t->on) return; - t->on = 1; + if (t->on) return; + t->on = 1; } void timer_remove(int id) { - struct timer *t = id2timer(id); - if (t->owndata) free(t->data); - t->next = first; - first = id; + struct timer *t = id2timer(id); + if (t->owndata) free(t->data); + t->next = first; + first = id; } void timerr_settime(struct timer *t, double interval) { - t->remain_time += (interval - t->interval); - t->interval = interval; + t->remain_time += (interval - t->interval); + t->interval = interval; } -struct timer *id2timer(int id) -{ - return &timers[id]; +struct timer *id2timer(int id) { + return &timers[id]; } diff --git a/source/engine/tinyspline.c b/source/engine/tinyspline.c index 53a5a3c..f19c6df 100644 --- a/source/engine/tinyspline.c +++ b/source/engine/tinyspline.c @@ -2,32 +2,30 @@ #include "tinyspline.h" #include "parson.h" /* serialization */ -#include /* malloc, free */ #include /* fabs, sqrt, acos */ -#include /* memcpy, memmove */ -#include /* FILE, fopen */ #include /* varargs */ +#include /* FILE, fopen */ +#include /* malloc, free */ +#include /* memcpy, memmove */ /* Suppress some useless MSVC warnings. */ #ifdef _MSC_VER #pragma warning(push) /* address of dllimport */ -#pragma warning(disable:4232) +#pragma warning(disable : 4232) /* function not inlined */ -#pragma warning(disable:4710) +#pragma warning(disable : 4710) /* byte padding */ -#pragma warning(disable:4820) +#pragma warning(disable : 4820) /* meaningless deprecation */ -#pragma warning(disable:4996) +#pragma warning(disable : 4996) /* Spectre mitigation */ -#pragma warning(disable:5045) +#pragma warning(disable : 5045) #endif -#define INIT_OUT_BSPLINE(in, out) \ - if ((in) != (out)) \ - ts_int_bspline_init(out); - - +#define INIT_OUT_BSPLINE(in, out) \ + if ((in) != (out)) \ + ts_int_bspline_init(out); /*! @name Internal Structs and Functions * @@ -38,302 +36,267 @@ /** * Stores the private data of ::tsBSpline. */ -struct tsBSplineImpl -{ - size_t deg; /**< Degree of B-Spline basis function. */ - size_t dim; /**< Dimensionality of the control points (2D => x, y). */ - size_t n_ctrlp; /**< Number of control points. */ - size_t n_knots; /**< Number of knots (n_ctrlp + deg + 1). */ +struct tsBSplineImpl { + size_t deg; /**< Degree of B-Spline basis function. */ + size_t dim; /**< Dimensionality of the control points (2D => x, y). */ + size_t n_ctrlp; /**< Number of control points. */ + size_t n_knots; /**< Number of knots (n_ctrlp + deg + 1). */ }; /** * Stores the private data of ::tsDeBoorNet. */ -struct tsDeBoorNetImpl -{ - tsReal u; /**< The evaluated knot. */ - size_t k; /**< The index [u_k, u_k+1) */ - size_t s; /**< Multiplicity of u_k. */ - size_t h; /**< Number of insertions required to obtain result. */ - size_t dim; /**< Dimensionality of the points (2D => x, y). */ - size_t n_points; /** Number of points in `points'. */ +struct tsDeBoorNetImpl { + tsReal u; /**< The evaluated knot. */ + size_t k; /**< The index [u_k, u_k+1) */ + size_t s; /**< Multiplicity of u_k. */ + size_t h; /**< Number of insertions required to obtain result. */ + size_t dim; /**< Dimensionality of the points (2D => x, y). */ + size_t n_points; /** Number of points in `points'. */ }; -void -ts_int_bspline_init(tsBSpline *spline) -{ - spline->pImpl = NULL; +void ts_int_bspline_init(tsBSpline *spline) { + spline->pImpl = NULL; } size_t -ts_int_bspline_sof_state(const tsBSpline *spline) -{ - return sizeof(struct tsBSplineImpl) + - ts_bspline_sof_control_points(spline) + - ts_bspline_sof_knots(spline); +ts_int_bspline_sof_state(const tsBSpline *spline) { + return sizeof(struct tsBSplineImpl) + + ts_bspline_sof_control_points(spline) + + ts_bspline_sof_knots(spline); } tsReal * -ts_int_bspline_access_ctrlp(const tsBSpline *spline) -{ - return (tsReal *) (& spline->pImpl[1]); +ts_int_bspline_access_ctrlp(const tsBSpline *spline) { + return (tsReal *)(&spline->pImpl[1]); } tsReal * -ts_int_bspline_access_knots(const tsBSpline *spline) -{ - return ts_int_bspline_access_ctrlp(spline) + - ts_bspline_len_control_points(spline); +ts_int_bspline_access_knots(const tsBSpline *spline) { + return ts_int_bspline_access_ctrlp(spline) + + ts_bspline_len_control_points(spline); } tsError ts_int_bspline_access_ctrlp_at(const tsBSpline *spline, size_t index, tsReal **ctrlp, - tsStatus *status) -{ - const size_t num = ts_bspline_num_control_points(spline); - if (index >= num) { - TS_RETURN_2(status, TS_INDEX_ERROR, - "index (%lu) >= num(control_points) (%lu)", - (unsigned long) index, - (unsigned long) num) - } - *ctrlp = ts_int_bspline_access_ctrlp(spline) + - index * ts_bspline_dimension(spline); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t num = ts_bspline_num_control_points(spline); + if (index >= num) { + TS_RETURN_2(status, TS_INDEX_ERROR, + "index (%lu) >= num(control_points) (%lu)", + (unsigned long)index, + (unsigned long)num) + } + *ctrlp = ts_int_bspline_access_ctrlp(spline) + + index * ts_bspline_dimension(spline); + TS_RETURN_SUCCESS(status) } tsError ts_int_bspline_access_knot_at(const tsBSpline *spline, size_t index, tsReal *knot, - tsStatus *status) -{ - const size_t num = ts_bspline_num_knots(spline); - if (index >= num) { - TS_RETURN_2(status, TS_INDEX_ERROR, - "index (%lu) >= num(knots) (%lu)", - (unsigned long) index, - (unsigned long) num) - } - *knot = ts_int_bspline_access_knots(spline)[index]; - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t num = ts_bspline_num_knots(spline); + if (index >= num) { + TS_RETURN_2(status, TS_INDEX_ERROR, + "index (%lu) >= num(knots) (%lu)", + (unsigned long)index, + (unsigned long)num) + } + *knot = ts_int_bspline_access_knots(spline)[index]; + TS_RETURN_SUCCESS(status) } -void -ts_int_deboornet_init(tsDeBoorNet *net) -{ - net->pImpl = NULL; +void ts_int_deboornet_init(tsDeBoorNet *net) { + net->pImpl = NULL; } size_t -ts_int_deboornet_sof_state(const tsDeBoorNet *net) -{ - return sizeof(struct tsDeBoorNetImpl) + - ts_deboornet_sof_points(net) + - ts_deboornet_sof_result(net); +ts_int_deboornet_sof_state(const tsDeBoorNet *net) { + return sizeof(struct tsDeBoorNetImpl) + + ts_deboornet_sof_points(net) + + ts_deboornet_sof_result(net); } tsReal * -ts_int_deboornet_access_points(const tsDeBoorNet *net) -{ - return (tsReal *) (& net->pImpl[1]); +ts_int_deboornet_access_points(const tsDeBoorNet *net) { + return (tsReal *)(&net->pImpl[1]); } tsReal * -ts_int_deboornet_access_result(const tsDeBoorNet *net) -{ - if (ts_deboornet_num_result(net) == 2) { - return ts_int_deboornet_access_points(net); - } else { - return ts_int_deboornet_access_points(net) + - /* Last point in `points`. */ - (ts_deboornet_len_points(net) - - ts_deboornet_dimension(net)); - } +ts_int_deboornet_access_result(const tsDeBoorNet *net) { + if (ts_deboornet_num_result(net) == 2) { + return ts_int_deboornet_access_points(net); + } else { + return ts_int_deboornet_access_points(net) + + /* Last point in `points`. */ + (ts_deboornet_len_points(net) - + ts_deboornet_dimension(net)); + } } /*! @} */ - - /*! @name B-Spline Data * * @{ */ size_t -ts_bspline_degree(const tsBSpline *spline) -{ - return spline->pImpl->deg; +ts_bspline_degree(const tsBSpline *spline) { + return spline->pImpl->deg; } size_t -ts_bspline_order(const tsBSpline *spline) -{ - return ts_bspline_degree(spline) + 1; +ts_bspline_order(const tsBSpline *spline) { + return ts_bspline_degree(spline) + 1; } size_t -ts_bspline_dimension(const tsBSpline *spline) -{ - return spline->pImpl->dim; +ts_bspline_dimension(const tsBSpline *spline) { + return spline->pImpl->dim; } size_t -ts_bspline_len_control_points(const tsBSpline *spline) -{ - return ts_bspline_num_control_points(spline) * - ts_bspline_dimension(spline); +ts_bspline_len_control_points(const tsBSpline *spline) { + return ts_bspline_num_control_points(spline) * + ts_bspline_dimension(spline); } size_t -ts_bspline_num_control_points(const tsBSpline *spline) -{ - return spline->pImpl->n_ctrlp; +ts_bspline_num_control_points(const tsBSpline *spline) { + return spline->pImpl->n_ctrlp; } size_t -ts_bspline_sof_control_points(const tsBSpline *spline) -{ - return ts_bspline_len_control_points(spline) * sizeof(tsReal); +ts_bspline_sof_control_points(const tsBSpline *spline) { + return ts_bspline_len_control_points(spline) * sizeof(tsReal); } const tsReal * -ts_bspline_control_points_ptr(const tsBSpline *spline) -{ - return ts_int_bspline_access_ctrlp(spline); +ts_bspline_control_points_ptr(const tsBSpline *spline) { + return ts_int_bspline_access_ctrlp(spline); } tsError ts_bspline_control_points(const tsBSpline *spline, tsReal **ctrlp, - tsStatus *status) -{ - const size_t size = ts_bspline_sof_control_points(spline); - *ctrlp = (tsReal*) malloc(size); - if (!*ctrlp) - TS_RETURN_0(status, TS_MALLOC, "out of memory") - memcpy(*ctrlp, ts_int_bspline_access_ctrlp(spline), size); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t size = ts_bspline_sof_control_points(spline); + *ctrlp = (tsReal *)malloc(size); + if (!*ctrlp) + TS_RETURN_0(status, TS_MALLOC, "out of memory") + memcpy(*ctrlp, ts_int_bspline_access_ctrlp(spline), size); + TS_RETURN_SUCCESS(status) } tsError ts_bspline_control_point_at_ptr(const tsBSpline *spline, size_t index, const tsReal **ctrlp, - tsStatus *status) -{ - tsReal *vals; - tsError err; - TS_TRY(try, err, status) - TS_CALL(try, err, ts_int_bspline_access_ctrlp_at( - spline, index, &vals, status)) - *ctrlp = vals; - TS_CATCH(err) - *ctrlp = NULL; - TS_END_TRY_RETURN(err) + tsStatus *status) { + tsReal *vals; + tsError err; + TS_TRY(try, err, status) + TS_CALL(try, err, ts_int_bspline_access_ctrlp_at(spline, index, &vals, status)) + *ctrlp = vals; + TS_CATCH(err) + *ctrlp = NULL; + TS_END_TRY_RETURN(err) } tsError ts_bspline_set_control_points(tsBSpline *spline, const tsReal *ctrlp, - tsStatus *status) -{ - const size_t size = ts_bspline_sof_control_points(spline); - memmove(ts_int_bspline_access_ctrlp(spline), ctrlp, size); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t size = ts_bspline_sof_control_points(spline); + memmove(ts_int_bspline_access_ctrlp(spline), ctrlp, size); + TS_RETURN_SUCCESS(status) } tsError ts_bspline_set_control_point_at(tsBSpline *spline, size_t index, const tsReal *ctrlp, - tsStatus *status) -{ - tsReal *to; - size_t size; - tsError err; - TS_TRY(try, err, status) - TS_CALL(try, err, ts_int_bspline_access_ctrlp_at( - spline, index, &to, status)) - size = ts_bspline_dimension(spline) * sizeof(tsReal); - memcpy(to, ctrlp, size); - TS_END_TRY_RETURN(err) + tsStatus *status) { + tsReal *to; + size_t size; + tsError err; + TS_TRY(try, err, status) + TS_CALL(try, err, ts_int_bspline_access_ctrlp_at(spline, index, &to, status)) + size = ts_bspline_dimension(spline) * sizeof(tsReal); + memcpy(to, ctrlp, size); + TS_END_TRY_RETURN(err) } size_t -ts_bspline_num_knots(const tsBSpline *spline) -{ - return spline->pImpl->n_knots; +ts_bspline_num_knots(const tsBSpline *spline) { + return spline->pImpl->n_knots; } size_t -ts_bspline_sof_knots(const tsBSpline *spline) -{ - return ts_bspline_num_knots(spline) * sizeof(tsReal); +ts_bspline_sof_knots(const tsBSpline *spline) { + return ts_bspline_num_knots(spline) * sizeof(tsReal); } const tsReal * -ts_bspline_knots_ptr(const tsBSpline *spline) -{ - return ts_int_bspline_access_knots(spline); +ts_bspline_knots_ptr(const tsBSpline *spline) { + return ts_int_bspline_access_knots(spline); } tsError ts_bspline_knots(const tsBSpline *spline, tsReal **knots, - tsStatus *status) -{ - const size_t size = ts_bspline_sof_knots(spline); - *knots = (tsReal*) malloc(size); - if (!*knots) - TS_RETURN_0(status, TS_MALLOC, "out of memory") - memcpy(*knots, ts_int_bspline_access_knots(spline), size); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t size = ts_bspline_sof_knots(spline); + *knots = (tsReal *)malloc(size); + if (!*knots) + TS_RETURN_0(status, TS_MALLOC, "out of memory") + memcpy(*knots, ts_int_bspline_access_knots(spline), size); + TS_RETURN_SUCCESS(status) } tsError ts_bspline_knot_at(const tsBSpline *spline, size_t index, tsReal *knot, - tsStatus *status) -{ - return ts_int_bspline_access_knot_at(spline, index, knot, status); + tsStatus *status) { + return ts_int_bspline_access_knot_at(spline, index, knot, status); } tsError ts_bspline_set_knots(tsBSpline *spline, const tsReal *knots, - tsStatus *status) -{ - const size_t size = ts_bspline_sof_knots(spline); - const size_t num_knots = ts_bspline_num_knots(spline); - const size_t order = ts_bspline_order(spline); - size_t idx, mult; - tsReal lst_knot, knot; - lst_knot = knots[0]; - mult = 1; - for (idx = 1; idx < num_knots; idx++) { - knot = knots[idx]; - if (ts_knots_equal(lst_knot, knot)) { - mult++; - } else if (lst_knot > knot) { - TS_RETURN_1(status, TS_KNOTS_DECR, - "decreasing knot vector at index: %lu", - (unsigned long) idx) - } else { - mult = 0; - } - if (mult > order) { - TS_RETURN_3(status, TS_MULTIPLICITY, - "mult(%f) (%lu) > order (%lu)", - knot, (unsigned long) mult, - (unsigned long) order) - } - lst_knot = knot; - } - memmove(ts_int_bspline_access_knots(spline), knots, size); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t size = ts_bspline_sof_knots(spline); + const size_t num_knots = ts_bspline_num_knots(spline); + const size_t order = ts_bspline_order(spline); + size_t idx, mult; + tsReal lst_knot, knot; + lst_knot = knots[0]; + mult = 1; + for (idx = 1; idx < num_knots; idx++) { + knot = knots[idx]; + if (ts_knots_equal(lst_knot, knot)) { + mult++; + } else if (lst_knot > knot) { + TS_RETURN_1(status, TS_KNOTS_DECR, + "decreasing knot vector at index: %lu", + (unsigned long)idx) + } else { + mult = 0; + } + if (mult > order) { + TS_RETURN_3(status, TS_MULTIPLICITY, + "mult(%f) (%lu) > order (%lu)", + knot, (unsigned long)mult, + (unsigned long)order) + } + lst_knot = knot; + } + memmove(ts_int_bspline_access_knots(spline), knots, size); + TS_RETURN_SUCCESS(status) } tsError @@ -341,122 +304,109 @@ ts_bspline_set_knots_varargs(tsBSpline *spline, tsStatus *status, tsReal knot0, double knot1, - ...) -{ - tsReal *values = NULL; - va_list argp; - size_t idx; - tsError err; + ...) { + tsReal *values = NULL; + va_list argp; + size_t idx; + tsError err; - TS_TRY(try, err, status) - TS_CALL(try, err, ts_bspline_knots( - spline, &values, status)) + TS_TRY(try, err, status) + TS_CALL(try, err, ts_bspline_knots(spline, &values, status)) - values[0] = knot0; - values[1] = (tsReal) knot1; - va_start(argp, knot1); - for (idx = 2; idx < ts_bspline_num_knots(spline); idx++) - values[idx] = (tsReal) va_arg(argp, double); - va_end(argp); + values[0] = knot0; + values[1] = (tsReal)knot1; + va_start(argp, knot1); + for (idx = 2; idx < ts_bspline_num_knots(spline); idx++) + values[idx] = (tsReal)va_arg(argp, double); + va_end(argp); - TS_CALL(try, err, ts_bspline_set_knots( - spline, values, status)) - TS_FINALLY - if (values) - free(values); - TS_END_TRY_RETURN(err) + TS_CALL(try, err, ts_bspline_set_knots(spline, values, status)) + TS_FINALLY + if (values) + free(values); + TS_END_TRY_RETURN(err) } tsError ts_bspline_set_knot_at(tsBSpline *spline, size_t index, tsReal knot, - tsStatus *status) -{ - tsError err; - tsReal *knots = NULL; - /* This is only for initialization. */ - tsReal oldKnot = ts_int_bspline_access_knots(spline)[0]; - TS_TRY(try, err, status) - TS_CALL(try, err, ts_int_bspline_access_knot_at( - spline, index, &oldKnot, status)) - /* knots must be set after reading oldKnot because the catch - * block assumes that oldKnot contains the correct value if - * knots is not NULL. */ - knots = ts_int_bspline_access_knots(spline); - knots[index] = knot; - TS_CALL(try, err, ts_bspline_set_knots( - spline, knots, status)) - TS_CATCH(err) - /* If knots is not NULL, oldKnot contains the correct value. */ - if (knots) - knots[index] = oldKnot; - TS_END_TRY_RETURN(err) + tsStatus *status) { + tsError err; + tsReal *knots = NULL; + /* This is only for initialization. */ + tsReal oldKnot = ts_int_bspline_access_knots(spline)[0]; + TS_TRY(try, err, status) + TS_CALL(try, err, ts_int_bspline_access_knot_at(spline, index, &oldKnot, status)) + /* knots must be set after reading oldKnot because the catch + * block assumes that oldKnot contains the correct value if + * knots is not NULL. */ + knots = ts_int_bspline_access_knots(spline); + knots[index] = knot; + TS_CALL(try, err, ts_bspline_set_knots(spline, knots, status)) + TS_CATCH(err) + /* If knots is not NULL, oldKnot contains the correct value. */ + if (knots) + knots[index] = oldKnot; + TS_END_TRY_RETURN(err) } /*! @} */ - - /*! @name B-Spline Initialization * * @{ */ tsBSpline -ts_bspline_init(void) -{ - tsBSpline spline; - ts_int_bspline_init(&spline); - return spline; +ts_bspline_init(void) { + tsBSpline spline; + ts_int_bspline_init(&spline); + return spline; } tsError ts_int_bspline_generate_knots(const tsBSpline *spline, tsBSplineType type, - tsStatus *status) -{ - const size_t n_knots = ts_bspline_num_knots(spline); - const size_t deg = ts_bspline_degree(spline); - const size_t order = ts_bspline_order(spline); - tsReal fac; /**< Factor used to calculate the knot values. */ - size_t i; /**< Used in for loops. */ - tsReal *knots; /**< Pointer to the knots of \p _result_. */ + tsStatus *status) { + const size_t n_knots = ts_bspline_num_knots(spline); + const size_t deg = ts_bspline_degree(spline); + const size_t order = ts_bspline_order(spline); + tsReal fac; /**< Factor used to calculate the knot values. */ + size_t i; /**< Used in for loops. */ + tsReal *knots; /**< Pointer to the knots of \p _result_. */ - /* order >= 1 implies 2*order >= 2 implies n_knots >= 2 */ - if (type == TS_BEZIERS && n_knots % order != 0) { - TS_RETURN_2(status, TS_NUM_KNOTS, - "num(knots) (%lu) %% order (%lu) != 0", - (unsigned long) n_knots, (unsigned long) order) - } + /* order >= 1 implies 2*order >= 2 implies n_knots >= 2 */ + if (type == TS_BEZIERS && n_knots % order != 0) { + TS_RETURN_2(status, TS_NUM_KNOTS, + "num(knots) (%lu) %% order (%lu) != 0", + (unsigned long)n_knots, (unsigned long)order) + } - knots = ts_int_bspline_access_knots(spline); + knots = ts_int_bspline_access_knots(spline); - if (type == TS_OPENED) { - knots[0] = TS_DOMAIN_DEFAULT_MIN; /* n_knots >= 2 */ - fac = (TS_DOMAIN_DEFAULT_MAX - TS_DOMAIN_DEFAULT_MIN) - / (n_knots - 1); /* n_knots >= 2 */ - for (i = 1; i < n_knots-1; i++) - knots[i] = TS_DOMAIN_DEFAULT_MIN + i*fac; - knots[i] = TS_DOMAIN_DEFAULT_MAX; /* n_knots >= 2 */ - } else if (type == TS_CLAMPED) { - /* n_knots >= 2*order == 2*(deg+1) == 2*deg + 2 > 2*deg - 1 */ - fac = (TS_DOMAIN_DEFAULT_MAX - TS_DOMAIN_DEFAULT_MIN) - / (n_knots - 2*deg - 1); - ts_arr_fill(knots, order, TS_DOMAIN_DEFAULT_MIN); - for (i = order ;i < n_knots-order; i++) - knots[i] = TS_DOMAIN_DEFAULT_MIN + (i-deg)*fac; - ts_arr_fill(knots + i, order, TS_DOMAIN_DEFAULT_MAX); - } else if (type == TS_BEZIERS) { - /* n_knots >= 2*order implies n_knots/order >= 2 */ - fac = (TS_DOMAIN_DEFAULT_MAX - TS_DOMAIN_DEFAULT_MIN) - / (n_knots/order - 1); - ts_arr_fill(knots, order, TS_DOMAIN_DEFAULT_MIN); - for (i = order; i < n_knots-order; i += order) - ts_arr_fill(knots + i, - order, - TS_DOMAIN_DEFAULT_MIN + (i/order)*fac); - ts_arr_fill(knots + i, order, TS_DOMAIN_DEFAULT_MAX); - } - TS_RETURN_SUCCESS(status) + if (type == TS_OPENED) { + knots[0] = TS_DOMAIN_DEFAULT_MIN; /* n_knots >= 2 */ + fac = (TS_DOMAIN_DEFAULT_MAX - TS_DOMAIN_DEFAULT_MIN) / (n_knots - 1); /* n_knots >= 2 */ + for (i = 1; i < n_knots - 1; i++) + knots[i] = TS_DOMAIN_DEFAULT_MIN + i * fac; + knots[i] = TS_DOMAIN_DEFAULT_MAX; /* n_knots >= 2 */ + } else if (type == TS_CLAMPED) { + /* n_knots >= 2*order == 2*(deg+1) == 2*deg + 2 > 2*deg - 1 */ + fac = (TS_DOMAIN_DEFAULT_MAX - TS_DOMAIN_DEFAULT_MIN) / (n_knots - 2 * deg - 1); + ts_arr_fill(knots, order, TS_DOMAIN_DEFAULT_MIN); + for (i = order; i < n_knots - order; i++) + knots[i] = TS_DOMAIN_DEFAULT_MIN + (i - deg) * fac; + ts_arr_fill(knots + i, order, TS_DOMAIN_DEFAULT_MAX); + } else if (type == TS_BEZIERS) { + /* n_knots >= 2*order implies n_knots/order >= 2 */ + fac = (TS_DOMAIN_DEFAULT_MAX - TS_DOMAIN_DEFAULT_MIN) / (n_knots / order - 1); + ts_arr_fill(knots, order, TS_DOMAIN_DEFAULT_MIN); + for (i = order; i < n_knots - order; i += order) + ts_arr_fill(knots + i, + order, + TS_DOMAIN_DEFAULT_MIN + (i / order) * fac); + ts_arr_fill(knots + i, order, TS_DOMAIN_DEFAULT_MAX); + } + TS_RETURN_SUCCESS(status) } tsError @@ -465,51 +415,49 @@ ts_bspline_new(size_t num_control_points, size_t degree, tsBSplineType type, tsBSpline *spline, - tsStatus *status) -{ - const size_t order = degree + 1; - const size_t num_knots = num_control_points + order; - const size_t len_ctrlp = num_control_points * dimension; + tsStatus *status) { + const size_t order = degree + 1; + const size_t num_knots = num_control_points + order; + const size_t len_ctrlp = num_control_points * dimension; - const size_t sof_real = sizeof(tsReal); - const size_t sof_impl = sizeof(struct tsBSplineImpl); - const size_t sof_ctrlp_vec = len_ctrlp * sof_real; - const size_t sof_knots_vec = num_knots * sof_real; - const size_t sof_spline = sof_impl + sof_ctrlp_vec + sof_knots_vec; - tsError err; + const size_t sof_real = sizeof(tsReal); + const size_t sof_impl = sizeof(struct tsBSplineImpl); + const size_t sof_ctrlp_vec = len_ctrlp * sof_real; + const size_t sof_knots_vec = num_knots * sof_real; + const size_t sof_spline = sof_impl + sof_ctrlp_vec + sof_knots_vec; + tsError err; - ts_int_bspline_init(spline); + ts_int_bspline_init(spline); - if (dimension < 1) { - TS_RETURN_0(status, TS_DIM_ZERO, "unsupported dimension: 0") - } - if (num_knots > TS_MAX_NUM_KNOTS) { - TS_RETURN_2(status, TS_NUM_KNOTS, - "unsupported number of knots: %lu > %i", - (unsigned long) num_knots, TS_MAX_NUM_KNOTS) - } - if (degree >= num_control_points) { - TS_RETURN_2(status, TS_DEG_GE_NCTRLP, - "degree (%lu) >= num(control_points) (%lu)", - (unsigned long) degree, - (unsigned long) num_control_points) - } + if (dimension < 1) { + TS_RETURN_0(status, TS_DIM_ZERO, "unsupported dimension: 0") + } + if (num_knots > TS_MAX_NUM_KNOTS) { + TS_RETURN_2(status, TS_NUM_KNOTS, + "unsupported number of knots: %lu > %i", + (unsigned long)num_knots, TS_MAX_NUM_KNOTS) + } + if (degree >= num_control_points) { + TS_RETURN_2(status, TS_DEG_GE_NCTRLP, + "degree (%lu) >= num(control_points) (%lu)", + (unsigned long)degree, + (unsigned long)num_control_points) + } - spline->pImpl = (struct tsBSplineImpl *) malloc(sof_spline); - if (!spline->pImpl) - TS_RETURN_0(status, TS_MALLOC, "out of memory") + spline->pImpl = (struct tsBSplineImpl *)malloc(sof_spline); + if (!spline->pImpl) + TS_RETURN_0(status, TS_MALLOC, "out of memory") - spline->pImpl->deg = degree; - spline->pImpl->dim = dimension; - spline->pImpl->n_ctrlp = num_control_points; - spline->pImpl->n_knots = num_knots; + spline->pImpl->deg = degree; + spline->pImpl->dim = dimension; + spline->pImpl->n_ctrlp = num_control_points; + spline->pImpl->n_knots = num_knots; - TS_TRY(try, err, status) - TS_CALL(try, err, ts_int_bspline_generate_knots( - spline, type, status)) - TS_CATCH(err) - ts_bspline_free(spline); - TS_END_TRY_RETURN(err) + TS_TRY(try, err, status) + TS_CALL(try, err, ts_int_bspline_generate_knots(spline, type, status)) + TS_CATCH(err) + ts_bspline_free(spline); + TS_END_TRY_RETURN(err) } tsError @@ -520,262 +468,226 @@ ts_bspline_new_with_control_points(size_t num_control_points, tsBSpline *spline, tsStatus *status, double first, - ...) -{ - tsReal *ctrlp = NULL; - va_list argp; - size_t i; - tsError err; + ...) { + tsReal *ctrlp = NULL; + va_list argp; + size_t i; + tsError err; - TS_TRY(try, err, status) - TS_CALL(try, err, ts_bspline_new( - num_control_points, dimension, - degree, type, spline, status)) - TS_CATCH(err) - ts_bspline_free(spline); - TS_END_TRY_ROE(err) - ctrlp = ts_int_bspline_access_ctrlp(spline); + TS_TRY(try, err, status) + TS_CALL(try, err, ts_bspline_new(num_control_points, dimension, degree, type, spline, status)) + TS_CATCH(err) + ts_bspline_free(spline); + TS_END_TRY_ROE(err) + ctrlp = ts_int_bspline_access_ctrlp(spline); - ctrlp[0] = (tsReal) first; - va_start(argp, first); - for (i = 1; i < ts_bspline_len_control_points(spline); i++) - ctrlp[i] = (tsReal) va_arg(argp, double); - va_end(argp); + ctrlp[0] = (tsReal)first; + va_start(argp, first); + for (i = 1; i < ts_bspline_len_control_points(spline); i++) + ctrlp[i] = (tsReal)va_arg(argp, double); + va_end(argp); - TS_RETURN_SUCCESS(status) + TS_RETURN_SUCCESS(status) } tsError ts_bspline_copy(const tsBSpline *src, tsBSpline *dest, - tsStatus *status) -{ - size_t size; - if (src == dest) - TS_RETURN_SUCCESS(status) - ts_int_bspline_init(dest); - size = ts_int_bspline_sof_state(src); - dest->pImpl = (struct tsBSplineImpl *) malloc(size); - if (!dest->pImpl) - TS_RETURN_0(status, TS_MALLOC, "out of memory") - memcpy(dest->pImpl, src->pImpl, size); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + size_t size; + if (src == dest) + TS_RETURN_SUCCESS(status) + ts_int_bspline_init(dest); + size = ts_int_bspline_sof_state(src); + dest->pImpl = (struct tsBSplineImpl *)malloc(size); + if (!dest->pImpl) + TS_RETURN_0(status, TS_MALLOC, "out of memory") + memcpy(dest->pImpl, src->pImpl, size); + TS_RETURN_SUCCESS(status) } -void -ts_bspline_move(tsBSpline *src, - tsBSpline *dest) -{ - if (src == dest) - return; - dest->pImpl = src->pImpl; - ts_int_bspline_init(src); +void ts_bspline_move(tsBSpline *src, + tsBSpline *dest) { + if (src == dest) + return; + dest->pImpl = src->pImpl; + ts_int_bspline_init(src); } -void -ts_bspline_free(tsBSpline *spline) -{ - if (spline->pImpl) - free(spline->pImpl); - ts_int_bspline_init(spline); +void ts_bspline_free(tsBSpline *spline) { + if (spline->pImpl) + free(spline->pImpl); + ts_int_bspline_init(spline); } /*! @} */ - - /*! @name De Boor Net Data * * @{ */ tsReal -ts_deboornet_knot(const tsDeBoorNet *net) -{ - return net->pImpl->u; +ts_deboornet_knot(const tsDeBoorNet *net) { + return net->pImpl->u; } size_t -ts_deboornet_index(const tsDeBoorNet *net) -{ - return net->pImpl->k; +ts_deboornet_index(const tsDeBoorNet *net) { + return net->pImpl->k; } size_t -ts_deboornet_multiplicity(const tsDeBoorNet *net) -{ - return net->pImpl->s; +ts_deboornet_multiplicity(const tsDeBoorNet *net) { + return net->pImpl->s; } size_t -ts_deboornet_num_insertions(const tsDeBoorNet *net) -{ - return net->pImpl->h; +ts_deboornet_num_insertions(const tsDeBoorNet *net) { + return net->pImpl->h; } size_t -ts_deboornet_dimension(const tsDeBoorNet *net) -{ - return net->pImpl->dim; +ts_deboornet_dimension(const tsDeBoorNet *net) { + return net->pImpl->dim; } size_t -ts_deboornet_len_points(const tsDeBoorNet *net) -{ - return ts_deboornet_num_points(net) * - ts_deboornet_dimension(net); +ts_deboornet_len_points(const tsDeBoorNet *net) { + return ts_deboornet_num_points(net) * + ts_deboornet_dimension(net); } size_t -ts_deboornet_num_points(const tsDeBoorNet *net) -{ - return net->pImpl->n_points; +ts_deboornet_num_points(const tsDeBoorNet *net) { + return net->pImpl->n_points; } size_t -ts_deboornet_sof_points(const tsDeBoorNet *net) -{ - return ts_deboornet_len_points(net) * sizeof(tsReal); +ts_deboornet_sof_points(const tsDeBoorNet *net) { + return ts_deboornet_len_points(net) * sizeof(tsReal); } const tsReal * -ts_deboornet_points_ptr(const tsDeBoorNet *net) -{ - return ts_int_deboornet_access_points(net); +ts_deboornet_points_ptr(const tsDeBoorNet *net) { + return ts_int_deboornet_access_points(net); } tsError ts_deboornet_points(const tsDeBoorNet *net, tsReal **points, - tsStatus *status) -{ - const size_t size = ts_deboornet_sof_points(net); - *points = (tsReal*) malloc(size); - if (!*points) - TS_RETURN_0(status, TS_MALLOC, "out of memory") - memcpy(*points, ts_int_deboornet_access_points(net), size); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t size = ts_deboornet_sof_points(net); + *points = (tsReal *)malloc(size); + if (!*points) + TS_RETURN_0(status, TS_MALLOC, "out of memory") + memcpy(*points, ts_int_deboornet_access_points(net), size); + TS_RETURN_SUCCESS(status) } size_t -ts_deboornet_len_result(const tsDeBoorNet *net) -{ - return ts_deboornet_num_result(net) * - ts_deboornet_dimension(net); +ts_deboornet_len_result(const tsDeBoorNet *net) { + return ts_deboornet_num_result(net) * + ts_deboornet_dimension(net); } size_t -ts_deboornet_num_result(const tsDeBoorNet *net) -{ - return ts_deboornet_num_points(net) == 2 ? 2 : 1; +ts_deboornet_num_result(const tsDeBoorNet *net) { + return ts_deboornet_num_points(net) == 2 ? 2 : 1; } size_t -ts_deboornet_sof_result(const tsDeBoorNet *net) -{ - return ts_deboornet_len_result(net) * sizeof(tsReal); +ts_deboornet_sof_result(const tsDeBoorNet *net) { + return ts_deboornet_len_result(net) * sizeof(tsReal); } const tsReal * -ts_deboornet_result_ptr(const tsDeBoorNet *net) -{ - return ts_int_deboornet_access_result(net); +ts_deboornet_result_ptr(const tsDeBoorNet *net) { + return ts_int_deboornet_access_result(net); } tsError ts_deboornet_result(const tsDeBoorNet *net, tsReal **result, - tsStatus *status) -{ - const size_t size = ts_deboornet_sof_result(net); - *result = (tsReal*) malloc(size); - if (!*result) - TS_RETURN_0(status, TS_MALLOC, "out of memory") - memcpy(*result, ts_int_deboornet_access_result(net), size); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t size = ts_deboornet_sof_result(net); + *result = (tsReal *)malloc(size); + if (!*result) + TS_RETURN_0(status, TS_MALLOC, "out of memory") + memcpy(*result, ts_int_deboornet_access_result(net), size); + TS_RETURN_SUCCESS(status) } /*! @} */ - - /*! @name De Boor Net Initialization * * @{ */ tsDeBoorNet -ts_deboornet_init(void) -{ - tsDeBoorNet net; - ts_int_deboornet_init(&net); - return net; +ts_deboornet_init(void) { + tsDeBoorNet net; + ts_int_deboornet_init(&net); + return net; } tsError ts_int_deboornet_new(const tsBSpline *spline, tsDeBoorNet *net, - tsStatus *status) -{ - const size_t dim = ts_bspline_dimension(spline); - const size_t deg = ts_bspline_degree(spline); - const size_t order = ts_bspline_order(spline); - const size_t num_points = (size_t)(order * (order+1) * 0.5f); - /* Handle `order == 1' which generates too few points. */ - const size_t fixed_num_points = num_points < 2 ? 2 : num_points; + tsStatus *status) { + const size_t dim = ts_bspline_dimension(spline); + const size_t deg = ts_bspline_degree(spline); + const size_t order = ts_bspline_order(spline); + const size_t num_points = (size_t)(order * (order + 1) * 0.5f); + /* Handle `order == 1' which generates too few points. */ + const size_t fixed_num_points = num_points < 2 ? 2 : num_points; - const size_t sof_real = sizeof(tsReal); - const size_t sof_impl = sizeof(struct tsDeBoorNetImpl); - const size_t sof_points_vec = fixed_num_points * dim * sof_real; - const size_t sof_net = sof_impl * sof_points_vec; + const size_t sof_real = sizeof(tsReal); + const size_t sof_impl = sizeof(struct tsDeBoorNetImpl); + const size_t sof_points_vec = fixed_num_points * dim * sof_real; + const size_t sof_net = sof_impl * sof_points_vec; - net->pImpl = (struct tsDeBoorNetImpl *) malloc(sof_net); - if (!net->pImpl) - TS_RETURN_0(status, TS_MALLOC, "out of memory") + net->pImpl = (struct tsDeBoorNetImpl *)malloc(sof_net); + if (!net->pImpl) + TS_RETURN_0(status, TS_MALLOC, "out of memory") - net->pImpl->u = 0.f; - net->pImpl->k = 0; - net->pImpl->s = 0; - net->pImpl->h = deg; - net->pImpl->dim = dim; - net->pImpl->n_points = fixed_num_points; - TS_RETURN_SUCCESS(status) + net->pImpl->u = 0.f; + net->pImpl->k = 0; + net->pImpl->s = 0; + net->pImpl->h = deg; + net->pImpl->dim = dim; + net->pImpl->n_points = fixed_num_points; + TS_RETURN_SUCCESS(status) } -void -ts_deboornet_free(tsDeBoorNet *net) -{ - if (net->pImpl) - free(net->pImpl); - ts_int_deboornet_init(net); +void ts_deboornet_free(tsDeBoorNet *net) { + if (net->pImpl) + free(net->pImpl); + ts_int_deboornet_init(net); } tsError ts_deboornet_copy(const tsDeBoorNet *src, tsDeBoorNet *dest, - tsStatus *status) -{ - size_t size; - if (src == dest) - TS_RETURN_SUCCESS(status) - ts_int_deboornet_init(dest); - size = ts_int_deboornet_sof_state(src); - dest->pImpl = (struct tsDeBoorNetImpl *) malloc(size); - if (!dest->pImpl) - TS_RETURN_0(status, TS_MALLOC, "out of memory") - memcpy(dest->pImpl, src->pImpl, size); - TS_RETURN_SUCCESS(status) + tsStatus *status) { + size_t size; + if (src == dest) + TS_RETURN_SUCCESS(status) + ts_int_deboornet_init(dest); + size = ts_int_deboornet_sof_state(src); + dest->pImpl = (struct tsDeBoorNetImpl *)malloc(size); + if (!dest->pImpl) + TS_RETURN_0(status, TS_MALLOC, "out of memory") + memcpy(dest->pImpl, src->pImpl, size); + TS_RETURN_SUCCESS(status) } -void -ts_deboornet_move(tsDeBoorNet *src, - tsDeBoorNet *dest) -{ - if (src == dest) - return; - dest->pImpl = src->pImpl; - ts_int_deboornet_init(src); +void ts_deboornet_move(tsDeBoorNet *src, + tsDeBoorNet *dest) { + if (src == dest) + return; + dest->pImpl = src->pImpl; + ts_int_deboornet_init(src); } /*! @} */ - - /*! @name Interpolation and Approximation Functions * * @{ @@ -784,22 +696,21 @@ tsError ts_int_cubic_point(const tsReal *point, size_t dim, tsBSpline *spline, - tsStatus *status) -{ - const size_t size = dim * sizeof(tsReal); - tsReal *ctrlp = NULL; - size_t i; - tsError err; - TS_CALL_ROE(err, ts_bspline_new( - 4, dim, 3, - TS_CLAMPED, spline, status)) - ctrlp = ts_int_bspline_access_ctrlp(spline); - for (i = 0; i < 4; i++) { - memcpy(ctrlp + i*dim, - point, - size); - } - TS_RETURN_SUCCESS(status) + tsStatus *status) { + const size_t size = dim * sizeof(tsReal); + tsReal *ctrlp = NULL; + size_t i; + tsError err; + TS_CALL_ROE(err, ts_bspline_new( + 4, dim, 3, + TS_CLAMPED, spline, status)) + ctrlp = ts_int_bspline_access_ctrlp(spline); + for (i = 0; i < 4; i++) { + memcpy(ctrlp + i * dim, + point, + size); + } + TS_RETURN_SUCCESS(status) } tsError @@ -809,72 +720,71 @@ ts_int_thomas_algorithm(const tsReal *a, size_t num, size_t dim, tsReal *d, - tsStatus *status) -{ - size_t i, j, k, l; - tsReal m, *cc = NULL; - tsError err; + tsStatus *status) { + size_t i, j, k, l; + tsReal m, *cc = NULL; + tsError err; - if (dim == 0) { - TS_RETURN_0(status, TS_DIM_ZERO, - "unsupported dimension: 0") - } - if (num <= 1) { - TS_RETURN_1(status, TS_NUM_POINTS, - "num(points) (%lu) <= 1", - (unsigned long) num) - } - cc = (tsReal *) malloc(num * sizeof(tsReal)); - if (!cc) TS_RETURN_0(status, TS_MALLOC, "out of memory") + if (dim == 0) { + TS_RETURN_0(status, TS_DIM_ZERO, + "unsupported dimension: 0") + } + if (num <= 1) { + TS_RETURN_1(status, TS_NUM_POINTS, + "num(points) (%lu) <= 1", + (unsigned long)num) + } + cc = (tsReal *)malloc(num * sizeof(tsReal)); + if (!cc) TS_RETURN_0(status, TS_MALLOC, "out of memory") - TS_TRY(try, err, status) - /* Forward sweep. */ - if (fabs(b[0]) <= fabs(c[0])) { - TS_THROW_2(try, err, status, TS_NO_RESULT, - "error: |%f| <= |%f|", b[0], c[0]) - } - /* |b[i]| > |c[i]| implies that |b[i]| > 0. Thus, the following - * statements cannot evaluate to division by zero.*/ - cc[0] = c[0] / b[0]; - for (i = 0; i < dim; i++) - d[i] = d[i] / b[0]; - for (i = 1; i < num; i++) { - if (fabs(b[i]) <= fabs(a[i]) + fabs(c[i])) { - TS_THROW_3(try, err, status, TS_NO_RESULT, - "error: |%f| <= |%f| + |%f|", - b[i], a[i], c[i]) - } - /* |a[i]| < |b[i]| and cc[i - 1] < 1. Therefore, the - * following statement cannot evaluate to division by - * zero. */ - m = 1.f / (b[i] - a[i] * cc[i - 1]); - /* |b[i]| > |a[i]| + |c[i]| implies that there must be - * an eps > 0 such that |b[i]| = |a[i]| + |c[i]| + eps. - * Even if |a[i]| is 0 (by which the result of the - * following statement becomes maximum), |c[i]| is less - * than |b[i]| by an amount of eps. By substituting the - * previous and the following statements (under the - * assumption that |a[i]| is 0), we obtain c[i] / b[i], - * which must be less than 1. */ - cc[i] = c[i] * m; - for (j = 0; j < dim; j++) { - k = i * dim + j; - l = (i-1) * dim + j; - d[k] = (d[k] - a[i] * d[l]) * m; - } - } + TS_TRY(try, err, status) + /* Forward sweep. */ + if (fabs(b[0]) <= fabs(c[0])) { + TS_THROW_2(try, err, status, TS_NO_RESULT, + "error: |%f| <= |%f|", b[0], c[0]) + } + /* |b[i]| > |c[i]| implies that |b[i]| > 0. Thus, the following + * statements cannot evaluate to division by zero.*/ + cc[0] = c[0] / b[0]; + for (i = 0; i < dim; i++) + d[i] = d[i] / b[0]; + for (i = 1; i < num; i++) { + if (fabs(b[i]) <= fabs(a[i]) + fabs(c[i])) { + TS_THROW_3(try, err, status, TS_NO_RESULT, + "error: |%f| <= |%f| + |%f|", + b[i], a[i], c[i]) + } + /* |a[i]| < |b[i]| and cc[i - 1] < 1. Therefore, the + * following statement cannot evaluate to division by + * zero. */ + m = 1.f / (b[i] - a[i] * cc[i - 1]); + /* |b[i]| > |a[i]| + |c[i]| implies that there must be + * an eps > 0 such that |b[i]| = |a[i]| + |c[i]| + eps. + * Even if |a[i]| is 0 (by which the result of the + * following statement becomes maximum), |c[i]| is less + * than |b[i]| by an amount of eps. By substituting the + * previous and the following statements (under the + * assumption that |a[i]| is 0), we obtain c[i] / b[i], + * which must be less than 1. */ + cc[i] = c[i] * m; + for (j = 0; j < dim; j++) { + k = i * dim + j; + l = (i - 1) * dim + j; + d[k] = (d[k] - a[i] * d[l]) * m; + } + } - /* Back substitution. */ - for (i = num-1; i > 0; i--) { - for (j = 0; j < dim; j++) { - k = (i-1) * dim + j; - l = i * dim + j; - d[k] -= cc[i-1] * d[l]; - } - } - TS_FINALLY - free(cc); - TS_END_TRY_RETURN(err) + /* Back substitution. */ + for (i = num - 1; i > 0; i--) { + for (j = 0; j < dim; j++) { + k = (i - 1) * dim + j; + l = i * dim + j; + d[k] -= cc[i - 1] * d[l]; + } + } + TS_FINALLY + free(cc); + TS_END_TRY_RETURN(err) } tsError @@ -882,80 +792,77 @@ ts_int_relaxed_uniform_cubic_bspline(const tsReal *points, size_t n, size_t dim, tsBSpline *spline, - tsStatus *status) -{ - const size_t order = 4; /**< Order of spline to interpolate. */ - const tsReal as = 1.f/6.f; /**< The value 'a sixth'. */ - const tsReal at = 1.f/3.f; /**< The value 'a third'. */ - const tsReal tt = 2.f/3.f; /**< The value 'two third'. */ - size_t sof_ctrlp; /**< Size of a single control point. */ - const tsReal* b = points; /**< Array of the b values. */ - tsReal* s; /**< Array of the s values. */ - size_t i, d; /**< Used in for loops */ - size_t j, k, l; /**< Used as temporary indices. */ - tsReal *ctrlp; /**< Pointer to the control points of \p _spline_. */ - tsError err; + tsStatus *status) { + const size_t order = 4; /**< Order of spline to interpolate. */ + const tsReal as = 1.f / 6.f; /**< The value 'a sixth'. */ + const tsReal at = 1.f / 3.f; /**< The value 'a third'. */ + const tsReal tt = 2.f / 3.f; /**< The value 'two third'. */ + size_t sof_ctrlp; /**< Size of a single control point. */ + const tsReal *b = points; /**< Array of the b values. */ + tsReal *s; /**< Array of the s values. */ + size_t i, d; /**< Used in for loops */ + size_t j, k, l; /**< Used as temporary indices. */ + tsReal *ctrlp; /**< Pointer to the control points of \p _spline_. */ + tsError err; - /* input validation */ - if (dim == 0) - TS_RETURN_0(status, TS_DIM_ZERO, "unsupported dimension: 0") - if (n <= 1) { - TS_RETURN_1(status, TS_NUM_POINTS, - "num(points) (%lu) <= 1", - (unsigned long) n) - } - /* in the following n >= 2 applies */ + /* input validation */ + if (dim == 0) + TS_RETURN_0(status, TS_DIM_ZERO, "unsupported dimension: 0") + if (n <= 1) { + TS_RETURN_1(status, TS_NUM_POINTS, + "num(points) (%lu) <= 1", + (unsigned long)n) + } + /* in the following n >= 2 applies */ - sof_ctrlp = dim * sizeof(tsReal); /* dim > 0 implies sof_ctrlp > 0 */ + sof_ctrlp = dim * sizeof(tsReal); /* dim > 0 implies sof_ctrlp > 0 */ - s = NULL; - TS_TRY(try, err, status) - /* n >= 2 implies n-1 >= 1 implies (n-1)*4 >= 4 */ - TS_CALL(try, err, ts_bspline_new( - (n-1) * 4, dim, order - 1, - TS_BEZIERS, spline, status)) - ctrlp = ts_int_bspline_access_ctrlp(spline); + s = NULL; + TS_TRY(try, err, status) + /* n >= 2 implies n-1 >= 1 implies (n-1)*4 >= 4 */ + TS_CALL(try, err, ts_bspline_new((n - 1) * 4, dim, order - 1, TS_BEZIERS, spline, status)) + ctrlp = ts_int_bspline_access_ctrlp(spline); - s = (tsReal*) malloc(n * sof_ctrlp); - if (!s) { - TS_THROW_0(try, err, status, TS_MALLOC, - "out of memory") - } + s = (tsReal *)malloc(n * sof_ctrlp); + if (!s) { + TS_THROW_0(try, err, status, TS_MALLOC, + "out of memory") + } - /* set s_0 to b_0 and s_n = b_n */ - memcpy(s, b, sof_ctrlp); - memcpy(s + (n-1)*dim, b + (n-1)*dim, sof_ctrlp); + /* set s_0 to b_0 and s_n = b_n */ + memcpy(s, b, sof_ctrlp); + memcpy(s + (n - 1) * dim, b + (n - 1) * dim, sof_ctrlp); - /* set s_i = 1/6*b_i + 2/3*b_{i-1} + 1/6*b_{i+1}*/ - for (i = 1; i < n-1; i++) { - for (d = 0; d < dim; d++) { - j = (i-1)*dim+d; - k = i*dim+d; - l = (i+1)*dim+d; - s[k] = as * b[j]; - s[k] += tt * b[k]; - s[k] += as * b[l]; - } - } + /* set s_i = 1/6*b_i + 2/3*b_{i-1} + 1/6*b_{i+1}*/ + for (i = 1; i < n - 1; i++) { + for (d = 0; d < dim; d++) { + j = (i - 1) * dim + d; + k = i * dim + d; + l = (i + 1) * dim + d; + s[k] = as * b[j]; + s[k] += tt * b[k]; + s[k] += as * b[l]; + } + } - /* create beziers from b and s */ - for (i = 0; i < n-1; i++) { - for (d = 0; d < dim; d++) { - j = i*dim+d; - k = i*4*dim+d; - l = (i+1)*dim+d; - ctrlp[k] = s[j]; - ctrlp[k+dim] = tt*b[j] + at*b[l]; - ctrlp[k+2*dim] = at*b[j] + tt*b[l]; - ctrlp[k+3*dim] = s[l]; - } - } - TS_CATCH(err) - ts_bspline_free(spline); - TS_FINALLY - if (s) - free(s); - TS_END_TRY_RETURN(err) + /* create beziers from b and s */ + for (i = 0; i < n - 1; i++) { + for (d = 0; d < dim; d++) { + j = i * dim + d; + k = i * 4 * dim + d; + l = (i + 1) * dim + d; + ctrlp[k] = s[j]; + ctrlp[k + dim] = tt * b[j] + at * b[l]; + ctrlp[k + 2 * dim] = at * b[j] + tt * b[l]; + ctrlp[k + 3 * dim] = s[l]; + } + } + TS_CATCH(err) + ts_bspline_free(spline); + TS_FINALLY + if (s) + free(s); + TS_END_TRY_RETURN(err) } tsError @@ -963,88 +870,84 @@ ts_bspline_interpolate_cubic_natural(const tsReal *points, size_t num_points, size_t dimension, tsBSpline *spline, - tsStatus *status) -{ - const size_t sof_ctrlp = dimension * sizeof(tsReal); - const size_t len_points = num_points * dimension; - const size_t num_int_points = num_points - 2; - const size_t len_int_points = num_int_points * dimension; - tsReal *thomas, *a, *b, *c, *d; - size_t i, j, k, l; - tsError err; + tsStatus *status) { + const size_t sof_ctrlp = dimension * sizeof(tsReal); + const size_t len_points = num_points * dimension; + const size_t num_int_points = num_points - 2; + const size_t len_int_points = num_int_points * dimension; + tsReal *thomas, *a, *b, *c, *d; + size_t i, j, k, l; + tsError err; - ts_int_bspline_init(spline); - if (num_points == 0) - TS_RETURN_0(status, TS_NUM_POINTS, "num(points) == 0") - if (num_points == 1) { - TS_CALL_ROE(err, ts_int_cubic_point( - points, dimension, spline, status)) - TS_RETURN_SUCCESS(status) - } - if (num_points == 2) { - return ts_int_relaxed_uniform_cubic_bspline( - points, num_points, dimension, spline, status); - } - /* `num_points` >= 3 */ - thomas = NULL; - TS_TRY(try, err, status) - thomas = (tsReal *) malloc( - /* `a', `b', `c' (note that `c' is equal to `a') */ - 2 * num_int_points * sizeof(tsReal) + - /* `d' and "result of the thomas algorithm" (which - contains `num_points' points) */ - num_points * dimension * sizeof(tsReal)); - if (!thomas) { - TS_THROW_0(try, err, status, TS_MALLOC, - "out of memory") - } - /* The system of linear equations is taken from: - * http://www.bakoma-tex.com/doc/generic/pst-bspline/ - * pst-bspline-doc.pdf */ - a = c = thomas; - ts_arr_fill(a, num_int_points, 1); - b = a + num_int_points; - ts_arr_fill(b, num_int_points, 4); - d = b + num_int_points; - /* 6 * S_{i+1} */ - for (i = 0; i < num_int_points; i++) { - for (j = 0; j < dimension; j++) { - k = i * dimension + j; - l = (i+1) * dimension + j; - d[k] = 6 * points[l]; - } - } - for (i = 0; i < dimension; i++) { - /* 6 * S_{1} - S_{0} */ - d[i] -= points[i]; - /* 6 * S_{n-1} - S_{n} */ - k = len_int_points - (i+1); - l = len_points - (i+1); - d[k] -= points[l]; - } - /* The Thomas algorithm requires at least two points. Hence, - * `num_int_points` == 1 must be handled separately (let's call - * it "Mini Thomas"). */ - if (num_int_points == 1) { - for (i = 0; i < dimension; i++) - d[i] *= (tsReal) 0.25f; - } else { - TS_CALL(try, err, ts_int_thomas_algorithm( - a, b, c, num_int_points, dimension, d, - status)) - } - memcpy(thomas, points, sof_ctrlp); - memmove(thomas + dimension, d, num_int_points * sof_ctrlp); - memcpy(thomas + (num_int_points+1) * dimension, - points + (num_points-1) * dimension, sof_ctrlp); - TS_CALL(try, err, ts_int_relaxed_uniform_cubic_bspline( - thomas, num_points, dimension, spline, status)) - TS_CATCH(err) - ts_bspline_free(spline); - TS_FINALLY - if (thomas) - free(thomas); - TS_END_TRY_RETURN(err) + ts_int_bspline_init(spline); + if (num_points == 0) + TS_RETURN_0(status, TS_NUM_POINTS, "num(points) == 0") + if (num_points == 1) { + TS_CALL_ROE(err, ts_int_cubic_point( + points, dimension, spline, status)) + TS_RETURN_SUCCESS(status) + } + if (num_points == 2) { + return ts_int_relaxed_uniform_cubic_bspline( + points, num_points, dimension, spline, status); + } + /* `num_points` >= 3 */ + thomas = NULL; + TS_TRY(try, err, status) + thomas = (tsReal *)malloc( + /* `a', `b', `c' (note that `c' is equal to `a') */ + 2 * num_int_points * sizeof(tsReal) + + /* `d' and "result of the thomas algorithm" (which + contains `num_points' points) */ + num_points * dimension * sizeof(tsReal)); + if (!thomas) { + TS_THROW_0(try, err, status, TS_MALLOC, + "out of memory") + } + /* The system of linear equations is taken from: + * http://www.bakoma-tex.com/doc/generic/pst-bspline/ + * pst-bspline-doc.pdf */ + a = c = thomas; + ts_arr_fill(a, num_int_points, 1); + b = a + num_int_points; + ts_arr_fill(b, num_int_points, 4); + d = b + num_int_points; + /* 6 * S_{i+1} */ + for (i = 0; i < num_int_points; i++) { + for (j = 0; j < dimension; j++) { + k = i * dimension + j; + l = (i + 1) * dimension + j; + d[k] = 6 * points[l]; + } + } + for (i = 0; i < dimension; i++) { + /* 6 * S_{1} - S_{0} */ + d[i] -= points[i]; + /* 6 * S_{n-1} - S_{n} */ + k = len_int_points - (i + 1); + l = len_points - (i + 1); + d[k] -= points[l]; + } + /* The Thomas algorithm requires at least two points. Hence, + * `num_int_points` == 1 must be handled separately (let's call + * it "Mini Thomas"). */ + if (num_int_points == 1) { + for (i = 0; i < dimension; i++) + d[i] *= (tsReal)0.25f; + } else { + TS_CALL(try, err, ts_int_thomas_algorithm(a, b, c, num_int_points, dimension, d, status)) + } + memcpy(thomas, points, sof_ctrlp); + memmove(thomas + dimension, d, num_int_points * sof_ctrlp); + memcpy(thomas + (num_int_points + 1) * dimension, + points + (num_points - 1) * dimension, sof_ctrlp); + TS_CALL(try, err, ts_int_relaxed_uniform_cubic_bspline(thomas, num_points, dimension, spline, status)) + TS_CATCH(err) + ts_bspline_free(spline); + TS_FINALLY + if (thomas) + free(thomas); + TS_END_TRY_RETURN(err) } tsError @@ -1056,129 +959,122 @@ ts_bspline_interpolate_catmull_rom(const tsReal *points, const tsReal *last, tsReal epsilon, tsBSpline *spline, - tsStatus *status) -{ - const size_t sof_real = sizeof(tsReal); - const size_t sof_ctrlp = dimension * sof_real; - const tsReal eps = (tsReal) fabs(epsilon); - tsReal *bs_ctrlp; /* Points to the control points of `spline`. */ - tsReal *cr_ctrlp; /**< The points to interpolate based on `points`. */ - size_t i, d; /**< Used in for loops. */ - tsError err; /**< Local error handling. */ - /* [https://en.wikipedia.org/wiki/ - * Centripetal_Catmull%E2%80%93Rom_spline] */ - tsReal t0, t1, t2, t3; /**< Catmull-Rom knots. */ - /* [https://stackoverflow.com/questions/30748316/ - * catmull-rom-interpolation-on-svg-paths/30826434#30826434] */ - tsReal c1, c2, d1, d2, m1, m2; /**< Used to calculate derivatives. */ - tsReal *p0, *p1, *p2, *p3; /**< Processed Catmull-Rom points. */ + tsStatus *status) { + const size_t sof_real = sizeof(tsReal); + const size_t sof_ctrlp = dimension * sof_real; + const tsReal eps = (tsReal)fabs(epsilon); + tsReal *bs_ctrlp; /* Points to the control points of `spline`. */ + tsReal *cr_ctrlp; /**< The points to interpolate based on `points`. */ + size_t i, d; /**< Used in for loops. */ + tsError err; /**< Local error handling. */ + /* [https://en.wikipedia.org/wiki/ + * Centripetal_Catmull%E2%80%93Rom_spline] */ + tsReal t0, t1, t2, t3; /**< Catmull-Rom knots. */ + /* [https://stackoverflow.com/questions/30748316/ + * catmull-rom-interpolation-on-svg-paths/30826434#30826434] */ + tsReal c1, c2, d1, d2, m1, m2; /**< Used to calculate derivatives. */ + tsReal *p0, *p1, *p2, *p3; /**< Processed Catmull-Rom points. */ - ts_int_bspline_init(spline); - if (dimension == 0) - TS_RETURN_0(status, TS_DIM_ZERO, "unsupported dimension: 0") - if (num_points == 0) - TS_RETURN_0(status, TS_NUM_POINTS, "num(points) == 0") - if (alpha < (tsReal) 0.0) alpha = (tsReal) 0.0; - if (alpha > (tsReal) 1.0) alpha = (tsReal) 1.0; + ts_int_bspline_init(spline); + if (dimension == 0) + TS_RETURN_0(status, TS_DIM_ZERO, "unsupported dimension: 0") + if (num_points == 0) + TS_RETURN_0(status, TS_NUM_POINTS, "num(points) == 0") + if (alpha < (tsReal)0.0) alpha = (tsReal)0.0; + if (alpha > (tsReal)1.0) alpha = (tsReal)1.0; - /* Copy `points` to `cr_ctrlp`. Add space for `first` and `last`. */ - cr_ctrlp = (tsReal *) malloc((num_points + 2) * sof_ctrlp); - if (!cr_ctrlp) - TS_RETURN_0(status, TS_MALLOC, "out of memory") - memcpy(cr_ctrlp + dimension, points, num_points * sof_ctrlp); + /* Copy `points` to `cr_ctrlp`. Add space for `first` and `last`. */ + cr_ctrlp = (tsReal *)malloc((num_points + 2) * sof_ctrlp); + if (!cr_ctrlp) + TS_RETURN_0(status, TS_MALLOC, "out of memory") + memcpy(cr_ctrlp + dimension, points, num_points * sof_ctrlp); - /* Remove redundant points from `cr_ctrlp`. Update `num_points`. */ - for (i = 1 /* 0 (`first`) is not assigned yet */; - i < num_points /* skip last point (inclusive end) */; - i++) { - p0 = cr_ctrlp + (i * dimension); - p1 = p0 + dimension; - if (ts_distance(p0, p1, dimension) <= eps) { - /* Are there any other points (after the one that is - * to be removed) that need to be shifted? */ - if (i < num_points - 1) { - memmove(p1, p1 + dimension, - (num_points - (i + 1)) * sof_ctrlp); - } - num_points--; - i--; - } - } + /* Remove redundant points from `cr_ctrlp`. Update `num_points`. */ + for (i = 1 /* 0 (`first`) is not assigned yet */; + i < num_points /* skip last point (inclusive end) */; + i++) { + p0 = cr_ctrlp + (i * dimension); + p1 = p0 + dimension; + if (ts_distance(p0, p1, dimension) <= eps) { + /* Are there any other points (after the one that is + * to be removed) that need to be shifted? */ + if (i < num_points - 1) { + memmove(p1, p1 + dimension, + (num_points - (i + 1)) * sof_ctrlp); + } + num_points--; + i--; + } + } - /* Check if there are still enough points for interpolation. */ - if (num_points == 1) { /* `num_points` can't be 0 */ - free(cr_ctrlp); /* The point is copied from `points`. */ - TS_CALL_ROE(err, ts_int_cubic_point( - points, dimension, spline, status)) - TS_RETURN_SUCCESS(status) - } + /* Check if there are still enough points for interpolation. */ + if (num_points == 1) { /* `num_points` can't be 0 */ + free(cr_ctrlp); /* The point is copied from `points`. */ + TS_CALL_ROE(err, ts_int_cubic_point( + points, dimension, spline, status)) + TS_RETURN_SUCCESS(status) + } - /* Add or generate `first` and `last`. Update `num_points`. */ - p0 = cr_ctrlp + dimension; - if (first && ts_distance(first, p0, dimension) > eps) { - memcpy(cr_ctrlp, first, sof_ctrlp); - } else { - p1 = p0 + dimension; - for (d = 0; d < dimension; d++) - cr_ctrlp[d] = p0[d] + (p0[d] - p1[d]); - } - p1 = cr_ctrlp + (num_points * dimension); - if (last && ts_distance(p1, last, dimension) > eps) { - memcpy(cr_ctrlp + ((num_points + 1) * dimension), - last, sof_ctrlp); - } else { - p0 = p1 - dimension; - for (d = 0; d < dimension; d++) { - cr_ctrlp[((num_points + 1) * dimension) + d] = - p1[d] + (p1[d] - p0[d]); - } - } - num_points = num_points + 2; + /* Add or generate `first` and `last`. Update `num_points`. */ + p0 = cr_ctrlp + dimension; + if (first && ts_distance(first, p0, dimension) > eps) { + memcpy(cr_ctrlp, first, sof_ctrlp); + } else { + p1 = p0 + dimension; + for (d = 0; d < dimension; d++) + cr_ctrlp[d] = p0[d] + (p0[d] - p1[d]); + } + p1 = cr_ctrlp + (num_points * dimension); + if (last && ts_distance(p1, last, dimension) > eps) { + memcpy(cr_ctrlp + ((num_points + 1) * dimension), + last, sof_ctrlp); + } else { + p0 = p1 - dimension; + for (d = 0; d < dimension; d++) { + cr_ctrlp[((num_points + 1) * dimension) + d] = + p1[d] + (p1[d] - p0[d]); + } + } + num_points = num_points + 2; - /* Transform the sequence of Catmull-Rom splines. */ - bs_ctrlp = NULL; - TS_TRY(try, err, status) - TS_CALL(try, err, ts_bspline_new( - (num_points - 3) * 4, dimension, 3, - TS_BEZIERS, spline, status)) - bs_ctrlp = ts_int_bspline_access_ctrlp(spline); - TS_CATCH(err) - free(cr_ctrlp); - TS_END_TRY_ROE(err) - for (i = 0; i < ts_bspline_num_control_points(spline) / 4; i++) { - p0 = cr_ctrlp + ((i+0) * dimension); - p1 = cr_ctrlp + ((i+1) * dimension); - p2 = cr_ctrlp + ((i+2) * dimension); - p3 = cr_ctrlp + ((i+3) * dimension); + /* Transform the sequence of Catmull-Rom splines. */ + bs_ctrlp = NULL; + TS_TRY(try, err, status) + TS_CALL(try, err, ts_bspline_new((num_points - 3) * 4, dimension, 3, TS_BEZIERS, spline, status)) + bs_ctrlp = ts_int_bspline_access_ctrlp(spline); + TS_CATCH(err) + free(cr_ctrlp); + TS_END_TRY_ROE(err) + for (i = 0; i < ts_bspline_num_control_points(spline) / 4; i++) { + p0 = cr_ctrlp + ((i + 0) * dimension); + p1 = cr_ctrlp + ((i + 1) * dimension); + p2 = cr_ctrlp + ((i + 2) * dimension); + p3 = cr_ctrlp + ((i + 3) * dimension); - t0 = (tsReal) 0.f; - t1 = t0 + (tsReal) pow(ts_distance(p0, p1, dimension), alpha); - t2 = t1 + (tsReal) pow(ts_distance(p1, p2, dimension), alpha); - t3 = t2 + (tsReal) pow(ts_distance(p2, p3, dimension), alpha); + t0 = (tsReal)0.f; + t1 = t0 + (tsReal)pow(ts_distance(p0, p1, dimension), alpha); + t2 = t1 + (tsReal)pow(ts_distance(p1, p2, dimension), alpha); + t3 = t2 + (tsReal)pow(ts_distance(p2, p3, dimension), alpha); - c1 = (t2-t1) / (t2-t0); - c2 = (t1-t0) / (t2-t0); - d1 = (t3-t2) / (t3-t1); - d2 = (t2-t1) / (t3-t1); + c1 = (t2 - t1) / (t2 - t0); + c2 = (t1 - t0) / (t2 - t0); + d1 = (t3 - t2) / (t3 - t1); + d2 = (t2 - t1) / (t3 - t1); - for (d = 0; d < dimension; d++) { - m1 = (t2-t1)*(c1*(p1[d]-p0[d])/(t1-t0) - + c2*(p2[d]-p1[d])/(t2-t1)); - m2 = (t2-t1)*(d1*(p2[d]-p1[d])/(t2-t1) - + d2*(p3[d]-p2[d])/(t3-t2)); - bs_ctrlp[((i*4 + 0) * dimension) + d] = p1[d]; - bs_ctrlp[((i*4 + 1) * dimension) + d] = p1[d] + m1/3; - bs_ctrlp[((i*4 + 2) * dimension) + d] = p2[d] - m2/3; - bs_ctrlp[((i*4 + 3) * dimension) + d] = p2[d]; - } - } - free(cr_ctrlp); - TS_RETURN_SUCCESS(status) + for (d = 0; d < dimension; d++) { + m1 = (t2 - t1) * (c1 * (p1[d] - p0[d]) / (t1 - t0) + c2 * (p2[d] - p1[d]) / (t2 - t1)); + m2 = (t2 - t1) * (d1 * (p2[d] - p1[d]) / (t2 - t1) + d2 * (p3[d] - p2[d]) / (t3 - t2)); + bs_ctrlp[((i * 4 + 0) * dimension) + d] = p1[d]; + bs_ctrlp[((i * 4 + 1) * dimension) + d] = p1[d] + m1 / 3; + bs_ctrlp[((i * 4 + 2) * dimension) + d] = p2[d] - m2 / 3; + bs_ctrlp[((i * 4 + 3) * dimension) + d] = p2[d]; + } + } + free(cr_ctrlp); + TS_RETURN_SUCCESS(status) } /*! @} */ - - /*! @name Query Functions * * @{ @@ -1188,180 +1084,175 @@ ts_int_bspline_find_knot(const tsBSpline *spline, tsReal knot, size_t *index, size_t *multiplicity, - tsStatus *status) -{ - const size_t deg = ts_bspline_degree(spline); - const size_t num_knots = ts_bspline_num_knots(spline); - const tsReal *knots = ts_int_bspline_access_knots(spline); - tsReal min, max; - size_t low, high; + tsStatus *status) { + const size_t deg = ts_bspline_degree(spline); + const size_t num_knots = ts_bspline_num_knots(spline); + const tsReal *knots = ts_int_bspline_access_knots(spline); + tsReal min, max; + size_t low, high; - ts_bspline_domain(spline, &min, &max); - if (knot < min && !ts_knots_equal(knot, min)) { - TS_RETURN_2(status, TS_U_UNDEFINED, - "knot (%f) < min(domain) (%f)", - knot, min) - } - if (knot > max && !ts_knots_equal(knot, max)) { - TS_RETURN_2(status, TS_U_UNDEFINED, - "knot (%f) > max(domain) (%f)", - knot, max) - } + ts_bspline_domain(spline, &min, &max); + if (knot < min && !ts_knots_equal(knot, min)) { + TS_RETURN_2(status, TS_U_UNDEFINED, + "knot (%f) < min(domain) (%f)", + knot, min) + } + if (knot > max && !ts_knots_equal(knot, max)) { + TS_RETURN_2(status, TS_U_UNDEFINED, + "knot (%f) > max(domain) (%f)", + knot, max) + } - /* Based on 'The NURBS Book' (Les Piegl and Wayne Tiller). */ - if (ts_knots_equal(knot, knots[num_knots - 1])) { - *index = num_knots - 1; - } else { - low = 0; - high = num_knots - 1; - *index = (low+high) / 2; - while (knot < knots[*index] || knot >= knots[*index + 1]) { - if (knot < knots[*index]) - high = *index; - else - low = *index; - *index = (low+high) / 2; - } - } + /* Based on 'The NURBS Book' (Les Piegl and Wayne Tiller). */ + if (ts_knots_equal(knot, knots[num_knots - 1])) { + *index = num_knots - 1; + } else { + low = 0; + high = num_knots - 1; + *index = (low + high) / 2; + while (knot < knots[*index] || knot >= knots[*index + 1]) { + if (knot < knots[*index]) + high = *index; + else + low = *index; + *index = (low + high) / 2; + } + } - /* Handle floating point errors. */ - while (*index < num_knots - 1 && /* there is a next knot */ - ts_knots_equal(knot, knots[*index + 1])) { - (*index)++; - } + /* Handle floating point errors. */ + while (*index < num_knots - 1 && /* there is a next knot */ + ts_knots_equal(knot, knots[*index + 1])) { + (*index)++; + } - /* Calculate knot's multiplicity. */ - for (*multiplicity = deg + 1; *multiplicity > 0 ; (*multiplicity)--) { - if (ts_knots_equal(knot, knots[*index - (*multiplicity-1)])) - break; - } + /* Calculate knot's multiplicity. */ + for (*multiplicity = deg + 1; *multiplicity > 0; (*multiplicity)--) { + if (ts_knots_equal(knot, knots[*index - (*multiplicity - 1)])) + break; + } - TS_RETURN_SUCCESS(status) + TS_RETURN_SUCCESS(status) } tsError ts_int_bspline_eval_woa(const tsBSpline *spline, tsReal u, tsDeBoorNet *net, - tsStatus *status) -{ - const size_t deg = ts_bspline_degree(spline); - const size_t order = ts_bspline_order(spline); - const size_t dim = ts_bspline_dimension(spline); - const size_t num_knots = ts_bspline_num_knots(spline); - const size_t sof_ctrlp = dim * sizeof(tsReal); + tsStatus *status) { + const size_t deg = ts_bspline_degree(spline); + const size_t order = ts_bspline_order(spline); + const size_t dim = ts_bspline_dimension(spline); + const size_t num_knots = ts_bspline_num_knots(spline); + const size_t sof_ctrlp = dim * sizeof(tsReal); - const tsReal *ctrlp = ts_int_bspline_access_ctrlp(spline); - const tsReal *knots = ts_int_bspline_access_knots(spline); - tsReal *points = NULL; /**< Pointer to the points of \p net. */ + const tsReal *ctrlp = ts_int_bspline_access_ctrlp(spline); + const tsReal *knots = ts_int_bspline_access_knots(spline); + tsReal *points = NULL; /**< Pointer to the points of \p net. */ - size_t k; /**< Index of \p u. */ - size_t s; /**< Multiplicity of \p u. */ + size_t k; /**< Index of \p u. */ + size_t s; /**< Multiplicity of \p u. */ - tsReal uk; /**< The actual used u. */ - size_t from; /**< Offset used to copy values. */ - size_t fst; /**< First affected control point, inclusive. */ - size_t lst; /**< Last affected control point, inclusive. */ - size_t N; /**< Number of affected control points. */ + tsReal uk; /**< The actual used u. */ + size_t from; /**< Offset used to copy values. */ + size_t fst; /**< First affected control point, inclusive. */ + size_t lst; /**< Last affected control point, inclusive. */ + size_t N; /**< Number of affected control points. */ - /* The following indices are used to create the DeBoor net. */ - size_t lidx; /**< Current left index. */ - size_t ridx; /**< Current right index. */ - size_t tidx; /**< Current to index. */ - size_t r, i, d; /**< Used in for loop. */ - tsReal ui; /**< Knot value at index i. */ - tsReal a, a_hat; /**< Weighting factors of control points. */ + /* The following indices are used to create the DeBoor net. */ + size_t lidx; /**< Current left index. */ + size_t ridx; /**< Current right index. */ + size_t tidx; /**< Current to index. */ + size_t r, i, d; /**< Used in for loop. */ + tsReal ui; /**< Knot value at index i. */ + tsReal a, a_hat; /**< Weighting factors of control points. */ - tsError err; + tsError err; - points = ts_int_deboornet_access_points(net); + points = ts_int_deboornet_access_points(net); - /* 1. Find index k such that u is in between [u_k, u_k+1). - * 2. Setup already known values. - * 3. Decide by multiplicity of u how to calculate point P(u). */ + /* 1. Find index k such that u is in between [u_k, u_k+1). + * 2. Setup already known values. + * 3. Decide by multiplicity of u how to calculate point P(u). */ - /* 1. */ - k = s = 0; - TS_CALL_ROE(err, ts_int_bspline_find_knot( - spline, u, &k, &s, status)) + /* 1. */ + k = s = 0; + TS_CALL_ROE(err, ts_int_bspline_find_knot( + spline, u, &k, &s, status)) - /* 2. */ - uk = knots[k]; /* Ensures that with any precision of */ - net->pImpl->u = /* tsReal the knot vector stays valid. */ - ts_knots_equal(u, uk) ? uk : u; - net->pImpl->k = k; - net->pImpl->s = s; - net->pImpl->h = deg < s ? 0 : deg-s; /* prevent underflow */ + /* 2. */ + uk = knots[k]; /* Ensures that with any precision of */ + net->pImpl->u = /* tsReal the knot vector stays valid. */ + ts_knots_equal(u, uk) ? uk : u; + net->pImpl->k = k; + net->pImpl->s = s; + net->pImpl->h = deg < s ? 0 : deg - s; /* prevent underflow */ - /* 3. (by 1. s <= order) - * - * 3a) Check for s = order. - * Take the two points k-s and k-s + 1. If one of - * them doesn't exist, take only the other. - * 3b) Use de boor algorithm to find point P(u). */ - if (s == order) { - /* only one of the two control points exists */ - if (k == deg || /* only the first */ - k == num_knots - 1) { /* only the last */ - from = k == deg ? 0 : (k-s) * dim; - net->pImpl->n_points = 1; - memcpy(points, ctrlp + from, sof_ctrlp); - } else { - from = (k-s) * dim; - net->pImpl->n_points = 2; - memcpy(points, ctrlp + from, 2 * sof_ctrlp); - } - } else { /* by 3a) s <= deg (order = deg+1) */ - fst = k-deg; /* by 1. k >= deg */ - lst = k-s; /* s <= deg <= k */ - N = lst-fst + 1; /* lst <= fst implies N >= 1 */ + /* 3. (by 1. s <= order) + * + * 3a) Check for s = order. + * Take the two points k-s and k-s + 1. If one of + * them doesn't exist, take only the other. + * 3b) Use de boor algorithm to find point P(u). */ + if (s == order) { + /* only one of the two control points exists */ + if (k == deg || /* only the first */ + k == num_knots - 1) { /* only the last */ + from = k == deg ? 0 : (k - s) * dim; + net->pImpl->n_points = 1; + memcpy(points, ctrlp + from, sof_ctrlp); + } else { + from = (k - s) * dim; + net->pImpl->n_points = 2; + memcpy(points, ctrlp + from, 2 * sof_ctrlp); + } + } else { /* by 3a) s <= deg (order = deg+1) */ + fst = k - deg; /* by 1. k >= deg */ + lst = k - s; /* s <= deg <= k */ + N = lst - fst + 1; /* lst <= fst implies N >= 1 */ - net->pImpl->n_points = (size_t)(N * (N+1) * 0.5f); + net->pImpl->n_points = (size_t)(N * (N + 1) * 0.5f); - /* copy initial values to output */ - memcpy(points, ctrlp + fst*dim, N * sof_ctrlp); + /* copy initial values to output */ + memcpy(points, ctrlp + fst * dim, N * sof_ctrlp); - lidx = 0; - ridx = dim; - tidx = N*dim; /* N >= 1 implies tidx > 0 */ - r = 1; - for (;r <= ts_deboornet_num_insertions(net); r++) { - i = fst + r; - for (; i <= lst; i++) { - ui = knots[i]; - a = (ts_deboornet_knot(net) - ui) / - (knots[i+deg-r+1] - ui); - a_hat = 1.f-a; + lidx = 0; + ridx = dim; + tidx = N * dim; /* N >= 1 implies tidx > 0 */ + r = 1; + for (; r <= ts_deboornet_num_insertions(net); r++) { + i = fst + r; + for (; i <= lst; i++) { + ui = knots[i]; + a = (ts_deboornet_knot(net) - ui) / + (knots[i + deg - r + 1] - ui); + a_hat = 1.f - a; - for (d = 0; d < dim; d++) { - points[tidx++] = - a_hat * points[lidx++] + - a * points[ridx++]; - } - } - lidx += dim; - ridx += dim; - } - } - TS_RETURN_SUCCESS(status) + for (d = 0; d < dim; d++) { + points[tidx++] = + a_hat * points[lidx++] + + a * points[ridx++]; + } + } + lidx += dim; + ridx += dim; + } + } + TS_RETURN_SUCCESS(status) } tsError ts_bspline_eval(const tsBSpline *spline, tsReal knot, tsDeBoorNet *net, - tsStatus *status) -{ - tsError err; - ts_int_deboornet_init(net); - TS_TRY(try, err, status) - TS_CALL(try, err, ts_int_deboornet_new( - spline, net, status)) - TS_CALL(try, err, ts_int_bspline_eval_woa( - spline, knot, net, status)) - TS_CATCH(err) - ts_deboornet_free(net); - TS_END_TRY_RETURN(err) + tsStatus *status) { + tsError err; + ts_int_deboornet_init(net); + TS_TRY(try, err, status) + TS_CALL(try, err, ts_int_deboornet_new(spline, net, status)) + TS_CALL(try, err, ts_int_bspline_eval_woa(spline, knot, net, status)) + TS_CATCH(err) + ts_deboornet_free(net); + TS_END_TRY_RETURN(err) } tsError @@ -1369,36 +1260,33 @@ ts_bspline_eval_all(const tsBSpline *spline, const tsReal *knots, size_t num, tsReal **points, - tsStatus *status) -{ - const size_t dim = ts_bspline_dimension(spline); - const size_t sof_point = dim * sizeof(tsReal); - const size_t sof_points = num * sof_point; - tsDeBoorNet net = ts_deboornet_init(); - tsReal *result; - size_t i; - tsError err; - TS_TRY(try, err, status) - *points = (tsReal *) malloc(sof_points); - if (!*points) { - TS_THROW_0(try, err, status, TS_MALLOC, - "out of memory") - } - TS_CALL(try, err, ts_int_deboornet_new( - spline,&net, status)) - for (i = 0; i < num; i++) { - TS_CALL(try, err, ts_int_bspline_eval_woa( - spline, knots[i], &net, status)) - result = ts_int_deboornet_access_result(&net); - memcpy((*points) + i * dim, result, sof_point); - } - TS_CATCH(err) - if (*points) - free(*points); - *points = NULL; - TS_FINALLY - ts_deboornet_free(&net); - TS_END_TRY_RETURN(err) + tsStatus *status) { + const size_t dim = ts_bspline_dimension(spline); + const size_t sof_point = dim * sizeof(tsReal); + const size_t sof_points = num * sof_point; + tsDeBoorNet net = ts_deboornet_init(); + tsReal *result; + size_t i; + tsError err; + TS_TRY(try, err, status) + *points = (tsReal *)malloc(sof_points); + if (!*points) { + TS_THROW_0(try, err, status, TS_MALLOC, + "out of memory") + } + TS_CALL(try, err, ts_int_deboornet_new(spline, &net, status)) + for (i = 0; i < num; i++) { + TS_CALL(try, err, ts_int_bspline_eval_woa(spline, knots[i], &net, status)) + result = ts_int_deboornet_access_result(&net); + memcpy((*points) + i * dim, result, sof_point); + } + TS_CATCH(err) + if (*points) + free(*points); + *points = NULL; + TS_FINALLY + ts_deboornet_free(&net); + TS_END_TRY_RETURN(err) } tsError @@ -1406,25 +1294,23 @@ ts_bspline_sample(const tsBSpline *spline, size_t num, tsReal **points, size_t *actual_num, - tsStatus *status) -{ - tsError err; - tsReal *knots; + tsStatus *status) { + tsError err; + tsReal *knots; - num = num == 0 ? 100 : num; - *actual_num = num; - knots = (tsReal *) malloc(num * sizeof(tsReal)); - if (!knots) { - *points = NULL; - TS_RETURN_0(status, TS_MALLOC, "out of memory") - } - ts_bspline_uniform_knot_seq(spline, num, knots); - TS_TRY(try, err, status) - TS_CALL(try, err, ts_bspline_eval_all( - spline, knots, num, points, status)) - TS_FINALLY - free(knots); - TS_END_TRY_RETURN(err) + num = num == 0 ? 100 : num; + *actual_num = num; + knots = (tsReal *)malloc(num * sizeof(tsReal)); + if (!knots) { + *points = NULL; + TS_RETURN_0(status, TS_MALLOC, "out of memory") + } + ts_bspline_uniform_knot_seq(spline, num, knots); + TS_TRY(try, err, status) + TS_CALL(try, err, ts_bspline_eval_all(spline, knots, num, points, status)) + TS_FINALLY + free(knots); + TS_END_TRY_RETURN(err) } tsError @@ -1436,113 +1322,107 @@ ts_bspline_bisect(const tsBSpline *spline, int ascending, size_t max_iter, tsDeBoorNet *net, - tsStatus *status) -{ - tsError err; - const size_t dim = ts_bspline_dimension(spline); - const tsReal eps = (tsReal) fabs(epsilon); - size_t i = 0; - tsReal dist = 0; - tsReal min, max, mid; - tsReal *P; + tsStatus *status) { + tsError err; + const size_t dim = ts_bspline_dimension(spline); + const tsReal eps = (tsReal)fabs(epsilon); + size_t i = 0; + tsReal dist = 0; + tsReal min, max, mid; + tsReal *P; - ts_int_deboornet_init(net); + ts_int_deboornet_init(net); - if (dim < index) { - TS_RETURN_2(status, TS_INDEX_ERROR, - "dimension (%lu) <= index (%lu)", - (unsigned long) dim, - (unsigned long) index) - } - if(max_iter == 0) - TS_RETURN_0(status, TS_NO_RESULT, "0 iterations") + if (dim < index) { + TS_RETURN_2(status, TS_INDEX_ERROR, + "dimension (%lu) <= index (%lu)", + (unsigned long)dim, + (unsigned long)index) + } + if (max_iter == 0) + TS_RETURN_0(status, TS_NO_RESULT, "0 iterations") - ts_bspline_domain(spline, &min, &max); - TS_TRY(try, err, status) - TS_CALL(try, err, ts_int_deboornet_new( - spline, net, status)) - do { - mid = (tsReal) ((min + max) / 2.0); - TS_CALL(try, err, ts_int_bspline_eval_woa( - spline, mid, net, status)) - P = ts_int_deboornet_access_result(net); - dist = ts_distance(&P[index], &value, 1); - if (dist <= eps) - TS_RETURN_SUCCESS(status) - if (ascending) { - if (P[index] < value) - min = mid; - else - max = mid; - } else { - if (P[index] < value) - max = mid; - else - min = mid; - } - } while (i++ < max_iter); - if (persnickety) { - TS_THROW_1(try, err, status, TS_NO_RESULT, - "maximum iterations (%lu) exceeded", - (unsigned long) max_iter) - } - TS_CATCH(err) - ts_deboornet_free(net); - TS_END_TRY_RETURN(err) + ts_bspline_domain(spline, &min, &max); + TS_TRY(try, err, status) + TS_CALL(try, err, ts_int_deboornet_new(spline, net, status)) + do { + mid = (tsReal)((min + max) / 2.0); + TS_CALL(try, err, ts_int_bspline_eval_woa(spline, mid, net, status)) + P = ts_int_deboornet_access_result(net); + dist = ts_distance(&P[index], &value, 1); + if (dist <= eps) + TS_RETURN_SUCCESS(status) + if (ascending) { + if (P[index] < value) + min = mid; + else + max = mid; + } else { + if (P[index] < value) + max = mid; + else + min = mid; + } + } while (i++ < max_iter); + if (persnickety) { + TS_THROW_1(try, err, status, TS_NO_RESULT, + "maximum iterations (%lu) exceeded", + (unsigned long)max_iter) + } + TS_CATCH(err) + ts_deboornet_free(net); + TS_END_TRY_RETURN(err) } void ts_bspline_domain(const tsBSpline *spline, tsReal *min, - tsReal *max) -{ - *min = ts_int_bspline_access_knots(spline) - [ts_bspline_degree(spline)]; - *max = ts_int_bspline_access_knots(spline) - [ts_bspline_num_knots(spline) - ts_bspline_order(spline)]; + tsReal *max) { + *min = ts_int_bspline_access_knots(spline) + [ts_bspline_degree(spline)]; + *max = ts_int_bspline_access_knots(spline) + [ts_bspline_num_knots(spline) - ts_bspline_order(spline)]; } tsError ts_bspline_is_closed(const tsBSpline *spline, tsReal epsilon, int *closed, - tsStatus *status) -{ - const size_t deg = ts_bspline_degree(spline); - const size_t dim = ts_bspline_dimension(spline); - tsBSpline derivative; - tsReal min, max; - tsDeBoorNet first, last; - size_t i; - tsError err; + tsStatus *status) { + const size_t deg = ts_bspline_degree(spline); + const size_t dim = ts_bspline_dimension(spline); + tsBSpline derivative; + tsReal min, max; + tsDeBoorNet first, last; + size_t i; + tsError err; - ts_int_bspline_init(&derivative); - ts_int_deboornet_init(&first); - ts_int_deboornet_init(&last); + ts_int_bspline_init(&derivative); + ts_int_deboornet_init(&first); + ts_int_deboornet_init(&last); - TS_TRY(try, err, status) - for (i = 0; i < deg; i++) { - TS_CALL(try, err, ts_bspline_derive( - spline, i, -1.f, &derivative, status)) - ts_bspline_domain(&derivative, &min, &max); - TS_CALL(try, err, ts_bspline_eval( - &derivative, min, &first, status)) - TS_CALL(try, err, ts_bspline_eval( - &derivative, max, &last, status)) - *closed = ts_distance( - ts_int_deboornet_access_result(&first), - ts_int_deboornet_access_result(&last), - dim) <= epsilon ? 1 : 0; - ts_bspline_free(&derivative); - ts_deboornet_free(&first); - ts_deboornet_free(&last); - if (!*closed) - TS_RETURN_SUCCESS(status) - } - TS_FINALLY - ts_bspline_free(&derivative); - ts_deboornet_free(&first); - ts_deboornet_free(&last); - TS_END_TRY_RETURN(err) + TS_TRY(try, err, status) + for (i = 0; i < deg; i++) { + TS_CALL(try, err, ts_bspline_derive(spline, i, -1.f, &derivative, status)) + ts_bspline_domain(&derivative, &min, &max); + TS_CALL(try, err, ts_bspline_eval(&derivative, min, &first, status)) + TS_CALL(try, err, ts_bspline_eval(&derivative, max, &last, status)) + *closed = ts_distance( + ts_int_deboornet_access_result(&first), + ts_int_deboornet_access_result(&last), + dim) <= epsilon + ? 1 + : 0; + ts_bspline_free(&derivative); + ts_deboornet_free(&first); + ts_deboornet_free(&last); + if (!*closed) + TS_RETURN_SUCCESS(status) + } + TS_FINALLY + ts_bspline_free(&derivative); + ts_deboornet_free(&first); + ts_deboornet_free(&last); + TS_END_TRY_RETURN(err) } tsError @@ -1551,169 +1431,156 @@ ts_bspline_compute_rmf(const tsBSpline *spline, size_t num, int has_first_normal, tsFrame *frames, - tsStatus *status) -{ - tsError err; - size_t i; - tsReal fx, fy, fz, fmin; - tsReal xc[3], xn[3], v1[3], c1, v2[3], c2, rL[3], tL[3]; - tsBSpline deriv = ts_bspline_init(); - tsDeBoorNet curr = ts_deboornet_init(); - tsDeBoorNet next = ts_deboornet_init(); + tsStatus *status) { + tsError err; + size_t i; + tsReal fx, fy, fz, fmin; + tsReal xc[3], xn[3], v1[3], c1, v2[3], c2, rL[3], tL[3]; + tsBSpline deriv = ts_bspline_init(); + tsDeBoorNet curr = ts_deboornet_init(); + tsDeBoorNet next = ts_deboornet_init(); - if (num < 1) - TS_RETURN_SUCCESS(status); + if (num < 1) + TS_RETURN_SUCCESS(status); - TS_TRY(try, err, status) - TS_CALL(try, err, ts_int_deboornet_new( - spline, &curr, status)) - TS_CALL(try, err, ts_int_deboornet_new( - spline, &next, status)) - TS_CALL(try, err, ts_bspline_derive( - spline, 1, (tsReal) -1.0, &deriv, status)) + TS_TRY(try, err, status) + TS_CALL(try, err, ts_int_deboornet_new(spline, &curr, status)) + TS_CALL(try, err, ts_int_deboornet_new(spline, &next, status)) + TS_CALL(try, err, ts_bspline_derive(spline, 1, (tsReal)-1.0, &deriv, status)) - /* Set position. */ - TS_CALL(try, err, ts_int_bspline_eval_woa( - spline, knots[0], &curr, status)) - ts_vec3_set(frames[0].position, - ts_int_deboornet_access_result(&curr), - ts_bspline_dimension(spline)); - /* Set tangent. */ - TS_CALL(try, err, ts_int_bspline_eval_woa( - &deriv, knots[0], &curr, status)) - ts_vec3_set(frames[0].tangent, - ts_int_deboornet_access_result(&curr), - ts_bspline_dimension(&deriv)); - ts_vec_norm(frames[0].tangent, 3, frames[0].tangent); - /* Set normal. */ - if (!has_first_normal) { - fx = (tsReal) fabs(frames[0].tangent[0]); - fy = (tsReal) fabs(frames[0].tangent[1]); - fz = (tsReal) fabs(frames[0].tangent[2]); - fmin = fx; /* x is min => 1, 0, 0 */ - ts_vec3_init(frames[0].normal, - (tsReal) 1.0, - (tsReal) 0.0, - (tsReal) 0.0); - if (fy < fmin) { /* y is min => 0, 1, 0 */ - fmin = fy; - ts_vec3_init(frames[0].normal, - (tsReal) 0.0, - (tsReal) 1.0, - (tsReal) 0.0); - } - if (fz < fmin) { /* z is min => 0, 0, 1 */ - ts_vec3_init(frames[0].normal, - (tsReal) 0.0, - (tsReal) 0.0, - (tsReal) 1.0); - } - ts_vec3_cross(frames[0].tangent, - frames[0].normal, - frames[0].normal); - ts_vec_norm(frames[0].normal, 3, frames[0].normal); - ts_vec3_cross(frames[0].tangent, - frames[0].normal, - frames[0].normal); - } else { - /* Never trust user input! */ - ts_vec_norm(frames[0].normal, 3, frames[0].normal); - } - /* Set binormal. */ - ts_vec3_cross(frames[0].tangent, - frames[0].normal, - frames[0].binormal); + /* Set position. */ + TS_CALL(try, err, ts_int_bspline_eval_woa(spline, knots[0], &curr, status)) + ts_vec3_set(frames[0].position, + ts_int_deboornet_access_result(&curr), + ts_bspline_dimension(spline)); + /* Set tangent. */ + TS_CALL(try, err, ts_int_bspline_eval_woa(&deriv, knots[0], &curr, status)) + ts_vec3_set(frames[0].tangent, + ts_int_deboornet_access_result(&curr), + ts_bspline_dimension(&deriv)); + ts_vec_norm(frames[0].tangent, 3, frames[0].tangent); + /* Set normal. */ + if (!has_first_normal) { + fx = (tsReal)fabs(frames[0].tangent[0]); + fy = (tsReal)fabs(frames[0].tangent[1]); + fz = (tsReal)fabs(frames[0].tangent[2]); + fmin = fx; /* x is min => 1, 0, 0 */ + ts_vec3_init(frames[0].normal, + (tsReal)1.0, + (tsReal)0.0, + (tsReal)0.0); + if (fy < fmin) { /* y is min => 0, 1, 0 */ + fmin = fy; + ts_vec3_init(frames[0].normal, + (tsReal)0.0, + (tsReal)1.0, + (tsReal)0.0); + } + if (fz < fmin) { /* z is min => 0, 0, 1 */ + ts_vec3_init(frames[0].normal, + (tsReal)0.0, + (tsReal)0.0, + (tsReal)1.0); + } + ts_vec3_cross(frames[0].tangent, + frames[0].normal, + frames[0].normal); + ts_vec_norm(frames[0].normal, 3, frames[0].normal); + ts_vec3_cross(frames[0].tangent, + frames[0].normal, + frames[0].normal); + } else { + /* Never trust user input! */ + ts_vec_norm(frames[0].normal, 3, frames[0].normal); + } + /* Set binormal. */ + ts_vec3_cross(frames[0].tangent, + frames[0].normal, + frames[0].binormal); - for (i = 0; i < num - 1; i++) { - /* Eval current and next point. */ - TS_CALL(try, err, ts_int_bspline_eval_woa( - spline, knots[i], &curr, status)) - TS_CALL(try, err, ts_int_bspline_eval_woa( - spline, knots[i+1], &next, status)) - ts_vec3_set(xc, /* xc is now the current point */ - ts_int_deboornet_access_result(&curr), - ts_bspline_dimension(spline)); - ts_vec3_set(xn, /* xn is now the next point */ - ts_int_deboornet_access_result(&next), - ts_bspline_dimension(spline)); + for (i = 0; i < num - 1; i++) { + /* Eval current and next point. */ + TS_CALL(try, err, ts_int_bspline_eval_woa(spline, knots[i], &curr, status)) + TS_CALL(try, err, ts_int_bspline_eval_woa(spline, knots[i + 1], &next, status)) + ts_vec3_set(xc, /* xc is now the current point */ + ts_int_deboornet_access_result(&curr), + ts_bspline_dimension(spline)); + ts_vec3_set(xn, /* xn is now the next point */ + ts_int_deboornet_access_result(&next), + ts_bspline_dimension(spline)); - /* Set position of U_{i+1}. */ - ts_vec3_set(frames[i+1].position, xn, 3); + /* Set position of U_{i+1}. */ + ts_vec3_set(frames[i + 1].position, xn, 3); - /* Compute reflection vector of R_{1}. */ - ts_vec_sub(xn, xc, 3, v1); - c1 = ts_vec_dot(v1, v1, 3); + /* Compute reflection vector of R_{1}. */ + ts_vec_sub(xn, xc, 3, v1); + c1 = ts_vec_dot(v1, v1, 3); - /* Compute r_{i}^{L} = R_{1} * r_{i}. */ - rL[0] = (tsReal) 2.0 / c1; - rL[1] = ts_vec_dot(v1, frames[i].normal, 3); - rL[2] = rL[0] * rL[1]; - ts_vec_mul(v1, 3, rL[2], rL); - ts_vec_sub(frames[i].normal, rL, 3, rL); + /* Compute r_{i}^{L} = R_{1} * r_{i}. */ + rL[0] = (tsReal)2.0 / c1; + rL[1] = ts_vec_dot(v1, frames[i].normal, 3); + rL[2] = rL[0] * rL[1]; + ts_vec_mul(v1, 3, rL[2], rL); + ts_vec_sub(frames[i].normal, rL, 3, rL); - /* Compute t_{i}^{L} = R_{1} * t_{i}. */ - tL[0] = (tsReal) 2.0 / c1; - tL[1] = ts_vec_dot(v1, frames[i].tangent, 3); - tL[2] = tL[0] * tL[1]; - ts_vec_mul(v1, 3, tL[2], tL); - ts_vec_sub(frames[i].tangent, tL, 3, tL); + /* Compute t_{i}^{L} = R_{1} * t_{i}. */ + tL[0] = (tsReal)2.0 / c1; + tL[1] = ts_vec_dot(v1, frames[i].tangent, 3); + tL[2] = tL[0] * tL[1]; + ts_vec_mul(v1, 3, tL[2], tL); + ts_vec_sub(frames[i].tangent, tL, 3, tL); - /* Compute reflection vector of R_{2}. */ - TS_CALL(try, err, ts_int_bspline_eval_woa( - &deriv, knots[i+1], &next, status)) - ts_vec3_set(xn, /* xn is now the next tangent */ - ts_int_deboornet_access_result(&next), - ts_bspline_dimension(&deriv)); - ts_vec_norm(xn, 3, xn); - ts_vec_sub(xn, tL, 3, v2); - c2 = ts_vec_dot(v2, v2, 3); + /* Compute reflection vector of R_{2}. */ + TS_CALL(try, err, ts_int_bspline_eval_woa(&deriv, knots[i + 1], &next, status)) + ts_vec3_set(xn, /* xn is now the next tangent */ + ts_int_deboornet_access_result(&next), + ts_bspline_dimension(&deriv)); + ts_vec_norm(xn, 3, xn); + ts_vec_sub(xn, tL, 3, v2); + c2 = ts_vec_dot(v2, v2, 3); - /* Compute r_{i+1} = R_{2} * r_{i}^{L}. */ - ts_vec3_set(xc, /* xc is now the next normal */ - frames[i+1].normal, 3); - xc[0] = (tsReal) 2.0 / c2; - xc[1] = ts_vec_dot(v2, rL, 3); - xc[2] = xc[0] * xc[1]; - ts_vec_mul(v2, 3, xc[2], xc); - ts_vec_sub(rL, xc, 3, xc); - ts_vec_norm(xc, 3, xc); + /* Compute r_{i+1} = R_{2} * r_{i}^{L}. */ + ts_vec3_set(xc, /* xc is now the next normal */ + frames[i + 1].normal, 3); + xc[0] = (tsReal)2.0 / c2; + xc[1] = ts_vec_dot(v2, rL, 3); + xc[2] = xc[0] * xc[1]; + ts_vec_mul(v2, 3, xc[2], xc); + ts_vec_sub(rL, xc, 3, xc); + ts_vec_norm(xc, 3, xc); - /* Compute vector s_{i+1} of U_{i+1}. */ - ts_vec3_cross(xn, xc, frames[i+1].binormal); + /* Compute vector s_{i+1} of U_{i+1}. */ + ts_vec3_cross(xn, xc, frames[i + 1].binormal); - /* Set vectors t_{i+1} and r_{i+1} of U_{i+1}. */ - ts_vec3_set(frames[i+1].tangent, xn, 3); - ts_vec3_set(frames[i+1].normal, xc, 3); - } - TS_FINALLY - ts_bspline_free(&deriv); - ts_deboornet_free(&curr); - ts_deboornet_free(&next); - TS_END_TRY_RETURN(err) + /* Set vectors t_{i+1} and r_{i+1} of U_{i+1}. */ + ts_vec3_set(frames[i + 1].tangent, xn, 3); + ts_vec3_set(frames[i + 1].normal, xc, 3); + } + TS_FINALLY + ts_bspline_free(&deriv); + ts_deboornet_free(&curr); + ts_deboornet_free(&next); + TS_END_TRY_RETURN(err) } -void -ts_bspline_uniform_knot_seq(const tsBSpline *spline, - size_t num, - tsReal *knots) -{ - size_t i; - tsReal min, max; - ts_bspline_domain(spline, &min, &max); - for (i = 0; i < num; i++) { - knots[i] = max - min; - knots[i] *= (tsReal) i / (num - 1); - knots[i] += min; - } - /* Set knots[0] after knots[num - 1] to ensure that - * knots[0] = min if num is 1. */ - knots[num - 1] = max; - knots[0] = min; +void ts_bspline_uniform_knot_seq(const tsBSpline *spline, + size_t num, + tsReal *knots) { + size_t i; + tsReal min, max; + ts_bspline_domain(spline, &min, &max); + for (i = 0; i < num; i++) { + knots[i] = max - min; + knots[i] *= (tsReal)i / (num - 1); + knots[i] += min; + } + /* Set knots[0] after knots[num - 1] to ensure that + * knots[0] = min if num is 1. */ + knots[num - 1] = max; + knots[0] = min; } /*! @} */ - - /*! @name Transformation Functions * * @{ @@ -1723,57 +1590,56 @@ ts_int_bspline_resize(const tsBSpline *spline, int n, int back, tsBSpline *resized, - tsStatus *status) -{ - const size_t deg = ts_bspline_degree(spline); - const size_t dim = ts_bspline_dimension(spline); - const size_t sof_real = sizeof(tsReal); + tsStatus *status) { + const size_t deg = ts_bspline_degree(spline); + const size_t dim = ts_bspline_dimension(spline); + const size_t sof_real = sizeof(tsReal); - const size_t num_ctrlp = ts_bspline_num_control_points(spline); - const size_t num_knots = ts_bspline_num_knots(spline); - const size_t nnum_ctrlp = num_ctrlp + n; /**< New length of ctrlp. */ - const size_t nnum_knots = num_knots + n; /**< New length of knots. */ - const size_t min_num_ctrlp_vec = n < 0 ? nnum_ctrlp : num_ctrlp; - const size_t min_num_knots_vec = n < 0 ? nnum_knots : num_knots; + const size_t num_ctrlp = ts_bspline_num_control_points(spline); + const size_t num_knots = ts_bspline_num_knots(spline); + const size_t nnum_ctrlp = num_ctrlp + n; /**< New length of ctrlp. */ + const size_t nnum_knots = num_knots + n; /**< New length of knots. */ + const size_t min_num_ctrlp_vec = n < 0 ? nnum_ctrlp : num_ctrlp; + const size_t min_num_knots_vec = n < 0 ? nnum_knots : num_knots; - const size_t sof_min_num_ctrlp = min_num_ctrlp_vec * dim * sof_real; - const size_t sof_min_num_knots = min_num_knots_vec * sof_real; + const size_t sof_min_num_ctrlp = min_num_ctrlp_vec * dim * sof_real; + const size_t sof_min_num_knots = min_num_knots_vec * sof_real; - tsBSpline tmp; /**< Temporarily stores the result. */ - const tsReal* from_ctrlp = ts_int_bspline_access_ctrlp(spline); - const tsReal* from_knots = ts_int_bspline_access_knots(spline); - tsReal* to_ctrlp = NULL; /**< Pointer to the control points of tmp. */ - tsReal* to_knots = NULL; /**< Pointer to the knots of tmp. */ + tsBSpline tmp; /**< Temporarily stores the result. */ + const tsReal *from_ctrlp = ts_int_bspline_access_ctrlp(spline); + const tsReal *from_knots = ts_int_bspline_access_knots(spline); + tsReal *to_ctrlp = NULL; /**< Pointer to the control points of tmp. */ + tsReal *to_knots = NULL; /**< Pointer to the knots of tmp. */ - tsError err; + tsError err; - if (n == 0) - return ts_bspline_copy(spline, resized, status); + if (n == 0) + return ts_bspline_copy(spline, resized, status); - INIT_OUT_BSPLINE(spline, resized) - TS_CALL_ROE(err, ts_bspline_new( - nnum_ctrlp, dim, deg, TS_OPENED, - &tmp, status)) - to_ctrlp = ts_int_bspline_access_ctrlp(&tmp); - to_knots = ts_int_bspline_access_knots(&tmp); + INIT_OUT_BSPLINE(spline, resized) + TS_CALL_ROE(err, ts_bspline_new( + nnum_ctrlp, dim, deg, TS_OPENED, + &tmp, status)) + to_ctrlp = ts_int_bspline_access_ctrlp(&tmp); + to_knots = ts_int_bspline_access_knots(&tmp); - /* Copy control points and knots. */ - if (!back && n < 0) { - memcpy(to_ctrlp, from_ctrlp - n*dim, sof_min_num_ctrlp); - memcpy(to_knots, from_knots - n , sof_min_num_knots); - } else if (!back && n > 0) { - memcpy(to_ctrlp + n*dim, from_ctrlp, sof_min_num_ctrlp); - memcpy(to_knots + n , from_knots, sof_min_num_knots); - } else { - /* n != 0 implies back == true */ - memcpy(to_ctrlp, from_ctrlp, sof_min_num_ctrlp); - memcpy(to_knots, from_knots, sof_min_num_knots); - } + /* Copy control points and knots. */ + if (!back && n < 0) { + memcpy(to_ctrlp, from_ctrlp - n * dim, sof_min_num_ctrlp); + memcpy(to_knots, from_knots - n, sof_min_num_knots); + } else if (!back && n > 0) { + memcpy(to_ctrlp + n * dim, from_ctrlp, sof_min_num_ctrlp); + memcpy(to_knots + n, from_knots, sof_min_num_knots); + } else { + /* n != 0 implies back == true */ + memcpy(to_ctrlp, from_ctrlp, sof_min_num_ctrlp); + memcpy(to_knots, from_knots, sof_min_num_knots); + } - if (spline == resized) - ts_bspline_free(resized); - ts_bspline_move(&tmp, resized); - TS_RETURN_SUCCESS(status) + if (spline == resized) + ts_bspline_free(resized); + ts_bspline_move(&tmp, resized); + TS_RETURN_SUCCESS(status) } tsError @@ -1781,102 +1647,99 @@ ts_bspline_derive(const tsBSpline *spline, size_t n, tsReal epsilon, tsBSpline *deriv, - tsStatus *status) -{ - const size_t sof_real = sizeof(tsReal); - const size_t dim = ts_bspline_dimension(spline); - const size_t sof_ctrlp = dim * sof_real; - size_t deg = ts_bspline_degree(spline); - size_t num_ctrlp = ts_bspline_num_control_points(spline); - size_t num_knots = ts_bspline_num_knots(spline); + tsStatus *status) { + const size_t sof_real = sizeof(tsReal); + const size_t dim = ts_bspline_dimension(spline); + const size_t sof_ctrlp = dim * sof_real; + size_t deg = ts_bspline_degree(spline); + size_t num_ctrlp = ts_bspline_num_control_points(spline); + size_t num_knots = ts_bspline_num_knots(spline); - tsBSpline worker; /**< Stores the intermediate result. */ - tsReal* ctrlp; /**< Pointer to the control points of worker. */ - tsReal* knots; /**< Pointer to the knots of worker. */ + tsBSpline worker; /**< Stores the intermediate result. */ + tsReal *ctrlp; /**< Pointer to the control points of worker. */ + tsReal *knots; /**< Pointer to the knots of worker. */ - size_t m, i, j, k, l; /**< Used in for loops. */ - tsReal *fst, *snd; /**< Pointer to first and second control point. */ - tsReal dist; /**< Distance between fst and snd. */ - tsReal kid1, ki1; /**< Knots at i+deg+1 and i+1. */ - tsReal span; /**< Distance between kid1 and ki1. */ + size_t m, i, j, k, l; /**< Used in for loops. */ + tsReal *fst, *snd; /**< Pointer to first and second control point. */ + tsReal dist; /**< Distance between fst and snd. */ + tsReal kid1, ki1; /**< Knots at i+deg+1 and i+1. */ + tsReal span; /**< Distance between kid1 and ki1. */ - tsBSpline swap; /**< Used to swap worker and derivative. */ - tsError err; + tsBSpline swap; /**< Used to swap worker and derivative. */ + tsError err; - INIT_OUT_BSPLINE(spline, deriv) - TS_CALL_ROE(err, ts_bspline_copy(spline, &worker, status)) - ctrlp = ts_int_bspline_access_ctrlp(&worker); - knots = ts_int_bspline_access_knots(&worker); + INIT_OUT_BSPLINE(spline, deriv) + TS_CALL_ROE(err, ts_bspline_copy(spline, &worker, status)) + ctrlp = ts_int_bspline_access_ctrlp(&worker); + knots = ts_int_bspline_access_knots(&worker); - TS_TRY(try, err, status) - for (m = 1; m <= n; m++) { /* from 1st to n'th derivative */ - if (deg == 0) { - ts_arr_fill(ctrlp, dim, 0.f); - ts_bspline_domain(spline, - &knots[0], - &knots[1]); - num_ctrlp = 1; - num_knots = 2; - break; - } - /* Check and, if possible, fix discontinuity. */ - for (i = 2*deg + 1; i < num_knots - (deg+1); i++) { - if (!ts_knots_equal(knots[i], knots[i-deg])) - continue; - fst = ctrlp + (i - (deg+1)) * dim; - snd = fst + dim; - dist = ts_distance(fst, snd, dim); - if (epsilon >= 0.f && dist > epsilon) { - TS_THROW_1(try, err, status, - TS_UNDERIVABLE, - "discontinuity at knot: %f", - knots[i]) - } - memmove(snd, - snd + dim, - (num_ctrlp - (i+1-deg)) * sof_ctrlp); - memmove(&knots[i], - &knots[i+1], - (num_knots - (i+1)) * sof_real); - num_ctrlp--; - num_knots--; - i += deg-1; - } - /* Derive continuous worker. */ - for (i = 0; i < num_ctrlp-1; i++) { - for (j = 0; j < dim; j++) { - k = i *dim + j; - l = (i+1)*dim + j; - ctrlp[k] = ctrlp[l] - ctrlp[k]; - kid1 = knots[i+deg+1]; - ki1 = knots[i+1]; - span = kid1 - ki1; - if (span < TS_KNOT_EPSILON) - span = TS_KNOT_EPSILON; - ctrlp[k] *= deg; - ctrlp[k] /= span; - } - } - deg -= 1; - num_ctrlp -= 1; - num_knots -= 2; - knots += 1; - } - TS_CALL(try, err, ts_bspline_new( - num_ctrlp, dim, deg, TS_OPENED, - &swap, status)) - memcpy(ts_int_bspline_access_ctrlp(&swap), - ctrlp, - num_ctrlp * sof_ctrlp); - memcpy(ts_int_bspline_access_knots(&swap), - knots, - num_knots * sof_real); - if (spline == deriv) - ts_bspline_free(deriv); - ts_bspline_move(&swap, deriv); - TS_FINALLY - ts_bspline_free(&worker); - TS_END_TRY_RETURN(err) + TS_TRY(try, err, status) + for (m = 1; m <= n; m++) { /* from 1st to n'th derivative */ + if (deg == 0) { + ts_arr_fill(ctrlp, dim, 0.f); + ts_bspline_domain(spline, + &knots[0], + &knots[1]); + num_ctrlp = 1; + num_knots = 2; + break; + } + /* Check and, if possible, fix discontinuity. */ + for (i = 2 * deg + 1; i < num_knots - (deg + 1); i++) { + if (!ts_knots_equal(knots[i], knots[i - deg])) + continue; + fst = ctrlp + (i - (deg + 1)) * dim; + snd = fst + dim; + dist = ts_distance(fst, snd, dim); + if (epsilon >= 0.f && dist > epsilon) { + TS_THROW_1(try, err, status, + TS_UNDERIVABLE, + "discontinuity at knot: %f", + knots[i]) + } + memmove(snd, + snd + dim, + (num_ctrlp - (i + 1 - deg)) * sof_ctrlp); + memmove(&knots[i], + &knots[i + 1], + (num_knots - (i + 1)) * sof_real); + num_ctrlp--; + num_knots--; + i += deg - 1; + } + /* Derive continuous worker. */ + for (i = 0; i < num_ctrlp - 1; i++) { + for (j = 0; j < dim; j++) { + k = i * dim + j; + l = (i + 1) * dim + j; + ctrlp[k] = ctrlp[l] - ctrlp[k]; + kid1 = knots[i + deg + 1]; + ki1 = knots[i + 1]; + span = kid1 - ki1; + if (span < TS_KNOT_EPSILON) + span = TS_KNOT_EPSILON; + ctrlp[k] *= deg; + ctrlp[k] /= span; + } + } + deg -= 1; + num_ctrlp -= 1; + num_knots -= 2; + knots += 1; + } + TS_CALL(try, err, ts_bspline_new(num_ctrlp, dim, deg, TS_OPENED, &swap, status)) + memcpy(ts_int_bspline_access_ctrlp(&swap), + ctrlp, + num_ctrlp * sof_ctrlp); + memcpy(ts_int_bspline_access_knots(&swap), + knots, + num_knots * sof_real); + if (spline == deriv) + ts_bspline_free(deriv); + ts_bspline_move(&swap, deriv); + TS_FINALLY + ts_bspline_free(&worker); + TS_END_TRY_RETURN(err) } tsError @@ -1884,119 +1747,118 @@ ts_int_bspline_insert_knot(const tsBSpline *spline, const tsDeBoorNet *net, size_t n, tsBSpline *result, - tsStatus *status) -{ - const size_t deg = ts_bspline_degree(spline); - const size_t order = ts_bspline_order(spline); - const size_t dim = ts_bspline_dimension(spline); - const tsReal knot = ts_deboornet_knot(net); - const size_t k = ts_deboornet_index(net); - const size_t mult = ts_deboornet_multiplicity(net); - const size_t sof_real = sizeof(tsReal); - const size_t sof_ctrlp = dim * sof_real; + tsStatus *status) { + const size_t deg = ts_bspline_degree(spline); + const size_t order = ts_bspline_order(spline); + const size_t dim = ts_bspline_dimension(spline); + const tsReal knot = ts_deboornet_knot(net); + const size_t k = ts_deboornet_index(net); + const size_t mult = ts_deboornet_multiplicity(net); + const size_t sof_real = sizeof(tsReal); + const size_t sof_ctrlp = dim * sof_real; - size_t N; /**< Number of affected control points. */ - tsReal* from; /**< Pointer to copy the values from. */ - tsReal* to; /**< Pointer to copy the values to. */ - int stride; /**< Stride of the next pointer to copy. */ - size_t i; /**< Used in for loops. */ + size_t N; /**< Number of affected control points. */ + tsReal *from; /**< Pointer to copy the values from. */ + tsReal *to; /**< Pointer to copy the values to. */ + int stride; /**< Stride of the next pointer to copy. */ + size_t i; /**< Used in for loops. */ - tsReal *ctrlp_spline, *ctrlp_result; - tsReal *knots_spline, *knots_result; - size_t num_ctrlp_result; - size_t num_knots_result; + tsReal *ctrlp_spline, *ctrlp_result; + tsReal *knots_spline, *knots_result; + size_t num_ctrlp_result; + size_t num_knots_result; - tsError err; + tsError err; - INIT_OUT_BSPLINE(spline, result) - if (n == 0) - return ts_bspline_copy(spline, result, status); - if (mult + n > order) { - TS_RETURN_4(status, TS_MULTIPLICITY, - "multiplicity(%f) (%lu) + %lu > order (%lu)", - knot, (unsigned long) mult, (unsigned long) n, - (unsigned long) order) - } + INIT_OUT_BSPLINE(spline, result) + if (n == 0) + return ts_bspline_copy(spline, result, status); + if (mult + n > order) { + TS_RETURN_4(status, TS_MULTIPLICITY, + "multiplicity(%f) (%lu) + %lu > order (%lu)", + knot, (unsigned long)mult, (unsigned long)n, + (unsigned long)order) + } - TS_CALL_ROE(err, ts_int_bspline_resize( - spline, (int)n, 1, result, status)) - ctrlp_spline = ts_int_bspline_access_ctrlp(spline); - knots_spline = ts_int_bspline_access_knots(spline); - ctrlp_result = ts_int_bspline_access_ctrlp(result); - knots_result = ts_int_bspline_access_knots(result); - num_ctrlp_result = ts_bspline_num_control_points(result); - num_knots_result = ts_bspline_num_knots(result); + TS_CALL_ROE(err, ts_int_bspline_resize( + spline, (int)n, 1, result, status)) + ctrlp_spline = ts_int_bspline_access_ctrlp(spline); + knots_spline = ts_int_bspline_access_knots(spline); + ctrlp_result = ts_int_bspline_access_ctrlp(result); + knots_result = ts_int_bspline_access_knots(result); + num_ctrlp_result = ts_bspline_num_control_points(result); + num_knots_result = ts_bspline_num_knots(result); - /* mult + n <= deg + 1 (order) with n >= 1 - * => mult <= deg - * => regular evaluation - * => N = h + 1 is valid */ - N = ts_deboornet_num_insertions(net) + 1; + /* mult + n <= deg + 1 (order) with n >= 1 + * => mult <= deg + * => regular evaluation + * => N = h + 1 is valid */ + N = ts_deboornet_num_insertions(net) + 1; - /* 1. Copy the relevant control points and knots from `spline'. - * 2. Copy the relevant control points and knots from `net'. */ + /* 1. Copy the relevant control points and knots from `spline'. + * 2. Copy the relevant control points and knots from `net'. */ - /* 1. - * - * a) Copy left hand side control points from `spline'. - * b) Copy right hand side control points from `spline'. - * c) Copy left hand side knots from `spline'. - * d) Copy right hand side knots form `spline'. */ - /*** Copy Control Points ***/ - memmove(ctrlp_result, ctrlp_spline, (k-deg) * sof_ctrlp); /* a) */ - from = (tsReal *) ctrlp_spline + dim*(k-deg+N); - /* n >= 0 implies to >= from */ - to = ctrlp_result + dim*(k-deg+N+n); - memmove(to, from, (num_ctrlp_result-n-(k-deg+N)) * sof_ctrlp); /* b) */ - /*** Copy Knots ***/ - memmove(knots_result, knots_spline, (k+1) * sof_real); /* c) */ - from = (tsReal *) knots_spline + k+1; - /* n >= 0 implies to >= from */ - to = knots_result + k+1+n; - memmove(to, from, (num_knots_result-n-(k+1)) * sof_real); /* d) */ + /* 1. + * + * a) Copy left hand side control points from `spline'. + * b) Copy right hand side control points from `spline'. + * c) Copy left hand side knots from `spline'. + * d) Copy right hand side knots form `spline'. */ + /*** Copy Control Points ***/ + memmove(ctrlp_result, ctrlp_spline, (k - deg) * sof_ctrlp); /* a) */ + from = (tsReal *)ctrlp_spline + dim * (k - deg + N); + /* n >= 0 implies to >= from */ + to = ctrlp_result + dim * (k - deg + N + n); + memmove(to, from, (num_ctrlp_result - n - (k - deg + N)) * sof_ctrlp); /* b) */ + /*** Copy Knots ***/ + memmove(knots_result, knots_spline, (k + 1) * sof_real); /* c) */ + from = (tsReal *)knots_spline + k + 1; + /* n >= 0 implies to >= from */ + to = knots_result + k + 1 + n; + memmove(to, from, (num_knots_result - n - (k + 1)) * sof_real); /* d) */ - /* 2. - * - * a) Copy left hand side control points from `net'. - * b) Copy middle part control points from `net'. - * c) Copy right hand side control points from `net'. - * d) Copy knot from `net' (`knot'). */ - from = ts_int_deboornet_access_points(net); - to = ctrlp_result + (k-deg)*dim; - stride = (int)(N*dim); + /* 2. + * + * a) Copy left hand side control points from `net'. + * b) Copy middle part control points from `net'. + * c) Copy right hand side control points from `net'. + * d) Copy knot from `net' (`knot'). */ + from = ts_int_deboornet_access_points(net); + to = ctrlp_result + (k - deg) * dim; + stride = (int)(N * dim); - /*** Copy Control Points ***/ - for (i = 0; i < n; i++) { /* a) */ - memcpy(to, from, sof_ctrlp); - from += stride; - to += dim; - stride -= (int)dim; - } - memcpy(to, from, (N-n) * sof_ctrlp); /* b) */ + /*** Copy Control Points ***/ + for (i = 0; i < n; i++) { /* a) */ + memcpy(to, from, sof_ctrlp); + from += stride; + to += dim; + stride -= (int)dim; + } + memcpy(to, from, (N - n) * sof_ctrlp); /* b) */ - from -= dim; - to += (N-n)*dim; - /* N = h+1 with h = deg-mult (ts_int_bspline_eval) - * => N = deg-mult+1 = order-mult. - * - * n <= order-mult - * => N-n+1 >= order-mult - order-mult + 1 = 1 - * => -(int)(N-n+1) <= -1. */ - stride = -(int)(N-n+1) * (int)dim; + from -= dim; + to += (N - n) * dim; + /* N = h+1 with h = deg-mult (ts_int_bspline_eval) + * => N = deg-mult+1 = order-mult. + * + * n <= order-mult + * => N-n+1 >= order-mult - order-mult + 1 = 1 + * => -(int)(N-n+1) <= -1. */ + stride = -(int)(N - n + 1) * (int)dim; - for (i = 0; i < n; i++) { /* c) */ - memcpy(to, from, sof_ctrlp); - from += stride; - stride -= (int)dim; - to += dim; - } - /*** Copy Knot ***/ - to = knots_result + k+1; - for (i = 0; i < n; i++) { /* d) */ - *to = knot; - to++; - } - TS_RETURN_SUCCESS(status) + for (i = 0; i < n; i++) { /* c) */ + memcpy(to, from, sof_ctrlp); + from += stride; + stride -= (int)dim; + to += dim; + } + /*** Copy Knot ***/ + to = knots_result + k + 1; + for (i = 0; i < n; i++) { /* d) */ + *to = knot; + to++; + } + TS_RETURN_SUCCESS(status) } tsError @@ -2004,165 +1866,147 @@ ts_bspline_insert_knot(const tsBSpline *spline, tsReal knot, size_t num, tsBSpline *result, - size_t* k, - tsStatus *status) -{ - tsDeBoorNet net; - tsError err; - INIT_OUT_BSPLINE(spline, result) - ts_int_deboornet_init(&net); - TS_TRY(try, err, status) - TS_CALL(try, err, ts_bspline_eval( - spline, knot, &net, status)) - TS_CALL(try, err, ts_int_bspline_insert_knot( - spline, &net, num, result, status)) - ts_deboornet_free(&net); - TS_CALL(try, err, ts_bspline_eval( - result, knot, &net, status)) - *k = ts_deboornet_index(&net); - TS_CATCH(err) - *k = 0; - TS_FINALLY - ts_deboornet_free(&net); - TS_END_TRY_RETURN(err) + size_t *k, + tsStatus *status) { + tsDeBoorNet net; + tsError err; + INIT_OUT_BSPLINE(spline, result) + ts_int_deboornet_init(&net); + TS_TRY(try, err, status) + TS_CALL(try, err, ts_bspline_eval(spline, knot, &net, status)) + TS_CALL(try, err, ts_int_bspline_insert_knot(spline, &net, num, result, status)) + ts_deboornet_free(&net); + TS_CALL(try, err, ts_bspline_eval(result, knot, &net, status)) + *k = ts_deboornet_index(&net); + TS_CATCH(err) + *k = 0; + TS_FINALLY + ts_deboornet_free(&net); + TS_END_TRY_RETURN(err) } tsError ts_bspline_split(const tsBSpline *spline, tsReal knot, tsBSpline *split, - size_t* k, - tsStatus *status) -{ - tsDeBoorNet net; - tsError err; - INIT_OUT_BSPLINE(spline, split) - ts_int_deboornet_init(&net); - TS_TRY(try, err, status) - TS_CALL(try, err, ts_bspline_eval( - spline, knot, &net, status)) - if (ts_deboornet_multiplicity(&net) - == ts_bspline_order(spline)) { - TS_CALL(try, err, ts_bspline_copy( - spline, split, status)) - *k = ts_deboornet_index(&net); - } else { - TS_CALL(try, err, ts_int_bspline_insert_knot( - spline, &net, - ts_deboornet_num_insertions(&net) + 1, - split, status)) - *k = ts_deboornet_index(&net) + - ts_deboornet_num_insertions(&net) + 1; - } - TS_CATCH(err) - *k = 0; - TS_FINALLY - ts_deboornet_free(&net); - TS_END_TRY_RETURN(err) + size_t *k, + tsStatus *status) { + tsDeBoorNet net; + tsError err; + INIT_OUT_BSPLINE(spline, split) + ts_int_deboornet_init(&net); + TS_TRY(try, err, status) + TS_CALL(try, err, ts_bspline_eval(spline, knot, &net, status)) + if (ts_deboornet_multiplicity(&net) == ts_bspline_order(spline)) { + TS_CALL(try, err, ts_bspline_copy(spline, split, status)) + *k = ts_deboornet_index(&net); + } else { + TS_CALL(try, err, ts_int_bspline_insert_knot(spline, &net, ts_deboornet_num_insertions(&net) + 1, split, status)) + *k = ts_deboornet_index(&net) + + ts_deboornet_num_insertions(&net) + 1; + } + TS_CATCH(err) + *k = 0; + TS_FINALLY + ts_deboornet_free(&net); + TS_END_TRY_RETURN(err) } tsError ts_bspline_tension(const tsBSpline *spline, tsReal beta, tsBSpline *out, - tsStatus *status) -{ - const size_t dim = ts_bspline_dimension(spline); - const size_t N = ts_bspline_num_control_points(spline); - const tsReal* p0 = ts_int_bspline_access_ctrlp(spline); - const tsReal* pn_1 = p0 + (N-1)*dim; + tsStatus *status) { + const size_t dim = ts_bspline_dimension(spline); + const size_t N = ts_bspline_num_control_points(spline); + const tsReal *p0 = ts_int_bspline_access_ctrlp(spline); + const tsReal *pn_1 = p0 + (N - 1) * dim; - tsReal s; /**< The straightening factor. */ - tsReal *ctrlp; /**< Pointer to the control points of `out'. */ - size_t i, d; /**< Used in for loops. */ - tsReal vec; /**< Straightening vector. */ - tsError err; + tsReal s; /**< The straightening factor. */ + tsReal *ctrlp; /**< Pointer to the control points of `out'. */ + size_t i, d; /**< Used in for loops. */ + tsReal vec; /**< Straightening vector. */ + tsError err; - TS_CALL_ROE(err, ts_bspline_copy(spline, out, status)) - ctrlp = ts_int_bspline_access_ctrlp(out); - if (beta < (tsReal) 0.0) beta = (tsReal) 0.0; - if (beta > (tsReal) 1.0) beta = (tsReal) 1.0; - s = 1.f - beta; + TS_CALL_ROE(err, ts_bspline_copy(spline, out, status)) + ctrlp = ts_int_bspline_access_ctrlp(out); + if (beta < (tsReal)0.0) beta = (tsReal)0.0; + if (beta > (tsReal)1.0) beta = (tsReal)1.0; + s = 1.f - beta; - for (i = 0; i < N; i++) { - for (d = 0; d < dim; d++) { - vec = ((tsReal)i / (N-1)) * (pn_1[d] - p0[d]); - ctrlp[i*dim + d] = beta * ctrlp[i*dim + d] + - s * (p0[d] + vec); - } - } - TS_RETURN_SUCCESS(status) + for (i = 0; i < N; i++) { + for (d = 0; d < dim; d++) { + vec = ((tsReal)i / (N - 1)) * (pn_1[d] - p0[d]); + ctrlp[i * dim + d] = beta * ctrlp[i * dim + d] + + s * (p0[d] + vec); + } + } + TS_RETURN_SUCCESS(status) } tsError ts_bspline_to_beziers(const tsBSpline *spline, tsBSpline *beziers, - tsStatus *status) -{ - const size_t deg = ts_bspline_degree(spline); - const size_t order = ts_bspline_order(spline); + tsStatus *status) { + const size_t deg = ts_bspline_degree(spline); + const size_t order = ts_bspline_order(spline); - int resize; /**< Number of control points to add/remove. */ - size_t k; /**< Index of the split knot value. */ - tsReal u_min; /**< Minimum of the knot values. */ - tsReal u_max; /**< Maximum of the knot values. */ + int resize; /**< Number of control points to add/remove. */ + size_t k; /**< Index of the split knot value. */ + tsReal u_min; /**< Minimum of the knot values. */ + tsReal u_max; /**< Maximum of the knot values. */ - tsBSpline tmp; /**< Temporarily stores the result. */ - tsReal *knots; /**< Pointer to the knots of tmp. */ - size_t num_knots; /**< Number of knots in tmp. */ + tsBSpline tmp; /**< Temporarily stores the result. */ + tsReal *knots; /**< Pointer to the knots of tmp. */ + size_t num_knots; /**< Number of knots in tmp. */ - tsError err; + tsError err; - INIT_OUT_BSPLINE(spline, beziers) - TS_CALL_ROE(err, ts_bspline_copy(spline, &tmp, status)) - knots = ts_int_bspline_access_knots(&tmp); - num_knots = ts_bspline_num_knots(&tmp); + INIT_OUT_BSPLINE(spline, beziers) + TS_CALL_ROE(err, ts_bspline_copy(spline, &tmp, status)) + knots = ts_int_bspline_access_knots(&tmp); + num_knots = ts_bspline_num_knots(&tmp); - TS_TRY(try, err, status) - /* DO NOT FORGET TO UPDATE knots AND num_knots AFTER EACH - * TRANSFORMATION OF tmp! */ + TS_TRY(try, err, status) + /* DO NOT FORGET TO UPDATE knots AND num_knots AFTER EACH + * TRANSFORMATION OF tmp! */ - /* Fix first control point if necessary. */ - u_min = knots[deg]; - if (!ts_knots_equal(knots[0], u_min)) { - TS_CALL(try, err, ts_bspline_split( - &tmp, u_min, &tmp, &k, status)) - resize = (int)(-1*deg + (deg*2 - k)); - TS_CALL(try, err, ts_int_bspline_resize( - &tmp, resize, 0, &tmp, status)) - knots = ts_int_bspline_access_knots(&tmp); - num_knots = ts_bspline_num_knots(&tmp); - } + /* Fix first control point if necessary. */ + u_min = knots[deg]; + if (!ts_knots_equal(knots[0], u_min)) { + TS_CALL(try, err, ts_bspline_split(&tmp, u_min, &tmp, &k, status)) + resize = (int)(-1 * deg + (deg * 2 - k)); + TS_CALL(try, err, ts_int_bspline_resize(&tmp, resize, 0, &tmp, status)) + knots = ts_int_bspline_access_knots(&tmp); + num_knots = ts_bspline_num_knots(&tmp); + } - /* Fix last control point if necessary. */ - u_max = knots[num_knots - order]; - if (!ts_knots_equal(knots[num_knots - 1], u_max)) { - TS_CALL(try, err, ts_bspline_split( - &tmp, u_max, &tmp, &k, status)) - num_knots = ts_bspline_num_knots(&tmp); - resize = (int)(-1*deg + (k - (num_knots - order))); - TS_CALL(try, err, ts_int_bspline_resize( - &tmp, resize, 1, &tmp, status)) - knots = ts_int_bspline_access_knots(&tmp); - num_knots = ts_bspline_num_knots(&tmp); - } + /* Fix last control point if necessary. */ + u_max = knots[num_knots - order]; + if (!ts_knots_equal(knots[num_knots - 1], u_max)) { + TS_CALL(try, err, ts_bspline_split(&tmp, u_max, &tmp, &k, status)) + num_knots = ts_bspline_num_knots(&tmp); + resize = (int)(-1 * deg + (k - (num_knots - order))); + TS_CALL(try, err, ts_int_bspline_resize(&tmp, resize, 1, &tmp, status)) + knots = ts_int_bspline_access_knots(&tmp); + num_knots = ts_bspline_num_knots(&tmp); + } - /* Split internal knots. */ - k = order; - while (k < num_knots - order) { - TS_CALL(try, err, ts_bspline_split( - &tmp, knots[k], &tmp, &k, status)) - knots = ts_int_bspline_access_knots(&tmp); - num_knots = ts_bspline_num_knots(&tmp); - k++; - } + /* Split internal knots. */ + k = order; + while (k < num_knots - order) { + TS_CALL(try, err, ts_bspline_split(&tmp, knots[k], &tmp, &k, status)) + knots = ts_int_bspline_access_knots(&tmp); + num_knots = ts_bspline_num_knots(&tmp); + k++; + } - if (spline == beziers) - ts_bspline_free(beziers); - ts_bspline_move(&tmp, beziers); - TS_FINALLY - ts_bspline_free(&tmp); - TS_END_TRY_RETURN(err) + if (spline == beziers) + ts_bspline_free(beziers); + ts_bspline_move(&tmp, beziers); + TS_FINALLY + ts_bspline_free(&tmp); + TS_END_TRY_RETURN(err) } tsError @@ -2170,252 +2014,246 @@ ts_bspline_elevate_degree(const tsBSpline *spline, size_t amount, tsReal epsilon, tsBSpline *elevated, - tsStatus * status) -{ - tsBSpline worker; - size_t dim, order; - tsReal *ctrlp, *knots; - size_t num_beziers, i, a, c, d, offset, idx; - tsReal f, f_hat, *first, *last; - tsError err; + tsStatus *status) { + tsBSpline worker; + size_t dim, order; + tsReal *ctrlp, *knots; + size_t num_beziers, i, a, c, d, offset, idx; + tsReal f, f_hat, *first, *last; + tsError err; - /* Trivial case. */ - if (amount == 0) - return ts_bspline_copy(spline, elevated, status); + /* Trivial case. */ + if (amount == 0) + return ts_bspline_copy(spline, elevated, status); - /* An overview of this algorithm can be found at: - * https://pages.mtu.edu/~shene/COURSES/cs3621/LAB/curve/elevation.html */ - INIT_OUT_BSPLINE(spline, elevated); - worker = ts_bspline_init(); - TS_TRY(try, err, status) - /* Decompose `spline' into a sequence of bezier curves and make - * space for the additional control points and knots that are - * to be inserted. Results are stored in `worker'. */ - TS_CALL(try, err, ts_bspline_to_beziers( - spline, &worker, status)); - num_beziers = ts_bspline_num_control_points(&worker) / - ts_bspline_order(&worker); - TS_CALL(try, err, ts_int_bspline_resize( - /* Resize by the number of knots to be inserted. Note - * that this creates too many control points (due to - * increasing the degree), which are removed at the end - * of this function. */ - &worker, (int) ((num_beziers+1) * amount), 1, &worker, - status)); - dim = ts_bspline_dimension(&worker); - order = ts_bspline_order(&worker); - ctrlp = ts_int_bspline_access_ctrlp(&worker); - knots = ts_int_bspline_access_knots(&worker); + /* An overview of this algorithm can be found at: + * https://pages.mtu.edu/~shene/COURSES/cs3621/LAB/curve/elevation.html */ + INIT_OUT_BSPLINE(spline, elevated); + worker = ts_bspline_init(); + TS_TRY(try, err, status) + /* Decompose `spline' into a sequence of bezier curves and make + * space for the additional control points and knots that are + * to be inserted. Results are stored in `worker'. */ + TS_CALL(try, err, ts_bspline_to_beziers(spline, &worker, status)); + num_beziers = ts_bspline_num_control_points(&worker) / + ts_bspline_order(&worker); + TS_CALL(try, err, ts_int_bspline_resize( + /* Resize by the number of knots to be inserted. Note + * that this creates too many control points (due to + * increasing the degree), which are removed at the end + * of this function. */ + &worker, (int)((num_beziers + 1) * amount), 1, &worker, status)); + dim = ts_bspline_dimension(&worker); + order = ts_bspline_order(&worker); + ctrlp = ts_int_bspline_access_ctrlp(&worker); + knots = ts_int_bspline_access_knots(&worker); - /* Move all but the first bezier curve to their new location in - * the control point array so that the additional control - * points can be inserted without overwriting the others. Note - * that iteration must run backwards. Otherwise, the moved - * values overwrite each other. */ - for (i = num_beziers - 1; i > 0; i--) { - /* `i' can be interpreted as the number of bezier - * curves before the current bezier curve. */ + /* Move all but the first bezier curve to their new location in + * the control point array so that the additional control + * points can be inserted without overwriting the others. Note + * that iteration must run backwards. Otherwise, the moved + * values overwrite each other. */ + for (i = num_beziers - 1; i > 0; i--) { + /* `i' can be interpreted as the number of bezier + * curves before the current bezier curve. */ - /* Location of current bezier curve. */ - offset = i * order * dim; - /* Each elevation inserts an additional control point - * into every bezier curve. `i * amount' is the total - * number of control points to be inserted before the - * current bezier curve. */ - memmove(ctrlp + offset + (i * amount * dim), - ctrlp + offset, - dim * order * sizeof(tsReal)); - } + /* Location of current bezier curve. */ + offset = i * order * dim; + /* Each elevation inserts an additional control point + * into every bezier curve. `i * amount' is the total + * number of control points to be inserted before the + * current bezier curve. */ + memmove(ctrlp + offset + (i * amount * dim), + ctrlp + offset, + dim * order * sizeof(tsReal)); + } - /* Move all but the first group of knots to their new location - * in the knot vector so that the additional knots can be - * inserted without overwriting the others. Note that iteration - * must run backwards. Otherwise, the moved values overwrite - * each other. */ - for (i = num_beziers; i > 0; i--) { - /* Note that the number of knot groups is one more than - * the number of bezier curves. `i' can be interpreted - * as the number of knot groups before the current - * group. */ + /* Move all but the first group of knots to their new location + * in the knot vector so that the additional knots can be + * inserted without overwriting the others. Note that iteration + * must run backwards. Otherwise, the moved values overwrite + * each other. */ + for (i = num_beziers; i > 0; i--) { + /* Note that the number of knot groups is one more than + * the number of bezier curves. `i' can be interpreted + * as the number of knot groups before the current + * group. */ - /* Location of current knot group. */ - offset = i * order; - /* Each elevation inserts an additional knot into every - * group of knots. `i * amount' is the total number of - * knots to be inserted before the current knot - * group. */ - memmove(knots + offset + (i * amount), - knots + offset, - order * sizeof(tsReal)); - } + /* Location of current knot group. */ + offset = i * order; + /* Each elevation inserts an additional knot into every + * group of knots. `i * amount' is the total number of + * knots to be inserted before the current knot + * group. */ + memmove(knots + offset + (i * amount), + knots + offset, + order * sizeof(tsReal)); + } - /* `worker' is now fully set up. - * The following formulas are based on: - * https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-elev.html */ - for (a = 0; a < amount; a++) { - /* For each bezier curve... */ - for (i = 0; i < num_beziers; i++) { - /* ... 1) Insert and update control points. */ + /* `worker' is now fully set up. + * The following formulas are based on: + * https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-elev.html */ + for (a = 0; a < amount; a++) { + /* For each bezier curve... */ + for (i = 0; i < num_beziers; i++) { + /* ... 1) Insert and update control points. */ - /* Location of current bezier curve. Each - * elevation (`a') inserts an additional - * control point into every bezier curve and - * increases the degree (`order') by one. The - * location is thus made up of two parts: - * - * i) `i * order', which is the location taking - * into account the increasing order but - * neglecting the control points that are to be - * inserted before the current bezier curve. It - * can be seen as some sort of base location: - * Where would the bezier curve be (with - * respect to the current value of `order') if - * no additional control points had to be - * inserted? - * - * ii) `i * (amount - a)', which is the total - * number of control points to be inserted - * before the current bezier curve - * (`i * amount') taking into account the - * increasing order (`order' and `a' are - * increased equally, thus, `a' compensates for - * the increasing value of `order'). This part - * adds the necessary offset to the base - * location (`i * order'). */ - offset = (i * order + i * (amount - a)) * dim; - /* Duplicate last control point to the new end - * position (next control point). */ - memmove(ctrlp + offset + ((order) * dim), - ctrlp + offset + ((order-1) * dim), - dim * sizeof(tsReal)); - /* All but the outer control points must be - * recalculated (domain: [1, order - 1]). By - * traversing backwards, control points can be - * modified in-place. */ - for (c = order - 1; c > 0; c--) { - /* Location of current control point - * within current bezier curve. */ - idx = offset + c * dim; - f = (tsReal) c / (tsReal) (order); - f_hat = 1 - f; - for (d = 0; d < dim; d++) { - /* For the sake of space, we - * increment idx by d and - * decrement it at the end of - * this loop. */ - idx += d; - ctrlp[idx] = - f * ctrlp[idx - dim] + - f_hat * ctrlp[idx]; - /* Reset idx. */ - idx -= d; - } - } + /* Location of current bezier curve. Each + * elevation (`a') inserts an additional + * control point into every bezier curve and + * increases the degree (`order') by one. The + * location is thus made up of two parts: + * + * i) `i * order', which is the location taking + * into account the increasing order but + * neglecting the control points that are to be + * inserted before the current bezier curve. It + * can be seen as some sort of base location: + * Where would the bezier curve be (with + * respect to the current value of `order') if + * no additional control points had to be + * inserted? + * + * ii) `i * (amount - a)', which is the total + * number of control points to be inserted + * before the current bezier curve + * (`i * amount') taking into account the + * increasing order (`order' and `a' are + * increased equally, thus, `a' compensates for + * the increasing value of `order'). This part + * adds the necessary offset to the base + * location (`i * order'). */ + offset = (i * order + i * (amount - a)) * dim; + /* Duplicate last control point to the new end + * position (next control point). */ + memmove(ctrlp + offset + ((order)*dim), + ctrlp + offset + ((order - 1) * dim), + dim * sizeof(tsReal)); + /* All but the outer control points must be + * recalculated (domain: [1, order - 1]). By + * traversing backwards, control points can be + * modified in-place. */ + for (c = order - 1; c > 0; c--) { + /* Location of current control point + * within current bezier curve. */ + idx = offset + c * dim; + f = (tsReal)c / (tsReal)(order); + f_hat = 1 - f; + for (d = 0; d < dim; d++) { + /* For the sake of space, we + * increment idx by d and + * decrement it at the end of + * this loop. */ + idx += d; + ctrlp[idx] = + f * ctrlp[idx - dim] + + f_hat * ctrlp[idx]; + /* Reset idx. */ + idx -= d; + } + } - /* ...2) Increase the multiplicity of the - * second knot group (maximum of the domain of - * the current bezier curve) by one. Note that - * this loop misses the last knot group (the - * group of the last bezier curve) as there is - * one more knot group than bezier curves to - * process. Thus, the last group must be - * increased separately after this loop. */ + /* ...2) Increase the multiplicity of the + * second knot group (maximum of the domain of + * the current bezier curve) by one. Note that + * this loop misses the last knot group (the + * group of the last bezier curve) as there is + * one more knot group than bezier curves to + * process. Thus, the last group must be + * increased separately after this loop. */ - /* Location of current knot group. Each - * elevation (`a') inserts an additional - * knot into the knot vector of every bezier - * curve and increases the degree (`order') by - * one. The location is thus made up of two - * parts: - * - * i) `i * order', which is the location taking - * into account the increasing order but - * neglecting the knots that are to be inserted - * before the current knot group. It can be - * seen as some sort of base location: Where - * would the knot group be (with respect to the - * current value of `order') if no additional - * knots had to be inserted? - * - * ii) `i * (amount - a)', which is the total - * number of knots to be inserted before the - * current knot group (`i * amount') taking - * into account the increasing order (`order' - * and `a' are increased equally, thus, `a' - * compensates for the increasing value of - * `order'). This part adds the necessary - * offset to the base location - * (`i * order'). */ - offset = i * order + i * (amount - a); - /* Duplicate knot. */ - knots[offset + order] = knots[offset]; - } + /* Location of current knot group. Each + * elevation (`a') inserts an additional + * knot into the knot vector of every bezier + * curve and increases the degree (`order') by + * one. The location is thus made up of two + * parts: + * + * i) `i * order', which is the location taking + * into account the increasing order but + * neglecting the knots that are to be inserted + * before the current knot group. It can be + * seen as some sort of base location: Where + * would the knot group be (with respect to the + * current value of `order') if no additional + * knots had to be inserted? + * + * ii) `i * (amount - a)', which is the total + * number of knots to be inserted before the + * current knot group (`i * amount') taking + * into account the increasing order (`order' + * and `a' are increased equally, thus, `a' + * compensates for the increasing value of + * `order'). This part adds the necessary + * offset to the base location + * (`i * order'). */ + offset = i * order + i * (amount - a); + /* Duplicate knot. */ + knots[offset + order] = knots[offset]; + } - /* Increase the multiplicity of the very last knot - * group (the second group of the last bezier curve) - * by one. For more details, see knot duplication in - * previous loop. */ - offset = num_beziers * order + - num_beziers * (amount - a); - knots[offset + order] = knots[offset]; + /* Increase the multiplicity of the very last knot + * group (the second group of the last bezier curve) + * by one. For more details, see knot duplication in + * previous loop. */ + offset = num_beziers * order + + num_beziers * (amount - a); + knots[offset + order] = knots[offset]; - /* Elevated by one. */ - order++; - } + /* Elevated by one. */ + order++; + } - /* Combine bezier curves. */ - d = 0; /* Number of removed knots/control points. */ - for (i = 0; i < num_beziers - 1; i++) { - /* Is the last control point of bezier curve `i' equal - * to the first control point of bezier curve `i+1'? */ - last = ctrlp + ( - i * order /* base location of `i' */ - - d /* minus the number of removed values */ - + (order - 1) /* jump to last control point */ - ) * dim; - first = last + dim; /* next control point */ - if (ts_distance(last, first, dim) <= epsilon) { - /* Move control points. */ - memmove(last, first, (num_beziers - 1 - i) * - order * dim * sizeof(tsReal)); + /* Combine bezier curves. */ + d = 0; /* Number of removed knots/control points. */ + for (i = 0; i < num_beziers - 1; i++) { + /* Is the last control point of bezier curve `i' equal + * to the first control point of bezier curve `i+1'? */ + last = ctrlp + (i * order /* base location of `i' */ + - d /* minus the number of removed values */ + + (order - 1) /* jump to last control point */ + ) * dim; + first = last + dim; /* next control point */ + if (ts_distance(last, first, dim) <= epsilon) { + /* Move control points. */ + memmove(last, first, (num_beziers - 1 - i) * order * dim * sizeof(tsReal)); - /* Move knots. `last' is the last knot of the - * second knot group of bezier curve `i'. - * `first' is the first knot of the first knot - * group of bezier curve `i+1'. The - * calculations are quite similar to those for - * the control points `last' and `first' (see - * above). */ - last = knots + i * order - d + (2 * order - 1); - first = last + 1; - memmove(last, first, (num_beziers - 1 - i) * - order * sizeof(tsReal)); + /* Move knots. `last' is the last knot of the + * second knot group of bezier curve `i'. + * `first' is the first knot of the first knot + * group of bezier curve `i+1'. The + * calculations are quite similar to those for + * the control points `last' and `first' (see + * above). */ + last = knots + i * order - d + (2 * order - 1); + first = last + 1; + memmove(last, first, (num_beziers - 1 - i) * order * sizeof(tsReal)); - /* Removed one knot/control point. */ - d++; - } - } + /* Removed one knot/control point. */ + d++; + } + } - /* Repair internal state. */ - worker.pImpl->deg = order - 1; - worker.pImpl->n_knots -= d; - worker.pImpl->n_ctrlp = ts_bspline_num_knots(&worker) - order; - memmove(ts_int_bspline_access_knots(&worker), - knots, ts_bspline_sof_knots(&worker)); - worker.pImpl = realloc(worker.pImpl, - ts_int_bspline_sof_state(&worker)); - if (worker.pImpl == NULL) { - TS_THROW_0(try, err, status, TS_MALLOC, - "out of memory") - } + /* Repair internal state. */ + worker.pImpl->deg = order - 1; + worker.pImpl->n_knots -= d; + worker.pImpl->n_ctrlp = ts_bspline_num_knots(&worker) - order; + memmove(ts_int_bspline_access_knots(&worker), + knots, ts_bspline_sof_knots(&worker)); + worker.pImpl = realloc(worker.pImpl, + ts_int_bspline_sof_state(&worker)); + if (worker.pImpl == NULL) { + TS_THROW_0(try, err, status, TS_MALLOC, + "out of memory") + } - /* Move `worker' to output parameter. */ - if (spline == elevated) - ts_bspline_free(elevated); - ts_bspline_move(&worker, elevated); - TS_FINALLY - ts_bspline_free(&worker); - TS_END_TRY_RETURN(err) + /* Move `worker' to output parameter. */ + if (spline == elevated) + ts_bspline_free(elevated); + ts_bspline_move(&worker, elevated); + TS_FINALLY + ts_bspline_free(&worker); + TS_END_TRY_RETURN(err) } tsError @@ -2424,98 +2262,85 @@ ts_bspline_align(const tsBSpline *s1, tsReal epsilon, tsBSpline *s1_out, tsBSpline *s2_out, - tsStatus *status) -{ - tsBSpline s1_worker, s2_worker, *smaller, *larger; - tsDeBoorNet net; /* the net of `smaller'. */ - size_t i, missing, remaining; - tsReal min, max, shift, nextKnot; - tsError err; + tsStatus *status) { + tsBSpline s1_worker, s2_worker, *smaller, *larger; + tsDeBoorNet net; /* the net of `smaller'. */ + size_t i, missing, remaining; + tsReal min, max, shift, nextKnot; + tsError err; - INIT_OUT_BSPLINE(s1, s1_out) - INIT_OUT_BSPLINE(s2, s2_out) - s1_worker = ts_bspline_init(); - s2_worker = ts_bspline_init(); - smaller = larger = NULL; - TS_TRY(try, err, status) - /* Set up `s1_worker' and `s2_worker'. After this - * if-elseif-else-block, `s1_worker' and `s2_worker' have same - * degree. */ - if (ts_bspline_degree(s1) < ts_bspline_degree(s2)) { - TS_CALL(try, err, ts_bspline_elevate_degree(s1, - ts_bspline_degree(s2) - ts_bspline_degree(s1), - epsilon, &s1_worker, status)) - TS_CALL(try, err, ts_bspline_copy( - s2, &s2_worker, status)) - } else if (ts_bspline_degree(s2) < ts_bspline_degree(s1)) { - TS_CALL(try, err, ts_bspline_elevate_degree(s2, - ts_bspline_degree(s1) - ts_bspline_degree(s2), - epsilon, &s2_worker, status)) - TS_CALL(try, err, ts_bspline_copy( - s1, &s1_worker, status)) - } else { - TS_CALL(try, err, ts_bspline_copy( - s1, &s1_worker, status)) - TS_CALL(try, err, ts_bspline_copy( - s2, &s2_worker, status)) - } + INIT_OUT_BSPLINE(s1, s1_out) + INIT_OUT_BSPLINE(s2, s2_out) + s1_worker = ts_bspline_init(); + s2_worker = ts_bspline_init(); + smaller = larger = NULL; + TS_TRY(try, err, status) + /* Set up `s1_worker' and `s2_worker'. After this + * if-elseif-else-block, `s1_worker' and `s2_worker' have same + * degree. */ + if (ts_bspline_degree(s1) < ts_bspline_degree(s2)) { + TS_CALL(try, err, ts_bspline_elevate_degree(s1, ts_bspline_degree(s2) - ts_bspline_degree(s1), epsilon, &s1_worker, status)) + TS_CALL(try, err, ts_bspline_copy(s2, &s2_worker, status)) + } else if (ts_bspline_degree(s2) < ts_bspline_degree(s1)) { + TS_CALL(try, err, ts_bspline_elevate_degree(s2, ts_bspline_degree(s1) - ts_bspline_degree(s2), epsilon, &s2_worker, status)) + TS_CALL(try, err, ts_bspline_copy(s1, &s1_worker, status)) + } else { + TS_CALL(try, err, ts_bspline_copy(s1, &s1_worker, status)) + TS_CALL(try, err, ts_bspline_copy(s2, &s2_worker, status)) + } - /* Set up `smaller', `larger', and `net'. */ - if (ts_bspline_num_knots(&s1_worker) < - ts_bspline_num_knots(&s2_worker)) { - smaller = &s1_worker; - larger = &s2_worker; - } else { - smaller = &s2_worker; - larger = &s1_worker; - } - TS_CALL(try, err, ts_int_deboornet_new( - smaller, &net, status)) + /* Set up `smaller', `larger', and `net'. */ + if (ts_bspline_num_knots(&s1_worker) < + ts_bspline_num_knots(&s2_worker)) { + smaller = &s1_worker; + larger = &s2_worker; + } else { + smaller = &s2_worker; + larger = &s1_worker; + } + TS_CALL(try, err, ts_int_deboornet_new(smaller, &net, status)) - /* Insert knots into `smaller' until it has the same number of - * knots (and therefore the same number of control points) as - * `larger'. */ - ts_bspline_domain(smaller, &min, &max); - missing = remaining = ts_bspline_num_knots(larger) - - ts_bspline_num_knots(smaller); - shift = (tsReal) 0.0; - if (missing > 0) - shift = ( (tsReal) 1.0 / missing ) * (tsReal) 0.5; - for (i = 0; remaining > 0; i++, remaining--) { - nextKnot = (max - min) * ((tsReal)i / missing) + min; - nextKnot += shift; - TS_CALL(try, err, ts_int_bspline_eval_woa( - smaller, nextKnot, &net, status)) - while (!ts_deboornet_num_insertions(&net)) { - /* Linear exploration for next knot. */ - nextKnot += 5 * TS_KNOT_EPSILON; - if (nextKnot > max) { - TS_THROW_0(try, err, status, - TS_NO_RESULT, - "no more knots for insertion") - } - TS_CALL(try, err, ts_int_bspline_eval_woa( - smaller, nextKnot, &net, status)) - } - TS_CALL(try, err, ts_int_bspline_insert_knot( - smaller, &net, 1, smaller, status)) - } + /* Insert knots into `smaller' until it has the same number of + * knots (and therefore the same number of control points) as + * `larger'. */ + ts_bspline_domain(smaller, &min, &max); + missing = remaining = ts_bspline_num_knots(larger) - + ts_bspline_num_knots(smaller); + shift = (tsReal)0.0; + if (missing > 0) + shift = ((tsReal)1.0 / missing) * (tsReal)0.5; + for (i = 0; remaining > 0; i++, remaining--) { + nextKnot = (max - min) * ((tsReal)i / missing) + min; + nextKnot += shift; + TS_CALL(try, err, ts_int_bspline_eval_woa(smaller, nextKnot, &net, status)) + while (!ts_deboornet_num_insertions(&net)) { + /* Linear exploration for next knot. */ + nextKnot += 5 * TS_KNOT_EPSILON; + if (nextKnot > max) { + TS_THROW_0(try, err, status, + TS_NO_RESULT, + "no more knots for insertion") + } + TS_CALL(try, err, ts_int_bspline_eval_woa(smaller, nextKnot, &net, status)) + } + TS_CALL(try, err, ts_int_bspline_insert_knot(smaller, &net, 1, smaller, status)) + } - if (s1 == s1_out) - ts_bspline_free(s1_out); - if (s2 == s2_out) - ts_bspline_free(s2_out); - ts_bspline_move(&s1_worker, s1_out); - /* if `s1_out' == `s2_out', `s2_worker' must not be moved - * because otherwise the memory of `s1_worker' is leaked - * (`s2_worker' overrides `s1_worker'). */ - if (s1_out != s2_out) - ts_bspline_move(&s2_worker, s2_out); - TS_FINALLY - ts_bspline_free(&s1_worker); - ts_bspline_free(&s2_worker); - ts_deboornet_free(&net); - TS_END_TRY_RETURN(err) + if (s1 == s1_out) + ts_bspline_free(s1_out); + if (s2 == s2_out) + ts_bspline_free(s2_out); + ts_bspline_move(&s1_worker, s1_out); + /* if `s1_out' == `s2_out', `s2_worker' must not be moved + * because otherwise the memory of `s1_worker' is leaked + * (`s2_worker' overrides `s1_worker'). */ + if (s1_out != s2_out) + ts_bspline_move(&s2_worker, s2_out); + TS_FINALLY + ts_bspline_free(&s1_worker); + ts_bspline_free(&s2_worker); + ts_deboornet_free(&net); + TS_END_TRY_RETURN(err) } tsError @@ -2524,93 +2349,86 @@ ts_bspline_morph(const tsBSpline *origin, tsReal t, tsReal epsilon, tsBSpline *out, - tsStatus *status) -{ - tsBSpline origin_al, target_al; /* aligned origin and target */ - tsReal *origin_al_c, *origin_al_k; /* control points and knots */ - tsReal *target_al_c, *target_al_k; /* control points and knots */ + tsStatus *status) { + tsBSpline origin_al, target_al; /* aligned origin and target */ + tsReal *origin_al_c, *origin_al_k; /* control points and knots */ + tsReal *target_al_c, *target_al_k; /* control points and knots */ - /* Properties of `out'. */ - size_t deg, dim, num_ctrlp, num_knots; - tsReal *ctrlp, *knots; - tsBSpline tmp; /* temporary buffer if `out' must be resized */ + /* Properties of `out'. */ + size_t deg, dim, num_ctrlp, num_knots; + tsReal *ctrlp, *knots; + tsBSpline tmp; /* temporary buffer if `out' must be resized */ - tsReal t_hat; - size_t i, offset, d; - tsError err; + tsReal t_hat; + size_t i, offset, d; + tsError err; - origin_al = ts_bspline_init(); - target_al = ts_bspline_init(); - TS_TRY(try, err, status) - /* Clamp `t' to domain [0, 1] and set up `t_hat'. */ - if (t < (tsReal) 0.0) t = (tsReal) 0.0; - if (t > (tsReal) 1.0) t = (tsReal) 1.0; - t_hat = (tsReal) 1.0 - t; + origin_al = ts_bspline_init(); + target_al = ts_bspline_init(); + TS_TRY(try, err, status) + /* Clamp `t' to domain [0, 1] and set up `t_hat'. */ + if (t < (tsReal)0.0) t = (tsReal)0.0; + if (t > (tsReal)1.0) t = (tsReal)1.0; + t_hat = (tsReal)1.0 - t; - /* Set up `origin_al' and `target_al'. */ - /* Degree must be elevated... */ - if (ts_bspline_degree(origin) != ts_bspline_degree(target) || - /* .. or knots (and thus control points) must be inserted. */ - ts_bspline_num_knots(origin) != ts_bspline_num_knots(target)) { - TS_CALL(try, err, ts_bspline_align( - origin, target, epsilon, &origin_al, &target_al, - status)); - } else { - /* Flat copy. */ - origin_al = *origin; - target_al = *target; - } - origin_al_c = ts_int_bspline_access_ctrlp(&origin_al); - origin_al_k = ts_int_bspline_access_knots(&origin_al); - target_al_c = ts_int_bspline_access_ctrlp(&target_al); - target_al_k = ts_int_bspline_access_knots(&target_al); + /* Set up `origin_al' and `target_al'. */ + /* Degree must be elevated... */ + if (ts_bspline_degree(origin) != ts_bspline_degree(target) || + /* .. or knots (and thus control points) must be inserted. */ + ts_bspline_num_knots(origin) != ts_bspline_num_knots(target)) { + TS_CALL(try, err, ts_bspline_align(origin, target, epsilon, &origin_al, &target_al, status)); + } else { + /* Flat copy. */ + origin_al = *origin; + target_al = *target; + } + origin_al_c = ts_int_bspline_access_ctrlp(&origin_al); + origin_al_k = ts_int_bspline_access_knots(&origin_al); + target_al_c = ts_int_bspline_access_ctrlp(&target_al); + target_al_k = ts_int_bspline_access_knots(&target_al); - /* Set up `out'. */ - deg = ts_bspline_degree(&origin_al); - num_ctrlp = ts_bspline_num_control_points(&origin_al); - dim = ts_bspline_dimension(&origin_al); - if (ts_bspline_dimension(&target_al) < dim) - dim = ts_bspline_dimension(&target_al); - if (out->pImpl == NULL) { - TS_CALL(try, err, ts_bspline_new(num_ctrlp, dim, deg, - TS_OPENED /* doesn't matter */, out, status)) - } else if (ts_bspline_degree(out) != deg || - ts_bspline_num_control_points(out) != num_ctrlp || - ts_bspline_dimension(out) != dim) { - TS_CALL(try, err, ts_bspline_new(num_ctrlp, dim, deg, - TS_OPENED /* doesn't matter */, &tmp, status)) - ts_bspline_free(out); - ts_bspline_move(&tmp, out); - } - num_knots = ts_bspline_num_knots(out); - ctrlp = ts_int_bspline_access_ctrlp(out); - knots = ts_int_bspline_access_knots(out); + /* Set up `out'. */ + deg = ts_bspline_degree(&origin_al); + num_ctrlp = ts_bspline_num_control_points(&origin_al); + dim = ts_bspline_dimension(&origin_al); + if (ts_bspline_dimension(&target_al) < dim) + dim = ts_bspline_dimension(&target_al); + if (out->pImpl == NULL) { + TS_CALL(try, err, ts_bspline_new(num_ctrlp, dim, deg, TS_OPENED /* doesn't matter */, out, status)) + } else if (ts_bspline_degree(out) != deg || + ts_bspline_num_control_points(out) != num_ctrlp || + ts_bspline_dimension(out) != dim) { + TS_CALL(try, err, ts_bspline_new(num_ctrlp, dim, deg, TS_OPENED /* doesn't matter */, &tmp, status)) + ts_bspline_free(out); + ts_bspline_move(&tmp, out); + } + num_knots = ts_bspline_num_knots(out); + ctrlp = ts_int_bspline_access_ctrlp(out); + knots = ts_int_bspline_access_knots(out); - /* Interpolate control points. */ - for (i = 0; i < num_ctrlp; i++) { - for (d = 0; d < dim; d++) { - offset = i * dim + d; - ctrlp[offset] = t * target_al_c[offset] + - t_hat * origin_al_c[offset]; - } - } + /* Interpolate control points. */ + for (i = 0; i < num_ctrlp; i++) { + for (d = 0; d < dim; d++) { + offset = i * dim + d; + ctrlp[offset] = t * target_al_c[offset] + + t_hat * origin_al_c[offset]; + } + } - /* Interpolate knots. */ - for (i = 0; i < num_knots; i++) { - knots[i] = t * target_al_k[i] + - t_hat * origin_al_k[i]; - } - TS_FINALLY - if (origin->pImpl != origin_al.pImpl) - ts_bspline_free(&origin_al); - if (target->pImpl != target_al.pImpl) - ts_bspline_free(&target_al); - TS_END_TRY_RETURN(err) + /* Interpolate knots. */ + for (i = 0; i < num_knots; i++) { + knots[i] = t * target_al_k[i] + + t_hat * origin_al_k[i]; + } + TS_FINALLY + if (origin->pImpl != origin_al.pImpl) + ts_bspline_free(&origin_al); + if (target->pImpl != target_al.pImpl) + ts_bspline_free(&target_al); + TS_END_TRY_RETURN(err) } /*! @} */ - - /*! @name Serialization and Persistence * * @{ @@ -2618,538 +2436,494 @@ ts_bspline_morph(const tsBSpline *origin, tsError ts_int_bspline_to_json(const tsBSpline *spline, JSON_Value **value, - tsStatus *status) -{ - const size_t deg = ts_bspline_degree(spline); - const size_t dim = ts_bspline_dimension(spline); - const size_t len_ctrlp = ts_bspline_len_control_points(spline); - const size_t len_knots = ts_bspline_num_knots(spline); - const tsReal *ctrlp = ts_int_bspline_access_ctrlp(spline); - const tsReal *knots = ts_int_bspline_access_knots(spline); + tsStatus *status) { + const size_t deg = ts_bspline_degree(spline); + const size_t dim = ts_bspline_dimension(spline); + const size_t len_ctrlp = ts_bspline_len_control_points(spline); + const size_t len_knots = ts_bspline_num_knots(spline); + const tsReal *ctrlp = ts_int_bspline_access_ctrlp(spline); + const tsReal *knots = ts_int_bspline_access_knots(spline); - size_t i; /**< Used in loops */ - tsError err; + size_t i; /**< Used in loops */ + tsError err; - JSON_Value *ctrlp_value; - JSON_Value *knots_value; - JSON_Object *spline_object; - JSON_Array *ctrlp_array; - JSON_Array *knots_array; + JSON_Value *ctrlp_value; + JSON_Value *knots_value; + JSON_Object *spline_object; + JSON_Array *ctrlp_array; + JSON_Array *knots_array; - *value = ctrlp_value = knots_value = NULL; - TS_TRY(values, err, status) - /* Init memory. */ - *value = json_value_init_object(); - if (!*value) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - ctrlp_value = json_value_init_array(); - if (!ctrlp_value) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - knots_value = json_value_init_array(); - if (!knots_value) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } + *value = ctrlp_value = knots_value = NULL; + TS_TRY(values, err, status) + /* Init memory. */ + *value = json_value_init_object(); + if (!*value) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + ctrlp_value = json_value_init_array(); + if (!ctrlp_value) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + knots_value = json_value_init_array(); + if (!knots_value) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } - /* Although the following functions cannot fail, that is, they - * won't return NULL or JSONFailure, we nevertheless handle - * unexpected return values. */ + /* Although the following functions cannot fail, that is, they + * won't return NULL or JSONFailure, we nevertheless handle + * unexpected return values. */ - /* Init output. */ - spline_object = json_value_get_object(*value); - if (!spline_object) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } + /* Init output. */ + spline_object = json_value_get_object(*value); + if (!spline_object) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } - /* Set degree and dimension. */ - if (JSONSuccess != json_object_set_number(spline_object, - "degree", - (double) deg)) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - if (JSONSuccess != json_object_set_number(spline_object, - "dimension", - (double) dim)) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } + /* Set degree and dimension. */ + if (JSONSuccess != json_object_set_number(spline_object, + "degree", + (double)deg)) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + if (JSONSuccess != json_object_set_number(spline_object, + "dimension", + (double)dim)) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } - /* Set control points. */ - if (JSONSuccess != json_object_set_value(spline_object, - "control_points", - ctrlp_value)) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - ctrlp_array = json_array(ctrlp_value); - if (!ctrlp_array) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - for (i = 0; i < len_ctrlp; i++) { - if (JSONSuccess != json_array_append_number( - ctrlp_array, (double) ctrlp[i])) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - } + /* Set control points. */ + if (JSONSuccess != json_object_set_value(spline_object, + "control_points", + ctrlp_value)) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + ctrlp_array = json_array(ctrlp_value); + if (!ctrlp_array) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + for (i = 0; i < len_ctrlp; i++) { + if (JSONSuccess != json_array_append_number( + ctrlp_array, (double)ctrlp[i])) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + } - /* Set knots. */ - if (JSONSuccess != json_object_set_value(spline_object, - "knots", - knots_value)) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - knots_array = json_array(knots_value); - if (!knots_array) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - for (i = 0; i < len_knots; i++) { - if (JSONSuccess != json_array_append_number( - knots_array, (double) knots[i])) { - TS_THROW_0(values, err, status, TS_MALLOC, - "out of memory") - } - } - TS_CATCH(err) - if (*value) - json_value_free(*value); - if (ctrlp_value && !json_value_get_parent(ctrlp_value)) - json_value_free(ctrlp_value); - if (knots_value && !json_value_get_parent(knots_value)) - json_value_free(knots_value); - *value = NULL; - TS_END_TRY_RETURN(err) + /* Set knots. */ + if (JSONSuccess != json_object_set_value(spline_object, + "knots", + knots_value)) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + knots_array = json_array(knots_value); + if (!knots_array) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + for (i = 0; i < len_knots; i++) { + if (JSONSuccess != json_array_append_number( + knots_array, (double)knots[i])) { + TS_THROW_0(values, err, status, TS_MALLOC, + "out of memory") + } + } + TS_CATCH(err) + if (*value) + json_value_free(*value); + if (ctrlp_value && !json_value_get_parent(ctrlp_value)) + json_value_free(ctrlp_value); + if (knots_value && !json_value_get_parent(knots_value)) + json_value_free(knots_value); + *value = NULL; + TS_END_TRY_RETURN(err) } tsError ts_int_bspline_parse_json(const JSON_Value *spline_value, tsBSpline *spline, - tsStatus *status) -{ - size_t deg, dim, len_ctrlp, num_knots; - tsReal *ctrlp, *knots; + tsStatus *status) { + size_t deg, dim, len_ctrlp, num_knots; + tsReal *ctrlp, *knots; - JSON_Object *spline_object; - JSON_Value *deg_value; - JSON_Value *dim_value; - JSON_Value *ctrlp_value; - JSON_Array *ctrlp_array; - JSON_Value *knots_value; - JSON_Array *knots_array; - JSON_Value *real_value; - size_t i; - tsError err; + JSON_Object *spline_object; + JSON_Value *deg_value; + JSON_Value *dim_value; + JSON_Value *ctrlp_value; + JSON_Array *ctrlp_array; + JSON_Value *knots_value; + JSON_Array *knots_array; + JSON_Value *real_value; + size_t i; + tsError err; - ts_int_bspline_init(spline); + ts_int_bspline_init(spline); - /* Read spline object. */ - if (json_value_get_type(spline_value) != JSONObject) - TS_RETURN_0(status, TS_PARSE_ERROR, "invalid json input") - spline_object = json_value_get_object(spline_value); - if (!spline_object) - TS_RETURN_0(status, TS_PARSE_ERROR, "invalid json input") + /* Read spline object. */ + if (json_value_get_type(spline_value) != JSONObject) + TS_RETURN_0(status, TS_PARSE_ERROR, "invalid json input") + spline_object = json_value_get_object(spline_value); + if (!spline_object) + TS_RETURN_0(status, TS_PARSE_ERROR, "invalid json input") - /* Read degree. */ - deg_value = json_object_get_value(spline_object, "degree"); - if (json_value_get_type(deg_value) != JSONNumber) - TS_RETURN_0(status, TS_PARSE_ERROR, "degree is not a number") - if (json_value_get_number(deg_value) < -0.01f) { - TS_RETURN_1(status, TS_PARSE_ERROR, - "degree (%f) < 0", - json_value_get_number(deg_value)) - } - deg = (size_t) json_value_get_number(deg_value); + /* Read degree. */ + deg_value = json_object_get_value(spline_object, "degree"); + if (json_value_get_type(deg_value) != JSONNumber) + TS_RETURN_0(status, TS_PARSE_ERROR, "degree is not a number") + if (json_value_get_number(deg_value) < -0.01f) { + TS_RETURN_1(status, TS_PARSE_ERROR, + "degree (%f) < 0", + json_value_get_number(deg_value)) + } + deg = (size_t)json_value_get_number(deg_value); - /* Read dimension. */ - dim_value = json_object_get_value(spline_object, "dimension"); - if (json_value_get_type(dim_value) != JSONNumber) { - TS_RETURN_0(status, TS_PARSE_ERROR, - "dimension is not a number") - } - if (json_value_get_number(dim_value) < 0.99f) { - TS_RETURN_1(status, TS_PARSE_ERROR, - "dimension (%f) < 1", - json_value_get_number(deg_value)) - } - dim = (size_t) json_value_get_number(dim_value); + /* Read dimension. */ + dim_value = json_object_get_value(spline_object, "dimension"); + if (json_value_get_type(dim_value) != JSONNumber) { + TS_RETURN_0(status, TS_PARSE_ERROR, + "dimension is not a number") + } + if (json_value_get_number(dim_value) < 0.99f) { + TS_RETURN_1(status, TS_PARSE_ERROR, + "dimension (%f) < 1", + json_value_get_number(deg_value)) + } + dim = (size_t)json_value_get_number(dim_value); - /* Read length of control point vector. */ - ctrlp_value = json_object_get_value(spline_object, "control_points"); - if (json_value_get_type(ctrlp_value) != JSONArray) { - TS_RETURN_0(status, TS_PARSE_ERROR, - "control_points is not an array") - } - ctrlp_array = json_value_get_array(ctrlp_value); - len_ctrlp = json_array_get_count(ctrlp_array); - if (len_ctrlp % dim != 0) { - TS_RETURN_2(status, TS_PARSE_ERROR, - "len(control_points) (%lu) %% dimension (%lu) != 0", - (unsigned long) len_ctrlp, (unsigned long) dim) - } + /* Read length of control point vector. */ + ctrlp_value = json_object_get_value(spline_object, "control_points"); + if (json_value_get_type(ctrlp_value) != JSONArray) { + TS_RETURN_0(status, TS_PARSE_ERROR, + "control_points is not an array") + } + ctrlp_array = json_value_get_array(ctrlp_value); + len_ctrlp = json_array_get_count(ctrlp_array); + if (len_ctrlp % dim != 0) { + TS_RETURN_2(status, TS_PARSE_ERROR, + "len(control_points) (%lu) %% dimension (%lu) != 0", + (unsigned long)len_ctrlp, (unsigned long)dim) + } - /* Read number of knots. */ - knots_value = json_object_get_value(spline_object, "knots"); - if (json_value_get_type(knots_value) != JSONArray) { - TS_RETURN_0(status, TS_PARSE_ERROR, - "knots is not an array") - } - knots_array = json_value_get_array(knots_value); - num_knots = json_array_get_count(knots_array); + /* Read number of knots. */ + knots_value = json_object_get_value(spline_object, "knots"); + if (json_value_get_type(knots_value) != JSONArray) { + TS_RETURN_0(status, TS_PARSE_ERROR, + "knots is not an array") + } + knots_array = json_value_get_array(knots_value); + num_knots = json_array_get_count(knots_array); - /* Create spline. */ - TS_TRY(try, err, status) - TS_CALL(try, err, ts_bspline_new( - len_ctrlp/dim, dim, deg, - TS_CLAMPED, spline, status)) - if (num_knots != ts_bspline_num_knots(spline)) - TS_THROW_2(try, err, status, TS_NUM_KNOTS, - "unexpected num(knots): (%lu) != (%lu)", - (unsigned long) num_knots, - (unsigned long) ts_bspline_num_knots(spline)) + /* Create spline. */ + TS_TRY(try, err, status) + TS_CALL(try, err, ts_bspline_new(len_ctrlp / dim, dim, deg, TS_CLAMPED, spline, status)) + if (num_knots != ts_bspline_num_knots(spline)) + TS_THROW_2(try, err, status, TS_NUM_KNOTS, + "unexpected num(knots): (%lu) != (%lu)", + (unsigned long)num_knots, + (unsigned long)ts_bspline_num_knots(spline)) - /* Set control points. */ - ctrlp = ts_int_bspline_access_ctrlp(spline); - for (i = 0; i < len_ctrlp; i++) { - real_value = json_array_get_value(ctrlp_array, i); - if (json_value_get_type(real_value) != JSONNumber) - TS_THROW_1(try, err, status, TS_PARSE_ERROR, - "control_points: value at index %lu is not a number", - (unsigned long) i) - ctrlp[i] = (tsReal) json_value_get_number(real_value); - } - TS_CALL(try, err, ts_bspline_set_control_points( - spline, ctrlp, status)) + /* Set control points. */ + ctrlp = ts_int_bspline_access_ctrlp(spline); + for (i = 0; i < len_ctrlp; i++) { + real_value = json_array_get_value(ctrlp_array, i); + if (json_value_get_type(real_value) != JSONNumber) + TS_THROW_1(try, err, status, TS_PARSE_ERROR, + "control_points: value at index %lu is not a number", + (unsigned long)i) + ctrlp[i] = (tsReal)json_value_get_number(real_value); + } + TS_CALL(try, err, ts_bspline_set_control_points(spline, ctrlp, status)) - /* Set knots. */ - knots = ts_int_bspline_access_knots(spline); - for (i = 0; i < num_knots; i++) { - real_value = json_array_get_value(knots_array, i); - if (json_value_get_type(real_value) != JSONNumber) - TS_THROW_1(try, err, status, TS_PARSE_ERROR, - "knots: value at index %lu is not a number", - (unsigned long) i) - knots[i] = (tsReal) json_value_get_number(real_value); - } - TS_CALL(try, err, ts_bspline_set_knots( - spline, knots, status)) - TS_CATCH(err) - ts_bspline_free(spline); - TS_END_TRY_RETURN(err) + /* Set knots. */ + knots = ts_int_bspline_access_knots(spline); + for (i = 0; i < num_knots; i++) { + real_value = json_array_get_value(knots_array, i); + if (json_value_get_type(real_value) != JSONNumber) + TS_THROW_1(try, err, status, TS_PARSE_ERROR, + "knots: value at index %lu is not a number", + (unsigned long)i) + knots[i] = (tsReal)json_value_get_number(real_value); + } + TS_CALL(try, err, ts_bspline_set_knots(spline, knots, status)) + TS_CATCH(err) + ts_bspline_free(spline); + TS_END_TRY_RETURN(err) } tsError ts_bspline_to_json(const tsBSpline *spline, char **json, - tsStatus *status) -{ - tsError err; - JSON_Value *value = NULL; - *json = NULL; - TS_CALL_ROE(err, ts_int_bspline_to_json(spline, &value, status)) - *json = json_serialize_to_string_pretty(value); - json_value_free(value); - if (!*json) - TS_RETURN_0(status, TS_MALLOC, "out of memory") - TS_RETURN_SUCCESS(status) + tsStatus *status) { + tsError err; + JSON_Value *value = NULL; + *json = NULL; + TS_CALL_ROE(err, ts_int_bspline_to_json(spline, &value, status)) + *json = json_serialize_to_string_pretty(value); + json_value_free(value); + if (!*json) + TS_RETURN_0(status, TS_MALLOC, "out of memory") + TS_RETURN_SUCCESS(status) } tsError ts_bspline_parse_json(const char *json, tsBSpline *spline, - tsStatus *status) -{ - tsError err; - JSON_Value *value = NULL; - ts_int_bspline_init(spline); - TS_TRY(try, err, status) - value = json_parse_string(json); - if (!value) { - TS_RETURN_0(status, TS_PARSE_ERROR, - "invalid json input") - } - TS_CALL(try, err, ts_int_bspline_parse_json( - value, spline, status)) - TS_FINALLY - if (value) - json_value_free(value); - TS_END_TRY_RETURN(err) + tsStatus *status) { + tsError err; + JSON_Value *value = NULL; + ts_int_bspline_init(spline); + TS_TRY(try, err, status) + value = json_parse_string(json); + if (!value) { + TS_RETURN_0(status, TS_PARSE_ERROR, + "invalid json input") + } + TS_CALL(try, err, ts_int_bspline_parse_json(value, spline, status)) + TS_FINALLY + if (value) + json_value_free(value); + TS_END_TRY_RETURN(err) } tsError ts_bspline_save(const tsBSpline *spline, const char *path, - tsStatus *status) -{ - tsError err; - JSON_Status json_status; - JSON_Value *value = NULL; - TS_CALL_ROE(err, ts_int_bspline_to_json(spline, &value, status)) - json_status = json_serialize_to_file_pretty(value, path); - json_value_free(value); - if (json_status != JSONSuccess) - TS_RETURN_0(status, TS_IO_ERROR, "unexpected io error") - TS_RETURN_SUCCESS(status) + tsStatus *status) { + tsError err; + JSON_Status json_status; + JSON_Value *value = NULL; + TS_CALL_ROE(err, ts_int_bspline_to_json(spline, &value, status)) + json_status = json_serialize_to_file_pretty(value, path); + json_value_free(value); + if (json_status != JSONSuccess) + TS_RETURN_0(status, TS_IO_ERROR, "unexpected io error") + TS_RETURN_SUCCESS(status) } tsError ts_bspline_load(const char *path, tsBSpline *spline, - tsStatus *status) -{ - tsError err; - FILE *file = NULL; - JSON_Value *value = NULL; - ts_int_bspline_init(spline); - TS_TRY(try, err, status) - file = fopen(path, "r"); - if (!file) { - TS_THROW_0(try, err, status, TS_IO_ERROR, - "unable to open file") - } - value = json_parse_file(path); - if (!value) { - TS_RETURN_0(status, TS_PARSE_ERROR, - "invalid json input") - } - TS_CALL(try, err, ts_int_bspline_parse_json( - value, spline, status)) - TS_FINALLY - if (file) - fclose(file); - if (value) - json_value_free(value); - TS_CATCH(err) - ts_bspline_free(spline); - TS_END_TRY_RETURN(err) + tsStatus *status) { + tsError err; + FILE *file = NULL; + JSON_Value *value = NULL; + ts_int_bspline_init(spline); + TS_TRY(try, err, status) + file = fopen(path, "r"); + if (!file) { + TS_THROW_0(try, err, status, TS_IO_ERROR, + "unable to open file") + } + value = json_parse_file(path); + if (!value) { + TS_RETURN_0(status, TS_PARSE_ERROR, + "invalid json input") + } + TS_CALL(try, err, ts_int_bspline_parse_json(value, spline, status)) + TS_FINALLY + if (file) + fclose(file); + if (value) + json_value_free(value); + TS_CATCH(err) + ts_bspline_free(spline); + TS_END_TRY_RETURN(err) } /*! @} */ - - /*! @name Vector Math * @{ */ -void -ts_vec2_init(tsReal *out, - tsReal x, - tsReal y) -{ - out[0] = x; - out[1] = y; +void ts_vec2_init(tsReal *out, + tsReal x, + tsReal y) { + out[0] = x; + out[1] = y; } -void -ts_vec3_init(tsReal *out, - tsReal x, - tsReal y, - tsReal z) -{ - out[0] = x; - out[1] = y; - out[2] = z; +void ts_vec3_init(tsReal *out, + tsReal x, + tsReal y, + tsReal z) { + out[0] = x; + out[1] = y; + out[2] = z; } -void -ts_vec4_init(tsReal *out, - tsReal x, - tsReal y, - tsReal z, - tsReal w) -{ - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; +void ts_vec4_init(tsReal *out, + tsReal x, + tsReal y, + tsReal z, + tsReal w) { + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; } -void -ts_vec2_set(tsReal *out, - const tsReal *x, - size_t dim) -{ - const size_t n = dim > 2 ? 2 : dim; - memmove(out, x, n * sizeof(tsReal)); - if (dim < 2) - ts_arr_fill(out + dim, 2 - dim, (tsReal) 0.0); +void ts_vec2_set(tsReal *out, + const tsReal *x, + size_t dim) { + const size_t n = dim > 2 ? 2 : dim; + memmove(out, x, n * sizeof(tsReal)); + if (dim < 2) + ts_arr_fill(out + dim, 2 - dim, (tsReal)0.0); } -void -ts_vec3_set(tsReal *out, - const tsReal *x, - size_t dim) -{ - const size_t n = dim > 3 ? 3 : dim; - memmove(out, x, n * sizeof(tsReal)); - if (dim < 3) - ts_arr_fill(out + dim, 3 - dim, (tsReal) 0.0); +void ts_vec3_set(tsReal *out, + const tsReal *x, + size_t dim) { + const size_t n = dim > 3 ? 3 : dim; + memmove(out, x, n * sizeof(tsReal)); + if (dim < 3) + ts_arr_fill(out + dim, 3 - dim, (tsReal)0.0); } -void -ts_vec4_set(tsReal *out, - const tsReal *x, - size_t dim) -{ - const size_t n = dim > 4 ? 4 : dim; - memmove(out, x, n * sizeof(tsReal)); - if (dim < 4) - ts_arr_fill(out + dim, 4 - dim, (tsReal) 0.0); +void ts_vec4_set(tsReal *out, + const tsReal *x, + size_t dim) { + const size_t n = dim > 4 ? 4 : dim; + memmove(out, x, n * sizeof(tsReal)); + if (dim < 4) + ts_arr_fill(out + dim, 4 - dim, (tsReal)0.0); } -void -ts_vec_add(const tsReal *x, - const tsReal *y, - size_t dim, - tsReal *out) -{ - size_t i; - for (i = 0; i < dim; i++) - out[i] = x[i] + y[i]; +void ts_vec_add(const tsReal *x, + const tsReal *y, + size_t dim, + tsReal *out) { + size_t i; + for (i = 0; i < dim; i++) + out[i] = x[i] + y[i]; } -void -ts_vec_sub(const tsReal *x, - const tsReal *y, - size_t dim, - tsReal *out) -{ - size_t i; - if (x == y) { - /* More stable version. */ - ts_arr_fill(out, dim, (tsReal) 0.0); - return; - } - for (i = 0; i < dim; i++) - out[i] = x[i] - y[i]; +void ts_vec_sub(const tsReal *x, + const tsReal *y, + size_t dim, + tsReal *out) { + size_t i; + if (x == y) { + /* More stable version. */ + ts_arr_fill(out, dim, (tsReal)0.0); + return; + } + for (i = 0; i < dim; i++) + out[i] = x[i] - y[i]; } tsReal ts_vec_dot(const tsReal *x, const tsReal *y, - size_t dim) -{ - size_t i; - tsReal dot = 0; - for (i = 0; i < dim; i++) - dot += x[i] * y[i]; - return dot; + size_t dim) { + size_t i; + tsReal dot = 0; + for (i = 0; i < dim; i++) + dot += x[i] * y[i]; + return dot; } tsReal ts_vec_angle(const tsReal *x, const tsReal *y, tsReal *buf, - size_t dim) -{ - const tsReal *x_norm, *y_norm; - if (buf) { - ts_vec_norm(x, dim, buf); - ts_vec_norm(y, dim, buf + dim); - x_norm = buf; - y_norm = buf + dim; - } else { - x_norm = x; - y_norm = y; - } - return (tsReal) ( - /* Use doubles as long as possible. */ - acos(ts_vec_dot(x_norm, - y_norm, - dim)) - * (180.0 / TS_PI) /* radiant to degree */ - ); + size_t dim) { + const tsReal *x_norm, *y_norm; + if (buf) { + ts_vec_norm(x, dim, buf); + ts_vec_norm(y, dim, buf + dim); + x_norm = buf; + y_norm = buf + dim; + } else { + x_norm = x; + y_norm = y; + } + return (tsReal)( + /* Use doubles as long as possible. */ + acos(ts_vec_dot(x_norm, + y_norm, + dim)) * + (180.0 / TS_PI) /* radiant to degree */ + ); } -void -ts_vec3_cross(const tsReal *x, - const tsReal *y, - tsReal *out) -{ - tsReal a, b, c; - a = x[1] * y[2] - x[2] * y[1]; - b = x[2] * y[0] - x[0] * y[2]; - c = x[0] * y[1] - x[1] * y[0]; - out[0] = a; - out[1] = b; - out[2] = c; +void ts_vec3_cross(const tsReal *x, + const tsReal *y, + tsReal *out) { + tsReal a, b, c; + a = x[1] * y[2] - x[2] * y[1]; + b = x[2] * y[0] - x[0] * y[2]; + c = x[0] * y[1] - x[1] * y[0]; + out[0] = a; + out[1] = b; + out[2] = c; } -void -ts_vec_norm(const tsReal *x, - size_t dim, - tsReal *out) -{ - size_t i; - const tsReal m = ts_vec_mag(x, dim); - if (m < TS_LENGTH_ZERO) { - ts_arr_fill(out, dim, (tsReal) 0.0); - return; - } - for (i = 0; i < dim; i++) - out[i] = x[i] / m; +void ts_vec_norm(const tsReal *x, + size_t dim, + tsReal *out) { + size_t i; + const tsReal m = ts_vec_mag(x, dim); + if (m < TS_LENGTH_ZERO) { + ts_arr_fill(out, dim, (tsReal)0.0); + return; + } + for (i = 0; i < dim; i++) + out[i] = x[i] / m; } tsReal ts_vec_mag(const tsReal *x, - size_t dim) -{ - size_t i; - tsReal sum = 0; - for (i = 0; i < dim; i++) - sum += (x[i] * x[i]); - return (tsReal) sqrt(sum); + size_t dim) { + size_t i; + tsReal sum = 0; + for (i = 0; i < dim; i++) + sum += (x[i] * x[i]); + return (tsReal)sqrt(sum); } -void -ts_vec_mul(const tsReal *x, - size_t dim, - tsReal val, - tsReal *out) -{ - size_t i; - for (i = 0; i < dim; i++) - out[i] = x[i] * val; +void ts_vec_mul(const tsReal *x, + size_t dim, + tsReal val, + tsReal *out) { + size_t i; + for (i = 0; i < dim; i++) + out[i] = x[i] * val; } /*! @} */ - - /*! @name Utility Functions * * @{ */ int ts_knots_equal(tsReal x, - tsReal y) -{ - return fabs(x-y) < TS_KNOT_EPSILON ? 1 : 0; + tsReal y) { + return fabs(x - y) < TS_KNOT_EPSILON ? 1 : 0; } void ts_arr_fill(tsReal *arr, size_t num, - tsReal val) -{ - size_t i; - for (i = 0; i < num; i++) - arr[i] = val; + tsReal val) { + size_t i; + for (i = 0; i < num; i++) + arr[i] = val; } tsReal ts_distance(const tsReal *x, const tsReal *y, - size_t dim) -{ - size_t i; - tsReal sum = 0; - for (i = 0; i < dim; i++) - sum += (x[i] - y[i]) * (x[i] - y[i]); - return (tsReal) sqrt(sum); + size_t dim) { + size_t i; + tsReal sum = 0; + for (i = 0; i < dim; i++) + sum += (x[i] - y[i]) * (x[i] - y[i]); + return (tsReal)sqrt(sum); } /*! @} */ diff --git a/source/engine/transform.c b/source/engine/transform.c index 722a124..cd1d7d3 100644 --- a/source/engine/transform.c +++ b/source/engine/transform.c @@ -1,52 +1,44 @@ #include "transform.h" #include -struct mTransform MakeTransform(mfloat_t pos[3], mfloat_t rotation[4], float scale) -{ - struct mTransform newT; - memcpy(newT.position, pos, sizeof(*pos)); - memcpy(newT.rotation, rotation, sizeof(*rotation)); - newT.scale = scale; - return newT; +struct mTransform MakeTransform(mfloat_t pos[3], mfloat_t rotation[4], float scale) { + struct mTransform newT; + memcpy(newT.position, pos, sizeof(*pos)); + memcpy(newT.rotation, rotation, sizeof(*rotation)); + newT.scale = scale; + return newT; } -mfloat_t *trans_forward(mfloat_t * res, - const struct mTransform *const trans) -{ - // YughLog(0, SDL_LOG_PRIORITY_WARN, "Rotation is %f", trans->rotation[0]); - return vec3_rotate_quat(res, FORWARD, trans->rotation); +mfloat_t *trans_forward(mfloat_t *res, + const struct mTransform *const trans) { + // YughLog(0, SDL_LOG_PRIORITY_WARN, "Rotation is %f", trans->rotation[0]); + return vec3_rotate_quat(res, FORWARD, trans->rotation); } -mfloat_t *trans_back(mfloat_t * res, const struct mTransform *trans) -{ - return vec3_rotate_quat(res, BACK, trans->rotation); +mfloat_t *trans_back(mfloat_t *res, const struct mTransform *trans) { + return vec3_rotate_quat(res, BACK, trans->rotation); } -mfloat_t *trans_up(mfloat_t * res, const struct mTransform *trans) -{ - return vec3_rotate_quat(res, UP, trans->rotation); +mfloat_t *trans_up(mfloat_t *res, const struct mTransform *trans) { + return vec3_rotate_quat(res, UP, trans->rotation); } -mfloat_t *trans_down(mfloat_t * res, const struct mTransform *trans) -{ - return vec3_rotate_quat(res, DOWN, trans->rotation); +mfloat_t *trans_down(mfloat_t *res, const struct mTransform *trans) { + return vec3_rotate_quat(res, DOWN, trans->rotation); } -mfloat_t *trans_right(mfloat_t * res, const struct mTransform *trans) -{ - return vec3_rotate_quat(res, RIGHT, trans->rotation); +mfloat_t *trans_right(mfloat_t *res, const struct mTransform *trans) { + return vec3_rotate_quat(res, RIGHT, trans->rotation); } -mfloat_t *trans_left(mfloat_t * res, const struct mTransform *trans) -{ - return vec3_rotate_quat(res, LEFT, trans->rotation); +mfloat_t *trans_left(mfloat_t *res, const struct mTransform *trans) { + return vec3_rotate_quat(res, LEFT, trans->rotation); } #include "nuke.h" -void trans_drawgui(struct mTransform *T) -{ - nuke_property_float3("Position", -1000.f, T->position, 1000.f, 1.f, 1.f); - nuke_property_float3("Rotation", 0.f, T->rotation, 360.f, 1.f, 0.1f); - nuke_property_float("Scale", 0.f, &T->scale, 1000.f, 0.1f, 0.1f); +void trans_drawgui(struct mTransform *T) { + nuke_property_float3("Position", -1000.f, T->position, 1000.f, 1.f, 1.f); + nuke_property_float3("Rotation", 0.f, T->rotation, 360.f, 1.f, 0.1f); + nuke_property_float("Scale", 0.f, &T->scale, 1000.f, 0.1f, 0.1f); } diff --git a/source/engine/window.c b/source/engine/window.c index 07f2c36..873fad1 100644 --- a/source/engine/window.c +++ b/source/engine/window.c @@ -1,12 +1,12 @@ #include "window.h" -#include -#include "texture.h" -#include "log.h" -#include -#include #include "input.h" -#include "script.h" +#include "log.h" #include "nuke.h" +#include "script.h" +#include "texture.h" +#include +#include +#include #include "openglrender.h" @@ -18,277 +18,248 @@ static struct window *windows = NULL; struct Texture *icon = NULL; -int is_win(struct window *s, GLFWwindow *w) -{ - return s->window == w; +int is_win(struct window *s, GLFWwindow *w) { + return s->window == w; } -void window_size_callback(GLFWwindow *w, int width, int height) -{ - +void window_size_callback(GLFWwindow *w, int width, int height) { } -struct window *winfind(GLFWwindow *w) -{ - for (int i = 0; i < arrlen(windows); i++) { - if (windows[i].window == w) - return &windows[i]; - } +struct window *winfind(GLFWwindow *w) { + for (int i = 0; i < arrlen(windows); i++) { + if (windows[i].window == w) + return &windows[i]; + } + return NULL; +} + +void window_iconify_callback(GLFWwindow *w, int iconified) { + struct window *win = winfind(w); + win->iconified = iconified; +} + +void window_focus_callback(GLFWwindow *w, int focused) { + struct window *win = winfind(w); + win->mouseFocus = focused; +} + +void window_maximize_callback(GLFWwindow *w, int maximized) { + struct window *win = winfind(w); + win->minimized = !maximized; +} + +void window_framebuffer_size_cb(GLFWwindow *w, int width, int height) { + struct window *win = winfind(w); + win->width = width; + win->height = height; + window_makecurrent(win); + win->render = 1; +} + +void window_close_callback(GLFWwindow *w) { + quit(); +} + +struct window *MakeSDLWindow(const char *name, int width, int height, uint32_t flags) { + if (arrcap(windows) == 0) + arrsetcap(windows, 5); + + GLFWwindow *sharewin = mainwin == NULL ? NULL : mainwin->window; + + if (sharewin) return sharewin; + + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_SAMPLES,1); + + struct window w = { + .width = width, + .height = height, + .id = arrlen(windows), + .window = glfwCreateWindow(width, height, name, NULL, sharewin)}; + + if (!w.window) { + YughError("Couldn't make GLFW window\n", 1); return NULL; + } + + glfwMakeContextCurrent(w.window); + // int version = gladLoadGL(glfwGetProcAddress); + // if (!version) { + // YughError("Failed to initialize OpenGL context."); + // exit(1); + // } + YughInfo("Loaded OpenGL %d.%d", 3, 3); + glfwSwapInterval(1); + + // Set callbacks + glfwSetWindowCloseCallback(w.window, window_close_callback); + glfwSetWindowSizeCallback(w.window, window_size_callback); + glfwSetFramebufferSizeCallback(w.window, window_framebuffer_size_cb); + glfwSetWindowFocusCallback(w.window, window_focus_callback); + glfwSetKeyCallback(w.window, win_key_callback); + + arrput(windows, w); + + if (arrlen(windows) == 1) + mainwin = &windows[0]; + + return &arrlast(windows); } -void window_iconify_callback(GLFWwindow *w, int iconified) -{ - struct window *win = winfind(w); - win->iconified = iconified; -} - -void window_focus_callback(GLFWwindow *w, int focused) -{ - struct window *win = winfind(w); - win->mouseFocus = focused; -} - -void window_maximize_callback(GLFWwindow *w, int maximized) -{ - struct window *win = winfind(w); - win->minimized = !maximized; -} - -void window_framebuffer_size_cb(GLFWwindow *w, int width, int height) -{ - struct window *win = winfind(w); - win->width = width; - win->height = height; - window_makecurrent(win); - win->render = 1; -} - -void window_close_callback(GLFWwindow *w) -{ - quit(); -} - - - -struct window *MakeSDLWindow(const char *name, int width, int height, uint32_t flags) -{ - if (arrcap(windows) == 0) - arrsetcap(windows, 5); - - GLFWwindow *sharewin = mainwin == NULL ? NULL : mainwin->window; - - if (sharewin) return sharewin; - - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,3); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - - struct window w = { - .width = width, - .height = height, - .id = arrlen(windows), - .window = glfwCreateWindow(width, height, name, NULL, sharewin) }; - - - if (!w.window) { - YughError("Couldn't make GLFW window\n", 1); - return NULL; - } - - glfwMakeContextCurrent(w.window); -// int version = gladLoadGL(glfwGetProcAddress); -// if (!version) { -// YughError("Failed to initialize OpenGL context."); -// exit(1); -// } - YughInfo("Loaded OpenGL %d.%d", 3,3); - glfwSwapInterval(1); - - // Set callbacks - glfwSetWindowCloseCallback(w.window, window_close_callback); - glfwSetWindowSizeCallback(w.window, window_size_callback); - glfwSetFramebufferSizeCallback(w.window, window_framebuffer_size_cb); - glfwSetWindowFocusCallback(w.window, window_focus_callback); - glfwSetKeyCallback(w.window, win_key_callback); - -// nuke_init(&w); - - arrput(windows, w); - - if (arrlen(windows) == 1) - mainwin = &windows[0]; - - return &arrlast(windows); -} - -void window_set_icon(const char *png) -{ +void window_set_icon(const char *png) { icon = texture_pullfromfile(png); window_seticon(mainwin, icon); } -void window_destroy(struct window *w) -{ - glfwDestroyWindow(w->window); - arrdelswap(windows, w->id); +void window_destroy(struct window *w) { + glfwDestroyWindow(w->window); + arrdelswap(windows, w->id); } struct window *window_i(int index) { - return &windows[index]; + return &windows[index]; } -void window_handle_event(struct window *w) -{ -/* - if (e->type == SDL_WINDOWEVENT && e->window.windowID == w->id) { // TODO: Check ptr direct? - switch (e->window.event) { - case SDL_WINDOWEVENT_SHOWN: - YughLog(0, SDL_LOG_PRIORITY_INFO, "Showed window %d.", w->id); - w->shown = true; - break; +void window_handle_event(struct window *w) { + /* + if (e->type == SDL_WINDOWEVENT && e->window.windowID == w->id) { // TODO: Check ptr direct? + switch (e->window.event) { + case SDL_WINDOWEVENT_SHOWN: + YughLog(0, SDL_LOG_PRIORITY_INFO, "Showed window %d.", w->id); + w->shown = true; + break; - case SDL_WINDOWEVENT_HIDDEN: - w->shown = false; - YughLog(0, SDL_LOG_PRIORITY_INFO, "Hid window %d.", w->id); - break; + case SDL_WINDOWEVENT_HIDDEN: + w->shown = false; + YughLog(0, SDL_LOG_PRIORITY_INFO, "Hid window %d.", w->id); + break; - case SDL_WINDOWEVENT_SIZE_CHANGED: + case SDL_WINDOWEVENT_SIZE_CHANGED: - w->width = e->window.data1; - w->height = e->window.data2; - YughLog(0, SDL_LOG_PRIORITY_INFO, - "Changed size of window %d: width %d, height %d.", - w->id, w->width, w->height); - window_makecurrent(w); - w->render = true; - break; + w->width = e->window.data1; + w->height = e->window.data2; + YughLog(0, SDL_LOG_PRIORITY_INFO, + "Changed size of window %d: width %d, height %d.", + w->id, w->width, w->height); + window_makecurrent(w); + w->render = true; + break; - case SDL_WINDOWEVENT_EXPOSED: - YughLog(0, SDL_LOG_PRIORITY_INFO, "Exposed window %d.", w->id); - w->render = true; - break; + case SDL_WINDOWEVENT_EXPOSED: + YughLog(0, SDL_LOG_PRIORITY_INFO, "Exposed window %d.", w->id); + w->render = true; + break; - case SDL_WINDOWEVENT_ENTER: - YughLog(0, SDL_LOG_PRIORITY_INFO, "Entered window %d.", w->id); - w->mouseFocus = true; - SDL_RaiseWindow(w->window); - break; + case SDL_WINDOWEVENT_ENTER: + YughLog(0, SDL_LOG_PRIORITY_INFO, "Entered window %d.", w->id); + w->mouseFocus = true; + SDL_RaiseWindow(w->window); + break; - case SDL_WINDOWEVENT_LEAVE: - YughLog(0, SDL_LOG_PRIORITY_INFO, "Left window %d.", w->id); - w->mouseFocus = false; - break; + case SDL_WINDOWEVENT_LEAVE: + YughLog(0, SDL_LOG_PRIORITY_INFO, "Left window %d.", w->id); + w->mouseFocus = false; + break; - case SDL_WINDOWEVENT_FOCUS_LOST: - YughLog(0, SDL_LOG_PRIORITY_INFO, - "Lost focus on window %d.", w->id); - w->keyboardFocus = false; - break; + case SDL_WINDOWEVENT_FOCUS_LOST: + YughLog(0, SDL_LOG_PRIORITY_INFO, + "Lost focus on window %d.", w->id); + w->keyboardFocus = false; + break; - case SDL_WINDOWEVENT_FOCUS_GAINED: - YughLog(0, SDL_LOG_PRIORITY_INFO, - "Gained focus on window %d.", w->id); - w->keyboardFocus = true; - break; + case SDL_WINDOWEVENT_FOCUS_GAINED: + YughLog(0, SDL_LOG_PRIORITY_INFO, + "Gained focus on window %d.", w->id); + w->keyboardFocus = true; + break; - case SDL_WINDOWEVENT_MINIMIZED: - YughLog(0, SDL_LOG_PRIORITY_INFO, - "Minimized window %d.", w->id); - w->minimized = true; - break; + case SDL_WINDOWEVENT_MINIMIZED: + YughLog(0, SDL_LOG_PRIORITY_INFO, + "Minimized window %d.", w->id); + w->minimized = true; + break; - case SDL_WINDOWEVENT_MAXIMIZED: - YughLog(0, SDL_LOG_PRIORITY_INFO, - "Maximized window %d.", w->id); - w->minimized = false; - break; + case SDL_WINDOWEVENT_MAXIMIZED: + YughLog(0, SDL_LOG_PRIORITY_INFO, + "Maximized window %d.", w->id); + w->minimized = false; + break; - case SDL_WINDOWEVENT_RESTORED: - YughLog(0, SDL_LOG_PRIORITY_INFO, - "Restored window %d.", w->id); - w->minimized = false; - break; + case SDL_WINDOWEVENT_RESTORED: + YughLog(0, SDL_LOG_PRIORITY_INFO, + "Restored window %d.", w->id); + w->minimized = false; + break; - case SDL_WINDOWEVENT_CLOSE: - YughLog(0, SDL_LOG_PRIORITY_INFO, "Closed window %d.", w->id); - break; - } - } -*/ + case SDL_WINDOWEVENT_CLOSE: + YughLog(0, SDL_LOG_PRIORITY_INFO, "Closed window %d.", w->id); + break; + } + } + */ } -void window_all_handle_events() -{ - for (int i = 0; i < arrlen(windows); i++) - window_handle_event(&windows[i]); +void window_all_handle_events() { + for (int i = 0; i < arrlen(windows); i++) + window_handle_event(&windows[i]); } -void window_makefullscreen(struct window *w) -{ - if (!w->fullscreen) - window_togglefullscreen(w); +void window_makefullscreen(struct window *w) { + if (!w->fullscreen) + window_togglefullscreen(w); } -void window_unfullscreen(struct window *w) -{ - if (w->fullscreen) - window_togglefullscreen(w); +void window_unfullscreen(struct window *w) { + if (w->fullscreen) + window_togglefullscreen(w); } -void window_togglefullscreen(struct window *w) -{ - w->fullscreen = !w->fullscreen; - - if (w->fullscreen) { - glfwMaximizeWindow(w->window); - } else { - glfwRestoreWindow(w->window); - } +void window_togglefullscreen(struct window *w) { + w->fullscreen = !w->fullscreen; + if (w->fullscreen) { + glfwMaximizeWindow(w->window); + } else { + glfwRestoreWindow(w->window); + } } -void window_makecurrent(struct window *w) -{ - - if (w->window != glfwGetCurrentContext()) - glfwMakeContextCurrent(w->window); - glViewport(0, 0, w->width, w->height); +void window_makecurrent(struct window *w) { + if (w->window != glfwGetCurrentContext()) + glfwMakeContextCurrent(w->window); + glViewport(0, 0, w->width, w->height); } - - -void window_swap(struct window *w) -{ - glfwSwapBuffers(w->window); +void window_swap(struct window *w) { + glfwSwapBuffers(w->window); } -void window_seticon(struct window *w, struct Texture *icon) -{ +void window_seticon(struct window *w, struct Texture *icon) { - static GLFWimage images[1]; - images[0].width = icon->width; - images[0].height = icon->height; - images[0].pixels = icon->data; - glfwSetWindowIcon(w->window, 1, images); + static GLFWimage images[1]; + images[0].width = icon->width; + images[0].height = icon->height; + images[0].pixels = icon->data; + glfwSetWindowIcon(w->window, 1, images); } -int window_hasfocus(struct window *w) -{ - return glfwGetWindowAttrib(w->window, GLFW_FOCUSED); +int window_hasfocus(struct window *w) { + return glfwGetWindowAttrib(w->window, GLFW_FOCUSED); } void window_render(struct window *w) { - window_makecurrent(w); - openglRender(w); - window_swap(w); + window_makecurrent(w); + openglRender(w); + window_swap(w); } void window_renderall() { - //arrwalk(windows, window_render); - for (int i = 0; i < arrlen(windows); i++) - window_render(&windows[i]); + // arrwalk(windows, window_render); + for (int i = 0; i < arrlen(windows); i++) + window_render(&windows[i]); } diff --git a/source/engine/yugine.c b/source/engine/yugine.c index d96f83a..f96f613 100644 --- a/source/engine/yugine.c +++ b/source/engine/yugine.c @@ -1,13 +1,12 @@ #include "yugine.h" - #include "camera.h" -#include "window.h" #include "engine.h" +#include "font.h" +#include "gameobject.h" #include "input.h" #include "openglrender.h" -#include "gameobject.h" -#include "font.h" +#include "window.h" #define MINIAUDIO_IMPLEMENTATION #include "miniaudio.h" @@ -16,8 +15,8 @@ #include "quickjs/quickjs.h" -#include "script.h" #include "ffi.h" +#include "script.h" #include "log.h" #include @@ -25,28 +24,26 @@ #include "2dphysics.h" +#include #include #include -#include #include "string.h" - #define SOKOL_TRACE_HOOKS #define SOKOL_GFX_IMPL #define SOKOL_GLCORE33 #include "sokol/sokol_gfx.h" - int physOn = 0; double renderlag = 0; double physlag = 0; double updatelag = 0; -double renderMS = 1/165.f; -double physMS = 1/120.f; -double updateMS = 1/60.f; +double renderMS = 1 / 165.f; +double physMS = 1 / 120.f; +double updateMS = 1 / 60.f; static int ed = 1; static int sim_play = 0; @@ -65,39 +62,37 @@ int fps; #define SIM_PAUSE 2 #define SIM_STEP 3 -void print_stacktrace() -{ - void *ents[512]; - size_t size; +void print_stacktrace() { + void *ents[512]; + size_t size; - size = backtrace(ents, 512); + size = backtrace(ents, 512); - YughCritical("====================BACKTRACE===================="); - char **stackstr = backtrace_symbols(ents, size); + YughCritical("====================BACKTRACE===================="); + char **stackstr = backtrace_symbols(ents, size); - YughInfo("Stack size is %d.", size); + YughInfo("Stack size is %d.", size); - for (int i = 0; i < size; i++) - YughCritical(stackstr[i]); + for (int i = 0; i < size; i++) + YughCritical(stackstr[i]); - js_stacktrace(); + js_stacktrace(); } void seghandle(int sig) { #ifdef __linux__ - if (strsignal(sig)) - YughCritical("CRASH! Signal: %s.", strsignal(sig)); + if (strsignal(sig)) + YughCritical("CRASH! Signal: %s.", strsignal(sig)); - print_stacktrace(); + print_stacktrace(); - exit(1); + exit(1); #endif } -void compile_script(const char *file) -{ +void compile_script(const char *file) { const char *script = slurp_text(file); - JSValue obj = JS_Eval(js, script, strlen(script), file, JS_EVAL_FLAG_COMPILE_ONLY|JS_EVAL_TYPE_GLOBAL); + JSValue obj = JS_Eval(js, script, strlen(script), file, JS_EVAL_FLAG_COMPILE_ONLY | JS_EVAL_TYPE_GLOBAL); size_t out_len; uint8_t *out; out = JS_WriteObject(js, &out_len, obj, JS_WRITE_OBJ_BYTECODE); @@ -107,159 +102,157 @@ void compile_script(const char *file) fclose(f); } -void sg_logging(const char *tag, uint32_t lvl, uint32_t id, const char *msg, uint32_t line, const char *file, void *data) -{ +void sg_logging(const char *tag, uint32_t lvl, uint32_t id, const char *msg, uint32_t line, const char *file, void *data) { mYughLog(0, 1, line, file, "tag: %s, msg: %s", tag, msg); } int main(int argc, char **args) { - int logout = 1; - ed = 1; + int logout = 1; + ed = 1; - script_startup(); + script_startup(); - for (int i = 1; i < argc; i++) { - if (args[i][0] == '-') { - switch(args[i][1]) { - case 'p': - ed = 0; - break; + for (int i = 1; i < argc; i++) { + if (args[i][0] == '-') { + switch (args[i][1]) { + case 'p': + ed = 0; + break; - case 'l': - if (i+1 < argc && args[i+1][0] != '-') { - log_setfile(args[i+1]); - i++; - continue; - } - else { - YughError("Expected a file for command line arg '-l'."); - exit(1); - } - - case 'v': - printf("Yugine version %s, %s build.\n", VER, INFO); - printf("Copyright 2022-2023 odplot productions LLC.\n"); - exit(1); - break; - - case 's': - compile_script(args[2]); - exit(0); - - case 'm': - logLevel = atoi(args[2]); - break; - - case 'h': - printf("-l Set log file\n"); - printf("-p Launch engine in play mode instead of editor mode\n"); - printf("-v Display engine info\n"); - printf("-c Redirect logging to console\n"); - exit(0); - break; - - case 'c': - logout = 0; - break; - - } + case 'l': + if (i + 1 < argc && args[i + 1][0] != '-') { + log_setfile(args[i + 1]); + i++; + continue; + } else { + YughError("Expected a file for command line arg '-l'."); + exit(1); } + + case 'v': + printf("Yugine version %s, %s build.\n", VER, INFO); + printf("Copyright 2022-2023 odplot productions LLC.\n"); + exit(1); + break; + + case 's': + compile_script(args[2]); + exit(0); + + case 'm': + logLevel = atoi(args[2]); + break; + + case 'h': + printf("-l Set log file\n"); + printf("-p Launch engine in play mode instead of editor mode\n"); + printf("-v Display engine info\n"); + printf("-c Redirect logging to console\n"); + exit(0); + break; + + case 'c': + logout = 0; + break; + } } + } #if DBG - if (logout) { - time_t now = time(NULL); - char fname[100]; - snprintf(fname, 100, "yugine-%d.log", now); - log_setfile(fname); - } + if (logout) { + time_t now = time(NULL); + char fname[100]; + snprintf(fname, 100, "yugine-%d.log", now); + log_setfile(fname); + } - YughInfo("Starting yugine version %s.", VER); + YughInfo("Starting yugine version %s.", VER); + + FILE *sysinfo = NULL; + /* sysinfo = popen("uname -a", "r"); + if (!sysinfo) { + YughWarn("Failed to get sys info."); + } else { + log_cat(sysinfo); + pclose(sysinfo); + }*/ + signal(SIGSEGV, seghandle); + signal(SIGABRT, seghandle); + signal(SIGFPE, seghandle); + signal(SIGBUS, seghandle); - FILE *sysinfo = NULL; -/* sysinfo = popen("uname -a", "r"); - if (!sysinfo) { - YughWarn("Failed to get sys info."); - } else { - log_cat(sysinfo); - pclose(sysinfo); - }*/ - signal(SIGSEGV, seghandle); - signal(SIGABRT, seghandle); - signal(SIGFPE, seghandle); - signal(SIGBUS, seghandle); - #endif - engine_init(); + engine_init(); - const GLFWvidmode *vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); - YughInfo("Refresh rate is %d", vidmode->refreshRate); + const GLFWvidmode *vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); + YughInfo("Refresh rate is %d", vidmode->refreshRate); - renderMS = 1.0/vidmode->refreshRate; + renderMS = 1.0 / vidmode->refreshRate; - sg_setup(&(sg_desc){ + sg_setup(&(sg_desc){ .logger = { - .func = sg_logging, - .user_data = NULL, + .func = sg_logging, + .user_data = NULL, }, - }); - - input_init(); - openglInit(); + .buffer_pool_size = 1024, + .context.sample_count = 1, + }); - if (ed) - script_dofile("scripts/editor.js"); - else - script_dofile("scripts/play.js"); + input_init(); + openglInit(); - while (!want_quit()) { - double elapsed = glfwGetTime() - lastTick; - deltaT = elapsed; - lastTick = glfwGetTime(); - double wait = fmax(0, renderMS-elapsed); - input_poll(wait); - window_all_handle_events(); + if (ed) + script_dofile("scripts/editor.js"); + else + script_dofile("scripts/play.js"); - framems[framei++] = elapsed; + while (!want_quit()) { + double elapsed = glfwGetTime() - lastTick; + deltaT = elapsed; + lastTick = glfwGetTime(); + double wait = fmax(0, renderMS - elapsed); + input_poll(wait); + window_all_handle_events(); - if (framei == FPSBUF) framei = 0; + framems[framei++] = elapsed; - if (sim_play == SIM_PLAY || sim_play == SIM_STEP) { - timer_update(elapsed * timescale); - physlag += elapsed; - call_updates(elapsed * timescale); - while (physlag >= physMS) { - phys_step = 1; - physlag -= physMS; - phys2d_update(physMS * timescale); - call_physics(physMS * timescale); - if (sim_play == SIM_STEP) sim_pause(); - phys_step = 0; - } - } + if (framei == FPSBUF) framei = 0; - renderlag += elapsed; - - if (renderlag >= renderMS) { - renderlag -= renderMS; - window_renderall(); - } - - gameobjects_cleanup(); + if (sim_play == SIM_PLAY || sim_play == SIM_STEP) { + timer_update(elapsed * timescale); + physlag += elapsed; + call_updates(elapsed * timescale); + while (physlag >= physMS) { + phys_step = 1; + physlag -= physMS; + phys2d_update(physMS * timescale); + call_physics(physMS * timescale); + if (sim_play == SIM_STEP) sim_pause(); + phys_step = 0; + } } - return 0; + renderlag += elapsed; + + if (renderlag >= renderMS) { + renderlag -= renderMS; + window_renderall(); + } + + gameobjects_cleanup(); + } + + return 0; } -int frame_fps() -{ - double fpsms = 0; - for (int i = 0; i < FPSBUF; i++) { - fpsms += framems[i]; - } +int frame_fps() { + double fpsms = 0; + for (int i = 0; i < FPSBUF; i++) { + fpsms += framems[i]; + } - return FPSBUF / fpsms; + return FPSBUF / fpsms; } int sim_playing() { return sim_play == SIM_PLAY; } @@ -275,19 +268,19 @@ void sim_pause() { } void sim_stop() { - /* Revert starting state of everything from sim_start */ - sim_play = SIM_STOP; + /* Revert starting state of everything from sim_start */ + sim_play = SIM_STOP; } int phys_stepping() { return phys_step; } void sim_step() { if (sim_paused()) { - YughInfo("Step"); - sim_play = SIM_STEP; + YughInfo("Step"); + sim_play = SIM_STEP; } } void set_timescale(float val) { - timescale = val; + timescale = val; } diff --git a/source/shaders/3d/shadowfrag.glsl b/source/shaders/3d/shadowfrag.glsl deleted file mode 100644 index 46b038f..0000000 --- a/source/shaders/3d/shadowfrag.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#version 330 core - -void main() -{ - // gl_FragDepth = gl_FragCoord.z; -} \ No newline at end of file diff --git a/source/shaders/circlefrag.glsl b/source/shaders/circlefrag.glsl index 05935d9..17a6f39 100644 --- a/source/shaders/circlefrag.glsl +++ b/source/shaders/circlefrag.glsl @@ -3,24 +3,27 @@ in vec2 coords; out vec4 color; -uniform float radius; -uniform int thickness; -uniform vec3 dbgColor; -uniform bool fill; -uniform float zoom; +//in int thickness; +in float radius; +//in bool fill; +in vec3 fcolor; +in vec2 pos; void main() { + int thickness = 1; + bool fill = false; // int tt = thickness + 1; float R1 = 1.f; - float R2 = 1.f - (thickness*zoom / radius); +// float R2 = 1.f - (thickness*zoom / radius); + float R2 = 1.f - (thickness/radius); float dist = sqrt(dot(coords, coords)); if (dist >= R2 && dist <= R1) - color = vec4(dbgColor, 1.f); + color = vec4(fcolor, 1.f); else if (dist < R2) - color = vec4(dbgColor, 0.1f); + color = vec4(fcolor, 0.1f); else discard; } diff --git a/source/shaders/circlevert.glsl b/source/shaders/circlevert.glsl index 4933173..264c0b6 100644 --- a/source/shaders/circlevert.glsl +++ b/source/shaders/circlevert.glsl @@ -1,12 +1,21 @@ #version 330 core -layout (location = 0) in vec4 vertex; +layout (location = 0) in vec2 vertex; +layout (location = 1) in vec3 acolor; +layout (location = 2) in vec2 apos; +layout (location = 3) in float aradius; +layout (location = 4) in float afill; + out vec2 coords; +out float radius; +out vec3 fcolor; + uniform mat4 proj; -uniform vec2 res; void main() { - gl_Position = proj * vec4(vertex.xy, 0.0, 1.0); - coords = vertex.zw; + gl_Position = proj * vec4((vertex * aradius) + apos, 0.0, 1.0); + coords = vertex.xy; + fcolor = acolor; + radius = aradius; } diff --git a/source/shaders/crtfrag.glsl b/source/shaders/crtfrag.glsl new file mode 100644 index 0000000..bd5356d --- /dev/null +++ b/source/shaders/crtfrag.glsl @@ -0,0 +1,26 @@ +#version 330 core +in vec2 TexCoords; + +out vec4 frag_color; + +uniform sampler2D diffuse_texture; + +void main() +{ + vec4 color = texture(diffuse_texture, TexCoords); +// float avg = 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; +// frag_color = vec4(avg,avg,avg,1.0); + float lc = 720.0/2.0; + float line = TexCoords.y * lc; + float line_intensity = mod(float(line),2); + + float off = line_intensity * 0.0005; + vec4 shift = vec4(off,0,0,0); + vec4 color_shift = vec4(0.001,0,0,0); + float r = color.r + color_shift.r + shift.r; + float g = color.g - color_shift.g + shift.g; + float b = color.b; + + frag_color = vec4(r, g*0.99, b, 1.0) * clamp(line_intensity, 0.85, 1.0); + frag_color = texture(diffuse_texture, TexCoords); +} diff --git a/source/shaders/diffuse_f.glsl b/source/shaders/diffuse_f.glsl new file mode 100644 index 0000000..016a296 --- /dev/null +++ b/source/shaders/diffuse_f.glsl @@ -0,0 +1,104 @@ +#version 330 core +in vec2 tex_coords; +in vec3 normal; +in vec3 frag_pos; +in vec4 frag_pos_light; + +out vec4 frag_color; + +uniform sampler2D diffuse; +uniform sampler2D normmap; +uniform sampler2D shadow_map; + +uniform vec3 point_pos; +uniform vec3 dir_dir; +uniform vec3 view_pos; +uniform vec3 spot_pos; +uniform vec3 spot_dir; + +/* Ambient light */ +float amb_str = 0.3; + +vec3 amb_color = vec3(1,1,1); + +float spec_str = 0.5; + +/* point */ +float constant = 1; +float linear = 0.09; +float quad = 0.032; + +/* spotlight */ +float cutoff = 12.5; /* cutoff in radians */ +float outer_cutoff = 17.5; + +vec3 norm = vec3(0,0,0); +vec3 view = vec3(0,0,0); + +float light_str(vec3 dir) +{ + float d = max(dot(norm, dir), 0.0); + vec3 refl = reflect(-dir, norm); + float s = pow(max(dot(view,refl), 0.0), 32); + + return s+d; +} + +float shadow_calc(vec4 fg) +{ + vec3 pc = fg.xyz / fg.w; + pc = pc * 0.5 + 0.5; + + if (pc.z > 1.0) + return 0.0; + + float closest_depth = texture(shadow_map, pc.xy).r; + float cur_depth = pc.z; + + vec3 light_dir = normalize(vec3(4,100,20) - frag_pos); /* light pos */ + float bias = max(0.05 * (1 - dot(norm, light_dir)), 0.005); + + return cur_depth - bias > closest_depth ? 1.0 : 0.0; + + float s; + vec2 texel_size = 1 / textureSize(shadow_map, 0); + + for (int x = -1; x <= 1; ++x) { + for (int y = -1; y <= 1; ++y) { + float pcf_depth = texture(shadow_map, pc.xy + vec2(x,y) * texel_size).r; + s += cur_depth - bias > pcf_depth ? 1.0 : 0.0; + } + } + + s /= 9.0; + + return s; +} + +void main() { + norm = normalize(normal); + view = normalize(view_pos - frag_pos); + + float point_amt = light_str(normalize(point_pos-frag_pos)); + float dist = length(point_pos - frag_pos); + float atten = 1.0 / (constant + linear * dist + quad * (dist*dist)); + point_amt *= atten; + + float dir_amt = light_str(normalize(-dir_dir)); + + vec3 spot_dir = normalize(spot_pos - frag_pos); + float theta = dot(spot_dir, normalize(-spot_dir)); + float spot_amt = 0; + + float epsilon = cutoff - outer_cutoff; + + if (theta > cutoff) { + float intensity = clamp((theta - outer_cutoff)/epsilon,0.0,1.0); + spot_amt = light_str(spot_dir) * intensity; + } + + vec4 mm = texture(diffuse,tex_coords); + float shadow = shadow_calc(frag_pos_light); + vec3 res = mm.rgb * (amb_str + (point_amt + dir_amt) * (1 - shadow)); + frag_color = vec4(res, mm.a); +} diff --git a/source/shaders/diffuse_v.glsl b/source/shaders/diffuse_v.glsl new file mode 100644 index 0000000..2252897 --- /dev/null +++ b/source/shaders/diffuse_v.glsl @@ -0,0 +1,23 @@ +#version 330 core +layout (location=0) in vec3 a_pos; +layout (location=1) in vec2 a_tex_coords; +layout (location=2) in vec3 a_norm; + +out vec2 tex_coords; +out vec3 normal; +out vec3 frag_pos; +out vec4 frag_pos_light; + + +uniform mat4 vp; +uniform mat4 model; +uniform mat4 proj; +uniform mat4 lsm; + +void main() { + frag_pos = vec3(model * vec4(a_pos, 1.0)); + gl_Position = proj * vp * vec4(frag_pos, 1.0); + tex_coords = a_tex_coords; + normal = mat3(transpose(inverse(model))) * a_norm; + frag_pos_light = lsm * vec4(frag_pos, 1.0); +} diff --git a/source/shaders/gridfrag.glsl b/source/shaders/gridfrag.glsl index c5a4ae3..c59a941 100644 --- a/source/shaders/gridfrag.glsl +++ b/source/shaders/gridfrag.glsl @@ -1,19 +1,27 @@ #version 330 -out vec4 color; +out vec4 frag_color; in vec2 apos; vec2 bpos; -uniform int thickness; -uniform int span; +uniform float thickness; /* thickness in pixels */ +uniform float span; +uniform vec3 color; void main(void) { - float t = thickness / 2.f; - bpos.x = mod(apos.x, span); - bpos.y = mod(apos.y, span); + float t = thickness / span; + t /= 2.0; + bpos.x = mod(apos.x, span) / span; + bpos.y = mod(apos.y, span) / span; + bpos.x -= t; + bpos.y -= t; - if (!(bpos.x <= t || bpos.x >= (span - t) || bpos.y <= t || bpos.y >= (span - t))) - discard; + float comp = min(bpos.x, bpos.y); - color = vec4(0.4f, 0.7f, 0.2f, 0.3f); -} \ No newline at end of file + if (comp > t) + discard; + + comp += t; + + frag_color = vec4(color, 1.0); +} diff --git a/source/shaders/gridvert.glsl b/source/shaders/gridvert.glsl index 7b754aa..7b16a03 100644 --- a/source/shaders/gridvert.glsl +++ b/source/shaders/gridvert.glsl @@ -1,17 +1,20 @@ #version 330 layout (location = 0) in vec2 pos; -out vec2 apos; -uniform vec2 offset; +out vec2 apos; layout (std140) uniform Projection { mat4 projection; }; +uniform vec2 offset; + void main() { - vec4 ipos = inverse(projection) * vec4(pos, 0.f, 1.f); - apos = ipos.xy + offset; +// vec4 ipos = inverse(projection) * vec4(pos, 0.f, 1.f); + apos = pos * vec2(600, 360); +// apos = pos + offset; + gl_Position = vec4(pos, 0.f, 1.f); } diff --git a/source/shaders/linefrag.glsl b/source/shaders/linefrag.glsl index fdd826b..c3c5314 100644 --- a/source/shaders/linefrag.glsl +++ b/source/shaders/linefrag.glsl @@ -6,5 +6,5 @@ uniform float alpha; void main() { - color = vec4(linecolor, alpha); -} \ No newline at end of file + color = vec4(1.f,1.f,1.f,1.f); +} diff --git a/source/shaders/linevert.glsl b/source/shaders/linevert.glsl index 3053b40..1d6dcfb 100644 --- a/source/shaders/linevert.glsl +++ b/source/shaders/linevert.glsl @@ -1,11 +1,9 @@ #version 330 layout (location = 0) in vec2 pos; -layout (std140) uniform Projection { - mat4 projection; -}; +uniform mat4 proj; void main() { - gl_Position = projection * vec4(pos, 0.f, 1.f); -} \ No newline at end of file + gl_Position = proj * vec4(pos, 0.f, 1.f); +} diff --git a/source/shaders/shadowfrag.glsl b/source/shaders/shadowfrag.glsl new file mode 100644 index 0000000..b0d8218 --- /dev/null +++ b/source/shaders/shadowfrag.glsl @@ -0,0 +1,8 @@ +#version 330 core +out float frag_color; + +void main() +{ +// frag_color = encode_depth(gl_FragCoord.z); + frag_color = gl_FragCoord.z; +} diff --git a/source/shaders/3d/shadowvert.glsl b/source/shaders/shadowvert.glsl similarity index 100% rename from source/shaders/3d/shadowvert.glsl rename to source/shaders/shadowvert.glsl diff --git a/source/shaders/textfrag.glsl b/source/shaders/textfrag.glsl index 75a1ff3..b0ade18 100644 --- a/source/shaders/textfrag.glsl +++ b/source/shaders/textfrag.glsl @@ -8,11 +8,8 @@ uniform sampler2D text; void main() { - -// color = vec4(fColor.xyz, texture(text, TexCoords).r); - color = vec4(1.f,1.f,1.f, texture(text, TexCoords).r); + color = vec4(fColor.xyz, texture(text, TexCoords).r); +// color = vec4(1.f, 1.f, 1.f, texture(text, TexCoords).r); if (color.a <= 0.1f) discard; - - }