]> git.tdb.fi Git - libs/gl.git/blobdiff - source/mesh.cpp
Load VertexFormat for Mesh as an array of VertexComponents
[libs/gl.git] / source / mesh.cpp
index c5e73ebd2afd625cda3d1d4041e8b7bd03145ed5..508054a521346ac45e394848fb0c7ec11f0fe799 100644 (file)
@@ -1,6 +1,6 @@
 #include "buffer.h"
-#include "extension.h"
 #include "mesh.h"
+#include "nv_primitive_restart.h"
 #include "renderer.h"
 
 using namespace std;
@@ -69,7 +69,7 @@ void Mesh::add_batch(const Batch &b)
                PrimitiveType type = b.get_type();
                can_append = (type==batches.back().get_type() &&
                        type!=LINE_STRIP && type!=LINE_LOOP && type!=POLYGON &&
-                       (type!=TRIANGLE_FAN || is_supported("GL_NV_primitive_restart")));
+                       (type!=TRIANGLE_FAN || NV_primitive_restart));
        }
 
        if(defer_ibuf)
@@ -85,7 +85,7 @@ void Mesh::add_batch(const Batch &b)
                Batch *prev = (batches.empty() ? 0 : &batches.back());
                batches.push_back(b);
                if(ibuf)
-                       batches.back().use_index_buffer(ibuf, prev);
+                       batches.back().use_buffer(ibuf, prev);
        }
 }
 
@@ -130,9 +130,15 @@ Mesh::Loader::Loader(Mesh &m):
        add("winding",  &Loader::winding);
 }
 
-void Mesh::Loader::vertices(VertexFormat f)
+void Mesh::Loader::vertices(const vector<VertexComponent> &c)
 {
-       obj.vertices.reset(f);
+       if(c.empty())
+               throw invalid_argument("No vertex components");
+
+       VertexFormat fmt;
+       for(vector<VertexComponent>::const_iterator i=c.begin(); i!=c.end(); ++i)
+               fmt = (fmt, *i);
+       obj.vertices.reset(fmt);
        load_sub(obj.vertices);
 }