2018-09-05 15:47:09 +00:00
|
|
|
#include "MyBatch.h"
|
|
|
|
|
2018-09-05 20:26:50 +00:00
|
|
|
MyBatch::MyBatch(const MyTriangle& triangle)
|
|
|
|
: m_triangle(&triangle)
|
2018-09-05 15:47:09 +00:00
|
|
|
{
|
2018-09-05 20:26:50 +00:00
|
|
|
|
2018-09-05 15:47:09 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 20:26:50 +00:00
|
|
|
void MyBatch::render() const
|
2018-09-05 15:47:09 +00:00
|
|
|
{
|
2018-09-05 20:26:50 +00:00
|
|
|
// For now, just render everything!
|
|
|
|
glBindVertexArray(m_vao);
|
|
|
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyBatch::populate_vbos()
|
|
|
|
{
|
|
|
|
glGenBuffers(1, &m_vbo);
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
|
|
|
m_triangle->populate_vbo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyBatch::setup_vao()
|
|
|
|
{
|
|
|
|
glGenVertexArrays(1, &m_vao);
|
|
|
|
glBindVertexArray(m_vao);
|
|
|
|
glEnableVertexAttribArray(0);
|
|
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
|
|
|
glBindVertexArray(0);
|
|
|
|
}
|
|
|
|
|