diff --git a/Makefile b/Makefile index b6be04f..4de79bb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: - $(CC) -o glonkers main.c $(pkg-config --cflags --libs sdl3) + $(CC) -o glonkers main.c $(pkg-config --cflags --libs sdl3 opengl) run: all ./glonkers diff --git a/flake.nix b/flake.nix index 3cd7762..dbbdc1e 100644 --- a/flake.nix +++ b/flake.nix @@ -15,10 +15,11 @@ src = ./.; naitiveBuildInputs = with pkgs; [ gcc - pkg-config ]; buildInputs = with pkgs; [ + pkg-config sdl3 + libGL ]; installPhase = '' mkdir -p $out/bin diff --git a/main.c b/main.c index 203721a..6eb7bfb 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,34 @@ #include +#include +#include int main() { - printf("hi"); + printf("Good Morning 🍵\n"); + SDL_Init(SDL_INIT_VIDEO); + SDL_Window* window = SDL_CreateWindow("SDL3 OpenGL Cube", + 800, 600, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); + if (!window) { + printf("CreateWindow Error: %s\n", SDL_GetError()); + SDL_Quit(); + return 1; + } + + SDL_GLContext glContext = SDL_GL_CreateContext(window); + if (!glContext) { + printf("GL Context Error: %s\n", SDL_GetError()); + SDL_DestroyWindow(window); + SDL_Quit(); + return 1; + } + glEnable(GL_DEPTH_TEST); + + SDL_Event e; + int running = 1; + while (SDL_PollEvent(&e)) { + if (e.type == SDL_EVENT_QUIT) running = false; + // Rendorrrr + glViewport(0, 0, 800, 600); + glClearColor(0.1f, 0.1f, 0.1f, 1.0f); // Dark gray background + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } }