X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexunit.cpp;h=d581598a6c190e2caf46c59d11140d403c30e79b;hb=f48b68626a98c4a0b8991764d174eb57895e805f;hp=4d5ff81a297dc9f4d3b1f5dfb564111a3257ecbb;hpb=abc16c5ab0fff0945d724febe9d5d3889fb8a6ce;p=libs%2Fgl.git diff --git a/source/texunit.cpp b/source/texunit.cpp index 4d5ff81a..d581598a 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,6 +33,22 @@ 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; @@ -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);