summaryrefslogtreecommitdiff
path: root/lib/texture.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/texture.cc')
-rw-r--r--lib/texture.cc30
1 files changed, 13 insertions, 17 deletions
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 <sys/types.h>
#include <SDL.h>
@@ -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);
@@ -289,9 +280,6 @@ void mogltk::texture::Generate() {
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);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
@@ -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();
}