diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-10-20 23:23:40 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-10-20 23:23:40 -0700 |
commit | 624b0a06edf7114950476a8ce79fff9927b1fc62 (patch) | |
tree | 159c9570df9c0bfdafe8f04c6b039fa8290b09a8 /src/pig.c | |
parent | 90ce0330f586dd7c0114beed6775ea6d47cf7c67 (diff) |
pig: show sad face on shader errors
Introduces sad-node.[ch] implementing a simple sad face shader node,
normally inactive but made active when the shader files fail to reload.
Diffstat (limited to 'src/pig.c')
-rw-r--r-- | src/pig.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -27,6 +27,7 @@ #include "m4f.h" #include "macros.h" #include "pig.h" +#include "sad-node.h" #include "shader-node.h" #include "shader.h" @@ -63,8 +64,12 @@ static void pig_uniforms_func(shader_t *shader, void *uniforms_ctxt, void *rende unsigned t0, t1; float r = randf(); - if (play_ticks_elapsed(play, PLAY_TICKS_TIMER2, 1000)) - shader_reload_files(shader); + if (play_ticks_elapsed(play, PLAY_TICKS_TIMER2, 1000)) { + if (shader_reload_files(shader) < 0) + stage_set_active(pig->sadface, 1); + else + stage_set_active(pig->sadface, 0); + } /* this one just keeps increasing */ t0 = play_ticks(play, PLAY_TICKS_TIMER0); @@ -212,6 +217,17 @@ static void * pig_init(play_t *play, int argc, char *argv[], unsigned flags) &pig->color ); + pig->sadface = sad_node_new(&(stage_conf_t){ + .parent = pig->stage, + .name = "sadface", + .layer = 3, + .active = 0, + .alpha = 1.f, + }, + &pig->transform, + &pig->color + ); + (void) shader_node_new_files(&(stage_conf_t){ .parent = pig->stage, .name = "shader", |