X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Ftexunit.cpp;h=9277c27704ebd8347c3c6a782fc1b6ff05fc8658;hb=HEAD;hp=74a23246b368ac6ad3b6b3d69765c5f6d4bbd82e;hpb=e1672476c5a258ff67fe1fcb47dd9a40b89169cb;p=libs%2Fgl.git diff --git a/source/texunit.cpp b/source/texunit.cpp deleted file mode 100644 index 74a23246..00000000 --- a/source/texunit.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include -#include -#include -#include "gl.h" -#include "misc.h" -#include "texunit.h" - -using namespace std; - -namespace Msp { -namespace GL { - -vector TexUnit::units; -TexUnit *TexUnit::cur_unit = 0; - -TexUnit::TexUnit(): - legacy(false), - texture(0) -{ } - -bool TexUnit::set_texture(const Texture *tex) -{ - bool result = (tex!=texture); - texture = tex; - return result; -} - -void TexUnit::bind() -{ - if(cur_unit!=this && (cur_unit || index)) - glActiveTexture(GL_TEXTURE0+index); - cur_unit = this; -} - -unsigned TexUnit::get_n_units() -{ - static int count = -1; - if(count<0) - { - if(ARB_vertex_shader) - count = get_i(GL_MAX_TEXTURE_IMAGE_UNITS); - else if(ARB_multitexture) - count = get_i(GL_MAX_TEXTURE_UNITS); - else - count = 1; - } - return count; -} - -unsigned TexUnit::get_n_legacy_units() -{ - static int count = -1; - if(count<0) - { - if(MSP_legacy_features) - count = get_i(GL_MAX_TEXTURE_UNITS); - else - count = 0; - } - return count; -} - -TexUnit &TexUnit::get_unit(unsigned n) -{ - if(n>0) - static Require _req(ARB_multitexture); - if(n>=get_n_units()) - throw out_of_range("TexUnit::get_unit"); - - if(units.size()<=n) - { - unsigned i = units.size(); - unsigned n_legacy = get_n_legacy_units(); - units.resize(n+1, TexUnit()); - for(; i::iterator i=units.begin(); i!=units.end(); ++i) - if(i->texture==tex) - return &*i; - return 0; -} - -} // namespace GL -} // namespace Msp