This commit is contained in:
2026-01-23 10:00:52 -06:00
parent 78312b28a0
commit 3669db73bb
2 changed files with 167 additions and 30 deletions

View File

@@ -89,6 +89,16 @@ void SDL_Surface_free(JSRuntime *rt, SDL_Surface *s) {
// Class definition
QJSCLASS(SDL_Surface,)
JSValue make_surface(JSContext *js, SDL_Surface *s){
JSValue ret = SDL_Surface2js(js,s);
JS_SetPropertyStr(js, ret, "width", JS_NewInt32(js, s->w));
JS_SetPropertyStr(js, ret, "height", JS_NewInt32(js, s->h));
JS_SetPropertyStr(js, ret, "format", pixelformat2js(js, s->format));
JS_SetPropertyStr(js, ret, "pitch", JS_NewFloat64(js, s->pitch));
return JS_Stone(js, ret);
}
// SDL_Surface methods
JSC_CCALL(surface_blit,
SDL_Surface *dst = js2SDL_Surface(js, self);
@@ -687,10 +697,6 @@ static const JSCFunctionListEntry js_SDL_Surface_funcs[] = {
MIST_FUNC_DEF(surface, pixels, 0),
MIST_FUNC_DEF(surface, convert, 1),
MIST_FUNC_DEF(surface, toJSON, 0),
JS_CGETSET_DEF("width", js_surface_get_width, NULL),
JS_CGETSET_DEF("height", js_surface_get_height, NULL),
JS_CGETSET_DEF("format", js_surface_get_format, NULL),
JS_CGETSET_DEF("pitch", js_surface_get_pitch, NULL),
};
// Helper function to create SDL_Surface from image object