diff --git a/src/display.cpp b/src/display.cpp index 207a26df0db..62758124dbe 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -2546,6 +2546,11 @@ void display::render() // It is not responsible for halos and floating labels. //DBG_DP << "display::render" << endl; + // No need to render if we aren't going to draw anything. + if(prevent_draw_) { + return; + } + // render to the offscreen buffer auto target_setter = draw::set_render_target(front_); draw(); @@ -2569,6 +2574,10 @@ bool display::expose(const SDL_Rect& region) // Note: clipping region is set by draw_manager, // and will be contained by . + if(prevent_draw_) { + return false; + } + // Blit from the pre-rendered front buffer. // TODO: draw_manager - API to get src region in output space rect src_region = region; diff --git a/src/display.hpp b/src/display.hpp index f075c8eda6b..4a5bcde9734 100644 --- a/src/display.hpp +++ b/src/display.hpp @@ -563,6 +563,15 @@ public: /** Checks if location @a loc or one of the adjacent tiles is visible on screen. */ bool tile_nearly_on_screen(const map_location &loc) const; + // TODO: draw_manager - this isn't really the correct solution + /** Prevent the game display from drawing. + * Used while story screen is showing to prevent flicker. */ + void set_prevent_draw(bool pd) { prevent_draw_ = pd; } + +private: + bool prevent_draw_ = false; + +public: /** Screen fade */ void fade_to(const color_t& color, int duration); void set_fade(const color_t& color); diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 29c89f1335c..826b8cd212d 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -242,6 +242,7 @@ void play_controller::init(const config& level) map_start_ = map_location(level.child_or_empty("display").child_or_empty("location")); if(start_faded_) { gui_->set_fade({0,0,0,255}); + gui_->set_prevent_draw(true); } // Ensure the loading screen doesn't end up underneath the game display diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index 62356c276f7..231947da199 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -130,6 +130,7 @@ void playsingle_controller::init_gui() } // Fade in + gui_->set_prevent_draw(false); if(!gui_->video().any_fake()) { gui_->fade_to({0,0,0,0}, 500); } else {