Check for texid >= 0 before accessing texture arrays.
PiperOrigin-RevId: 659567553 Change-Id: Ia4aaa85b85e3f27e632c03a9f50b10894d29a97b
This commit is contained in:
committed by
Copybara-Service
parent
0610c1d0e9
commit
4dc8f884de
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user