a8c4b05d2f
This commit gets creates the ObjectOriented scene and gets it working. The current test program swaps a triangle from small to large with the 1 and 2 keys on the keyboard. (1 for small and 2 for large). The small triangle is rendered by the simple scene and the large one is rendered by the object oriented one.
32 lines
564 B
C++
32 lines
564 B
C++
#include "MyBatch.h"
|
|
|
|
MyBatch::MyBatch(const MyTriangle& triangle)
|
|
: m_triangle(&triangle)
|
|
{
|
|
|
|
}
|
|
|
|
void MyBatch::render() const
|
|
{
|
|
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);
|
|
}
|
|
|