]> git.tdb.fi Git - libs/gl.git/blob - source/texunit.cpp
Windows compatibility:
[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 #include "extension.h"
9 #include "gl.h"
10 #include "texunit.h"
11 #include "version_1_3.h"
12
13 using namespace std;
14
15 namespace Msp {
16 namespace GL {
17
18 TexUnit::TexUnit():
19         texture(0)
20 {
21         require_version(1, 3);
22 }
23
24 bool TexUnit::set_texture(const Texture *tex)
25 {
26         bool result=(tex!=texture);
27         texture=tex;
28         return result;
29 }
30
31 TexUnit &TexUnit::activate(unsigned n)
32 {
33         if(units.size()<=n)
34                 units.resize(n+1);
35
36         glActiveTexture(GL_TEXTURE0+n);
37         cur_unit=&units[n];
38
39         return units[n];
40 }
41
42 TexUnit &TexUnit::current()
43 {
44         if(!cur_unit)
45                 return activate(0);
46         return *cur_unit;
47 }
48
49 vector<TexUnit> TexUnit::units;
50 TexUnit *TexUnit::cur_unit=0;
51
52 } // namespace GL
53 } // namespace Msp