diff options
author | Loïc Hoguin <[email protected]> | 2014-04-07 21:13:08 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-04-07 21:13:08 +0200 |
commit | 872301b55c4df71d704e1b2e2e8947e040045b8e (patch) | |
tree | c1ee1c03ae79d3a8d4f134957acc9e281985e2dc /c_src | |
parent | 01a9d5eeb3e1e77239b5daef9895719f25bd9b9f (diff) | |
download | esdl2-872301b55c4df71d704e1b2e2e8947e040045b8e.tar.gz esdl2-872301b55c4df71d704e1b2e2e8947e040045b8e.tar.bz2 esdl2-872301b55c4df71d704e1b2e2e8947e040045b8e.zip |
Add sdl_texture:get_alpha_mod/1
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_texture.c | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 3afef48..73f2ed2 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -197,6 +197,7 @@ F(img_load, 1) \ /* sdl_texture */ \ F(create_texture_from_surface, 2) \ + F(get_texture_alpha_mod, 1) \ /* sdl_version */ \ F(get_version, 0) \ F(get_revision, 0) \ diff --git a/c_src/sdl_texture.c b/c_src/sdl_texture.c index 4741bb6..2b78cc9 100644 --- a/c_src/sdl_texture.c +++ b/c_src/sdl_texture.c @@ -49,3 +49,28 @@ NIF_FUNCTION(create_texture_from_surface) return nif_thread_call(env, thread_create_texture_from_surface, 2, NIF_RES_GET(Renderer, renderer_res), NIF_RES_GET(Surface, surface_res)); } + +// get_texture_alpha_mod + +NIF_CALL_HANDLER(thread_get_texture_alpha_mod) +{ + Uint8 alpha; + + if (SDL_GetTextureAlphaMod(args[0], &alpha)) + return sdl_error_tuple(env); + + return enif_make_tuple2(env, + atom_ok, + enif_make_uint(env, alpha) + ); +} + +NIF_FUNCTION(get_texture_alpha_mod) +{ + void* texture_res; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Texture, &texture_res)); + + return nif_thread_call(env, thread_get_texture_alpha_mod, 1, + NIF_RES_GET(Texture, texture_res)); +} |