[Bf-committers] glGetIntegerv(GL_TEXTURE_2D. &id) is incorrect.

Jason Wilkins jason.a.wilkins at gmail.com
Tue Jul 23 00:44:48 CEST 2013

GL_TEXTURE_2D is the enable bit, not the bound texture.

So, the code...

glGetIntegerv(GL_TEXTURE_2D. &prev_tex_id)

... also sometimes written as ...

prev_tex_id = glaGetOneInteger(GL_TEXTURE_2D)

... is incorrect, I think what is meant is the binding state...

glGetIntegerv(GL_TEXTURE_BINDING_2D, &prev_tex_id)

... or ...

prev_tex_id = glaGetOneInteger(GL_TEXTURE_BINDING_2D)

The fact that Blender still works tells me that this code (and the later
code rebinding the previous texture) is probably unneeded and can be
removed.  It must be that all functions that draw with a texture map do not
call other functions that change the texture before they need the previous
texture again.

This is especially apparent since any call to a function that has this bug
will result in the bound texture being either 0 or 1 (The value of GL_FALSE
and GL_TRUE).

More information about the Bf-committers mailing list