This commit is contained in:
Rakarake 2025-12-08 03:57:28 +01:00
parent 0d3340713c
commit 27b04eb7d4
3 changed files with 33 additions and 3 deletions

View file

@ -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

View file

@ -15,10 +15,11 @@
src = ./.;
naitiveBuildInputs = with pkgs; [
gcc
pkg-config
];
buildInputs = with pkgs; [
pkg-config
sdl3
libGL
];
installPhase = ''
mkdir -p $out/bin

31
main.c
View file

@ -1,5 +1,34 @@
#include <stdio.h>
#include <GL/gl.h>
#include <SDL3/SDL.h>
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);
}
}