]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texunit.cpp
Style update: add spaces around assignment operators
[libs/gl.git] / source / texunit.cpp
index 91a33ecc378d966644e11aaf90c11524ffbc1bd0..1155fa96286be0ab199280e61ea909115545df30 100644 (file)
@@ -1,14 +1,14 @@
 /* $Id$
 
 This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2008  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-#include <GL/glext.h>
+#include "extension.h"
+#include "gl.h"
 #include "texunit.h"
+#include "version_1_3.h"
 
 using namespace std;
 
@@ -17,12 +17,20 @@ namespace GL {
 
 TexUnit::TexUnit():
        texture(0)
-{ }
+{
+}
 
 bool TexUnit::set_texture(const Texture *tex)
 {
-       bool result=(tex!=texture);
-       texture=tex;
+       bool result = (tex!=texture);
+       texture = tex;
+       return result;
+}
+
+bool TexUnit::set_texenv(const TexEnv *env)
+{
+       bool result = (texenv!=env);
+       texenv = env;
        return result;
 }
 
@@ -31,8 +39,12 @@ TexUnit &TexUnit::activate(unsigned n)
        if(units.size()<=n)
                units.resize(n+1);
 
-       glActiveTextureARB(GL_TEXTURE0+n);
-       cur_unit=&units[n];
+       if(cur_unit!=&units[n] && (cur_unit || n))
+       {
+               static RequireVersion _ver(1, 3);
+               glActiveTexture(GL_TEXTURE0+n);
+       }
+       cur_unit = &units[n];
 
        return units[n];
 }
@@ -45,7 +57,7 @@ TexUnit &TexUnit::current()
 }
 
 vector<TexUnit> TexUnit::units;
-TexUnit *TexUnit::cur_unit=0;
+TexUnit *TexUnit::cur_unit = 0;
 
 } // namespace GL
 } // namespace Msp