From ef06af793a6f48af60375690f419cae094d16970 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Sun, 3 Mar 2019 18:54:25 +0000 Subject: [PATCH] Don't apply the color table unless a texture is bound --- GL/state.c | 15 ++++++++++----- GL/texture.c | 6 ++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/GL/state.c b/GL/state.c index 0fcfd81..8c63127 100644 --- a/GL/state.c +++ b/GL/state.c @@ -221,9 +221,6 @@ void _glUpdatePVRTextureContext(pvr_poly_cxt_t* context, GLshort textureUnit) { } else { context->txr.enable = PVR_TEXTURE_DISABLE; } - - /* Apply the texture palette if necessary */ - _glApplyColorTable(); } static GLboolean LIGHTING_ENABLED = GL_FALSE; @@ -301,8 +298,12 @@ GLAPI void APIENTRY glEnable(GLenum cap) { case GL_COLOR_MATERIAL: COLOR_MATERIAL_ENABLED = GL_TRUE; break; - case GL_SHARED_TEXTURE_PALETTE_EXT: + case GL_SHARED_TEXTURE_PALETTE_EXT: { SHARED_PALETTE_ENABLED = GL_TRUE; + + /* Apply the texture palette if necessary */ + _glApplyColorTable(); + } break; case GL_LIGHT0: case GL_LIGHT1: @@ -351,8 +352,12 @@ GLAPI void APIENTRY glDisable(GLenum cap) { case GL_COLOR_MATERIAL: COLOR_MATERIAL_ENABLED = GL_FALSE; break; - case GL_SHARED_TEXTURE_PALETTE_EXT: + case GL_SHARED_TEXTURE_PALETTE_EXT: { SHARED_PALETTE_ENABLED = GL_FALSE; + + /* Restore whatever palette may exist on a bound texture */ + _glApplyColorTable(); + } break; case GL_LIGHT0: case GL_LIGHT1: diff --git a/GL/texture.c b/GL/texture.c index b683533..f2d6f8b 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -255,6 +255,9 @@ void APIENTRY glBindTexture(GLenum target, GLuint texture) { } TEXTURE_UNITS[ACTIVE_TEXTURE] = (TextureObject*) named_array_get(&TEXTURE_OBJECTS, texture); + + /* Apply the texture palette if necessary */ + _glApplyColorTable(); } else { TEXTURE_UNITS[ACTIVE_TEXTURE] = NULL; } @@ -1028,6 +1031,9 @@ GLAPI void APIENTRY glColorTableEXT(GLenum target, GLenum internalFormat, GLsize src += sourceStride; dst += 4; } + + /* Apply the texture palette if necessary */ + _glApplyColorTable(); } GLAPI void APIENTRY glColorSubTableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data) {