]> git.tdb.fi Git - libs/gl.git/blobdiff - source/mesh.h
Simplify VAO setup code
[libs/gl.git] / source / mesh.h
index 6181d5fb9bc1b9126248d2e786f826a77c7c92bd..730b724c9e81a9eee6072cac1d4762b503dbd6fc 100644 (file)
@@ -17,7 +17,7 @@ Raw mesh data, consisting of a VertexArray and one or more Batches.  Though a
 Mesh can draw itself, it's usually used as part of Renderables rather than on
 its own.
 */
-class Mesh
+class Mesh: public Bindable<Mesh>
 {
        friend class MeshBuilder;
 
@@ -37,7 +37,9 @@ private:
        std::list<Batch> batches;
        Buffer *vbuf;
        Buffer *ibuf;
+       unsigned vao_id;
        bool defer_buffers;
+       mutable bool dirty;
        const WindingTest *winding;
 
 public:
@@ -49,9 +51,11 @@ public:
        void use_buffers(bool);
 private:
        void create_buffers();
+       void setup_vao() const;
 
 public:
        const VertexArray &get_vertices() const { return vertices; }
+       const Buffer *get_index_buffer() const { return ibuf; }
        unsigned get_n_vertices() const;
        float *modify_vertex(unsigned);
 
@@ -62,6 +66,10 @@ public:
 
        void draw() const;
        void draw(Renderer &) const;
+
+       void bind() const;
+
+       static void unbind();
 };
 
 } // namespace GL