Skip to content

Commit

Permalink
textures: ignore texture 0 in glDeleteTextures()
Browse files Browse the repository at this point in the history
Ths OpenGL spec says that the texture index 0 must be silently ignored
by glDeleteTextures(). Failure to ignore this value was causing weird
artifacts with text labels in Neverball.

We also invert the logic of the "if" condition, to make it easier to
read.
  • Loading branch information
mardy committed Nov 9, 2024
1 parent b32a714 commit c2f84c9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void glDeleteTextures(GLsizei n, const GLuint *textures)
GX_DrawDone();
while (n-- > 0) {
int i = *texlist++;
if (!(i < 0 || i >= _MAX_GL_TEX)) {
if (i > 0 && i < _MAX_GL_TEX) {
void *data = GX_GetTexObjData(&texture_list[i].texobj);
if (data != 0)
free(MEM_PHYSICAL_TO_K0(data));
Expand Down

0 comments on commit c2f84c9

Please sign in to comment.