fix syntax
This commit is contained in:
30
render.c
30
render.c
@@ -41,11 +41,11 @@ JSC_CCALL(SDL_Renderer_rect,
|
||||
SDL_SetRenderDrawColorFloat(r, color.x, color.y, color.z, color.w);
|
||||
}
|
||||
|
||||
if (JS_IsArray(js,argv[0])) {
|
||||
if (JS_IsArray(argv[0])) {
|
||||
int len = JS_ArrayLength(js,argv[0]);
|
||||
rect rects[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
JSValue val = JS_GetPropertyUint32(js,argv[0],i);
|
||||
JSValue val = JS_GetPropertyNumber(js,argv[0],i);
|
||||
rects[i] = js2rect(js,val);
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
@@ -63,11 +63,11 @@ JSC_CCALL(SDL_Renderer_fillrect,
|
||||
SDL_SetRenderDrawColorFloat(r, color.x, color.y, color.z, color.w);
|
||||
}
|
||||
|
||||
if (JS_IsArray(js,argv[0])) {
|
||||
if (JS_IsArray(argv[0])) {
|
||||
int len = JS_ArrayLength(js,argv[0]);
|
||||
rect rects[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
JSValue val = JS_GetPropertyUint32(js,argv[0],i);
|
||||
JSValue val = JS_GetPropertyNumber(js,argv[0],i);
|
||||
rects[i] = js2rect(js,val);
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
@@ -102,9 +102,12 @@ JSC_CCALL(renderer_load_texture,
|
||||
SDL_Surface *surf = js2SDL_Surface(js, argv[0]);
|
||||
SDL_Texture *tex = SDL_CreateTextureFromSurface(renderer, surf);
|
||||
if (!tex) return JS_ThrowReferenceError(js, "Could not create texture from surface: %s", SDL_GetError());
|
||||
ret = SDL_Texture2js(js, tex);
|
||||
JS_SetPropertyStr(js, ret, "width", number2js(js,tex->w));
|
||||
JS_SetPropertyStr(js,ret,"height", number2js(js,tex->h));
|
||||
JS_FRAME(js);
|
||||
JS_LOCAL(result, SDL_Texture2js(js, tex));
|
||||
JS_SetPropertyStr(js, result, "width", number2js(js,tex->w));
|
||||
JS_SetPropertyStr(js, result, "height", number2js(js,tex->h));
|
||||
JS_RestoreFrame(_js_ctx, _js_gc_frame, _js_local_frame);
|
||||
ret = result;
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_get_image,
|
||||
@@ -128,12 +131,12 @@ JSC_CCALL(renderer_line,
|
||||
SDL_SetRenderDrawColorFloat(r, color.x, color.y, color.z, color.w);
|
||||
}
|
||||
|
||||
if (JS_IsArray(js,argv[0])) {
|
||||
if (JS_IsArray(argv[0])) {
|
||||
int len = JS_ArrayLength(js,argv[0]);
|
||||
vec2 points[len];
|
||||
assert(sizeof(vec2) == sizeof(SDL_FPoint));
|
||||
for (int i = 0; i < len; i++) {
|
||||
JSValue val = JS_GetPropertyUint32(js,argv[0],i);
|
||||
JSValue val = JS_GetPropertyNumber(js,argv[0],i);
|
||||
points[i] = js2vec2(js,val);
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
@@ -148,12 +151,12 @@ JSC_CCALL(renderer_point,
|
||||
SDL_SetRenderDrawColorFloat(r, color.x, color.y, color.z, color.w);
|
||||
}
|
||||
|
||||
if (JS_IsArray(js,argv[0])) {
|
||||
if (JS_IsArray(argv[0])) {
|
||||
int len = JS_ArrayLength(js,argv[0]);
|
||||
vec2 points[len];
|
||||
assert(sizeof(vec2) ==sizeof(SDL_FPoint));
|
||||
for (int i = 0; i < len; i++) {
|
||||
JSValue val = JS_GetPropertyUint32(js,argv[0],i);
|
||||
JSValue val = JS_GetPropertyNumber(js,argv[0],i);
|
||||
points[i] = js2vec2(js,val);
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
@@ -243,8 +246,9 @@ JSC_CCALL(SDL_Renderer_constructor,
|
||||
|
||||
CELL_USE_INIT(
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
JSValue renderer_ctor = QJSCLASSPREP_FUNCS_CTOR(SDL_Renderer,1);
|
||||
JS_FRAME(js);
|
||||
JS_LOCAL(renderer_ctor, QJSCLASSPREP_FUNCS_CTOR(SDL_Renderer,1));
|
||||
QJSCLASSPREP_NO_FUNCS(SDL_Texture)
|
||||
|
||||
return renderer_ctor;
|
||||
JS_RETURN(renderer_ctor);
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user