From 1b932fddaf57b496c856ff8ec81ea786cb9261fe Mon Sep 17 00:00:00 2001 From: pogokeen Date: Sat, 14 Jul 2018 21:36:34 +0000 Subject: [PATCH] sdlayer.cpp: Don't destroy window resouces if switching between software rendering on glsurface and Polymost/Polymer git-svn-id: https://svn.eduke32.com/eduke32@6938 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/engine.cpp | 1 - source/build/src/glsurface.cpp | 4 ++++ source/build/src/sdlayer.cpp | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index c51ae5991..bd5a8c252 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -9941,7 +9941,6 @@ int32_t videoSetGameMode(char davidoption, int32_t daxdim, int32_t daydim, int32 if (videoGetRenderMode() >= REND_POLYMOST) { - //POGOTODO: if we switch to software & then back to GL, this call tries to delete textures that were already lost from the GL Context deletion polymost_glreset(); polymost_glinit(); } diff --git a/source/build/src/glsurface.cpp b/source/build/src/glsurface.cpp index 5344ae245..1150a1263 100644 --- a/source/build/src/glsurface.cpp +++ b/source/build/src/glsurface.cpp @@ -171,11 +171,15 @@ void glsurface_destroy() glDeleteBuffers(1, &quadVertsID); quadVertsID = 0; + glDisableVertexAttribArray(0); + glDisableVertexAttribArray(1); + glDeleteTextures(1, &bufferTexID); bufferTexID = 0; glDeleteTextures(1, &paletteTexID); paletteTexID = 0; + glUseProgram(0); glDeleteProgram(shaderProgramID); shaderProgramID = 0; } diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index fd7acc90d..8e6ddaadd 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -1453,8 +1453,13 @@ int32_t setvideomode_sdlcommon(int32_t *x, int32_t *y, int32_t c, int32_t fs, in { if (bpp > 8) polymost_glreset(); - else if (!nogl) + } + if (!nogl) + { + if (bpp == 8) glsurface_destroy(); + if ((fs == fullscreen) && (*x == xres) && (*y == yres) && (bpp != 0) && !videomodereset) + return 0; } #endif @@ -1586,7 +1591,14 @@ int32_t videoSetMode(int32_t x, int32_t y, int32_t c, int32_t fs) int32_t regrab = 0, ret; ret = setvideomode_sdlcommon(&x, &y, c, fs, ®rab); - if (ret != 1) return ret; + if (ret != 1) + { + if (ret == 0) + { + setvideomode_sdlcommonpost(x, y, c, fs, regrab); + } + return ret; + } // deinit destroy_window_resources();