X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexunit.cpp;h=1155fa96286be0ab199280e61ea909115545df30;hp=bda7599143a11bf05abcf330a58eca6895c3da67;hb=b617c5d7b5283ad260a77f01e42e6170cabbc03d;hpb=a4ec5410595ddf37bfbc0e85ad87d31a9cbf94f1 diff --git a/source/texunit.cpp b/source/texunit.cpp index bda75991..1155fa96 100644 --- a/source/texunit.cpp +++ b/source/texunit.cpp @@ -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::units; -TexUnit *TexUnit::cur_unit=0; +TexUnit *TexUnit::cur_unit = 0; } // namespace GL } // namespace Msp