}
}
- sort(uniforms, &uniform_tag_compare);
+ sort_member(uniforms, &UniformInfo::tag);
if(ARB_uniform_buffer_object)
{
for(unsigned i=0; i<count; ++i)
if(!uniform_names[i].empty())
// The element is already known to be present
- uniforms_by_index[i] = &*lower_bound(uniforms, Tag(uniform_names[i]), &search<UniformInfo, Tag, &UniformInfo::tag>);
+ uniforms_by_index[i] = &*lower_bound_member(uniforms, Tag(uniform_names[i]), &UniformInfo::tag);
query_uniform_blocks(uniforms_by_index);
}
uniforms_by_index[query_indices[j]]->matrix_stride = values[j];
}
- sort(info.uniforms.begin(), info.uniforms.end(), uniform_location_compare);
+ sort(info.uniforms, uniform_location_compare);
info.layout_hash = compute_layout_hash(info.uniforms);
}
}
}
}
- sort(uniforms, &uniform_tag_compare);
+ sort_member(uniforms, &UniformInfo::tag);
for(unsigned i=0; i<uniform_blocks.size(); ++i)
{
for(vector<string>::const_iterator j=names.begin(); j!=names.end(); ++j)
{
// The element is already known to be present
- UniformInfo &uni = *lower_bound(uniforms, Tag(*j), &search<UniformInfo, Tag, &UniformInfo::tag>);
+ UniformInfo &uni = *lower_bound_member(uniforms, Tag(*j), &UniformInfo::tag);
block.uniforms.push_back(&uni);
uni.block = █
}
return uni1->location<uni2->location;
}
-bool Program::uniform_tag_compare(const UniformInfo &uni1, const UniformInfo &uni2)
-{
- return uni1.tag<uni2.tag;
-}
-
-template<typename T, typename A, A T::*member>
-bool Program::search(const T &item, const A &key)
-{
- return item.*member<key;
-}
-
string Program::get_info_log() const
{
GLsizei len = get_program_i(id, GL_INFO_LOG_LENGTH);
const Program::UniformInfo &Program::get_uniform_info(const string &name) const
{
- vector<UniformInfo>::const_iterator i = lower_bound(uniforms, Tag(name), &search<UniformInfo, Tag, &UniformInfo::tag>);
+ vector<UniformInfo>::const_iterator i = lower_bound_member(uniforms, Tag(name), &UniformInfo::tag);
if(i==uniforms.end() || i->name!=name)
throw key_error(name);
return *i;
const Program::UniformInfo &Program::get_uniform_info(Tag tag) const
{
- vector<UniformInfo>::const_iterator i = lower_bound(uniforms, tag, &search<UniformInfo, Tag, &UniformInfo::tag>);
+ vector<UniformInfo>::const_iterator i = lower_bound_member(uniforms, tag, &UniformInfo::tag);
if(i==uniforms.end() || i->tag!=tag)
throw key_error(tag);
return *i;
if(name[name.size()-1]==']')
throw invalid_argument("Program::get_uniform_location");
- vector<UniformInfo>::const_iterator i = lower_bound(uniforms, Tag(name), &search<UniformInfo, Tag, &UniformInfo::tag>);
+ vector<UniformInfo>::const_iterator i = lower_bound_member(uniforms, Tag(name), &UniformInfo::tag);
return i!=uniforms.end() && i->name==name && i->block->bind_point<0 ? i->location : -1;
}
int Program::get_uniform_location(Tag tag) const
{
- vector<UniformInfo>::const_iterator i = lower_bound(uniforms, tag, &search<UniformInfo, Tag, &UniformInfo::tag>);
+ vector<UniformInfo>::const_iterator i = lower_bound_member(uniforms, tag, &UniformInfo::tag);
return i!=uniforms.end() && i->tag==tag && i->block->bind_point<0 ? i->location : -1;
}
const Program::AttributeInfo &Program::get_attribute_info(const string &name) const
{
- vector<AttributeInfo>::const_iterator i = lower_bound(attributes, name, &search<AttributeInfo, string, &AttributeInfo::name>);
+ vector<AttributeInfo>::const_iterator i = lower_bound_member(attributes, name, &AttributeInfo::name);
if(i==attributes.end() || i->name!=name)
throw key_error(name);
return *i;
if(name[name.size()-1]==']')
throw invalid_argument("Program::get_attribute_location");
- vector<AttributeInfo>::const_iterator i = lower_bound(attributes, name, &search<AttributeInfo, string, &AttributeInfo::name>);
+ vector<AttributeInfo>::const_iterator i = lower_bound_member(attributes, name, &AttributeInfo::name);
return i!=attributes.end() && i->name==name ? i->location : -1;
}
+#include <msp/core/algorithm.h>
#include <msp/core/maputils.h>
#include <msp/debug/demangle.h>
#include <msp/gl/extensions/arb_direct_state_access.h>
throw too_many_uniforms(tag.str());
}
- vector<TaggedUniform>::iterator j = lower_bound(uniforms.begin(), uniforms.end(), tag, uniform_tag_compare);
+ vector<TaggedUniform>::iterator j = lower_bound_member(uniforms, tag, &TaggedUniform::tag);
TaggedUniform nu;
nu.tag = tag;
void ProgramData::remove_uniform(Tag tag)
{
- vector<TaggedUniform>::const_iterator i = lower_bound(uniforms.begin(), uniforms.end(), tag, uniform_tag_compare);
+ vector<TaggedUniform>::const_iterator i = lower_bound_member(uniforms, tag, &TaggedUniform::tag);
if(i==uniforms.end() || i->tag!=tag)
return;
return (i>=0 ? uniforms[i].value : 0);
}
-bool ProgramData::uniform_tag_compare(const TaggedUniform &tu, Tag tag)
-{
- return tu.tag<tag;
-}
-
int ProgramData::find_uniform_index(Tag tag) const
{
- vector<TaggedUniform>::const_iterator i = lower_bound(uniforms.begin(), uniforms.end(), tag, uniform_tag_compare);
+ vector<TaggedUniform>::const_iterator i = lower_bound_member(uniforms, tag, &TaggedUniform::tag);
return ((i!=uniforms.end() && i->tag==tag) ? i-uniforms.begin() : -1);
}