Brenta Engine 1.2
Loading...
Searching...
No Matches
buffer.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <glad/glad.h> // OpenGL driver
9
10namespace brenta
11{
12
13namespace types
14{
15
22class buffer
23{
24public:
28 unsigned int id;
33 GLenum target;
34
39 {
40 }
41
42 buffer(GLenum input_target);
43
44 constexpr buffer(const buffer&) = delete;
45 constexpr buffer& operator=(const buffer&) = delete;
46
47 constexpr buffer(buffer&& other) noexcept
48 {
49 this->id = other.id;
50 this->target = other.target;
51 other.id = 0;
52 }
53 constexpr buffer& operator=(buffer&& other) noexcept
54 {
55 this->id = other.id;
56 this->target = other.target;
57 other.id = 0;
58 return *this;
59 }
60
61 ~buffer();
62
63 void init(GLenum input_target);
64 void destroy();
65 void bind();
66 void unbind();
67
68 // Getters
69
70 int get_id();
71 GLenum get_target();
72
73 // Setters
74
75 void set_id(unsigned int id);
76 void set_target(GLenum target);
77
78 // Utilities
79
87 void copy_data(GLsizeiptr size, const void *data, GLenum usage);
98 void copy_vertices(GLsizeiptr size, const void *data, GLenum usage);
108 void copy_indices(GLsizeiptr size, const void *data, GLenum usage);
109};
110
111} // namespace types
112
113} // namespace brenta
Buffer wrapper around OpenGL buffer objects.
Definition buffer.hpp:23
void copy_indices(GLsizeiptr size, const void *data, GLenum usage)
Copy data to the buffer object.
Definition buffer.cpp:27
void copy_vertices(GLsizeiptr size, const void *data, GLenum usage)
Copy data to the buffer object.
Definition buffer.cpp:36
void copy_data(GLsizeiptr size, const void *data, GLenum usage)
Copy data to the buffer object.
Definition buffer.cpp:22
buffer()
Default constructor, does nothing.
Definition buffer.hpp:38
unsigned int id
Buffer object id, generated by OpenGL.
Definition buffer.hpp:28
GLenum target
Buffer object target (like GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER...)
Definition buffer.hpp:33