]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarray.h
Convert VertexArray into a Bufferable
[libs/gl.git] / source / vertexarray.h
index 82a6b6ac5260cb3bd074404480187022f2b03b37..fb8f51b026d82e40c2ef4dd70da31f2f3c66027f 100644 (file)
@@ -6,6 +6,7 @@
 #include <msp/core/refptr.h>
 #include <msp/datafile/loader.h>
 #include "bindable.h"
+#include "bufferable.h"
 #include "datatype.h"
 #include "primitivetype.h"
 #include "vertexarraybuilder.h"
@@ -16,7 +17,7 @@ namespace GL {
 
 class Buffer;
 
-class VertexArray: public Bindable<VertexArray>
+class VertexArray: public Bindable<VertexArray>, public Bufferable
 {
 public:
        class Loader: public DataFile::Loader, public VertexArrayBuilder
@@ -38,8 +39,6 @@ private:
        std::vector<float> data;
        unsigned stride;
        std::vector<Array> arrays;
-       RefPtr<Buffer> vbuf;
-       bool defer_vbuf;
        mutable bool dirty;
 
        VertexArray(const VertexArray &);
@@ -54,15 +53,16 @@ private:
        static unsigned get_array_slot(unsigned char);
 
 public:
-       void use_vertex_buffer();
-       void use_vertex_buffer(Buffer *);
+       /// Deprecated alias for use_buffer
+       void use_vertex_buffer(Buffer *b) { use_buffer(b); }
 
        void clear();
        void reserve(unsigned);
        float *append();
        float *modify(unsigned);
 private:
-       void set_dirty();
+       virtual unsigned get_data_size() const;
+       virtual void upload_data() const;
 
 public:
        unsigned size() const { return data.size()/stride; }