]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/programdata.cpp
Use the new _member utility functions to search and sort things
[libs/gl.git] / source / render / programdata.cpp
index 9c23e8a5eb26eefd2da1654975ccf5af62d1d4b2..272489bb585f0d9536dd94653b0b8fb039b42fea 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/core/algorithm.h>
 #include <msp/core/maputils.h>
 #include <msp/debug/demangle.h>
 #include <msp/gl/extensions/arb_direct_state_access.h>
@@ -173,7 +174,7 @@ void ProgramData::add_uniform(Tag tag, Uniform *uni)
                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;
@@ -456,7 +457,7 @@ void ProgramData::uniform_matrix4_array(Tag tag, unsigned n, const float *v)
 
 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;
 
@@ -489,14 +490,9 @@ const Uniform *ProgramData::find_uniform(Tag tag) const
        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);
 }
 
@@ -636,7 +632,7 @@ void ProgramData::apply() const
 
                // Update the contents of all dirty blocks.
                bool buffered_blocks_updated = false;
-               std::vector<ProgramBlock>::iterator j = pu.blocks.begin();
+               vector<ProgramBlock>::iterator j = pu.blocks.begin();
                for(vector<Program::UniformBlockInfo>::const_iterator i=prog_blocks.begin(); i!=prog_blocks.end(); ++i, ++j)
                {
                        if(!j->shared || !j->shared->dirty)