X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexunit.cpp;h=7eb89a98c0515219dfd66d2a8448e622f2226dac;hb=485315ca65cb40f33253008a79b0933997bd74f5;hp=4d5ff81a297dc9f4d3b1f5dfb564111a3257ecbb;hpb=abc16c5ab0fff0945d724febe9d5d3889fb8a6ce;p=libs%2Fgl.git diff --git a/source/texunit.cpp b/source/texunit.cpp index 4d5ff81a..7eb89a98 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" @@ -21,7 +15,9 @@ TexUnit *TexUnit::cur_unit = 0; TexUnit::TexUnit(): texture(0), texenv(0) -{ } +{ + fill(texgen, texgen+4, static_cast(0)); +} bool TexUnit::set_texture(const Texture *tex) { @@ -37,12 +33,28 @@ bool TexUnit::set_texenv(const TexEnv *env) return result; } +bool TexUnit::set_texgen(unsigned i, const TexGen *gen) +{ + if(i>=4) + throw invalid_argument("TexUnit::set_texgen"); + bool result = (texgen[i]!=gen); + texgen[i] = gen; + return result; +} + +const TexGen *TexUnit::get_texgen(unsigned i) +{ + if(i>=4) + throw invalid_argument("TexUnit::get_texgen"); + return texgen[i]; +} + unsigned TexUnit::get_n_units() { static int count = -1; if(count<0) { - if(is_version_at_least(2, 0) || is_supported("ARB_vertex_shader")) + if(is_version_at_least(2, 0) || is_supported("GL_ARB_vertex_shader")) glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &count); else if(is_version_at_least(1, 3)) glGetIntegerv(GL_MAX_TEXTURE_UNITS, &count); @@ -55,7 +67,7 @@ unsigned TexUnit::get_n_units() TexUnit &TexUnit::activate(unsigned n) { if(n>=get_n_units()) - throw InvalidParameterValue("Invalid texture unit number"); + throw out_of_range("TexUnit::activate"); if(units.size()<=n) units.resize(n+1);