From 2c90324d18fb955eee766d7049f62de9ac4ff867 Mon Sep 17 00:00:00 2001 From: Kasper Date: Thu, 13 Mar 2025 10:54:51 +0200 Subject: [PATCH] use shared sdl --- CMakeLists.txt | 2 ++ hiisi/CMakeLists.txt | 3 +-- hiisi/hiisi.cpp | 4 ++-- hiisi/main.cpp | 5 +++-- live-reloader.sh | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c432fc2..11137f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,3 +10,5 @@ add_subdirectory(hiisi) add_executable(hiisi-run hiisi/main.cpp) + +target_link_libraries(hiisi-run) diff --git a/hiisi/CMakeLists.txt b/hiisi/CMakeLists.txt index db643a4..e52fb74 100644 --- a/hiisi/CMakeLists.txt +++ b/hiisi/CMakeLists.txt @@ -8,5 +8,4 @@ add_library(hiisi-engine SHARED set_property(TARGET hiisi-engine PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET hiisi-engine PROPERTY LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -target_link_libraries(hiisi-engine PRIVATE - SDL3::SDL3) +target_link_libraries(hiisi-engine SDL3::SDL3-shared) diff --git a/hiisi/hiisi.cpp b/hiisi/hiisi.cpp index 3755bbc..8a518bf 100644 --- a/hiisi/hiisi.cpp +++ b/hiisi/hiisi.cpp @@ -55,7 +55,7 @@ int iterate(EngineData *state) const float scale = ((float) (((int) (now % 1000)) - 500) / 500.0f) * direction; /* as you can see from this, rendering draws over whatever was drawn before it. */ - SDL_SetRenderDrawColor(renderer, 0, 50, 50, SDL_ALPHA_OPAQUE); /* black, full alpha */ + SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); /* black, full alpha */ SDL_RenderClear(renderer); /* start with a blank canvas. */ /* Rectangles are comprised of set of X and Y coordinates, plus width and @@ -84,7 +84,7 @@ int iterate(EngineData *state) rects[0].y = 50; rects[0].w = 100 + (100 * scale); rects[0].h = 50 + (50 * scale); - SDL_SetRenderDrawColor(renderer, 0, 0, 255, SDL_ALPHA_OPAQUE); /* blue, full alpha */ + SDL_SetRenderDrawColor(renderer, 0, 255, 255, SDL_ALPHA_OPAQUE); /* blue, full alpha */ SDL_RenderFillRect(renderer, &rects[0]); diff --git a/hiisi/main.cpp b/hiisi/main.cpp index 0f842dc..bb8981b 100644 --- a/hiisi/main.cpp +++ b/hiisi/main.cpp @@ -18,7 +18,7 @@ void reload_signal_handler(int) { Engine load_hiisi() { const char *name = "build/hiisi/libhiisi-engine.so"; - void *mod = dlopen(name, RTLD_NOW); + void *mod = dlopen(name, RTLD_NOW|RTLD_GLOBAL); Lmid_t list; dlinfo(mod, RTLD_DI_LMID, &list); @@ -104,9 +104,10 @@ int main(int argc, char **argv) { while (hiisi.event(&state)) { hiisi.iterate(&state); if (reload_requested) { - dlclose(hiisi.module); + Engine oldEngine = hiisi; hiisi = load_hiisi(); reload_requested = false; + // dlclose(oldEngine.module); } } diff --git a/live-reloader.sh b/live-reloader.sh index a8f33a0..9c7e6d9 100755 --- a/live-reloader.sh +++ b/live-reloader.sh @@ -3,7 +3,7 @@ echo "Watching changes in hiisi..." while true; do inotifywait -e modify build/hiisi/libhiisi-engine.so - echo "$(date \"%H:%M:%S\") - Hiisi changed!" + echo "$(date +\"%H:%M:%S\") - Hiisi changed!" HIISI_PID=$(pgrep -x hiisi-run) kill -USR1 "${HIISI_PID}" && echo "Signal sent!" || echo "Signal send failed!"