From cfb7d1fdb274109e4ca7474d19faa5e174f607c8 Mon Sep 17 00:00:00 2001 From: ewasylishen Date: Sun, 13 Dec 2015 07:23:04 +0000 Subject: [PATCH] GLSLGamma_GammaCorrect: clear the cached texture binding in GL_Bind properly, after the glBindTexture calls earlier in this function. Fixes a obscure bug where: - a bsp with no textures (pink checkerboard displayed) - gamma != 1 - nothing else on screen (sbar hidden, r_drawviewmodel 0) would result in the screen turning to noise. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1263 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/gl_rmain.c | 2 +- quakespasm/Quake/gl_texmgr.c | 18 ++++++++++++++++++ quakespasm/Quake/gl_texmgr.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/quakespasm/Quake/gl_rmain.c b/quakespasm/Quake/gl_rmain.c index fad620b4..908425a6 100644 --- a/quakespasm/Quake/gl_rmain.c +++ b/quakespasm/Quake/gl_rmain.c @@ -251,7 +251,7 @@ void GLSLGamma_GammaCorrect (void) GL_UseProgramFunc (0); // clear cached binding - GL_Bind (notexture); + GL_ClearBindings (); } /* diff --git a/quakespasm/Quake/gl_texmgr.c b/quakespasm/Quake/gl_texmgr.c index c1fc9d3f..7a18d48b 100644 --- a/quakespasm/Quake/gl_texmgr.c +++ b/quakespasm/Quake/gl_texmgr.c @@ -1521,3 +1521,21 @@ static void GL_DeleteTexture (gltexture_t *texture) texture->texnum = 0; } + +/* +================ +GL_ClearBindings -- ericw + +Invalidates cached bindings, so the next GL_Bind calls for each TMU will +make real glBindTexture calls. +Call this after changing the binding outside of GL_Bind. +================ +*/ +void GL_ClearBindings(void) +{ + int i; + for (i = 0; i < 3; i++) + { + currenttexture[i] = -1; + } +} diff --git a/quakespasm/Quake/gl_texmgr.h b/quakespasm/Quake/gl_texmgr.h index f772df30..6597b0cc 100644 --- a/quakespasm/Quake/gl_texmgr.h +++ b/quakespasm/Quake/gl_texmgr.h @@ -104,6 +104,7 @@ void GL_SelectTexture (GLenum target); void GL_DisableMultitexture (void); //selects texture unit 0 void GL_EnableMultitexture (void); //selects texture unit 1 void GL_Bind (gltexture_t *texture); +void GL_ClearBindings (void); #endif /* _GL_TEXMAN_H */