17 m_index_count =
static_cast<int>(
indices.size());
18 m_vertex_length = max * vertex_count;
19 m_index_length = max * m_index_count;
21 m_vertices.resize(m_vertex_length, {});
22 m_vao.reserve(m_vertex_length, m_index_length);
25 std::vector<unsigned int> index_data;
26 index_data.reserve(m_index_length);
29 for (
auto i = 0; i < max; ++i)
31 for (
auto j = 0; j < m_index_count; ++j)
33 index_data.emplace_back(
indices[j] + offset);
37 offset += vertex_count;
40 m_vao.sub_buffer_indices(0, m_index_length, index_data);
45 this->m_vertex_count = vb.m_vertex_count;
46 this->m_index_count = vb.m_index_count;
47 this->m_count = vb.m_count;
48 this->m_vertex_length = vb.m_vertex_length;
49 this->m_index_length = vb.m_index_length;
50 this->m_vertices = std::move(vb.m_vertices);
51 this->m_vao = std::move(vb.m_vao);
58 this->m_vertex_count = vb.m_vertex_count;
59 this->m_index_count = vb.m_index_count;
60 this->m_count = vb.m_count;
61 this->m_vertex_length = vb.m_vertex_length;
62 this->m_index_length = vb.m_index_length;
63 this->m_vertices = std::move(vb.m_vertices);
64 this->m_vao = std::move(vb.m_vao);
82 for (
auto i = 0; i <
vertices.size(); ++i)
84 m_vertices[m_vertex_count + i].m_pos =
vertices[i].m_pos;
85 m_vertices[m_vertex_count + i].m_texels =
vertices[i].m_texels;
86 m_vertices[m_vertex_count + i].m_index =
vertices[i].m_index;
89 m_vertex_count +=
static_cast<int>(
vertices.size());
90 m_count += m_index_count;
thread_local const float vertices[]
Video.cpp galaxy.
thread_local const unsigned int indices[]
Abstraction for OpenGL vertex array objects.
void bind() const
Bind this vertex array.
void * offset() noexcept
Gets index offset.
void sub_buffer_vertices(const unsigned int vi, const int vertex_size, const std::span< Vertex > vertices) const
Sub-buffer vertex buffer.
A group of vertices for multiple renderables batched together.
int m_vertex_count
Amount of vertices to flush.
void bind() const noexcept
Bind this batchs vertex array object.
VertexBatch()=delete
Constructor.
std::vector< Vertex > m_vertices
CPU side reserved vertices.
VertexArray m_vao
VAO object for GPU data.
void push(const std::vector< Vertex > &vertices) noexcept
Add vertex and index data to batch.
VertexBatch & operator=(VertexBatch &&) noexcept
Move assignment operator.
void flush() noexcept
Copy all data to GPU.
int count() const noexcept
Get the index count.
void prepare() noexcept
Sets up counters to begin pushing vertices.
~VertexBatch() noexcept
Destructor.
int m_count
Amount of renderables to draw.
void * offset() noexcept
Gets index offset.
VertexArray & vao() noexcept
Gets internal VAO.