aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-04-03 13:02:52 +0200
committerLoïc Hoguin <[email protected]>2014-04-03 13:02:52 +0200
commit059ada86139b0cd42675180e553dc916323311d7 (patch)
tree9138a9095bc450f955cf44381df72bbd93341ad8
parent4454f9a00ca8aa85e78e71fb7ef670d802c671e2 (diff)
downloadesdl2-059ada86139b0cd42675180e553dc916323311d7.tar.gz
esdl2-059ada86139b0cd42675180e553dc916323311d7.tar.bz2
esdl2-059ada86139b0cd42675180e553dc916323311d7.zip
Add sdl_window:get_max_size/1
-rw-r--r--c_src/esdl2.h1
-rw-r--r--c_src/sdl_window.c24
-rw-r--r--src/esdl2.erl4
-rw-r--r--src/sdl_window.erl5
4 files changed, 34 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index 9b9f0e2..6a13a42 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -166,6 +166,7 @@
F(get_window_flags, 1) \
F(get_window_grab, 1) \
F(get_window_id, 1) \
+ F(get_window_maximum_size, 1) \
// Generated declarations for the NIF.
diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c
index 2ec3ba0..49fa005 100644
--- a/c_src/sdl_window.c
+++ b/c_src/sdl_window.c
@@ -206,3 +206,27 @@ NIF_FUNCTION(get_window_id)
return nif_thread_call(env, thread_get_window_id, 1,
NIF_RES_GET(Window, window_res));
}
+
+// get_window_maximum_size
+
+NIF_CALL_HANDLER(thread_get_window_maximum_size)
+{
+ int w, h;
+
+ SDL_GetWindowMaximumSize(args[0], &w, &h);
+
+ return enif_make_tuple2(env,
+ enif_make_int(env, w),
+ enif_make_int(env, h)
+ );
+}
+
+NIF_FUNCTION(get_window_maximum_size)
+{
+ void* window_res;
+
+ BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res));
+
+ return nif_thread_call(env, thread_get_window_maximum_size, 1,
+ NIF_RES_GET(Window, window_res));
+}
diff --git a/src/esdl2.erl b/src/esdl2.erl
index b069662..788d5fb 100644
--- a/src/esdl2.erl
+++ b/src/esdl2.erl
@@ -78,6 +78,7 @@
-export([get_window_flags/1]).
-export([get_window_grab/1]).
-export([get_window_id/1]).
+-export([get_window_maximum_size/1]).
%% @todo We probably want to accept an env variable or somthing for the location.
-on_load(on_load/0).
@@ -241,3 +242,6 @@ get_window_grab(_) ->
get_window_id(_) ->
erlang:nif_error({not_loaded, ?MODULE}).
+
+get_window_maximum_size(_) ->
+ erlang:nif_error({not_loaded, ?MODULE}).
diff --git a/src/sdl_window.erl b/src/sdl_window.erl
index 7b7afca..f3376f8 100644
--- a/src/sdl_window.erl
+++ b/src/sdl_window.erl
@@ -21,6 +21,7 @@
-export([get_flags/1]).
-export([is_input_grabbed/1]).
-export([get_id/1]).
+-export([get_max_size/1]).
create(Title, X, Y, W, H, Flags) ->
esdl2:create_window(Title, X, Y, W, H, Flags),
@@ -52,3 +53,7 @@ is_input_grabbed(Window) ->
get_id(Window) ->
esdl2:get_window_id(Window),
receive {'_nif_thread_ret_', Ret} -> Ret end.
+
+get_max_size(Window) ->
+ esdl2:get_window_maximum_size(Window),
+ receive {'_nif_thread_ret_', Ret} -> Ret end.