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.
41 lines
760 B
C++
41 lines
760 B
C++
#include "MyTriangle.h"
|
|
|
|
#include "Mesh.h"
|
|
|
|
MyTriangle::MyTriangle()
|
|
{
|
|
MeshType* mesh = new MeshType();
|
|
mesh->vertices = new VertexType[3]
|
|
{
|
|
{ 0.0f, 0.75f, 0.0f },
|
|
{ 0.75f, -0.75f, 0.0f },
|
|
{ -0.75f, -0.75f, 0.0f },
|
|
};
|
|
mesh->vertex_count = 3;
|
|
mesh->indices = new unsigned int[3] { 0, 1, 2, };
|
|
mesh->index_count = 3;
|
|
m_p_mesh = mesh;
|
|
}
|
|
|
|
MyTriangle::~MyTriangle()
|
|
{
|
|
if (m_p_mesh != nullptr)
|
|
{
|
|
if (m_p_mesh->vertices != nullptr)
|
|
{
|
|
delete[] m_p_mesh->vertices;
|
|
}
|
|
if (m_p_mesh->indices != nullptr)
|
|
{
|
|
delete[] m_p_mesh->indices;
|
|
}
|
|
delete m_p_mesh;
|
|
m_p_mesh = nullptr;
|
|
}
|
|
}
|
|
|
|
void MyTriangle::populate_vbo() const
|
|
{
|
|
glBufferData(GL_ARRAY_BUFFER, m_p_mesh->vertex_count * sizeof(VertexType), m_p_mesh->vertices, GL_STATIC_DRAW);
|
|
}
|