X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmesh.cpp;h=572ac6195502afc97259a45857d94998c666fa4d;hb=d7e7f87d173156aa12694ce54d688c40a2eabe2e;hp=0e58aa269a1bbdb7679aa36737f0a79ecdb95663;hpb=7d6b7b18221e670810bdd0505995b8f1fa012eb4;p=libs%2Fgl.git diff --git a/source/mesh.cpp b/source/mesh.cpp index 0e58aa26..572ac619 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -1,6 +1,5 @@ #include "buffer.h" #include "mesh.h" -#include "nv_primitive_restart.h" #include "renderer.h" using namespace std; @@ -63,22 +62,13 @@ float *Mesh::modify_vertex(unsigned i) void Mesh::add_batch(const Batch &b) { - bool can_append = false; - if(!batches.empty()) - { - PrimitiveType type = b.get_type(); - can_append = (type==batches.back().get_type() && - type!=LINE_STRIP && type!=LINE_LOOP && type!=POLYGON && - (type!=TRIANGLE_FAN || NV_primitive_restart)); - } - if(defer_ibuf) { ibuf = new Buffer(ELEMENT_ARRAY_BUFFER); defer_ibuf = false; } - if(can_append) + if(!batches.empty() && batches.back().can_append(b.get_type())) batches.back().append(b); else { @@ -130,9 +120,15 @@ Mesh::Loader::Loader(Mesh &m): add("winding", &Loader::winding); } -void Mesh::Loader::vertices(VertexFormat f) +void Mesh::Loader::vertices(const vector &c) { - obj.vertices.reset(f); + if(c.empty()) + throw invalid_argument("No vertex components"); + + VertexFormat fmt; + for(vector::const_iterator i=c.begin(); i!=c.end(); ++i) + fmt = (fmt, *i); + obj.vertices.reset(fmt); load_sub(obj.vertices); }