X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexunit.cpp;h=4d71e3b9492674a3a3e0f1712d6d45d526c679bb;hb=2157e9320c60d561208dfdf6034e9a06781c9f30;hp=a542796548f0ae120bc9037b81bf0e2e3071c0fd;hpb=7e9e15a12fb398798f2719545cc8553354c1e389;p=libs%2Fgl.git diff --git a/source/texunit.cpp b/source/texunit.cpp index a5427965..4d71e3b9 100644 --- a/source/texunit.cpp +++ b/source/texunit.cpp @@ -1,10 +1,4 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007-2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #include "extension.h" #include "gl.h" #include "texunit.h" @@ -41,19 +35,21 @@ unsigned TexUnit::get_n_units() { static int count = -1; if(count<0) - // XXX Should use GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS since GL 2.0 - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &count); + { + if(is_version_at_least(2, 0) || is_supported("ARB_vertex_shader")) + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &count); + else if(is_version_at_least(1, 3)) + glGetIntegerv(GL_MAX_TEXTURE_UNITS, &count); + else + count = 1; + } return count; } TexUnit &TexUnit::activate(unsigned n) { - if(n>0) - { - static RequireVersion _ver(1, 3); - if(n>=get_n_units()) - throw InvalidParameterValue("Invalid texture unit number"); - } + if(n>=get_n_units()) + throw out_of_range("TexUnit::activate"); if(units.size()<=n) units.resize(n+1);