freedom
This commit is contained in:
parent
9cf8be1561
commit
164c8dd15f
3 changed files with 25 additions and 5 deletions
10
flake.nix
10
flake.nix
|
|
@ -14,12 +14,14 @@
|
||||||
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
|
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
|
||||||
name = "glonkers";
|
name = "glonkers";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
buildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
pkg-config
|
pkg-config
|
||||||
libGL
|
|
||||||
wayland
|
|
||||||
wayland-protocols
|
|
||||||
wayland-scanner
|
wayland-scanner
|
||||||
|
wayland-protocols
|
||||||
|
wayland
|
||||||
|
];
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
libGL
|
||||||
];
|
];
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
|
|
||||||
17
renderer.c
17
renderer.c
|
|
@ -134,9 +134,24 @@ Renderer new_renderer() {
|
||||||
return 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.
|
/// shader_path cannot be NULL.
|
||||||
void render(Renderer *state, int w, int h, double time, char *shader_path, int reload_shader) {
|
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 = load_shader(shader_path);
|
||||||
state->shader_path = shader_path;
|
state->shader_path = shader_path;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
#ifndef RENDERER_H
|
#ifndef RENDERER_H
|
||||||
#define RENDERER_H
|
#define RENDERER_H
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
typedef struct Renderer {
|
typedef struct Renderer {
|
||||||
char *shader_path;
|
char *shader_path;
|
||||||
unsigned int shader;
|
unsigned int shader;
|
||||||
unsigned int vao;
|
unsigned int vao;
|
||||||
|
struct stat shader_file_modified;
|
||||||
} Renderer;
|
} Renderer;
|
||||||
|
|
||||||
Renderer new_renderer();
|
Renderer new_renderer();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue