remove unnecessary functions
Some checks failed
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
Some checks failed
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
This commit is contained in:
@@ -20,8 +20,15 @@ render.load_texture(img)
|
||||
img.texture = context.load_texture(img.surface)
|
||||
}
|
||||
|
||||
var current_color = Color.white
|
||||
|
||||
render.queue = function(cmd)
|
||||
{
|
||||
if (cmd.color && cmd.color != current_color) {
|
||||
current_color = cmd.color
|
||||
context.draw_color(current_color)
|
||||
}
|
||||
|
||||
switch(cmd.type) {
|
||||
case "geometry":
|
||||
context.geometry(cmd.texture, cmd.mesh)
|
||||
@@ -45,4 +52,9 @@ render.queue = function(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
render.get_image = function(rect)
|
||||
{
|
||||
return context.get_image(rect)
|
||||
}
|
||||
|
||||
return render
|
||||
|
||||
164
source/jsffi.c
164
source/jsffi.c
@@ -1014,8 +1014,6 @@ void SDL_Window_free(JSRuntime *rt, SDL_Window *w)
|
||||
SDL_DestroyWindow(w);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SDL_Renderer_free(JSRuntime *rt, SDL_Renderer *r)
|
||||
{
|
||||
SDL_DestroyRenderer(r);
|
||||
@@ -2711,32 +2709,6 @@ JSC_CCALL(SDL_Renderer_draw_color,
|
||||
SDL_SetRenderDrawColorFloat(renderer, color.r,color.g,color.b,color.a);
|
||||
)
|
||||
|
||||
JSC_CCALL(SDL_Renderer_rect,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[1])) {
|
||||
colorf color = js2color(js,argv[1]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
if (JS_IsArray(js,argv[0])) {
|
||||
int len = js_arrlen(js,argv[0]);
|
||||
rect rects[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
JSValue val = JS_GetPropertyUint32(js,argv[0],i);
|
||||
rects[i] = transform_rect(r,js2rect(js,val), &cam_mat);
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
SDL_RenderRects(r,rects,len);
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
rect rect = js2rect(js,argv[0]);
|
||||
|
||||
rect = transform_rect(r,rect, &cam_mat);
|
||||
|
||||
SDL_RenderRect(r, &rect);
|
||||
)
|
||||
|
||||
SDL_GPUColorTargetInfo js2SDL_GPUColorTargetInfo(JSContext *js, JSValue v)
|
||||
{
|
||||
SDL_GPUColorTargetInfo info = {0};
|
||||
@@ -2762,83 +2734,6 @@ JSC_CCALL(renderer_load_texture,
|
||||
JS_SetProperty(js,ret,height, number2js(js,tex->h));
|
||||
)
|
||||
|
||||
JSC_CCALL(SDL_Renderer_fillrect,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[1])) {
|
||||
colorf color = js2color(js,argv[1]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
if (JS_IsArray(js,argv[0])) {
|
||||
int len = js_arrlen(js,argv[0]);
|
||||
rect rects[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
JSValue val = JS_GetPropertyUint32(js,argv[0],i);
|
||||
rects[i] = js2rect(js,val);
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
if (!SDL_RenderFillRects(r,rects,len))
|
||||
return JS_ThrowReferenceError(js, "Could not render rectangle: %s", SDL_GetError());
|
||||
}
|
||||
//rect rect = transform_rect(r,js2rect(js,argv[0]),&cam_mat);
|
||||
rect rect = js2rect(js, argv[0]);
|
||||
|
||||
if (!SDL_RenderFillRect(r, &rect))
|
||||
return JS_ThrowReferenceError(js, "Could not render rectangle: %s", SDL_GetError());
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_texture,
|
||||
SDL_Renderer *renderer = js2SDL_Renderer(js,self);
|
||||
SDL_Texture *tex = js2SDL_Texture(js,argv[0]);
|
||||
rect dst = transform_rect(renderer,js2rect(js,argv[1]), &cam_mat);
|
||||
|
||||
if (!JS_IsUndefined(argv[3])) {
|
||||
colorf color = js2color(js,argv[3]);
|
||||
SDL_SetTextureColorModFloat(tex, color.r, color.g, color.b);
|
||||
SDL_SetTextureAlphaModFloat(tex,color.a);
|
||||
}
|
||||
if (JS_IsUndefined(argv[2]))
|
||||
SDL_RenderTexture(renderer,tex,NULL,&dst);
|
||||
else {
|
||||
|
||||
rect src = js2rect(js,argv[2]);
|
||||
|
||||
SDL_RenderTextureRotated(renderer, tex, &src, &dst, 0, NULL, SDL_FLIP_NONE);
|
||||
}
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_tile,
|
||||
SDL_Renderer *renderer = js2SDL_Renderer(js,self);
|
||||
if (!renderer) return JS_ThrowTypeError(js,"self was not a renderer");
|
||||
SDL_Texture *tex = js2SDL_Texture(js,argv[0]);
|
||||
if (!tex) return JS_ThrowTypeError(js,"first argument was not a texture");
|
||||
rect dst = js2rect(js,argv[1]);
|
||||
if (!dst.w) dst.w = tex->w;
|
||||
if (!dst.h) dst.h = tex->h;
|
||||
float scale = js2number(js,argv[3]);
|
||||
if (!scale) scale = 1;
|
||||
if (JS_IsUndefined(argv[2]))
|
||||
SDL_RenderTextureTiled(renderer,tex,NULL,scale, &dst);
|
||||
else {
|
||||
rect src = js2rect(js,argv[2]);
|
||||
SDL_RenderTextureTiled(renderer,tex,&src,scale, &dst);
|
||||
}
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_slice9,
|
||||
SDL_Renderer *renderer = js2SDL_Renderer(js,self);
|
||||
SDL_Texture *tex = js2SDL_Texture(js,argv[0]);
|
||||
lrtb bounds = js2lrtb(js,argv[2]);
|
||||
rect src, dst;
|
||||
src = transform_rect(renderer,js2rect(js,argv[3]),&cam_mat);
|
||||
dst = transform_rect(renderer,js2rect(js,argv[1]), &cam_mat);
|
||||
|
||||
SDL_RenderTexture9Grid(renderer, tex,
|
||||
JS_IsUndefined(argv[3]) ? NULL : &src,
|
||||
bounds.l, bounds.r, bounds.t, bounds.b, 0.0,
|
||||
JS_IsUndefined(argv[1]) ? NULL : &dst);
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_get_image,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
SDL_Surface *surf = NULL;
|
||||
@@ -2851,24 +2746,8 @@ JSC_CCALL(renderer_get_image,
|
||||
return SDL_Surface2js(js,surf);
|
||||
)
|
||||
|
||||
JSC_SCALL(renderer_fasttext,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[2])) {
|
||||
colorf color = js2color(js,argv[2]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
HMM_Vec2 pos = js2vec2(js,argv[1]);
|
||||
pos.y += 8;
|
||||
HMM_Vec2 tpos = HMM_MulM3V3(cam_mat, (HMM_Vec3){pos.x,pos.y,1}).xy;
|
||||
SDL_RenderDebugText(r, tpos.x, tpos.y, str);
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_line,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[1])) {
|
||||
colorf color = js2color(js,argv[1]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
if (JS_IsArray(js,argv[0])) {
|
||||
int len = js_arrlen(js,argv[0]);
|
||||
@@ -2885,10 +2764,6 @@ JSC_CCALL(renderer_line,
|
||||
|
||||
JSC_CCALL(renderer_point,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[1])) {
|
||||
colorf color = js2color(js,argv[1]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
if (JS_IsArray(js,argv[0])) {
|
||||
int len = js_arrlen(js,argv[0]);
|
||||
@@ -2985,18 +2860,6 @@ JSC_CCALL(renderer_viewport,
|
||||
}
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_get_viewport,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
SDL_Rect vp;
|
||||
SDL_GetRenderViewport(r, &vp);
|
||||
rect re;
|
||||
re.x = vp.x;
|
||||
re.y = vp.y;
|
||||
re.h = vp.h;
|
||||
re.w = vp.w;
|
||||
return rect2js(js,re);
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_clip,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (JS_IsUndefined(argv[0]))
|
||||
@@ -3127,31 +2990,24 @@ JSC_CCALL(renderer_make_sprite_mesh,
|
||||
JS_SetProperty(js, ret, count, number2js(js, count));
|
||||
)
|
||||
|
||||
|
||||
|
||||
static const JSCFunctionListEntry js_SDL_Renderer_funcs[] = {
|
||||
MIST_FUNC_DEF(SDL_Renderer, draw_color, 1),
|
||||
MIST_FUNC_DEF(SDL_Renderer, present, 0),
|
||||
MIST_FUNC_DEF(SDL_Renderer, clear, 0),
|
||||
MIST_FUNC_DEF(SDL_Renderer, rect, 2),
|
||||
MIST_FUNC_DEF(SDL_Renderer, fillrect, 2),
|
||||
MIST_FUNC_DEF(renderer, line, 2),
|
||||
MIST_FUNC_DEF(renderer, point, 2),
|
||||
MIST_FUNC_DEF(renderer, load_texture, 1),
|
||||
MIST_FUNC_DEF(renderer, texture, 4),
|
||||
MIST_FUNC_DEF(renderer, slice9, 4),
|
||||
MIST_FUNC_DEF(renderer, tile, 4),
|
||||
MIST_FUNC_DEF(renderer, get_image, 1),
|
||||
MIST_FUNC_DEF(renderer, fasttext, 2),
|
||||
MIST_FUNC_DEF(renderer, line, 1),
|
||||
MIST_FUNC_DEF(renderer, point, 1),
|
||||
MIST_FUNC_DEF(renderer, geometry, 2),
|
||||
MIST_FUNC_DEF(renderer, load_texture, 1),
|
||||
MIST_FUNC_DEF(renderer, get_image, 1),
|
||||
|
||||
MIST_FUNC_DEF(renderer, scale, 1),
|
||||
MIST_FUNC_DEF(renderer,logical_size,1),
|
||||
MIST_FUNC_DEF(renderer,viewport,1),
|
||||
MIST_FUNC_DEF(renderer,clip,1),
|
||||
MIST_FUNC_DEF(renderer,vsync,1),
|
||||
MIST_FUNC_DEF(renderer, logical_size,1),
|
||||
MIST_FUNC_DEF(renderer, viewport,1),
|
||||
MIST_FUNC_DEF(renderer, clip,1),
|
||||
MIST_FUNC_DEF(renderer, vsync,1),
|
||||
|
||||
MIST_FUNC_DEF(renderer, coords, 1),
|
||||
MIST_FUNC_DEF(renderer, camera, 2),
|
||||
MIST_FUNC_DEF(renderer, get_viewport,0),
|
||||
MIST_FUNC_DEF(renderer, screen2world, 1),
|
||||
MIST_FUNC_DEF(renderer, target, 1),
|
||||
MIST_FUNC_DEF(renderer, make_sprite_mesh, 2),
|
||||
|
||||
Reference in New Issue
Block a user