summary refs log tree commit diff
path: root/src/GFX/Binder.hpp
blob: 92faebe2c66cb81355c69daa3b3acdec8161c6c5 (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
47
48
#pragma once

#include <cstdint>
#include "Mesh.hpp"

namespace MC::GFX {

class BindableMesh {
public:
    void bind() const;
    void unbind() const;

    bool has_indices() const;
    size_t size() const;

private:
    BindableMesh(
        uint32_t vao,
        size_t vertex_count,
        size_t attribute_count
    ) : m_vao(vao),
        m_vertex_count(vertex_count),
        m_has_indices(vertex_count > 0),
        m_attribute_count(attribute_count) {};

    uint32_t m_vao;
    size_t m_vertex_count;
    bool m_has_indices;
    size_t m_attribute_count;

    friend class Binder;
};

class Binder {
public:
    Binder() = default;;

    static BindableMesh load(const Mesh& mesh);

private:
    static uint32_t create_vao();
    static void unbind_vao();

    static void store_in_attribute_list(uint32_t attribute, int attribute_size, int type_size, const void* data, long data_size);
    static void store_indices(const uint32_t* indices, size_t indices_size);
};

}