X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexenv.cpp;fp=source%2Ftexenv.cpp;h=0000000000000000000000000000000000000000;hb=f1b12c992db974c679d85ae6ec22cd318199d0d5;hp=c8af55f85febad1b22c5560efb0c7f688fca405e;hpb=67538c60b8baa6816b8ae2d343ae62d881e6c58d;p=libs%2Fgl.git diff --git a/source/texenv.cpp b/source/texenv.cpp deleted file mode 100644 index c8af55f8..00000000 --- a/source/texenv.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "texenv.h" -#include "texunit.h" - -namespace Msp { -namespace GL { - -TexEnv::TexEnv(): - mode(MODULATE), - color(0, 0, 0, 0) -{ } - -TexEnv::~TexEnv() -{ - if(this!=&default_object()) - { - while(TexUnit *unit = TexUnit::find_unit(this)) - unbind_from(unit->get_index()); - } -} - -const TexEnv &TexEnv::default_object() -{ - static TexEnv obj; - return obj; -} - -void TexEnv::update_parameter(int mask) const -{ - if(TexUnit::current().get_texenv()!=this) - { - TexUnit *unit = TexUnit::find_unit(this); - if(!unit) - return; - - unit->bind(); - } - - if(mask&MODE) - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode); - if(mask&COLOR) - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &color.r); -} - -void TexEnv::set_mode(TexEnvMode m) -{ - mode = m; - update_parameter(MODE); -} - -void TexEnv::set_color(const Color &c) -{ - color = c; - update_parameter(COLOR); -} - -void TexEnv::bind_to(unsigned i) const -{ - TexUnit &unit = TexUnit::get_unit(i); - if(unit.set_texenv(this)) - { - unit.bind(); - update_parameter(-1); - } -} - -const TexEnv *TexEnv::current(unsigned i) -{ - return TexUnit::get_unit(i).get_texenv(); -} - -void TexEnv::unbind_from(unsigned i) -{ - default_object().bind_to(i); -} - -} // namespace GL -} // namespace Msp