From 37ec8d030f500f2b7075f4b11930abe2e3531486 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 1 Nov 2022 12:47:50 +0000 Subject: [PATCH] Fix loading screen glitches --- Source/diablo.cpp | 10 +++++++++- Source/interfac.cpp | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 15e616dda..459fb9a64 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -704,8 +704,16 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) LastMouseButtonAction = MouseActionType::None; sgbMouseDown = CLICK_NONE; ShowProgress(GetCustomEvent(event.type)); + RedrawEverything(); - DrawAndBlit(); + if (!HeadlessMode) { + while (IsRedrawEverything()) { + // In direct rendering mode with double/triple buffering, we need + // to prepare all buffers before fading in. + DrawAndBlit(); + } + } + LoadPWaterPalette(); if (gbRunGame) PaletteFadeIn(8); diff --git a/Source/interfac.cpp b/Source/interfac.cpp index d5203e396..bd1ded376 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -467,6 +467,17 @@ void ShowProgress(interface_mode uMsg) if (!HeadlessMode) { assert(ghMainWnd); + if (RenderDirectlyToOutputSurface && PalSurface != nullptr) { + // Ensure that all back buffers have the full progress bar. + const void *initialPixels = PalSurface->pixels; + do { + DrawCutsceneForeground(); + if (DiabloUiSurface() == PalSurface) + BltFast(nullptr, nullptr); + RenderPresent(); + } while (PalSurface->pixels != initialPixels); + } + PaletteFadeOut(8); }