summaryrefslogtreecommitdiff
path: root/lib/gltexture.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gltexture.cc')
-rw-r--r--lib/gltexture.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/gltexture.cc b/lib/gltexture.cc
index f33fe98..564ffad 100644
--- a/lib/gltexture.cc
+++ b/lib/gltexture.cc
@@ -11,6 +11,8 @@ mogltk::texture * mogltk::texture::header = 0;
mogltk::texture * mogltk::texture::footer = 0;
#endif
+mogltk::texture * mogltk::texture::active = 0;
+
mogltk::texture::texture(int w, int h, bool plane) throw (GeneralException) : width(w), height(h),
texture_allocated(false), planar(plane), tainted(true) {
if ((BITCOUNT(w) != 1) || (BITCOUNT(h) != 1))
@@ -116,8 +118,10 @@ void mogltk::texture::Bind(bool expand) {
if ((!texture_allocated) || tainted)
Generate();
glEnable(GL_TEXTURE_2D);
+ if (active == this)
+ return;
#ifdef DEBUG
- printm(M_INFO, "Binding texture index %i\n", tex);
+ printm(M_INFO, "Binding texture index %i.\n", tex);
#endif
glBindTexture(GL_TEXTURE_2D, tex);
if (expand) {
@@ -127,6 +131,8 @@ void mogltk::texture::Bind(bool expand) {
glMatrixMode(GL_MODELVIEW);
}
+ active = this;
+
#ifdef TRACE_TEXTURES
if (header == this)
return;
@@ -158,6 +164,10 @@ GLuint mogltk::texture::GetHeight() {
void mogltk::texture::Unbind(void) {
glDisable(GL_TEXTURE_2D);
+ active = 0;
+#ifdef DEBUG
+ printm(M_INFO, "Unbinding texture.\n");
+#endif
}
void mogltk::texture::Taint(void) {