diff options
author | Loïc Hoguin <[email protected]> | 2014-04-03 16:50:10 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-04-03 16:50:50 +0200 |
commit | dd6f7c6bbfb27d26f432b64e66d41f3b58db944c (patch) | |
tree | b1d93761552de9ac2a22461f9a7a25541969b449 /c_src | |
parent | fa5e7eca92e37289138f78ffff131d7a2cf735ec (diff) | |
download | esdl2-dd6f7c6bbfb27d26f432b64e66d41f3b58db944c.tar.gz esdl2-dd6f7c6bbfb27d26f432b64e66d41f3b58db944c.tar.bz2 esdl2-dd6f7c6bbfb27d26f432b64e66d41f3b58db944c.zip |
Add sdl_window:set_brightness/2
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_window.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 55b9a2b..2eb447b 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -177,6 +177,7 @@ F(raise_window, 1) \ F(restore_window, 1) \ F(set_window_bordered, 2) \ + F(set_window_brightness, 2) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index adaa9eb..b8e8711 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -455,3 +455,33 @@ NIF_FUNCTION(set_window_bordered) return nif_thread_cast(env, thread_set_window_bordered, 2, NIF_RES_GET(Window, window_res), b); } + +// set_window_brightness + +NIF_CALL_HANDLER(thread_set_window_brightness) +{ + int ret = SDL_SetWindowBrightness(args[0], *((double*)args[1])); + + enif_free(args[1]); + + if (ret != 0) + return sdl_error_tuple(env); + + return atom_ok; +} + +NIF_FUNCTION(set_window_brightness) +{ + void* window_res; + double f; + double *fp; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + BADARG_IF(!enif_get_double(env, argv[1], &f)); + + fp = (double*)enif_alloc(sizeof(double)); + *fp = f; + + return nif_thread_call(env, thread_set_window_brightness, 2, + NIF_RES_GET(Window, window_res), fp); +} |