]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarray.h
Minor fixes, courtesy of Apple's compiler
[libs/gl.git] / source / vertexarray.h
index d8484d83ca882ebb1c5e0d215aee57a930270dbf..82a6b6ac5260cb3bd074404480187022f2b03b37 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,22 @@ public:
        };
 
 private:
-       struct ArrayMask
+       struct Array
        {
-               enum
-               {
-                       B = (sizeof(unsigned)*CHAR_BIT),
-                       N = (63+B)/B
-               };
+               unsigned char component;
+               unsigned char offset;
 
-               unsigned mask[N];
-
-               ArrayMask();
-
-               void set(unsigned);
-               bool is_set(unsigned) const;
+               Array();
        };
 
        VertexFormat format;
        std::vector<float> data;
        unsigned stride;
+       std::vector<Array> arrays;
        RefPtr<Buffer> vbuf;
        bool defer_vbuf;
        mutable bool dirty;
 
-       static ArrayMask enabled_arrays;
-
        VertexArray(const VertexArray &);
        VertexArray &operator=(const VertexArray &);
 public:
@@ -58,7 +50,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 *);
 
@@ -75,6 +70,8 @@ public:
        const float *operator[](unsigned i) const { return &data[0]+i*stride; }
 
        void apply() const;
+private:
+       static void apply_arrays(const std::vector<Array> *, const std::vector<Array> *, const float *, unsigned);
 };
 
 } // namespace GL