small refactor
This commit is contained in:
+8
-6
@@ -23,9 +23,15 @@ static void key_callback(Window *window, int key,
|
||||
}
|
||||
}
|
||||
|
||||
void loop(Window *window, ShaderProgram program) {
|
||||
void loop(Window *window, ShaderProgram program, bool hot_reload,
|
||||
File fragment_shader) {
|
||||
Context context;
|
||||
|
||||
if (hot_reload && should_update_file(&fragment_shader)) {
|
||||
update_file(&fragment_shader);
|
||||
update_program(program, fragment_shader);
|
||||
}
|
||||
|
||||
context = get_window_context(window);
|
||||
|
||||
apply_program(program, context);
|
||||
@@ -54,11 +60,7 @@ void forge_run(Parameters params) {
|
||||
}
|
||||
|
||||
while (!window_should_close(window)) {
|
||||
if (params.hot_reload && should_update_file(&fragment_shader)) {
|
||||
update_file(&fragment_shader);
|
||||
update_program(program, fragment_shader);
|
||||
}
|
||||
loop(window, program);
|
||||
loop(window, program, params.hot_reload, fragment_shader);
|
||||
}
|
||||
|
||||
close_window(window, true);
|
||||
|
||||
Reference in New Issue
Block a user