diff --git a/src/render/render_gl3.c b/src/render/render_gl3.c index 06ded789..b00003ae 100644 --- a/src/render/render_gl3.c +++ b/src/render/render_gl3.c @@ -95,7 +95,7 @@ static void settexture(int type, int state, const mjrContext* con, const mjvGeom // explicit texture coordinates else if (type == mjtexREGULAR && geom->texcoord) { // enable - if (state) { + if (state && texid >= 0) { glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, con->texture[texid]); @@ -109,7 +109,7 @@ static void settexture(int type, int state, const mjrContext* con, const mjvGeom } // 2D - else if (type == mjtexREGULAR && con->textureType[texid] == mjTEXTURE_2D) { + else if (type == mjtexREGULAR && texid >= 0 && con->textureType[texid] == mjTEXTURE_2D) { // enable if (state) { glActiveTexture(GL_TEXTURE0); @@ -161,7 +161,7 @@ static void settexture(int type, int state, const mjrContext* con, const mjvGeom // cube or skybox else { // enable - if (state) { + if (state && texid >= 0) { glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_CUBE_MAP); glEnable(GL_TEXTURE_GEN_S);