X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fvertexarray.h;h=8e72d9554c7e39078b2ddebed2e94d5f8434fd59;hb=16f6f15328b3a6eec87b1b5e5822368966d44a38;hp=9610905d218994fcb2e539a6fe06d1a4e3934a41;hpb=85facfb688035b5bbc9a3a87d080582fbf34930b;p=libs%2Fgl.git diff --git a/source/vertexarray.h b/source/vertexarray.h index 9610905d..8e72d955 100644 --- a/source/vertexarray.h +++ b/source/vertexarray.h @@ -11,6 +11,7 @@ Distributed under the LGPL #include #include #include +#include "primitivetype.h" #include "types.h" #include "vertexarraybuilder.h" #include "vertexformat.h" @@ -29,6 +30,16 @@ public: Loader(VertexArray &); }; +private: + VertexFormat format; + std::vector data; + uint stride; + VertexBuffer *vbuf; + bool own_vbuf; + + VertexArray(const VertexArray &); + VertexArray &operator=(const VertexArray &); +public: VertexArray(VertexFormat); ~VertexArray(); @@ -36,20 +47,16 @@ public: const std::vector &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 modify(); void apply() const; void update_data(); + float *append(); + float *operator[](unsigned i) { return &data[0]+i*stride; } + const float *operator[](unsigned i) const { return &data[0]+i*stride; } private: - VertexFormat format; - std::vector 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;