summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDaniel Hader <[email protected]>2026-06-14 12:58:14 -0500
committerDaniel Hader <[email protected]>2026-06-14 12:58:14 -0500
commit482ea0261cb9f0def49ce3df542b2a7f811262d1 (patch)
tree3bb961316b2ca856409b9f3b2145036ae9f5d704 /src/main.c
build and test environment using makefile and basic SDL3 setup
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..d57a434
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,67 @@
+#include "input.h"
+#include <SDL3/SDL.h>
+#include <SDL3/SDL_video.h>
+
+struct LEO_App {
+ SDL_Window *window;
+ SDL_GLContext gl_context;
+};
+
+int LEO_App_init(struct LEO_App *app)
+{
+ if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
+ return 1;
+ }
+
+ app->window = SDL_CreateWindow("title", 640, 480, SDL_WINDOW_OPENGL);
+ if (app->window == NULL) {
+ return 2;
+ }
+
+ app->gl_context = SDL_GL_CreateContext(app->window);
+ if (app->gl_context == NULL) {
+ return 3;
+ }
+
+ return 0;
+}
+
+void LEO_App_run(struct LEO_App *app)
+{
+ SDL_Event event;
+ while (true) {
+ while (SDL_PollEvent(&event))
+ LEO_Input_update(event);
+
+ if (LEO_Input_quit())
+ break;
+
+ SDL_GL_SwapWindow(app->window);
+
+ SDL_Delay(10);
+ }
+}
+
+void LEO_App_free(struct LEO_App *app)
+{
+ if (app->gl_context != NULL)
+ SDL_GL_DestroyContext(app->gl_context);
+
+ if (app->window != NULL)
+ SDL_DestroyWindow(app->window);
+
+ SDL_Quit();
+}
+
+int main(int argc, char **argv)
+{
+ struct LEO_App app;
+ if (LEO_App_init(&app)) {
+ SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "failed to init app: %s", SDL_GetError());
+ }
+
+ LEO_App_run(&app);
+
+ LEO_App_free(&app);
+ return 0;
+}