diff --git a/src/stagedraw.c b/src/stagedraw.c index d7dab067..a8540914 100644 --- a/src/stagedraw.c +++ b/src/stagedraw.c @@ -54,6 +54,7 @@ static struct { PostprocessShader *viewport_pp; FBPair fb_pairs[NUM_FBPAIRS]; FBPair powersurge_fbpair; + FBPair *current_postprocess_fbpair; bool framerate_graphs; bool objpool_stats; @@ -352,11 +353,15 @@ void stage_draw_shutdown(void) { stage_draw_destroy_framebuffers(); } -FBPair* stage_get_fbpair(StageFBPair id) { +FBPair *stage_get_fbpair(StageFBPair id) { assert(id >= 0 && id < NUM_FBPAIRS); return stagedraw.fb_pairs + id; } +FBPair *stage_get_postprocess_fbpair(void) { + return NOT_NULL(stagedraw.current_postprocess_fbpair); +} + static void stage_draw_collision_areas(void) { #ifdef DEBUG static bool enabled, keystate_saved; @@ -1005,8 +1010,7 @@ void stage_draw_scene(StageInfo *stage) { coevent_signal(&stagedraw.events.background_drawn); // draw bomb background - // FIXME: we need a more flexible and consistent way for entities to hook - // into the various stages of scene drawing code. + // TODO: remove this; use events if(global.plr.mode->procs.bombbg /*&& player_is_bomb_active(&global.plr)*/) { global.plr.mode->procs.bombbg(&global.plr); } @@ -1023,7 +1027,12 @@ void stage_draw_scene(StageInfo *stage) { fbpair_swap(foreground); r_blend(BLEND_NONE); + stagedraw.current_postprocess_fbpair = foreground; + + coevent_signal(&stagedraw.events.postprocess_before_overlay); + // bomb effects shader if present and player bombing + // TODO: remove this; use events if(global.plr.mode->procs.bomb_shader && player_is_bomb_active(&global.plr)) { ShaderRule rules[] = { global.plr.mode->procs.bomb_shader, NULL }; apply_shader_rules(rules, foreground); @@ -1033,6 +1042,8 @@ void stage_draw_scene(StageInfo *stage) { // this stuff is not affected by the screen shake effect stage_draw_overlay(); + coevent_signal(&stagedraw.events.postprocess_after_overlay); + // stage postprocessing apply_shader_rules(global.stage->procs->postprocess_rules, foreground); @@ -1047,6 +1058,8 @@ void stage_draw_scene(StageInfo *stage) { NULL ); + stagedraw.current_postprocess_fbpair = NULL; + // prepare for 2D rendering into the main framebuffer (actual screen) r_framebuffer(video_get_screen_framebuffer()); set_ortho(SCREEN_W, SCREEN_H); diff --git a/src/stagedraw.h b/src/stagedraw.h index 5c93d7e6..eec7623f 100644 --- a/src/stagedraw.h +++ b/src/stagedraw.h @@ -23,7 +23,9 @@ typedef enum StageFBPair { } StageFBPair; typedef COEVENTS_ARRAY( - background_drawn + background_drawn, + postprocess_before_overlay, + postprocess_after_overlay ) StageDrawEvents; void stage_draw_pre_init(void); @@ -46,6 +48,7 @@ bool stage_should_draw_particle(Projectile *p); void stage_display_clear_screen(const StageClearBonus *bonus); FBPair *stage_get_fbpair(StageFBPair id) attr_returns_nonnull; +FBPair *stage_get_postprocess_fbpair(void) attr_returns_nonnull; Framebuffer *stage_add_foreground_framebuffer(const char *label, float scale_worst, float scale_best, uint num_attachments, FBAttachmentConfig attachments[num_attachments]); Framebuffer *stage_add_background_framebuffer(const char *label, float scale_worst, float scale_best, uint num_attachments, FBAttachmentConfig attachments[num_attachments]);