Copperfield Engine 0.1
C++ Game Engine
Loading...
Searching...
No Matches
buffer.hpp
1#pragma once
2
3#include <memory>
4#include <vector>
5namespace coma{
6class Vec2;
7class Vec3;
8}
9class Buffer {
10public:
11 enum class Target {
12 kTarget_Vertex_Data,
13 kTarget_Elements,
14 };
16 Buffer() = delete;
17
23 Buffer(const std::vector<coma::Vec3>& pos,const std::vector<coma::Vec3>& normal,
24 const std::vector<coma::Vec3>& color,const std::vector<coma::Vec2>& uv);
25
29 Buffer(const void* data, unsigned int size);
30
33 Buffer(const Buffer& other) = delete;
34
38 Buffer(Buffer&& other) noexcept;
39
43 Buffer& operator=(Buffer& other) = delete;
44
48 Buffer& operator=(Buffer&& other) noexcept;
49
51 ~Buffer();
52
57 void bindBuffer(const Target t) const;
58
60 void bindVertexArray() const;
61
64 unsigned int size() const;
65
72 void uploadData(const void* data, unsigned int size, unsigned int offset = 0);
73
80 void enableVertexArray(const unsigned int index, const unsigned int size,
81 const unsigned int stride,
82 const unsigned long long offset);
85 unsigned int buffer_id() const;
86
87private:
88 unsigned int buffer_id_;
89 unsigned int vertex_array_id_;
90 unsigned int size_;
91 bool valid_;
92};
93
94class Mesh {
95public:
96 Mesh(const std::vector<coma::Vec3>& pos,
97 const std::vector<coma::Vec3>& normal,
98 const std::vector<coma::Vec3>& color, const std::vector<coma::Vec2>& uv,
99 const void* data, unsigned int size)
100 : mesh_{std::make_unique<Buffer>(pos, normal, color, uv)},
101 indices_{std::make_unique<Buffer>(data, size)} {}
102
103 std::unique_ptr<Buffer> mesh_;
104 std::unique_ptr<Buffer> indices_;
105};
represents mathematical vector with 2 components
Definition: vector_2.h:7
represents mathematical vector with 3 components
Definition: vector_3.h:12
copperdielf Math Library
Definition: buffer.hpp:5