diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index c1b39e5563..20f6f469f4 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -278,6 +278,12 @@ void FGLRenderer::BindTonemapPalette(int texunit) } } +void FGLRenderer::ClearTonemapPalette() +{ + delete mTonemapPalette; + mTonemapPalette = nullptr; +} + //----------------------------------------------------------------------------- // // Apply lens distortion and place the result in the HUD/2D texture diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index fba3a09eac..d154766d68 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -111,6 +111,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) gllight = glpart2 = glpart = mirrortexture = NULL; mLights = NULL; m2DDrawer = nullptr; + mTonemapPalette = nullptr; } void gl_LoadModels(); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index da2a11ed0e..4b663680f6 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -167,6 +167,7 @@ public: void BloomScene(); void TonemapScene(); void BindTonemapPalette(int texunit); + void ClearTonemapPalette(); void LensDistortScene(); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); void Flush() { CopyToBackbuffer(nullptr, true); } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index ec8b3f599e..ae1fabaed9 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -310,6 +310,9 @@ void OpenGLFrameBuffer::UpdatePalette() bb>>=8; palette_brightness = (rr*77 + gg*143 + bb*35)/255; + + if (GLRenderer) + GLRenderer->ClearTonemapPalette(); } void OpenGLFrameBuffer::GetFlashedPalette (PalEntry pal[256])