make sdl unremovable
This commit is contained in:
@@ -8,6 +8,8 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
add_subdirectory(3rd/SDL EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(hiisi)
|
||||
|
||||
target_link_options(SDL3-shared PRIVATE -Wl,-z,nodelete)
|
||||
|
||||
add_executable(hiisi-run
|
||||
hiisi/main.cpp)
|
||||
|
||||
|
||||
@@ -66,17 +66,17 @@ int iterate(EngineData *state)
|
||||
/* Let's draw a single rectangle (square, really). */
|
||||
rects[0].x = rects[0].y = 100;
|
||||
rects[0].w = rects[0].h = 100 + (100 * scale);
|
||||
SDL_SetRenderDrawColor(renderer, 250, 0, 0, SDL_ALPHA_OPAQUE); /* red, full alpha */
|
||||
SDL_SetRenderDrawColor(renderer, 250, 0, 255, SDL_ALPHA_OPAQUE); /* red, full alpha */
|
||||
SDL_RenderRect(renderer, &rects[0]);
|
||||
|
||||
/* Now let's draw several rectangles with one function call. */
|
||||
for (i = 0; i < 3; i++) {
|
||||
const float size = (i+1) * 50.0f;
|
||||
const float size = (i+1) * 500.0f;
|
||||
rects[i].w = rects[i].h = size + (size * scale);
|
||||
rects[i].x = (WINDOW_WIDTH - rects[i].w) / 2; /* center it. */
|
||||
rects[i].y = (WINDOW_HEIGHT - rects[i].h) / 2; /* center it. */
|
||||
}
|
||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE); /* green, full alpha */
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 0, SDL_ALPHA_OPAQUE); /* green, full alpha */
|
||||
SDL_RenderRects(renderer, rects, 3); /* draw three rectangles at once */
|
||||
|
||||
/* those were rectangle _outlines_, really. You can also draw _filled_ rectangles! */
|
||||
@@ -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, 255, 255, SDL_ALPHA_OPAQUE); /* blue, full alpha */
|
||||
SDL_SetRenderDrawColor(renderer, 50, 25, 255, SDL_ALPHA_OPAQUE); /* blue, full alpha */
|
||||
SDL_RenderFillRect(renderer, &rects[0]);
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ int iterate(EngineData *state)
|
||||
rects[i].w = w;
|
||||
rects[i].h = h;
|
||||
}
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE); /* white, full alpha */
|
||||
SDL_SetRenderDrawColor(renderer, 25, 255, 255, SDL_ALPHA_OPAQUE); /* white, full alpha */
|
||||
SDL_RenderFillRects(renderer, rects, SDL_arraysize(rects));
|
||||
|
||||
SDL_RenderPresent(renderer); /* put it all on the screen! */
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include <signal.h>
|
||||
#include <atomic>
|
||||
|
||||
struct app_state {};
|
||||
|
||||
std::atomic<bool> reload_requested(false);
|
||||
|
||||
void reload_signal_handler(int) {
|
||||
@@ -18,7 +16,7 @@ void reload_signal_handler(int) {
|
||||
|
||||
Engine load_hiisi() {
|
||||
const char *name = "build/hiisi/libhiisi-engine.so";
|
||||
void *mod = dlopen(name, RTLD_NOW|RTLD_GLOBAL);
|
||||
void *mod = dlopen(name, RTLD_NOW);
|
||||
|
||||
Lmid_t list;
|
||||
dlinfo(mod, RTLD_DI_LMID, &list);
|
||||
@@ -104,10 +102,9 @@ int main(int argc, char **argv) {
|
||||
while (hiisi.event(&state)) {
|
||||
hiisi.iterate(&state);
|
||||
if (reload_requested) {
|
||||
Engine oldEngine = hiisi;
|
||||
dlclose(hiisi.module);
|
||||
hiisi = load_hiisi();
|
||||
reload_requested = false;
|
||||
// dlclose(oldEngine.module);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "Watching changes in hiisi..."
|
||||
while true; do
|
||||
inotifywait -e modify build/hiisi/libhiisi-engine.so
|
||||
echo "$(date +\"%H:%M:%S\") - Hiisi changed!"
|
||||
|
||||
HIISI_PID=$(pgrep -x hiisi-run)
|
||||
kill -USR1 "${HIISI_PID}" && echo "Signal sent!" || echo "Signal send failed!"
|
||||
done
|
||||
inotifywait --monitor -e modify build/hiisi/ |
|
||||
while read -r _ action file; do
|
||||
sleep 0.1
|
||||
echo "$(date +%H:%M:%S): Hiisi changed!"
|
||||
echo "$action on $file"
|
||||
HIISI_PID=$(pgrep -x hiisi-run)
|
||||
kill -USR1 "${HIISI_PID}" && echo "Signal sent!" || echo "Signal send failed!"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user