From ec5f1c1b5f0ce57a2f823579abfee7ed65bd67ef Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 25 Jan 2021 18:11:18 +0100 Subject: [PATCH] Fixed the annoying white screen flashing when starting the application. --- es-core/src/renderers/Renderer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index 45af73e9a..537d9baec 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -212,6 +212,12 @@ namespace Renderer return false; } + // Create a black surface which will avoid the white screen that would otherwise flash + // by briefly before the splash screen is rendered when using some graphics drivers. + SDL_Surface* blackSurface = SDL_GetWindowSurface(sdlWindow); + SDL_FillRect(blackSurface, nullptr, SDL_MapRGB(blackSurface->format, 0x00, 0x00, 0x00)); + SDL_UpdateWindowSurface(sdlWindow); + LOG(LogInfo) << "Setting up OpenGL..."; if (!createContext()) @@ -324,7 +330,6 @@ namespace Renderer setViewport(viewport); setProjection(projection); - swapBuffers(); return true; } @@ -426,7 +431,7 @@ namespace Renderer vertices[3] = { { _x + _wL, _y + _hL }, { 0.0f, 0.0f }, colorEnd }; // Round vertices. - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; i++) vertices[i].pos.round(); if (_opacity < 1.0) {