]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarray.h
Rework vertex array application
[libs/gl.git] / source / vertexarray.h
index d8484d83ca882ebb1c5e0d215aee57a930270dbf..26204b312134e4bc1c5ebf2ebe845c19ff205304 100644 (file)
@@ -5,6 +5,7 @@
 #include <vector>
 #include <msp/core/refptr.h>
 #include <msp/datafile/loader.h>
+#include "bindable.h"
 #include "datatype.h"
 #include "primitivetype.h"
 #include "vertexarraybuilder.h"
@@ -15,7 +16,7 @@ namespace GL {
 
 class Buffer;
 
-class VertexArray
+class VertexArray: public Bindable<VertexArray>
 {
 public:
        class Loader: public DataFile::Loader, public VertexArrayBuilder
@@ -25,31 +26,14 @@ public:
        };
 
 private:
-       struct ArrayMask
-       {
-               enum
-               {
-                       B = (sizeof(unsigned)*CHAR_BIT),
-                       N = (63+B)/B
-               };
-
-               unsigned mask[N];
-
-               ArrayMask();
-
-               void set(unsigned);
-               bool is_set(unsigned) const;
-       };
-
        VertexFormat format;
        std::vector<float> data;
        unsigned stride;
+       std::vector<unsigned char> arrays;
        RefPtr<Buffer> vbuf;
        bool defer_vbuf;
        mutable bool dirty;
 
-       static ArrayMask enabled_arrays;
-
        VertexArray(const VertexArray &);
        VertexArray &operator=(const VertexArray &);
 public:
@@ -58,7 +42,10 @@ public:
 
        void reset(const VertexFormat &);
        const VertexFormat &get_format() const { return format; }
+private:
+       static unsigned get_array_slot(unsigned char);
 
+public:
        void use_vertex_buffer();
        void use_vertex_buffer(Buffer *);