From 4a201c81a99a36d037fd94d6b9015b6dec4dbef1 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 22 Feb 2026 20:52:56 +0100 Subject: [PATCH] rendering: Added sdl --- makefile | 2 +- src/config.h | 3 ++- src/lrts.h | 4 ++++ src/p_r_sdl/p_init.c | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/p_r_sdl/p_init.c diff --git a/makefile b/makefile index 44e87dd..c783fa2 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ TEST_NAME=test$(NAME) DBGCFLAGS=-g -fsanitize=address DBGLDFLAGS=-fsanitize=address CFLAGS=-Wall -pedantic $(DBGCFLAGS) -std=c89 -LIBS= +LIBS=-lSDL3 LDFLAGS=$(DBGLDFLAGS) $(LIBS) INSTALL_DIR=/usr/local diff --git a/src/config.h b/src/config.h index cc71b16..cdb4226 100644 --- a/src/config.h +++ b/src/config.h @@ -11,6 +11,7 @@ /* Platform and renderer configuration */ #define LRTS_PLATFORM_POSIX -#define LRTS_RENDERER_CLI +#define LRTS_RENDERER_SDL +/* #define LRTS_RENDERER_CLI */ #endif diff --git a/src/lrts.h b/src/lrts.h index 7fecfc9..d3ee797 100644 --- a/src/lrts.h +++ b/src/lrts.h @@ -34,6 +34,10 @@ #endif +#ifdef LRTS_RENDERER_SDL +#include "p_r_sdl/p_init.c" +#endif + #ifdef LRTS_RENDERER_CLI #include "p_r_cli/p_init.c" #endif diff --git a/src/p_r_sdl/p_init.c b/src/p_r_sdl/p_init.c new file mode 100644 index 0000000..5297589 --- /dev/null +++ b/src/p_r_sdl/p_init.c @@ -0,0 +1,15 @@ +#include "../p_platform.h" +#include + +int p_render_init(void) { + if (!SDL_Init(SDL_INIT_VIDEO)) { + u_fprintf(u_stderr, "Failed to init video: %s\n", + SDL_GetError()); + exit(-1); + } + return 0; +} + +int p_renderer_finish(void) { + return 0; +} -- 2.30.2