galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
VertexBuffer.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_GRAPHICS_GL_VERTEXBUFFER_HPP_
9#define GALAXY_GRAPHICS_GL_VERTEXBUFFER_HPP_
10
11#include <span>
12
14
15namespace galaxy
16{
20 class VertexBuffer final
21 {
22 public:
27
31 VertexBuffer(VertexBuffer&&) noexcept;
32
37
42
49 void buffer(std::span<Vertex> vertices, std::span<unsigned int> indices);
50
57 void reserve(const int vertex_count, const int index_count);
58
69 void sub_buffer(
70 const unsigned int vi,
71 const int vertex_size,
72 const std::span<Vertex> vertices,
73 const unsigned int ei,
74 const int index_size,
75 std::span<unsigned int> indices
76 ) const;
77
85 void sub_buffer_vertices(const unsigned int vi, const int vertex_size, const std::span<Vertex> vertices) const;
86
94 void sub_buffer_indices(const unsigned int ei, const int index_size, std::span<unsigned int> indices) const;
95
104 void erase(const unsigned int vi, const int vertex_count, const unsigned int ei, const int index_count) const;
105
109 void clear() const;
110
116 [[nodiscard]]
117 int count() const noexcept;
118
124 [[nodiscard]]
125 void* offset() noexcept;
126
132 [[nodiscard]]
133 unsigned int id() const noexcept;
134
135 private:
139 VertexBuffer(const VertexBuffer&) = delete;
144
145 private:
149 unsigned int m_id;
150
154 std::size_t m_offset;
155
160 };
161} // namespace galaxy
162
163#endif
thread_local const float vertices[]
Video.cpp galaxy.
Definition Video.cpp:19
thread_local const unsigned int indices[]
Definition Video.cpp:21
Abstraction for OpenGL vertex buffer objects.
unsigned int m_id
ID returned by OpenGL when generating buffer.
void buffer(std::span< Vertex > vertices, std::span< unsigned int > indices)
Create vertex buffer.
int count() const noexcept
Get the index count.
int m_count
Index buffer count.
VertexBuffer()
Constructor.
void sub_buffer_indices(const unsigned int ei, const int index_size, std::span< unsigned int > indices) const
Sub-buffer element/index buffer.
void sub_buffer_vertices(const unsigned int vi, const int vertex_size, const std::span< Vertex > vertices) const
Sub-buffer vertex buffer.
void sub_buffer(const unsigned int vi, const int vertex_size, const std::span< Vertex > vertices, const unsigned int ei, const int index_size, std::span< unsigned int > indices) const
Sub-buffer vertex buffer.
void clear() const
Clear buffer data.
VertexBuffer(const VertexBuffer &)=delete
Copy constructor.
void erase(const unsigned int vi, const int vertex_count, const unsigned int ei, const int index_count) const
Erase a specfic segment of data.
void * offset() noexcept
Gets index offset.
void reserve(const int vertex_count, const int index_count)
Create vertex buffer without uploading.
VertexBuffer & operator=(VertexBuffer &&) noexcept
Move assignment operator.
~VertexBuffer()
Destructor.
std::size_t m_offset
Index buffer offset.
unsigned int id() const noexcept
Get OpenGL handle.
VertexBuffer & operator=(const VertexBuffer &)=delete
Copy assignment operator.
Animated.cpp galaxy.
Definition Animated.cpp:16