2 #include <msp/gl/extensions/arb_multitexture.h>
3 #include <msp/gl/extensions/arb_vertex_shader.h>
14 vector<TexUnit> TexUnit::units;
15 TexUnit *TexUnit::cur_unit = 0;
22 bool TexUnit::set_texture(const Texture *tex)
24 bool result = (tex!=texture);
29 bool TexUnit::set_sampler(const Sampler *samp)
31 bool result = (samp!=sampler);
38 if(cur_unit!=this && (cur_unit || index))
39 glActiveTexture(GL_TEXTURE0+index);
43 unsigned TexUnit::get_n_units()
45 static int count = -1;
49 count = get_i(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
50 else if(ARB_multitexture)
51 count = get_i(GL_MAX_TEXTURE_UNITS);
58 TexUnit &TexUnit::get_unit(unsigned n)
61 static Require _req(ARB_multitexture);
63 throw out_of_range("TexUnit::get_unit");
67 unsigned i = units.size();
68 units.resize(n+1, TexUnit());
69 for(; i<units.size(); ++i)
76 TexUnit &TexUnit::current()
83 TexUnit *TexUnit::find_unit(const Texture *tex)
85 for(vector<TexUnit>::iterator i=units.begin(); i!=units.end(); ++i)