From 31ed419dfa0271612e663a914075026c6b2f1f23 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Thu, 28 Feb 2019 18:28:43 +0000 Subject: [PATCH] Don't allow zero as a valid texture ID --- GL/texture.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/GL/texture.c b/GL/texture.c index e1f2d3a..cf5dea5 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -240,14 +240,14 @@ void APIENTRY glBindTexture(GLenum target, GLuint texture) { return; } - /* If this didn't come from glGenTextures, then we should initialize the - * texture the first time it's bound */ - if(!named_array_used(&TEXTURE_OBJECTS, texture)) { - TextureObject* txr = named_array_reserve(&TEXTURE_OBJECTS, texture); - _glInitializeTextureObject(txr, texture); - } - if(texture) { + /* If this didn't come from glGenTextures, then we should initialize the + * texture the first time it's bound */ + if(!named_array_used(&TEXTURE_OBJECTS, texture)) { + TextureObject* txr = named_array_reserve(&TEXTURE_OBJECTS, texture); + _glInitializeTextureObject(txr, texture); + } + TEXTURE_UNITS[ACTIVE_TEXTURE] = (TextureObject*) named_array_get(&TEXTURE_OBJECTS, texture); } else { TEXTURE_UNITS[ACTIVE_TEXTURE] = NULL;