--- /dev/null
+#ifndef MSP_GL_TEXUNIT_H_
+#define MSP_GL_TEXUNIT_H_
+
+#include <vector>
+
+namespace Msp {
+namespace GL {
+
+class Sampler;
+class Texture;
+
+/**
+Keeps track of texture unit related state. Intended for internal use.
+*/
+class TexUnit
+{
+private:
+ unsigned index;
+ const Texture *texture;
+ const Sampler *sampler;
+
+ static std::vector<TexUnit> units;
+ static TexUnit *cur_unit;
+
+ TexUnit();
+
+public:
+ unsigned get_index() const { return index; }
+ bool set_texture(const Texture *);
+ const Texture *get_texture() const { return texture; }
+ bool set_sampler(const Sampler *);
+ const Sampler *get_sampler() const { return sampler; }
+ void bind();
+
+ static unsigned get_n_units();
+ static TexUnit &get_unit(unsigned);
+ static TexUnit ¤t();
+ static TexUnit *find_unit(const Texture *);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif