From a7cc19f9e254d0ee391b2b65ef6da6e471da803c Mon Sep 17 00:00:00 2001 From: Henrique Alves Date: Thu, 25 Apr 2024 23:51:58 +0300 Subject: Adding more API --- sources/texture.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 sources/texture.h (limited to 'sources/texture.h') diff --git a/sources/texture.h b/sources/texture.h new file mode 100644 index 0000000..8dfb996 --- /dev/null +++ b/sources/texture.h @@ -0,0 +1,29 @@ +int texture_2d_tag; + +static s7_pointer free_texture_2d(s7_scheme *s7, s7_pointer obj) { + Texture2D *texture = (Texture2D *) s7_c_object_value(obj); + UnloadTexture(*texture); + free(texture); + return(NULL); +} + +static s7_pointer rl_draw_texture(s7_scheme *s7, s7_pointer args) { + Texture2D *texture = (Texture2D *) s7_c_object_value(s7_car(args)); + DrawTexture(*texture, 100, 100, WHITE); + return(NULL); +} + +static s7_pointer rl_load_texture(s7_scheme *s7, s7_pointer args) { + Texture2D texture = LoadTexture("./assets/test.png"); + Texture2D *texture_ptr = (Texture2D *) malloc(sizeof(Texture2D)); + *texture_ptr = texture; + return (s7_make_c_object(s7, texture_2d_tag, (void *) texture_ptr)); +} + +static void rl_texture_define_methods(s7_scheme *s7) { + s7_define_function(s7, "rl-load-texture", rl_load_texture, 0, 0, false, "test"); + s7_define_function(s7, "rl-draw-texture", rl_draw_texture, 1, 0, false, "test"); + + texture_2d_tag = s7_make_c_type(s7, "texture-2d"); + s7_c_type_set_gc_free(s7, texture_2d_tag, free_texture_2d); +} -- cgit v1.2.3