From: Mikko Rasa Date: Thu, 28 Nov 2013 11:11:35 +0000 (+0200) Subject: Give TexEnv a default object since it can't be disabled X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=dcd8bd3a16a4af8e77aa84877b3f8a4fb03b8c7e;p=libs%2Fgl.git Give TexEnv a default object since it can't be disabled --- diff --git a/source/texenv.cpp b/source/texenv.cpp index ff77e8ce..ff9ea197 100644 --- a/source/texenv.cpp +++ b/source/texenv.cpp @@ -5,9 +5,16 @@ namespace Msp { namespace GL { TexEnv::TexEnv(): - mode(MODULATE) + mode(MODULATE), + color(0, 0, 0, 0) { } +const TexEnv &TexEnv::default_object() +{ + static TexEnv obj; + return obj; +} + void TexEnv::set_mode(TexEnvMode m) { mode = m; @@ -40,14 +47,7 @@ const TexEnv *TexEnv::current(unsigned i) void TexEnv::unbind_from(unsigned i) { - TexUnit &unit = TexUnit::get_unit(i); - if(unit.set_texenv(0)) - { - unit.bind(); - Color black(0, 0, 0, 0); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, MODULATE); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &black.r); - } + default_object().bind_to(i); } } // namespace GL diff --git a/source/texenv.h b/source/texenv.h index 1327bb85..55a12f30 100644 --- a/source/texenv.h +++ b/source/texenv.h @@ -25,6 +25,9 @@ private: public: TexEnv(); + + static const TexEnv &default_object(); + void set_mode(TexEnvMode); void set_color(const Color &); TexEnvMode get_mode() const { return mode; }