]> git.tdb.fi Git - libs/gl.git/commitdiff
Add the meshbuilder.* files too
authorMikko Rasa <tdb@tdb.fi>
Tue, 26 Feb 2008 10:29:52 +0000 (10:29 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 26 Feb 2008 10:29:52 +0000 (10:29 +0000)
source/meshbuilder.cpp [new file with mode: 0644]
source/meshbuilder.h [new file with mode: 0644]

diff --git a/source/meshbuilder.cpp b/source/meshbuilder.cpp
new file mode 100644 (file)
index 0000000..cd3be66
--- /dev/null
@@ -0,0 +1,35 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "mesh.h"
+#include "meshbuilder.h"
+
+namespace Msp {
+namespace GL {
+
+MeshBuilder::MeshBuilder(Mesh &m):
+       PrimitiveBuilder(m.vertices),
+       mesh(m),
+       first(0)
+{ }
+
+void MeshBuilder::begin_()
+{
+       first=array.size();
+}
+
+void MeshBuilder::end_()
+{
+       Batch batch(type);
+       unsigned last=array.size();
+       for(unsigned i=first; i<last; ++i)
+               batch.append(i);
+       mesh.add_batch(batch);
+}
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/meshbuilder.h b/source/meshbuilder.h
new file mode 100644 (file)
index 0000000..dbeb0f5
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_MESHBUILDER_H_
+#define MSP_GL_MESHBUILDER_H_
+
+#include "primitivebuilder.h"
+
+namespace Msp {
+namespace GL {
+
+class Mesh;
+
+class MeshBuilder: public PrimitiveBuilder
+{
+private:
+       Mesh  &mesh;
+       unsigned first;
+
+public:
+       MeshBuilder(Mesh &);
+private:
+       virtual void begin_();
+       virtual void end_();
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif