]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texenv.cpp
Object model for Material and TexEnv
[libs/gl.git] / source / texenv.cpp
diff --git a/source/texenv.cpp b/source/texenv.cpp
new file mode 100644 (file)
index 0000000..6e5cca7
--- /dev/null
@@ -0,0 +1,43 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2008  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "texenv.h"
+#include "texunit.h"
+
+namespace Msp {
+namespace GL {
+
+TexEnv::TexEnv():
+       mode(MODULATE)
+{ }
+
+void TexEnv::set_mode(TexEnvMode m)
+{
+       mode=m;
+}
+
+void TexEnv::set_color(const Color &c)
+{
+       color=c;
+}
+
+void TexEnv::bind()
+{
+       if(TexUnit::current().set_texenv(this))
+       {
+               glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
+               glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &color.r);
+       }
+}
+
+void TexEnv::unbind()
+{
+       TexUnit::current().set_texenv(0);
+}
+
+} // namespace GL
+} // namespace Msp