]> git.tdb.fi Git - libs/gl.git/commitdiff
Make TexUnits aware of their incides
authorMikko Rasa <tdb@tdb.fi>
Wed, 27 Nov 2013 08:30:26 +0000 (10:30 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 27 Nov 2013 08:30:26 +0000 (10:30 +0200)
source/texunit.cpp
source/texunit.h

index aa52aed4525a1c398aa2cf6f08793388074a723f..2b3418fee43cb4fe7a7f0276ad2f6ffdb2d602ea 100644 (file)
@@ -72,7 +72,12 @@ TexUnit &TexUnit::activate(unsigned n)
                throw out_of_range("TexUnit::activate");
 
        if(units.size()<=n)
+       {
+               unsigned i = units.size();
                units.resize(n+1);
+               for(; i<units.size(); ++i)
+                       units[i].index = i;
+       }
 
        if(cur_unit!=&units[n] && (cur_unit || n))
                glActiveTexture(GL_TEXTURE0+n);
index 82c4b5795baafa5a095e1eb126b0b146ba5b5f63..93f6dd085e80497450aae252c9dda4618211eccd 100644 (file)
@@ -13,6 +13,7 @@ class Texture;
 class TexUnit
 {
 private:
+       unsigned index;
        const Texture *texture;
        const TexEnv *texenv;
        const TexGen *texgen[4];
@@ -23,6 +24,7 @@ private:
 public:
        TexUnit();
 
+       unsigned get_index() const { return index; }
        bool set_texture(const Texture *);
        const Texture *get_texture() const { return texture; }
        bool set_texenv(const TexEnv *);