2 #include <msp/gl/extensions/arb_multitexture.h>
3 #include <msp/gl/extensions/arb_vertex_shader.h>
4 #include <msp/gl/extensions/msp_legacy_features.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);
31 if(cur_unit!=this && (cur_unit || index))
32 glActiveTexture(GL_TEXTURE0+index);
36 unsigned TexUnit::get_n_units()
38 static int count = -1;
42 count = get_i(GL_MAX_TEXTURE_IMAGE_UNITS);
43 else if(ARB_multitexture)
44 count = get_i(GL_MAX_TEXTURE_UNITS);
51 unsigned TexUnit::get_n_legacy_units()
53 static int count = -1;
56 if(MSP_legacy_features)
57 count = get_i(GL_MAX_TEXTURE_UNITS);
64 TexUnit &TexUnit::get_unit(unsigned n)
67 static Require _req(ARB_multitexture);
69 throw out_of_range("TexUnit::get_unit");
73 unsigned i = units.size();
74 unsigned n_legacy = get_n_legacy_units();
75 units.resize(n+1, TexUnit());
76 for(; i<units.size(); ++i)
79 units[i].legacy = (i<n_legacy);
86 TexUnit &TexUnit::current()
93 TexUnit *TexUnit::find_unit(const Texture *tex)
95 for(vector<TexUnit>::iterator i=units.begin(); i!=units.end(); ++i)