]> 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 fd0fe31423db1c6f76413f818f493eb661167b02..1155fa96286be0ab199280e61ea909115545df30 100644 (file)
@@ -1,7 +1,14 @@
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-#include <GL/glext.h>
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007-2008  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "extension.h"
+#include "gl.h"
 #include "texunit.h"
+#include "version_1_3.h"
 
 using namespace std;
 
@@ -10,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;
 }
 
@@ -24,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];
 }
@@ -38,7 +57,7 @@ TexUnit &TexUnit::current()
 }
 
 vector<TexUnit> TexUnit::units;
-TexUnit *TexUnit::cur_unit=0;
+TexUnit *TexUnit::cur_unit = 0;
 
 } // namespace GL
 } // namespace Msp