]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/instancearray.cpp
Use C++11 features with containers
[libs/gl.git] / source / render / instancearray.cpp
index 293fa6cdad8e1ee55384df261a50f22b58997a25..a53a988105d410a3fd3d58be119876b43a58f040 100644 (file)
@@ -28,10 +28,9 @@ InstanceArray::InstanceArray(const Object &o):
        matrix_offset(0)
 {
        const Technique *tech = object.get_technique();
-       const Technique::PassMap &passes = tech->get_passes();
-       for(Technique::PassMap::const_iterator i=passes.begin(); i!=passes.end(); ++i)
+       for(const auto &kvp: tech->get_passes())
        {
-               const Program *shprog = i->second.get_shader_program();
+               const Program *shprog = kvp.second.get_shader_program();
                if(!shprog)
                        throw invalid_argument("InstanceArray::InstanceArray");
 
@@ -65,8 +64,8 @@ InstanceArray::InstanceArray(const Object &o):
 
 InstanceArray::~InstanceArray()
 {
-       for(vector<ObjectInstance *>::iterator i=instances.begin(); i!=instances.end(); ++i)
-               delete *i;
+       for(ObjectInstance *i: instances)
+               delete i;
        delete vtx_setup;
        delete instance_data;
        delete instance_buffer;
@@ -94,7 +93,7 @@ void InstanceArray::append(ObjectInstance *inst)
 
 void InstanceArray::remove(ObjectInstance &inst)
 {
-       vector<ObjectInstance *>::iterator i = find(instances, &inst);
+       auto i = find(instances, &inst);
        if(i==instances.end())
                throw key_error(&inst);
 
@@ -141,12 +140,12 @@ void InstanceArray::render(Renderer &renderer, Tag tag) const
        }
        else
        {
-               for(vector<ObjectInstance *>::const_iterator i=instances.begin(); i!=instances.end(); ++i)
+               for(ObjectInstance *i: instances)
                {
-                       const Matrix &m = *(*i)->get_matrix();
+                       const Matrix &m = *i->get_matrix();
                        for(unsigned j=0; j<3; ++j)
                                glVertexAttrib4f(matrix_location+j, m(j, 0), m(j, 1), m(j, 2), m(j, 3));
-                       (*i)->render(renderer, tag);
+                       i->render(renderer, tag);
                }
        }
 }