TINYGL: Changed the way tinyGL textures are disposed.

This commit is contained in:
Stefano Musumeci 2014-07-25 12:59:51 +02:00
parent f0de01af01
commit 2b3fd8501a
3 changed files with 13 additions and 1 deletions

View File

@ -54,6 +54,7 @@ GLTexture *alloc_texture(GLContext *c, int h) {
*ht = t; *ht = t;
t->handle = h; t->handle = h;
t->disposed = false;
return t; return t;
} }
@ -258,7 +259,8 @@ void tglDeleteTextures(int n, const unsigned int *textures) {
if (t == c->current_texture) { if (t == c->current_texture) {
tglBindTexture(TGL_TEXTURE_2D, 0); tglBindTexture(TGL_TEXTURE_2D, 0);
} }
TinyGL::free_texture(c, textures[i]); t->disposed = true;
//TinyGL::free_texture(c, textures[i]);
} }
} }
} }

View File

@ -138,6 +138,7 @@ struct GLTexture {
GLImage images[MAX_TEXTURE_LEVELS]; GLImage images[MAX_TEXTURE_LEVELS];
int handle; int handle;
struct GLTexture *next, *prev; struct GLTexture *next, *prev;
bool disposed;
}; };

View File

@ -10,6 +10,15 @@ void tglPresentBuffer() {
} }
c->drawCallsQueue.clear(); c->drawCallsQueue.clear();
TinyGL::GLTexture *t = c->shared_state.texture_hash_table[0];
while (t) {
int handle = t->handle;
if (t->disposed) {
TinyGL::free_texture(c, handle);
}
t = t->next;
}
Graphics::Internal::tglCleanupImages(); Graphics::Internal::tglCleanupImages();
} }