Files
prosperon/prosperon.h
2025-11-26 20:26:31 -06:00

67 lines
2.2 KiB
C

#ifndef PROSPERON_H
#define PROSPERON_H
#include "HandmadeMath.h"
#include "sprite.h"
#include "transform.h"
// Common data structures
struct lrtb {
float l;
float r;
float t;
float b;
};
typedef struct lrtb lrtb;
typedef struct text_vert text_vert;
typedef HMM_Vec4 colorf;
typedef SDL_FRect rect;
typedef SDL_Rect irect;
JSValue rect2js(JSContext *js, rect r);
rect js2rect(JSContext *js, JSValue v);
HMM_Vec2 js2vec2(JSContext *js, JSValue v);
JSValue vec22js(JSContext *js, HMM_Vec2 v);
colorf js2color(JSContext *js, JSValue v);
double js2number(JSContext *js, JSValue v);
JSValue number2js(JSContext *js, double n);
SDL_Window *js2SDL_Window(JSContext *js, JSValue v);
JSValue SDL_Window2js(JSContext *js, SDL_Window *w);
void *get_gpu_buffer(JSContext *js, JSValue argv, size_t *stride, size_t *size);
double js_getnum_str(JSContext *js, JSValue v, const char *str);
sprite *js2sprite(JSContext *js, JSValue v);
HMM_Vec3 js2vec3(JSContext *js, JSValue v);
JSValue vec32js(JSContext *js, HMM_Vec3 v);
HMM_Vec4 js2vec4(JSContext *js, JSValue v);
JSValue vec42js(JSContext *js, HMM_Vec4 v);
JSValue make_gpu_buffer(JSContext *js, void *data, size_t size, int type, int elements, int copy, int index);
JSValue make_quad_indices_buffer(JSContext *js, int quads);
JSClassID js_SDL_Surface_id;
// Common conversion functions used across modules
JSValue rect2js(JSContext *js, rect r);
JSValue vec22js(JSContext *js, HMM_Vec2 v);
JSValue vec32js(JSContext *js, HMM_Vec3 v);
JSValue vec42js(JSContext *js, HMM_Vec4 v);
JSValue quat2js(JSContext *js, HMM_Quat q);
JSValue color2js(JSContext *js, colorf c);
JSValue number2js(JSContext *js, double d);
JSValue angle2js(JSContext *js, double a);
double js_getnum_str(JSContext *js, JSValue v, const char *str);
rect js2rect(JSContext *js, JSValue v);
HMM_Vec2 js2vec2(JSContext *js, JSValue v);
HMM_Vec3 js2vec3(JSContext *js, JSValue v);
HMM_Vec4 js2vec4(JSContext *js, JSValue v);
HMM_Quat js2quat(JSContext *js, JSValue v);
colorf js2color(JSContext *js, JSValue v);
double js2number(JSContext *js, JSValue v);
double js2angle(JSContext *js, JSValue v);
lrtb js2lrtb(JSContext *js, JSValue v);
JSValue lrtb2js(JSContext *js, lrtb r);
#endif