]> git.tdb.fi Git - libs/gl.git/blob - source/texunit.cpp
Add Id tags and copyright notices to files
[libs/gl.git] / source / texunit.cpp
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #define GL_GLEXT_PROTOTYPES
9 #include <GL/gl.h>
10 #include <GL/glext.h>
11 #include "texunit.h"
12
13 using namespace std;
14
15 namespace Msp {
16 namespace GL {
17
18 TexUnit::TexUnit():
19         texture(0)
20 { }
21
22 bool TexUnit::set_texture(const Texture *tex)
23 {
24         bool result=(tex!=texture);
25         texture=tex;
26         return result;
27 }
28
29 TexUnit &TexUnit::activate(unsigned n)
30 {
31         if(units.size()<=n)
32                 units.resize(n+1);
33
34         glActiveTextureARB(GL_TEXTURE0+n);
35         cur_unit=&units[n];
36
37         return units[n];
38 }
39
40 TexUnit &TexUnit::current()
41 {
42         if(!cur_unit)
43                 return activate(0);
44         return *cur_unit;
45 }
46
47 vector<TexUnit> TexUnit::units;
48 TexUnit *TexUnit::cur_unit=0;
49
50 } // namespace GL
51 } // namespace Msp