make sdl unremovable

This commit is contained in:
Kasper Sauramo
2025-03-13 17:28:48 +02:00
parent 4a393035a2
commit e84760fb8f
4 changed files with 17 additions and 17 deletions

View File

@@ -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! */

View File

@@ -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);
}
}