]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarray.h
Require mspgbase now that Image was moved there
[libs/gl.git] / source / vertexarray.h
index 9610905d218994fcb2e539a6fe06d1a4e3934a41..f0baf2d4a84fa8896b21c351149d9cd28612ee04 100644 (file)
@@ -11,6 +11,7 @@ Distributed under the LGPL
 #include <vector>
 #include <msp/core/refptr.h>
 #include <msp/datafile/loader.h>
+#include "primitivetype.h"
 #include "types.h"
 #include "vertexarraybuilder.h"
 #include "vertexformat.h"
@@ -22,6 +23,8 @@ class VertexBuffer;
 
 class VertexArray
 {
+       friend class VertexArrayBuilder;
+
 public:
        class Loader: public DataFile::Loader, public VertexArrayBuilder
        {
@@ -29,6 +32,16 @@ public:
                Loader(VertexArray &);
        };
 
+private:
+       VertexFormat format;
+       std::vector<float> data;
+       uint         stride;
+       VertexBuffer *vbuf;
+       bool         own_vbuf;
+
+       VertexArray(const VertexArray &);
+       VertexArray &operator=(const VertexArray &);
+public:
        VertexArray(VertexFormat);
        ~VertexArray();
 
@@ -36,20 +49,14 @@ public:
        const std::vector<float> &get_data() const { return data; }
        void         use_vertex_buffer();
        void         use_vertex_buffer(VertexBuffer *);
+       void         reserve(unsigned);
+       unsigned     size() const { return data.size()/stride; }
        void         clear();
        void         reset(VertexFormat);
        RefPtr<VertexArrayBuilder> modify();
        void         apply() const;
        void         update_data();
 private:
-       VertexFormat format;
-       std::vector<float> data;
-       uint         stride;
-       VertexBuffer *vbuf;
-       bool         own_vbuf;
-
-       VertexArray(const VertexArray &);
-       VertexArray &operator=(const VertexArray &);
        void set_array(unsigned, unsigned, unsigned) const;
 
        static unsigned enabled_arrays;