Skip to content

Commit 8114a4c

Browse files
authored
Merge pull request scp-fs2open#7493 from Goober5000/fix/supernova_clip
clip the supernova whiteout to the letterbox
2 parents 0856b82 + 49d6f7a commit 8114a4c

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

freespace2/freespace.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,21 @@ void game_sunspot_process(float frametime)
821821
}
822822

823823

824+
// Top/bottom bar height for the "dead view" / supernova letterbox
825+
static int dead_view_letterbox_yborder()
826+
{
827+
return gr_screen.max_h / 4;
828+
}
829+
830+
// Apply the clip rect for the "dead view" / supernova letterbox interior
831+
static void set_dead_view_letterbox_clip()
832+
{
833+
int yborder = dead_view_letterbox_yborder();
834+
// Numeric constants encouraged by J "pig farmer" S, who shall remain semi-anonymous.
835+
// J.S. I've changed my ways!! See the new "no constants" code!!!
836+
gr_set_clip(0, yborder, gr_screen.max_w, gr_screen.max_h - yborder*2, GR_RESIZE_NONE);
837+
}
838+
824839
/**
825840
* Call once a frame to diminish the flash effect to 0.
826841
* @param frametime Period over which to dimish at ::DIMINISH_RATE
@@ -904,7 +919,18 @@ static void game_flash_diminish(float frametime)
904919
if ( b < 0 ) b = 0; else if ( b > 255 ) b = 255;
905920

906921
if ( (r!=0) || (g!=0) || (b!=0) ) {
922+
// the letterbox bars are drawn earlier in the frame, but game_render_hud calls gr_reset_clip()
923+
// before this runs, so the flash would paint over the bars unless we re-apply the letterbox clip
924+
bool letterbox_active = (Game_mode & GM_DEAD) || (supernova_stage() >= SUPERNOVA_STAGE::HIT);
925+
if (letterbox_active) {
926+
set_dead_view_letterbox_clip();
927+
}
928+
907929
gr_flash( r, g, b );
930+
931+
if (letterbox_active) {
932+
gr_reset_clip();
933+
}
908934
}
909935
}
910936

@@ -2575,18 +2601,15 @@ void game_set_view_clip(float /*frametime*/)
25752601
if ((Game_mode & GM_DEAD) || (supernova_stage() >= SUPERNOVA_STAGE::HIT))
25762602
{
25772603
// Set the clip region for the letterbox "dead view"
2578-
int yborder = gr_screen.max_h/4;
2579-
25802604
if (g3_in_frame() == 0) {
2605+
int yborder = dead_view_letterbox_yborder();
25812606
// Ensure that the bars are black
25822607
gr_set_color(0,0,0);
25832608
gr_set_bitmap(0); // Valathil - Don't ask me why this has to be here but otherwise the black bars don't draw
25842609
gr_rect(0, 0, gr_screen.max_w, yborder, GR_RESIZE_NONE);
25852610
gr_rect(0, gr_screen.max_h-yborder, gr_screen.max_w, yborder, GR_RESIZE_NONE);
25862611
} else {
2587-
// Numeric constants encouraged by J "pig farmer" S, who shall remain semi-anonymous.
2588-
// J.S. I've changed my ways!! See the new "no constants" code!!!
2589-
gr_set_clip(0, yborder, gr_screen.max_w, gr_screen.max_h - yborder*2, GR_RESIZE_NONE );
2612+
set_dead_view_letterbox_clip();
25902613
}
25912614
}
25922615
else {

0 commit comments

Comments
 (0)