+bool TexUnit::set_texenv(const TexEnv *env)
+{
+ bool result = (texenv!=env);
+ 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;
+ if(count<0)
+ {
+ if(is_version_at_least(2, 0) || is_supported("ARB_vertex_shader"))
+ glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &count);
+ else if(is_version_at_least(1, 3))
+ glGetIntegerv(GL_MAX_TEXTURE_UNITS, &count);
+ else
+ count = 1;
+ }
+ return count;
+}
+