freedom
This commit is contained in:
parent
9cf8be1561
commit
164c8dd15f
3 changed files with 25 additions and 5 deletions
17
renderer.c
17
renderer.c
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue