From e6bdc84343eb931e368adc4d1713dd91f1d6073e Mon Sep 17 00:00:00 2001 From: Lorenzo Torres Date: Sat, 1 Nov 2025 16:32:49 +0100 Subject: [PATCH] refactoring --- {opengl => gl}/gl.c | 0 {opengl => gl}/gl.h | 0 {opengl => gl}/khrplatform.h | 0 {opengl => gl}/platform.c | 11 +++++++++-- makefile | 2 +- platform.h | 1 + types.h | 19 +++++++++++++++++++ utils.h | 5 +++++ 8 files changed, 35 insertions(+), 3 deletions(-) rename {opengl => gl}/gl.c (100%) rename {opengl => gl}/gl.h (100%) rename {opengl => gl}/khrplatform.h (100%) rename {opengl => gl}/platform.c (79%) create mode 100644 types.h create mode 100644 utils.h diff --git a/opengl/gl.c b/gl/gl.c similarity index 100% rename from opengl/gl.c rename to gl/gl.c diff --git a/opengl/gl.h b/gl/gl.h similarity index 100% rename from opengl/gl.h rename to gl/gl.h diff --git a/opengl/khrplatform.h b/gl/khrplatform.h similarity index 100% rename from opengl/khrplatform.h rename to gl/khrplatform.h diff --git a/opengl/platform.c b/gl/platform.c similarity index 79% rename from opengl/platform.c rename to gl/platform.c index 2d0517e..8bdc580 100644 --- a/opengl/platform.c +++ b/gl/platform.c @@ -3,8 +3,15 @@ #define RGFW_OPENGL #include "../rgfw.h" -int platform_run(int argc, char **argv) +/* + * This function is the entrypoint for the whole + * game. Its role is to initialize OpenGL, create + * the renderer and start the game loop. + */ +int platform_run(i32 argc, u8 **argv) { + (void) argc; + (void) argv; RGFW_glHints* hints = RGFW_getGlobalHints_OpenGL(); hints->major = 3; @@ -24,7 +31,7 @@ int platform_run(int argc, char **argv) RGFW_window_setExitKey(win, RGFW_escape); - const GLubyte *version = glGetString(GL_VERSION); + const u8 *version = glGetString(GL_VERSION); printf("OpenGL Version: %s\n", version); printf("GLAD Version: %d.%d\n", GLAD_VERSION_MAJOR(glad_version), GLAD_VERSION_MINOR(glad_version)); diff --git a/makefile b/makefile index e3792bc..c8c97aa 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ include config.mk SRC:=topaz.c ifeq (${BACKEND},gl) - SRC += opengl/gl.c opengl/platform.c + SRC += gl/gl.c gl/platform.c endif OBJ:=${SRC:.c=.o} diff --git a/platform.h b/platform.h index e524f24..664235f 100644 --- a/platform.h +++ b/platform.h @@ -1,6 +1,7 @@ #ifndef PLATFORM_H #define PLATFORM_H +/* Check out gl/platform.c or vk/platform.c */ int platform_run(int argc, char **argv); #endif diff --git a/types.h b/types.h new file mode 100644 index 0000000..cff5630 --- /dev/null +++ b/types.h @@ -0,0 +1,19 @@ +#ifndef TYPES_H +#define TYPES_H + +#include +#include + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +typedef int8_t i8; +typedef int16_t i16; +typedef int32_t i32; +typedef int64_t i64; + +typedef size_t usize; + +#endif diff --git a/utils.h b/utils.h new file mode 100644 index 0000000..2b8a367 --- /dev/null +++ b/utils.h @@ -0,0 +1,5 @@ +#ifndef UTILS_H +#define UTILS_H + + +#endif