aboutsummaryrefslogtreecommitdiffstats
path: root/c_src
diff options
context:
space:
mode:
Diffstat (limited to 'c_src')
-rw-r--r--c_src/esdl2.h1
-rw-r--r--c_src/sdl_window.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index 3a69b8f..7aea80f 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -169,6 +169,7 @@
F(get_window_maximum_size, 1) \
F(get_window_minimum_size, 1) \
F(get_window_position, 1) \
+ F(get_window_size, 1) \
// Generated declarations for the NIF.
diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c
index 9ddd3f4..becf4d4 100644
--- a/c_src/sdl_window.c
+++ b/c_src/sdl_window.c
@@ -302,3 +302,27 @@ NIF_FUNCTION(get_window_position)
return nif_thread_call(env, thread_get_window_position, 1,
NIF_RES_GET(Window, window_res));
}
+
+// get_window_size
+
+NIF_CALL_HANDLER(thread_get_window_size)
+{
+ int w, h;
+
+ SDL_GetWindowSize(args[0], &w, &h);
+
+ return enif_make_tuple2(env,
+ enif_make_int(env, w),
+ enif_make_int(env, h)
+ );
+}
+
+NIF_FUNCTION(get_window_size)
+{
+ void* window_res;
+
+ BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res));
+
+ return nif_thread_call(env, thread_get_window_size, 1,
+ NIF_RES_GET(Window, window_res));
+}