From 0f31316fc0e67d9f00638b913ac91d3009c47e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 3 Apr 2014 20:10:18 +0200 Subject: Add sdl_window:set_title/2 --- c_src/esdl2.h | 1 + c_src/sdl_window.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'c_src') diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 433b262..2a0a231 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -185,6 +185,7 @@ F(set_window_minimum_size, 3) \ F(set_window_position, 3) \ F(set_window_size, 3) \ + F(set_window_title, 2) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index 5719779..065e39a 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -623,3 +623,24 @@ NIF_FUNCTION(set_window_size) return nif_thread_cast(env, thread_set_window_size, 3, NIF_RES_GET(Window, window_res), w, h); } + +// set_window_title + +NIF_CAST_HANDLER(thread_set_window_title) +{ + SDL_SetWindowTitle(args[0], args[1]); + + enif_free(args[1]); +} + +NIF_FUNCTION(set_window_title) +{ + void* window_res; + char* title = (char*)enif_alloc(255); + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + BADARG_IF(!enif_get_string(env, argv[1], title, 255, ERL_NIF_LATIN1)); + + return nif_thread_cast(env, thread_set_window_title, 2, + NIF_RES_GET(Window, window_res), title); +} -- cgit v1.2.3