charcoal/OpenGLEngine/MyBatch.cpp

33 lines
601 B
C++
Raw Normal View History

#include "MyBatch.h"
MyBatch::MyBatch(const MyTriangle& triangle)
: m_triangle(&triangle)
{
}
void MyBatch::render() const
{
// 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);
}