X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmesh.cpp;h=508054a521346ac45e394848fb0c7ec11f0fe799;hb=f98e4dc9f86e4d8603359b2b45ae02a2acd65605;hp=67f9698cfa36468d5fb6955f49b5ce5774b95e0f;hpb=635d00bc1a9ba43ef1224681a14d0710a098cf87;p=libs%2Fgl.git diff --git a/source/mesh.cpp b/source/mesh.cpp index 67f9698c..508054a5 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -1,13 +1,6 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "buffer.h" -#include "extension.h" #include "mesh.h" +#include "nv_primitive_restart.h" #include "renderer.h" using namespace std; @@ -76,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) @@ -92,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); } } @@ -124,6 +117,8 @@ void Mesh::draw(Renderer &renderer) const for(list::const_iterator i=batches.begin(); i!=batches.end(); ++i) renderer.draw(*i); + + renderer.set_winding_test(0); } @@ -135,9 +130,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); }