summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2006-02-02 17:29:04 +0000
committerpixel <pixel>2006-02-02 17:29:04 +0000
commit58d8064ce2beb470ed36ea6bf4b0ac5bed8d0079 (patch)
tree48356a8dd0edaf6c902947746272658f934c7fc1
parentc3b798273403e6dc80245d43d3ae75be5e48946c (diff)
Having a better texture tainting solution, which will hopefully avoid texture mess when going fullscreen.
-rw-r--r--include/texture.h5
-rw-r--r--lib/base.cc3
-rw-r--r--lib/font.cc7
-rw-r--r--lib/glbase.cc3
-rw-r--r--lib/shape.cc4
-rw-r--r--lib/sprite.cc3
-rw-r--r--lib/texture.cc30
7 files changed, 31 insertions, 24 deletions
diff --git a/include/texture.h b/include/texture.h
index 879adce..228f016 100644
--- a/include/texture.h
+++ b/include/texture.h
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: texture.h,v 1.10 2006-01-31 17:02:39 pixel Exp $ */
+/* $Id: texture.h,v 1.11 2006-02-02 17:29:04 pixel Exp $ */
#ifndef __TEXTURE_H__
#define __TEXTURE_H__
@@ -48,6 +48,9 @@ namespace mogltk {
void Taint(void);
static void Taintall(void);
void DumpBMP(const String &);
+
+ String name;
+
private:
GLuint width, height, tex;
bool texture_allocated;
diff --git a/lib/base.cc b/lib/base.cc
index 85606c6..db0e77f 100644
--- a/lib/base.cc
+++ b/lib/base.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: base.cc,v 1.15 2005-04-03 19:39:06 pixel Exp $ */
+/* $Id: base.cc,v 1.16 2006-02-02 17:29:05 pixel Exp $ */
#include <stdio.h>
#include <SDL.h>
@@ -151,6 +151,7 @@ mogltk::texture * mogltk::base::GrabTexture() {
int w = nextpower(GetWidth());
int h = nextpower(GetHeight());
texture * r = new texture(w, h);
+ r->name = "texture grabbed";
SDL_BlitSurface(getsurface(), NULL, r->GetSurface(), NULL);
diff --git a/lib/font.cc b/lib/font.cc
index 8527d15..fab51e4 100644
--- a/lib/font.cc
+++ b/lib/font.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: font.cc,v 1.17 2005-12-01 13:48:12 pixel Exp $ */
+/* $Id: font.cc,v 1.18 2006-02-02 17:29:05 pixel Exp $ */
#include <stdarg.h>
#include <SDL.h>
@@ -150,6 +150,7 @@ mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255), shadow(0), w
for (i = 0; i < nbT; i++) {
fonttex[i] = alloctexture();
+ fonttex[i]->name = "Main font texture number " + String(i);
for (j = 0; j < 15; j++) {
fontcache[j][i] = 0;
}
@@ -605,6 +606,7 @@ mogltk::texture * mogltk::font::printtex(rect * _r, const ugly_string & m, va_li
ph = nextpower(r.h);
t = new texture(pw, ph);
+ t->name = String("Text-on-texture: '") + m.p + "'";
for (p = buffer; *p; p++) {
if (*p == '\n') {
@@ -672,7 +674,7 @@ mogltk::font * mogltk::SystemFont;
mogltk::font * mogltk::FixedFont;
mogltk::texture * mogltk::font::alloctexture() {
- return new mogltk::texture(256, 256);
+ return new texture(256, 256);
}
void mogltk::font::Bind(int f) {
@@ -691,6 +693,7 @@ void mogltk::font::checknbind(int index, ColorP c) {
if (!fontcache[i][index]) {
fontcache[i][index] = alloctexture();
+ fontcache[i][index]->name = "Color font texture number " + String(index);
for (y = 0; y < 256; y++) {
for (x = 0; x < 256; x++) {
t.fromSDL(fontcache[15][index]->GetPixels()[(y << 8) + x], f);
diff --git a/lib/glbase.cc b/lib/glbase.cc
index 2edeec5..89b849a 100644
--- a/lib/glbase.cc
+++ b/lib/glbase.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: glbase.cc,v 1.22 2004-11-27 21:48:03 pixel Exp $ */
+/* $Id: glbase.cc,v 1.23 2006-02-02 17:29:05 pixel Exp $ */
#include <stdio.h>
#include <SDL.h>
@@ -224,6 +224,7 @@ mogltk::texture * mogltk::glbase::GrabTexture() {
int w = nextpower(GetWidth());
int h = nextpower(GetHeight());
texture * r = new texture(w, h);
+ r->name = "Texture grabbed.";
SDL_Surface * t;
t = GrabSurface();
diff --git a/lib/shape.cc b/lib/shape.cc
index 7a3312a..63b0920 100644
--- a/lib/shape.cc
+++ b/lib/shape.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: shape.cc,v 1.20 2005-12-01 13:48:12 pixel Exp $ */
+/* $Id: shape.cc,v 1.21 2006-02-02 17:29:05 pixel Exp $ */
#include <math.h>
#include <limits.h>
@@ -177,6 +177,7 @@ mogltk::texture * mogltk::fill::Talloc() {
for (y = 1; y <= (maxY - minY); y <<= 1);
cached = new texture(x, y, true);
+ cached->name = "Fill-texture - cached";
return cached;
}
@@ -190,6 +191,7 @@ mogltk::texture * mogltk::fill::STalloc() {
for (y = 1; y <= (maxY - minY); y <<= 1);
scached = new texture(x, y, true);
+ cached->name = "Fill-texture - scached";
return scached;
}
diff --git a/lib/sprite.cc b/lib/sprite.cc
index bd0df94..bce6bf2 100644
--- a/lib/sprite.cc
+++ b/lib/sprite.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: sprite.cc,v 1.15 2004-11-27 21:48:03 pixel Exp $ */
+/* $Id: sprite.cc,v 1.16 2006-02-02 17:29:05 pixel Exp $ */
#include <SDL.h>
#include "engine.h"
@@ -85,6 +85,7 @@ void mogltk::Sprite::alloc() {
mogltk::Sprite::TexList::TexList(int size) {
tex = new texture(size, size, true);
+ tex->name = "Sprite texture.";
if (header)
header->prev = this;
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();
}