diff options
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_renderer.c | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 6648e7e..9ddd2d5 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -186,6 +186,7 @@ F(render_get_scale, 1) \ F(render_get_viewport, 1) \ F(render_present, 1) \ + F(render_set_clip_rect, 5) \ F(render_set_logical_size, 3) \ F(set_render_draw_color, 5) \ /* sdl_surface */ \ diff --git a/c_src/sdl_renderer.c b/c_src/sdl_renderer.c index 483b60b..9d873bb 100644 --- a/c_src/sdl_renderer.c +++ b/c_src/sdl_renderer.c @@ -757,6 +757,33 @@ NIF_FUNCTION(render_present) NIF_RES_GET(Renderer, renderer_res)); } +// render_set_clip_rect + +NIF_CALL_HANDLER(thread_render_set_clip_rect) +{ + SDL_Rect rect = {(long)args[1], (long)args[2], (long)args[3], (long)args[4]}; + + if (SDL_RenderSetClipRect(args[0], &rect)) + return sdl_error_tuple(env); + + return atom_ok; +} + +NIF_FUNCTION(render_set_clip_rect) +{ + void* renderer_res; + int x, y, w, h; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Renderer, &renderer_res)); + BADARG_IF(!enif_get_int(env, argv[1], &x)); + BADARG_IF(!enif_get_int(env, argv[2], &y)); + BADARG_IF(!enif_get_int(env, argv[3], &w)); + BADARG_IF(!enif_get_int(env, argv[4], &h)); + + return nif_thread_call(env, thread_render_set_clip_rect, 5, + NIF_RES_GET(Renderer, renderer_res), x, y, w, h); +} + // render_set_logical_size NIF_CALL_HANDLER(thread_render_set_logical_size) |