From a280c20b4eb7b378ae8e404d5d80112b47cffc3d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 Aug 2014 19:00:17 +0200 Subject: [PATCH] - fixed: If we want to cache texture binding state we have to reset it in all places where a texture becomes unbound. --- src/gl/system/gl_wipe.cpp | 1 + src/gl/textures/gl_hwtexture.cpp | 1 + src/gl/textures/gl_material.cpp | 5 +++++ src/gl/textures/gl_material.h | 1 + 4 files changed, 8 insertions(+) diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index 57ad3ba89..53af826bd 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -240,6 +240,7 @@ void OpenGLFrameBuffer::WipeCleanup() delete wipeendscreen; wipeendscreen = NULL; } + FMaterial::ClearLastTexture(); } //========================================================================== diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index d076f6a3e..f491169b4 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -403,6 +403,7 @@ void FHardwareTexture::UnbindAll() { Unbind(texunit); } + FMaterial::ClearLastTexture(); } //=========================================================================== diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 503c0b793..efbbec332 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -753,6 +753,7 @@ void FMaterial::BindToFrameBuffer() // must create the hardware texture first mBaseLayer->Bind(0, 0, 0, false, NULL); FHardwareTexture::Unbind(0); + ClearLastTexture(); } mBaseLayer->mHwTexture->BindToFrameBuffer(); } @@ -809,3 +810,7 @@ void FMaterial::FlushAll() } } +void FMaterial::ClearLastTexture() +{ + last = NULL; +} diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 714ab5a03..dfdbeb743 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -253,6 +253,7 @@ public: static void FlushAll(); static FMaterial *ValidateTexture(FTexture * tex, bool expand); static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans); + static void ClearLastTexture(); };