This commit is contained in:
Rakarake 2026-01-03 17:12:24 +01:00
parent 9cf8be1561
commit 164c8dd15f
3 changed files with 25 additions and 5 deletions

View file

@ -14,12 +14,14 @@
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
name = "glonkers";
src = ./.;
buildInputs = with pkgs; [
nativeBuildInputs = with pkgs; [
pkg-config
libGL
wayland
wayland-protocols
wayland-scanner
wayland-protocols
wayland
];
buildInputs = with pkgs; [
libGL
];
installPhase = ''
mkdir -p $out/bin

View file

@ -134,9 +134,24 @@ Renderer new_renderer() {
return renderer;
}
int shader_file_was_modified(Renderer *state) {
struct stat buf;
stat(state->shader_path, &buf);
int modified = buf.st_mtime != state->shader_file_modified.st_mtime;
if (modified) {
state->shader_file_modified = buf;
}
return modified;
}
/// shader_path cannot be NULL.
void render(Renderer *state, int w, int h, double time, char *shader_path, int reload_shader) {
if (reload_shader || strcmp(state->shader_path, shader_path)) {
int m = shader_file_was_modified(state);
if (m) {
printf("AWOOGA\n");
}
if (m || reload_shader || strcmp(state->shader_path, shader_path)) {
state->shader = load_shader(shader_path);
state->shader_path = shader_path;
}

View file

@ -1,10 +1,13 @@
#ifndef RENDERER_H
#define RENDERER_H
#include <sys/stat.h>
typedef struct Renderer {
char *shader_path;
unsigned int shader;
unsigned int vao;
struct stat shader_file_modified;
} Renderer;
Renderer new_renderer();