From f0981aa6b09e67ec57b7cb92421513415292e97f Mon Sep 17 00:00:00 2001 From: pixel Date: Tue, 17 Dec 2002 00:09:50 +0000 Subject: Commit of the day... --- lib/gltexture.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/gltexture.cc') 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) { -- cgit v1.2.3