trying to read commands from std while displaying things, fixes
This commit is contained in:
parent
a32e44f45f
commit
dc791e3481
5 changed files with 43 additions and 9 deletions
11
renderer.c
11
renderer.c
|
|
@ -68,12 +68,16 @@ GLuint create_shader(const char *fragment_src) {
|
|||
|
||||
GLuint load_shader(const char *path) {
|
||||
FILE *handle = fopen(path, "r");
|
||||
if (handle == NULL) {
|
||||
printf("failed to open shader file\n");
|
||||
exit(1);
|
||||
}
|
||||
fseek(handle, 0L, SEEK_END);
|
||||
long length = ftell(handle);
|
||||
fseek(handle, 0L, SEEK_SET);
|
||||
char *string = malloc(length * sizeof(char));
|
||||
if (!fread(string, sizeof(char), length, handle)) {
|
||||
printf("failed to read shader file");
|
||||
printf("failed to read shader file\n");
|
||||
exit(1);
|
||||
}
|
||||
fclose(handle);
|
||||
|
|
@ -143,9 +147,10 @@ Renderer new_renderer() {
|
|||
}
|
||||
|
||||
/// shader_path cannot be NULL.
|
||||
void render(Renderer *state, int w, int h, double time, char *shader_path) {
|
||||
if (strcmp(state->shader_path, shader_path)) {
|
||||
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)) {
|
||||
state->shader = load_shader(shader_path);
|
||||
state->shader_path = shader_path;
|
||||
}
|
||||
|
||||
checkGlError();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue