diff --git a/source/build/src/glsurface.cpp b/source/build/src/glsurface.cpp index 3704b4f5b..3f26e5c77 100644 --- a/source/build/src/glsurface.cpp +++ b/source/build/src/glsurface.cpp @@ -67,7 +67,6 @@ bool glsurface_initialize(vec2_t bufferResolution) bufferTexture = GLInterface.NewTexture(); bufferTexture->CreateTexture(bufferRes.x, bufferRes.y, true, false); - GLInterface.Init(); glsurface_setPalette(curpalettefaded); const char* const VERTEX_SHADER_CODE = diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 64fda1a25..beb2f38b9 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -794,8 +794,6 @@ void polymost_glinit() //glEnable(GL_LINE_SMOOTH); globalflags |= GLOBAL_NO_GL_TILESHADES; // This re-enables the old fading logic without re-adding the r_usetileshades variable. The entire thing will have to be done on a more abstract level anyway. - GLInterface.Init(); - GLInterface.mSamplers->SetTextureFilterMode(gltexfiltermode, glanisotropy); #ifdef USE_GLEXT diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 183068b7e..5d59d1b5f 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -17,6 +17,7 @@ #include "sdl_inc.h" #include "softsurface.h" #include "m_argv.h" +#include "../../glbackend/glbackend.h" #ifdef USE_OPENGL # include "glad/glad.h" @@ -569,11 +570,13 @@ int32_t videoSetVsync(int32_t newSync) else #endif { + /* vsync_renderlayer = newSync; videoResetMode(); if (videoSetGameMode(fullscreen, xres, yres, bpp, upscalefactor)) OSD_Printf("restartvid: Reset failed...\n"); + */ } return newSync; @@ -1395,6 +1398,11 @@ void sdlayer_setvideomode_opengl(void) glinfo.dumped = 1; bpp = oldbpp; } + + GLInterface.Deinit(); + GLInterface.Init(); + GLInterface.mSamplers->SetTextureFilterMode(gltexfiltermode, glanisotropy); + } #endif // defined USE_OPENGL @@ -1508,10 +1516,15 @@ void setrefreshrate(void) refreshfreq = error ? -1 : newmode.refresh_rate; } +int called = 0; int32_t videoSetMode(int32_t x, int32_t y, int32_t c, int32_t fs) { int32_t regrab = 0, ret; + if (called++) + { + assert(0); + } ret = setvideomode_sdlcommon(&x, &y, c, fs, ®rab); if (ret != 1) { diff --git a/source/glbackend/gl_samplers.cpp b/source/glbackend/gl_samplers.cpp index 08f66c5ad..d5080ad9e 100644 --- a/source/glbackend/gl_samplers.cpp +++ b/source/glbackend/gl_samplers.cpp @@ -75,7 +75,7 @@ FSamplerManager::~FSamplerManager() void FSamplerManager::UnbindAll() { - for (int i = 0; i < 8 /* fixme */; i++) + for (int i = 0; i < 16 /* fixme */; i++) { glBindSampler(i, 0); } diff --git a/source/glbackend/gl_samplers.h b/source/glbackend/gl_samplers.h index b650396d0..95cd05405 100644 --- a/source/glbackend/gl_samplers.h +++ b/source/glbackend/gl_samplers.h @@ -25,6 +25,7 @@ class FSamplerManager unsigned int mSamplers[NumSamplers]; void UnbindAll(); + void CreateSamplers(); public: diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 08c804b1d..e2140aa1c 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -2,6 +2,7 @@ #include "glad/glad.h" #include "gl_samplers.h" + GLInstance GLInterface; void GLInstance::Init() @@ -16,6 +17,7 @@ void GLInstance::Init() void GLInstance::Deinit() { if (mSamplers) delete mSamplers; + mSamplers = nullptr; } std::pair GLInstance::AllocVertices(size_t num)