Given that new/delete on such small objects are cheap and this happens
rarely, it is probably not worth the extra complexity. (In the process,
fix a minor bug related to out-of-memory; not that new will actually
ever return NULL on any compilers newer then MSVC6.)
-
- // Recycle a glsl_texture with deleted glTexture.
- glsl_texture gtex = 0;
- for (int i = 0; i < texture_list.count(); ++i) {
- glsl_texture tex = (glsl_texture) texture_list.peek(i);
- if (!tex->used && !tex->width && !tex->height) {
- gtex = tex;
- break;
- }
- }
unlock();
GLuint tex = 0;
glGenTextures(1, &tex);
if (!tex) {
unlock();
GLuint tex = 0;
glGenTextures(1, &tex);
if (!tex) {
- glDeleteTextures(1, &tex);
+ glsl_texture gtex = new glsl_texture_s;
- gtex = new glsl_texture_s;
- if (!gtex)
- return NULL;
+ glDeleteTextures(1, &tex);
+ return NULL;
}
glBindTexture( GL_TEXTURE_2D, tex );
}
glBindTexture( GL_TEXTURE_2D, tex );
void GlslManager::cleanupContext()
{
lock();
void GlslManager::cleanupContext()
{
lock();
- for (int i = 0; i < texture_list.count(); ++i) {
- glsl_texture texture = (glsl_texture) texture_list.peek(i);
+ while (texture_list.peek_back()) {
+ glsl_texture texture = (glsl_texture) texture_list.peek_back();
glDeleteTextures(1, &texture->texture);
glDeleteTextures(1, &texture->texture);
- texture->used = 0;
- texture->width = 0;
- texture->height = 0;
+ delete texture;
+ texture_list.pop_back();
}
if (pbo) {
glDeleteBuffers(1, &pbo->pbo);
}
if (pbo) {
glDeleteBuffers(1, &pbo->pbo);