X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexunit.cpp;h=9277c27704ebd8347c3c6a782fc1b6ff05fc8658;hp=9b905120db6861d54204b172264d58c6f5340383;hb=d5c26741ed3952dd54c8a7f43ad42ba79bf2d977;hpb=f1b12c992db974c679d85ae6ec22cd318199d0d5 diff --git a/source/texunit.cpp b/source/texunit.cpp index 9b905120..9277c277 100644 --- a/source/texunit.cpp +++ b/source/texunit.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "gl.h" #include "misc.h" #include "texunit.h" @@ -14,13 +15,17 @@ vector TexUnit::units; TexUnit *TexUnit::cur_unit = 0; TexUnit::TexUnit(): - texture(0) + legacy(false), + texture(0), + tex_legacy(false) { } -bool TexUnit::set_texture(const Texture *tex) +bool TexUnit::set_texture(const Texture *tex, bool lgc) { - bool result = (tex!=texture); + lgc = (lgc && legacy && tex); + bool result = (tex!=texture || lgc!=tex_legacy); texture = tex; + tex_legacy = lgc; return result; } @@ -37,7 +42,7 @@ unsigned TexUnit::get_n_units() if(count<0) { if(ARB_vertex_shader) - count = get_i(GL_MAX_TEXTURE_IMAGE_UNITS); + count = get_i(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS); else if(ARB_multitexture) count = get_i(GL_MAX_TEXTURE_UNITS); else @@ -46,6 +51,19 @@ unsigned TexUnit::get_n_units() 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) @@ -56,9 +74,13 @@ TexUnit &TexUnit::get_unit(unsigned n) if(units.size()<=n) { unsigned i = units.size(); + unsigned n_legacy = get_n_legacy_units(); units.resize(n+1, TexUnit()); for(; i