]> git.tdb.fi Git - libs/gl.git/blob - source/texunit.cpp
Add vertex arrays and buffers
[libs/gl.git] / source / texunit.cpp
1 #define GL_GLEXT_PROTOTYPES
2 #include <GL/gl.h>
3 #include <GL/glext.h>
4 #include "texunit.h"
5
6 using namespace std;
7
8 namespace Msp {
9 namespace GL {
10
11 TexUnit::TexUnit():
12         texture(0)
13 { }
14
15 bool TexUnit::set_texture(const Texture *tex)
16 {
17         bool result=(tex!=texture);
18         texture=tex;
19         return result;
20 }
21
22 TexUnit &TexUnit::activate(unsigned n)
23 {
24         if(units.size()<=n)
25                 units.resize(n+1);
26
27         glActiveTextureARB(GL_TEXTURE0+n);
28         cur_unit=&units[n];
29
30         return units[n];
31 }
32
33 TexUnit &TexUnit::current()
34 {
35         if(!cur_unit)
36                 return activate(0);
37         return *cur_unit;
38 }
39
40 vector<TexUnit> TexUnit::units;
41 TexUnit *TexUnit::cur_unit=0;
42
43 } // namespace GL
44 } // namespace Msp