From a0faeaf8f6b829c69af11012ec72f87108893505 Mon Sep 17 00:00:00 2001 From: pogokeen Date: Mon, 25 Jun 2018 14:53:42 +0000 Subject: [PATCH] Revert a number of changes from r6929 and r6930 that are no longer necessary. Fix root causes of issues causing crash and black screen in Mapster32 when switching back and forth between 3D & 2D modes git-svn-id: https://svn.eduke32.com/eduke32@6931 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/build.cpp | 2 +- source/build/src/engine.cpp | 23 +++++++++++++---------- source/build/src/glsurface.cpp | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source/build/src/build.cpp b/source/build/src/build.cpp index 9b72842c9..e2e6ee44b 100644 --- a/source/build/src/build.cpp +++ b/source/build/src/build.cpp @@ -769,7 +769,7 @@ int app_main(int argc, char const * const * argv) g_videoBrightness = 0.0; videoSetPalette(0,0,0); - if (videoSetGameMode(fullscreen, xdim2d, ydim2d, bppgame) < 0) + if (videoSetGameMode(fullscreen, xdim2d, ydim2d, 8) < 0) { CallExtUnInit(); engineUnInit(); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index a36863970..c51ae5991 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -9825,6 +9825,14 @@ static void videoAllocateBuffers(void) ysavecnt = YSAVES; nodesperline = tabledivide32_noinline(YSAVES, ydim); + +#ifdef USE_OPENGL + extern char nogl; + if (videoGetRenderMode() == REND_CLASSIC && !nogl) + { + glsurface_initialize({xdim, ydim}); + } +#endif } #ifdef USE_OPENGL @@ -9899,11 +9907,6 @@ int32_t videoSetGameMode(char davidoption, int32_t daxdim, int32_t daydim, int32 #ifdef USE_OPENGL fxdim = (float) daxdim; fydim = (float) daydim; - - if (videoGetRenderMode() == REND_CLASSIC && !nogl) - { - glsurface_initialize({xdim, ydim}); - } #endif videoAllocateBuffers(); @@ -12759,21 +12762,21 @@ void videoSet2dMode(int32_t daxdim, int32_t daydim) ydim = yres; #ifdef USE_OPENGL - extern char nogl; - fxdim = (float) xres; fydim = (float) yres; - if (!nogl) - glsurface_initialize({ xres, yres }); + rendmode = REND_CLASSIC; #endif + videoAllocateBuffers(); ydim16 = yres - STATUS2DSIZ2; halfxdim16 = xres >> 1; midydim16 = ydim16 >> 1; // scale(200,yres,480); - videoClearScreen(0L); + videoBeginDrawing(); //{{{ + Bmemset((char *)frameplace, 0, yres*bytesperline); + videoEndDrawing(); //}}} } qsetmode = ((daxdim<<16)|(daydim&0xffff)); diff --git a/source/build/src/glsurface.cpp b/source/build/src/glsurface.cpp index 2a3d00340..4c861b0f0 100644 --- a/source/build/src/glsurface.cpp +++ b/source/build/src/glsurface.cpp @@ -85,6 +85,7 @@ bool glsurface_initialize(vec2_t inputBufferResolution) glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); + glActiveTexture(GL_TEXTURE0); glGenTextures(1, &bufferTexID); glBindTexture(GL_TEXTURE_2D, bufferTexID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);