]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texunit.cpp
Lots of comment updates
[libs/gl.git] / source / texunit.cpp
index 4d5ff81a297dc9f4d3b1f5dfb564111a3257ecbb..d581598a6c190e2caf46c59d11140d403c30e79b 100644 (file)
@@ -1,10 +1,4 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007-2008  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
+#include <stdexcept>
 #include "extension.h"
 #include "gl.h"
 #include "texunit.h"
@@ -21,7 +15,9 @@ TexUnit *TexUnit::cur_unit = 0;
 TexUnit::TexUnit():
        texture(0),
        texenv(0)
-{ }
+{
+       fill(texgen, texgen+4, static_cast<const TexGen *>(0));
+}
 
 bool TexUnit::set_texture(const Texture *tex)
 {
@@ -37,6 +33,22 @@ bool TexUnit::set_texenv(const TexEnv *env)
        return result;
 }
 
+bool TexUnit::set_texgen(unsigned i, const TexGen *gen)
+{
+       if(i>=4)
+               throw invalid_argument("TexUnit::set_texgen");
+       bool result = (texgen[i]!=gen);
+       texgen[i] = gen;
+       return result;
+}
+
+const TexGen *TexUnit::get_texgen(unsigned i)
+{
+       if(i>=4)
+               throw invalid_argument("TexUnit::get_texgen");
+       return texgen[i];
+}
+
 unsigned TexUnit::get_n_units()
 {
        static int count = -1;
@@ -55,7 +67,7 @@ unsigned TexUnit::get_n_units()
 TexUnit &TexUnit::activate(unsigned n)
 {
        if(n>=get_n_units())
-               throw InvalidParameterValue("Invalid texture unit number");
+               throw out_of_range("TexUnit::activate");
 
        if(units.size()<=n)
                units.resize(n+1);