From 58d8064ce2beb470ed36ea6bf4b0ac5bed8d0079 Mon Sep 17 00:00:00 2001 From: pixel Date: Thu, 2 Feb 2006 17:29:04 +0000 Subject: Having a better texture tainting solution, which will hopefully avoid texture mess when going fullscreen. --- lib/texture.cc | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'lib/texture.cc') diff --git a/lib/texture.cc b/lib/texture.cc index 45e9f3b..aa927c8 100644 --- a/lib/texture.cc +++ b/lib/texture.cc @@ -17,9 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: texture.cc,v 1.13 2006-02-02 14:09:49 pixel Exp $ */ - -#define DEBUG +/* $Id: texture.cc,v 1.14 2006-02-02 17:29:05 pixel Exp $ */ #include #include @@ -32,8 +30,6 @@ #endif #include "gettext.h" -#define DEBUG 1 - mogltk::texture * mogltk::texture::header = 0; mogltk::texture * mogltk::texture::footer = 0; @@ -82,9 +78,7 @@ mogltk::texture::texture(Handle * h, bool plane) throw (GeneralException) : width = temp->w; height = temp->h; -#ifdef DEBUG printm(M_INFO, "Creating texture from file: size %ix%i\n", height, width); -#endif if ((!ISPOT(width)) || (!ISPOT(height))) { SDL_FreeSurface(temp); @@ -143,9 +137,7 @@ mogltk::texture::texture(SDL_Surface * temp, bool plane) throw (GeneralException width = temp->w; height = temp->h; -#ifdef DEBUG printm(M_INFO, "Creating texture from file: size %ix%i\n", height, width); -#endif if ((!ISPOT(width)) || (!ISPOT(height))) { throw GeneralException(_("Size of the texture not a power of 2!")); @@ -273,9 +265,8 @@ void mogltk::texture::Generate() { } glGenTextures(1, &tex); -#ifdef DEBUG - printm(M_INFO, _("Generated texture index: %i\n"), tex); -#endif + + printm(M_INFO, "Generated texture " + name + " with index " + tex + "\n"); glBindTexture(GL_TEXTURE_2D, tex); @@ -288,9 +279,6 @@ void mogltk::texture::Generate() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels); } else { -#endif -#ifdef DEBUG - printm(M_INFO, _("Generating 3D texture: %i\n"), tex); #endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -360,12 +348,20 @@ void mogltk::texture::Unbind(void) { } void mogltk::texture::Taint(void) { - if (taintable) + if (taintable) { + printm(M_INFO, "Tainting texture " + name + "\n"); tainted = true; + if (active == this) + Unbind(); + if (texture_allocated) { + glDeleteTextures(1, &tex); + texture_allocated = false; + } + } } void mogltk::texture::Taintall(void) { - active = 0; + Unbind(); if (header) header->recTaint(); } -- cgit v1.2.3