2 #include <msp/gl/extensions/arb_multitexture.h>
3 #include <msp/gl/extensions/arb_vertex_shader.h>
13 vector<TexUnit> TexUnit::units;
14 TexUnit *TexUnit::cur_unit = 0;
20 fill(texgen, texgen+4, static_cast<const TexGen *>(0));
23 bool TexUnit::set_texture(const Texture *tex)
25 bool result = (tex!=texture);
30 bool TexUnit::set_texenv(const TexEnv *env)
32 bool result = (texenv!=env);
37 bool TexUnit::set_texgen(unsigned i, const TexGen *gen)
40 throw out_of_range("TexUnit::set_texgen");
41 bool result = (texgen[i]!=gen);
46 const TexGen *TexUnit::get_texgen(unsigned i)
49 throw out_of_range("TexUnit::get_texgen");
55 if(cur_unit!=this && (cur_unit || index))
56 glActiveTexture(GL_TEXTURE0+index);
60 unsigned TexUnit::get_n_units()
62 static int count = -1;
66 count = get_i(GL_MAX_TEXTURE_IMAGE_UNITS);
67 else if(ARB_multitexture)
68 count = get_i(GL_MAX_TEXTURE_UNITS);
75 TexUnit &TexUnit::get_unit(unsigned n)
78 static Require _req(ARB_multitexture);
80 throw out_of_range("TexUnit::get_unit");
84 unsigned i = units.size();
86 for(; i<units.size(); ++i)
93 TexUnit &TexUnit::current()
100 TexUnit *TexUnit::find_unit(const Texture *tex)
102 for(vector<TexUnit>::iterator i=units.begin(); i!=units.end(); ++i)
108 TexUnit *TexUnit::find_unit(const TexEnv *env)
110 for(vector<TexUnit>::iterator i=units.begin(); i!=units.end(); ++i)