aboutsummaryrefslogtreecommitdiff
path: root/include/mglpp/graphics/VertexBuffer.hpp
blob: 79adeb0746c065f38781b02f5e86937422a4b3d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef MGLPP_VERTEX_BUFFER_HPP
#define MGLPP_VERTEX_BUFFER_HPP

#include "PrimitiveType.hpp"
#include "Drawable.hpp"

extern "C" {
#include <mgl/graphics/vertex_buffer.h>
}

namespace mgl {
    class Texture;
    struct Vertex;

    class VertexBuffer : public Drawable {
    public:
        enum Usage {
            Stream,
            Dynamic,
            Static
        };

        VertexBuffer();
        VertexBuffer(const VertexBuffer&) = delete;
        VertexBuffer& operator=(const VertexBuffer&) = delete;
        ~VertexBuffer();

        void set_position(vec2f position) override;
        void set_color(Color color) override;
        vec2f get_position() const override;

        void set_texture(Texture *texture);
        const Texture* get_texture() const;

        size_t size() const;

        bool update(const Vertex *vertices, size_t vertex_count, PrimitiveType primitive_type, Usage usage);
    protected:
        void draw(Window &window) override;
    private:
        mgl_vertex_buffer vertex_buffer;
        Texture *texture;
    };
}

#endif /* MGLPP_VERTEX_BUFFER_HPP */