use shared sdl
This commit is contained in:
@@ -10,3 +10,5 @@ add_subdirectory(hiisi)
|
||||
|
||||
add_executable(hiisi-run
|
||||
hiisi/main.cpp)
|
||||
|
||||
target_link_libraries(hiisi-run)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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!"
|
||||
|
||||
Reference in New Issue
Block a user