]> 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 bda7599143a11bf05abcf330a58eca6895c3da67..1155fa96286be0ab199280e61ea909115545df30 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2008  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -18,13 +18,19 @@ namespace GL {
 TexUnit::TexUnit():
        texture(0)
 {
-       require_version(1, 3);
 }
 
 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;
 }
 
@@ -33,8 +39,12 @@ TexUnit &TexUnit::activate(unsigned n)
        if(units.size()<=n)
                units.resize(n+1);
 
-       glActiveTexture(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];
 }
@@ -47,7 +57,7 @@ TexUnit &TexUnit::current()
 }
 
 vector<TexUnit> TexUnit::units;
-TexUnit *TexUnit::cur_unit=0;
+TexUnit *TexUnit::cur_unit = 0;
 
 } // namespace GL
 } // namespace Msp