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