From debea8cfeccc653029feb85933642ab01c9afeba Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sun, 10 Oct 2021 02:40:21 -0400 Subject: [PATCH] Wait until window is exposed before getting surface. (Initial screen draw could be incomplete without this.) --- sdl2/pdcscrn.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdl2/pdcscrn.c b/sdl2/pdcscrn.c index 903735c5..14bb0c29 100644 --- a/sdl2/pdcscrn.c +++ b/sdl2/pdcscrn.c @@ -159,6 +159,7 @@ int _get_displaynum(void) int PDC_scr_open(void) { + SDL_Event event; int displaynum = 0; PDC_LOG(("PDC_scr_open() - called\n")); @@ -293,6 +294,13 @@ int PDC_scr_open(void) SDL_PumpEvents(); + /* Wait until window is exposed before getting surface */ + + while (SDL_PollEvent(&event)) + if (SDL_WINDOWEVENT == event.type && + SDL_WINDOWEVENT_EXPOSED == event.window.event) + break; + if (!pdc_screen) { pdc_screen = SDL_GetWindowSurface(pdc_window);