43 lines
1.7 KiB
C++
43 lines
1.7 KiB
C++
#include "TexturedBatch.h"
|
|
|
|
namespace charcoal
|
|
{
|
|
namespace builtin
|
|
{
|
|
namespace textured
|
|
{
|
|
void Batch::preprender() const
|
|
{
|
|
glActiveTexture(GL_TEXTURE0);
|
|
glBindTexture(GL_TEXTURE_2D, m_p_renderable->get_texture()->get_texture());
|
|
glBindSampler(0, m_p_renderable->get_sampler()->get_sampler());
|
|
}
|
|
|
|
void Batch::setup_vao()
|
|
{
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
|
|
glEnableVertexAttribArray(0);
|
|
glEnableVertexAttribArray(1);
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position));
|
|
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, uv));
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[0]);
|
|
glEnableVertexAttribArray(2);
|
|
glEnableVertexAttribArray(3);
|
|
glEnableVertexAttribArray(4);
|
|
glEnableVertexAttribArray(5);
|
|
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(0 * sizeof(vec4)));
|
|
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(1 * sizeof(vec4)));
|
|
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(2 * sizeof(vec4)));
|
|
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(3 * sizeof(vec4)));
|
|
|
|
glVertexAttribDivisor(0, 0); // Send the mesh data once
|
|
glVertexAttribDivisor(1, 0); // Send the mesh data once
|
|
glVertexAttribDivisor(2, 1); // Send the offset data for each instance drawn
|
|
glVertexAttribDivisor(3, 1); // Send the offset data for each instance drawn
|
|
glVertexAttribDivisor(4, 1); // Send the offset data for each instance drawn
|
|
glVertexAttribDivisor(5, 1); // Send the offset data for each instance drawn
|
|
}
|
|
}
|
|
}
|
|
}
|