X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmesh.cpp;h=d421769abc257a775d53a4b0c73909cd92c36abb;hb=abc16c5ab0fff0945d724febe9d5d3889fb8a6ce;hp=d43e0d0efdd421b43b209c0e8f4f280d2529c895;hpb=76e338af116120d93d082ad247591ec9adad9233;p=libs%2Fgl.git diff --git a/source/mesh.cpp b/source/mesh.cpp index d43e0d0e..d421769a 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -29,14 +29,14 @@ void Mesh::use_vertex_buffer(bool b) { vertices.use_vertex_buffer(); if(!ibuf) - ibuf=new Buffer(ELEMENT_ARRAY_BUFFER); + ibuf = new Buffer(ELEMENT_ARRAY_BUFFER); update_index_buffer(); } else { vertices.use_vertex_buffer(0); delete ibuf; - ibuf=0; + ibuf = 0; } } @@ -63,11 +63,11 @@ void Mesh::draw() const if(ibuf) { ibuf->bind(); - unsigned offset=0; + unsigned offset = 0; for(list::const_iterator i=batches.begin(); i!=batches.end(); ++i) { i->draw_with_buffer(offset); - offset+=i->size(); + offset += i->size(); } ibuf->unbind(); } @@ -83,23 +83,23 @@ void Mesh::update_index_buffer() if(!ibuf) return; - unsigned total=0; + unsigned total = 0; for(list::const_iterator i=batches.begin(); i!=batches.end(); ++i) - total+=i->size(); + total += i->size(); ibuf->data(total*sizeof(unsigned), 0); - unsigned offset=0; + unsigned offset = 0; for(list::const_iterator i=batches.begin(); i!=batches.end(); ++i) { ibuf->sub_data(offset*sizeof(unsigned), i->size()*sizeof(unsigned), &i->get_indices()[0]); - offset+=i->size(); + offset += i->size(); } ibuf->unbind(); } Mesh::Loader::Loader(Mesh &m): - mesh(m) + DataFile::ObjectLoader(m) { add("vertices", &Loader::vertices); add("batch", &Loader::batch); @@ -107,14 +107,14 @@ Mesh::Loader::Loader(Mesh &m): void Mesh::Loader::vertices(VertexFormat f) { - mesh.vertices.reset(f); - load_sub(mesh.vertices); + obj.vertices.reset(f); + load_sub(obj.vertices); } void Mesh::Loader::batch(PrimitiveType p) { - mesh.batches.push_back(Batch(p)); - load_sub(mesh.batches.back()); + obj.batches.push_back(Batch(p)); + load_sub(obj.batches.back()); } } // namespace GL