2018-09-15 01:29:05 +00:00
|
|
|
#include "LitBatch.h"
|
|
|
|
|
|
|
|
namespace charcoal
|
|
|
|
{
|
|
|
|
namespace builtin
|
|
|
|
{
|
|
|
|
void LitBatch::setup_vao()
|
|
|
|
{
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
|
|
|
|
glEnableVertexAttribArray(0);
|
|
|
|
glEnableVertexAttribArray(1);
|
2018-09-15 03:30:14 +00:00
|
|
|
glEnableVertexAttribArray(2);
|
2018-09-15 01:29:05 +00:00
|
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(LitVertex), (void*)(offsetof(LitVertex, position)));
|
|
|
|
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(LitVertex), (void*)(offsetof(LitVertex, normal)));
|
2018-09-15 07:46:42 +00:00
|
|
|
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(LitVertex), (void*)(offsetof(LitVertex, material)));
|
2018-09-15 01:29:05 +00:00
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[0]);
|
|
|
|
glEnableVertexAttribArray(3);
|
|
|
|
glEnableVertexAttribArray(4);
|
|
|
|
glEnableVertexAttribArray(5);
|
2018-09-15 03:30:14 +00:00
|
|
|
glEnableVertexAttribArray(6);
|
|
|
|
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(0 * sizeof(vec4)));
|
|
|
|
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(1 * sizeof(vec4)));
|
|
|
|
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(2 * sizeof(vec4)));
|
|
|
|
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(3 * sizeof(vec4)));
|
2018-09-15 01:29:05 +00:00
|
|
|
|
|
|
|
glVertexAttribDivisor(0, 0); // Send the mesh data once
|
|
|
|
glVertexAttribDivisor(1, 0); // Send the mesh data once
|
2018-09-15 03:30:14 +00:00
|
|
|
glVertexAttribDivisor(2, 0); // Send the mesh data once
|
2018-09-15 01:29:05 +00:00
|
|
|
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
|
2018-09-15 03:30:14 +00:00
|
|
|
glVertexAttribDivisor(6, 1); // Send the offset data for each instance drawn
|
2018-09-15 01:29:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|