Fix bugs in texture deletion
This commit is contained in:
parent
c4c0bf4239
commit
462eb40d7a
34
GL/texture.c
34
GL/texture.c
|
@ -559,15 +559,27 @@ void APIENTRY glGenTextures(GLsizei n, GLuint *textures) {
|
||||||
void APIENTRY glDeleteTextures(GLsizei n, GLuint *textures) {
|
void APIENTRY glDeleteTextures(GLsizei n, GLuint *textures) {
|
||||||
TRACE();
|
TRACE();
|
||||||
|
|
||||||
while(n--) {
|
gl_assert(TEXTURE_OBJECTS.element_size > 0);
|
||||||
TextureObject* txr = (TextureObject*) named_array_get(&TEXTURE_OBJECTS, *textures);
|
|
||||||
|
for(GLsizei i = 0; i < n; ++i) {
|
||||||
|
GLuint id = textures[i];
|
||||||
|
if(id == 0) {
|
||||||
|
/* Zero is the "default texture" and we never allow deletion of it */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextureObject* txr = (TextureObject*) named_array_get(&TEXTURE_OBJECTS, id);
|
||||||
|
|
||||||
if(txr) {
|
if(txr) {
|
||||||
/* Make sure we update framebuffer objects that have this texture attached */
|
gl_assert(txr->index == id);
|
||||||
_glWipeTextureOnFramebuffers(*textures);
|
|
||||||
|
|
||||||
if(txr == TEXTURE_UNITS[ACTIVE_TEXTURE]) {
|
/* Make sure we update framebuffer objects that have this texture attached */
|
||||||
TEXTURE_UNITS[ACTIVE_TEXTURE] = NULL;
|
_glWipeTextureOnFramebuffers(id);
|
||||||
|
|
||||||
|
for(GLuint j = 0; j < MAX_GLDC_TEXTURE_UNITS; ++j) {
|
||||||
|
if(txr == TEXTURE_UNITS[j]) {
|
||||||
|
TEXTURE_UNITS[j] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(txr->data) {
|
if(txr->data) {
|
||||||
|
@ -588,12 +600,14 @@ void APIENTRY glDeleteTextures(GLsizei n, GLuint *textures) {
|
||||||
free(txr->palette);
|
free(txr->palette);
|
||||||
txr->palette = NULL;
|
txr->palette = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
named_array_release(&TEXTURE_OBJECTS, id);
|
||||||
|
textures[i] = 0;
|
||||||
|
txr->index = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
named_array_release(&TEXTURE_OBJECTS, *textures);
|
gl_assert(TEXTURE_OBJECTS.element_size > 0);
|
||||||
*textures = 0;
|
|
||||||
textures++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APIENTRY glBindTexture(GLenum target, GLuint texture) {
|
void APIENTRY glBindTexture(GLenum target, GLuint texture) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user