From b1a0108a961ec24ec7af922b60355947c453e31f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 25 Aug 2016 19:58:50 +0200 Subject: [PATCH] Fix tonemap palette not being rebuilt on palette change --- src/gl/renderer/gl_postprocess.cpp | 6 ++++++ src/gl/renderer/gl_renderer.cpp | 1 + src/gl/renderer/gl_renderer.h | 1 + src/gl/system/gl_framebuffer.cpp | 3 +++ 4 files changed, 11 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index c1b39e556..20f6f469f 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 fba3a09ea..d154766d6 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 da2a11ed0..4b663680f 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 ec8b3f599..ae1fabaed 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])