]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texunit.cpp
Alter the working logic of Bufferable to avoid some problems
[libs/gl.git] / source / texunit.cpp
index dde3d406ca71fcbb5cfa034805a91a9784da6fe7..d581598a6c190e2caf46c59d11140d403c30e79b 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdexcept>
 #include "extension.h"
 #include "gl.h"
 #include "texunit.h"
@@ -14,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)
 {
@@ -30,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;
@@ -48,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);