From deb451e04c703615d19fd5c3b6863499c09ae2ba Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 7 Oct 2017 23:56:10 +0200 Subject: [PATCH] improved displaying FPS (debug mode only) --- src/game.c | 5 +++++ src/tools.c | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/game.c b/src/game.c index bc402eca..ce4fd8cb 100644 --- a/src/game.c +++ b/src/game.c @@ -11227,8 +11227,13 @@ void GameActionsExt() fps_frames = 0; fps_counter = Counter(); + /* always draw FPS to screen after FPS value was updated */ redraw_mask |= REDRAW_FPS; } + + /* only draw FPS if no screen areas are deactivated (invisible warp mode) */ + if (GetDrawDeactivationMask() == REDRAW_NONE) + redraw_mask |= REDRAW_FPS; } } diff --git a/src/tools.c b/src/tools.c index d15f800e..324bd45b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -622,11 +622,24 @@ void DrawFramesPerSecond() char text[100]; int font_nr = FONT_TEXT_2; int font_width = getFontWidth(font_nr); + int draw_deactivation_mask = GetDrawDeactivationMask(); + boolean draw_masked = (draw_deactivation_mask == REDRAW_NONE); - sprintf(text, "%04.1f fps", global.frames_per_second); + /* draw FPS with leading space (needed if field buffer deactivated) */ + sprintf(text, " %04.1f fps", global.frames_per_second); - DrawTextExt(backbuffer, WIN_XSIZE - font_width * strlen(text), 0, text, - font_nr, BLIT_OPAQUE); + /* override draw deactivation mask (required for invisible warp mode) */ + SetDrawDeactivationMask(REDRAW_NONE); + + /* draw opaque FPS if field buffer deactivated, else draw masked FPS */ + DrawTextExt(backbuffer, SX + SXSIZE - font_width * strlen(text), SY, text, + font_nr, (draw_masked ? BLIT_MASKED : BLIT_OPAQUE)); + + /* set draw deactivation mask to previous value */ + SetDrawDeactivationMask(draw_deactivation_mask); + + /* force full-screen redraw in this frame */ + redraw_mask = REDRAW_ALL; } #if DEBUG_FRAME_TIME -- 2.34.1