From 781045cadfa7301101f749a2799feb30ab44f0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 3 Apr 2014 19:59:42 +0200 Subject: Add sdl_window:set_size/3 --- c_src/esdl2.h | 1 + c_src/sdl_window.c | 20 ++++++++++++++++++++ src/esdl2.erl | 4 ++++ src/sdl_window.erl | 4 ++++ 4 files changed, 29 insertions(+) diff --git a/c_src/esdl2.h b/c_src/esdl2.h index c7817b2..433b262 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -184,6 +184,7 @@ F(set_window_maximum_size, 3) \ F(set_window_minimum_size, 3) \ F(set_window_position, 3) \ + F(set_window_size, 3) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index fea00cc..5719779 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -603,3 +603,23 @@ NIF_FUNCTION(set_window_position) return nif_thread_cast(env, thread_set_window_position, 3, NIF_RES_GET(Window, window_res), x, y); } + +// set_window_size + +NIF_CAST_HANDLER(thread_set_window_size) +{ + SDL_SetWindowSize(args[0], (long)args[1], (long)args[2]); +} + +NIF_FUNCTION(set_window_size) +{ + void* window_res; + int w, h; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + BADARG_IF(!enif_get_int(env, argv[1], &w)); + BADARG_IF(!enif_get_int(env, argv[2], &h)); + + return nif_thread_cast(env, thread_set_window_size, 3, + NIF_RES_GET(Window, window_res), w, h); +} diff --git a/src/esdl2.erl b/src/esdl2.erl index c1e7651..31c4ce9 100644 --- a/src/esdl2.erl +++ b/src/esdl2.erl @@ -96,6 +96,7 @@ -export([set_window_maximum_size/3]). -export([set_window_minimum_size/3]). -export([set_window_position/3]). +-export([set_window_size/3]). %% @todo We probably want to accept an env variable or somthing for the location. -on_load(on_load/0). @@ -313,3 +314,6 @@ set_window_minimum_size(_, _, _) -> set_window_position(_, _, _) -> erlang:nif_error({not_loaded, ?MODULE}). + +set_window_size(_, _, _) -> + erlang:nif_error({not_loaded, ?MODULE}). diff --git a/src/sdl_window.erl b/src/sdl_window.erl index 80e5376..f44c1cd 100644 --- a/src/sdl_window.erl +++ b/src/sdl_window.erl @@ -39,6 +39,7 @@ -export([set_max_size/3]). -export([set_min_size/3]). -export([set_pos/3]). +-export([set_size/3]). create(Title, X, Y, W, H, Flags) -> esdl2:create_window(Title, X, Y, W, H, Flags), @@ -132,3 +133,6 @@ set_min_size(Window, W, H) -> set_pos(Window, X, Y) -> esdl2:set_window_position(Window, X, Y). + +set_size(Window, W, H) -> + esdl2:set_window_size(Window, W, H). -- cgit v1.2.3