2 #include <msp/gl/extensions/arb_multitexture.h>
3 #include <msp/gl/extensions/arb_vertex_shader.h>
12 vector<TexUnit> TexUnit::units;
13 TexUnit *TexUnit::cur_unit = 0;
19 fill(texgen, texgen+4, static_cast<const TexGen *>(0));
22 bool TexUnit::set_texture(const Texture *tex)
24 bool result = (tex!=texture);
29 bool TexUnit::set_texenv(const TexEnv *env)
31 bool result = (texenv!=env);
36 bool TexUnit::set_texgen(unsigned i, const TexGen *gen)
39 throw out_of_range("TexUnit::set_texgen");
40 bool result = (texgen[i]!=gen);
45 const TexGen *TexUnit::get_texgen(unsigned i)
48 throw out_of_range("TexUnit::get_texgen");
54 if(cur_unit!=this && (cur_unit || index))
55 glActiveTexture(GL_TEXTURE0+index);
59 unsigned TexUnit::get_n_units()
61 static int count = -1;
65 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &count);
66 else if(ARB_multitexture)
67 glGetIntegerv(GL_MAX_TEXTURE_UNITS, &count);
74 TexUnit &TexUnit::get_unit(unsigned n)
77 static Require _req(ARB_multitexture);
79 throw out_of_range("TexUnit::get_unit");
83 unsigned i = units.size();
85 for(; i<units.size(); ++i)
92 TexUnit &TexUnit::current()
99 TexUnit *TexUnit::find_unit(const Texture *tex)
101 for(vector<TexUnit>::iterator i=units.begin(); i!=units.end(); ++i)
107 TexUnit *TexUnit::find_unit(const TexEnv *env)
109 for(vector<TexUnit>::iterator i=units.begin(); i!=units.end(); ++i)