From 6b5f7b4763ef5a28c270095ded70d720fd4b5b8e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 23 Apr 2019 13:05:33 +0300 Subject: [PATCH] - destroy SDL window on Vulkan to OpenGL fallback https://forum.zdoom.org/viewtopic.php?t=64412 --- src/posix/sdl/sdlglvideo.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 47580f830..78f545216 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -145,6 +145,14 @@ namespace Priv } } + void DestroyWindow() + { + assert(Priv::window != nullptr); + + SDL_DestroyWindow(Priv::window); + Priv::window = nullptr; + } + void SetupPixelFormat(int multisample, const int *glver) { SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); @@ -276,6 +284,11 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer () } catch (CRecoverableError const&) { + if (Priv::window != nullptr) + { + Priv::DestroyWindow(); + } + Priv::vulkanEnabled = false; } } @@ -428,8 +441,7 @@ SystemGLFrameBuffer::SystemGLFrameBuffer(void *hMonitor, bool fullscreen) GLContext = SDL_GL_CreateContext(Priv::window); if (GLContext == nullptr) { - SDL_DestroyWindow(Priv::window); - Priv::window = nullptr; + Priv::DestroyWindow(); } else { @@ -447,8 +459,7 @@ SystemGLFrameBuffer::~SystemGLFrameBuffer () SDL_GL_DeleteContext(GLContext); } - SDL_DestroyWindow(Priv::window); - Priv::window = nullptr; + Priv::DestroyWindow(); } }