diff options
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_renderer.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 1f0ee3c..f0e54c9 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -151,6 +151,7 @@ F(create_renderer, 3) \ F(get_num_render_drivers, 0) \ F(get_render_draw_blend_mode, 1) \ + F(get_render_draw_color, 1) \ F(render_clear, 1) \ F(render_copy, 4) \ F(render_present, 1) \ diff --git a/c_src/sdl_renderer.c b/c_src/sdl_renderer.c index 5f90f14..7787a3c 100644 --- a/c_src/sdl_renderer.c +++ b/c_src/sdl_renderer.c @@ -133,6 +133,36 @@ NIF_FUNCTION(get_render_draw_blend_mode) NIF_RES_GET(Renderer, renderer_res)); } +// get_render_draw_color + +NIF_CALL_HANDLER(thread_get_render_draw_color) +{ + Uint8 r, g, b, a; + + if (SDL_GetRenderDrawColor(args[0], &r, &g, &b, &a)) + return sdl_error_tuple(env); + + return enif_make_tuple2(env, + atom_ok, + enif_make_tuple4(env, + enif_make_uint(env, r), + enif_make_uint(env, g), + enif_make_uint(env, b), + enif_make_uint(env, a) + ) + ); +} + +NIF_FUNCTION(get_render_draw_color) +{ + void* renderer_res; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Renderer, &renderer_res)); + + return nif_thread_call(env, thread_get_render_draw_color, 1, + NIF_RES_GET(Renderer, renderer_res)); +} + // render_clear NIF_CALL_HANDLER(thread_render_clear) |