X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.cpp;h=749a7d9cf67735cbc60958f0c606b9f1452e4087;hb=ec0f55e58e978ce780c81629c39f2f5e474072c6;hp=52150f3f7f2be252f4beca3f04c237b8b05e1107;hpb=0646b330ffa9ea7fd77e2078257499b1d58ac0f7;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index 52150f3f..749a7d9c 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -97,7 +97,8 @@ Program::Program(const StandardFeatures &features) init(); add_standard_shaders(features); - link(); + if(!features.transform) + link(); } Program::Program(const string &vert, const string &frag) @@ -258,7 +259,23 @@ int Program::get_uniform_location(const string &n) const { map::const_iterator i = uniforms.find(n); if(i==uniforms.end()) + { + if(n[n.size()-1]==']') + { + string::size_type open_bracket = n.rfind('['); + if(open_bracket!=string::npos) + { + /* The requested name looks like an array. glGetActiveUniform only + gives us the first element of the array, so try to look that up and + add an offset. */ + int offset = lexical_cast(n.substr(open_bracket+1, n.size()-2-open_bracket)); + i = uniforms.find(n.substr(0, open_bracket)+"[0]"); + if(i!=uniforms.end() && offsetsecond.size) + return i->second.location+offset; + } + } return -1; + } return i->second.location; }