diff options
-rw-r--r-- | CMakeLists.txt | 20 | ||||
-rw-r--r-- | scripts/main.scm | 8 | ||||
-rw-r--r-- | sources/main.c | 1 | ||||
-rw-r--r-- | sources/text.h | 7 |
4 files changed, 33 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b192bf0..bb1e39f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,26 @@ endif() if (EMSCRIPTEN) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s GL_ENABLE_GET_PROC_ADDRESS=1 --embed-file assets --embed-file scripts") set(CMAKE_EXECUTABLE_SUFFIX ".html") # This line is used to set your executable to build with the emscripten html template so that you can directly open it. + add_custom_command( + TARGET ${CMAKE_PROJECT_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/assets $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/assets + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/scripts $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/scripts + ) + add_custom_command( + TARGET ${CMAKE_PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/scripts ${CMAKE_SOURCE_DIR}/out/scripts + COMMAND ${CMAKE_COMMAND} -E copy_directory $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/assets ${CMAKE_SOURCE_DIR}/out/assets + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/${CMAKE_PROJECT_NAME}.html ${CMAKE_SOURCE_DIR}/out/${CMAKE_PROJECT_NAME}.html + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/${CMAKE_PROJECT_NAME}.js ${CMAKE_SOURCE_DIR}/out/${CMAKE_PROJECT_NAME}.js + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/${CMAKE_PROJECT_NAME}.wasm ${CMAKE_SOURCE_DIR}/out/${CMAKE_PROJECT_NAME}.wasm + ) +else () + add_custom_command( + TARGET ${CMAKE_PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/scripts ${CMAKE_SOURCE_DIR}/out/scripts + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/assets ${CMAKE_SOURCE_DIR}/out/assets + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/${CMAKE_PROJECT_NAME} ${CMAKE_SOURCE_DIR}/out/${CMAKE_PROJECT_NAME} + ) endif () # Setting ASSETS_PATH diff --git a/scripts/main.scm b/scripts/main.scm index 9066381..96053b1 100644 --- a/scripts/main.scm +++ b/scripts/main.scm @@ -1,15 +1,17 @@ (define a 0) -;;(define b 0) +(define b 0) (define update (lambda () (set! a (+ a 1)) - ;;(set! b (rl-load-texture)) + (set! b (rl-load-texture)) ;;(display b) - + ;;(gc) )) (define draw (lambda () (rl-draw-text (number->string a)) + (display "ue") + (rl-draw-texture b) )) diff --git a/sources/main.c b/sources/main.c index 309e8c3..3601fe3 100644 --- a/sources/main.c +++ b/sources/main.c @@ -48,6 +48,7 @@ int main(int argc, char* argv[]) { InitWindow(screen_width, screen_height, "SLGJ - 2024"); SetTargetFPS(60); + printf("foi"); char filename[] = SCRIPTS_PATH"main.scm"; s7_load(s7, filename); diff --git a/sources/text.h b/sources/text.h index 74716c1..fed7181 100644 --- a/sources/text.h +++ b/sources/text.h @@ -17,6 +17,12 @@ static s7_pointer rl_draw_text(s7_scheme *s7, s7_pointer args) { 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)); @@ -27,6 +33,7 @@ static s7_pointer rl_load_texture(s7_scheme *s7, s7_pointer args) { static void rl_text_define_methods(s7_scheme *s7) { s7_define_safe_function(s7, "rl-draw-text", rl_draw_text, 1, 0, false, "test"); s7_define_safe_function(s7, "rl-load-texture", rl_load_texture, 0, 0, false, "test"); + s7_define_safe_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); |