#ifndef QJS_COMMON_H #define QJS_COMMON_H #include #include "HandmadeMath.h" #include "render.h" #include // Forward declarations typedef struct sprite sprite; typedef struct transform transform; // Common conversion functions - to JavaScript JSValue vec22js(JSContext *js, HMM_Vec2 v); JSValue vec32js(JSContext *js, HMM_Vec3 v); JSValue vec42js(JSContext *js, HMM_Vec4 v); JSValue rect2js(JSContext *js, rect r); JSValue number2js(JSContext *js, double n); // Common conversion functions - from JavaScript HMM_Vec2 js2vec2(JSContext *js, JSValue v); HMM_Vec3 js2vec3(JSContext *js, JSValue v); HMM_Vec4 js2vec4(JSContext *js, JSValue v); rect js2rect(JSContext *js, JSValue v); irect js2irect(JSContext *js, JSValue v); colorf js2color(JSContext *js, JSValue v); double js2number(JSContext *js, JSValue v); sprite *js2sprite(JSContext *js, JSValue v); transform *js2transform(JSContext *js, JSValue v); // SDL type conversion functions SDL_Window *js2SDL_Window(JSContext *js, JSValue v); SDL_Renderer *js2SDL_Renderer(JSContext *js, JSValue v); SDL_Texture *js2SDL_Texture(JSContext *js, JSValue v); SDL_ScaleMode js2SDL_ScaleMode(JSContext *js, JSValue v); JSValue SDL_Window2js(JSContext *js, SDL_Window *w); JSValue SDL_Renderer2js(JSContext *js, SDL_Renderer *r); JSValue SDL_Texture2js(JSContext *js, SDL_Texture *t); // GPU buffer functions JSValue make_gpu_buffer(JSContext *js, void *data, size_t size, int type, int elements, int copy, int index); void *get_gpu_buffer(JSContext *js, JSValue argv, size_t *stride, size_t *size); JSValue make_quad_indices_buffer(JSContext *js, int quads); // Matrix conversion HMM_Mat3 transform2mat3(transform *t); // Utility functions double js_getnum_str(JSContext *js, JSValue v, const char *str); #endif /* QJS_COMMON_H */