2018-09-05 06:49:02 +00:00
|
|
|
#include "MyTriangle.h"
|
|
|
|
|
2018-09-05 15:47:09 +00:00
|
|
|
#include "Mesh.h"
|
|
|
|
|
2018-09-05 06:49:02 +00:00
|
|
|
MyTriangle::MyTriangle()
|
|
|
|
{
|
2018-09-05 15:47:09 +00:00
|
|
|
MeshType* mesh = new MeshType();
|
|
|
|
mesh->vertices = new VertexType[3]
|
|
|
|
{
|
2018-09-05 23:10:38 +00:00
|
|
|
{ 0.0f, 0.75f, 0.0f },
|
|
|
|
{ 0.75f, -0.75f, 0.0f },
|
|
|
|
{ -0.75f, -0.75f, 0.0f },
|
2018-09-05 15:47:09 +00:00
|
|
|
};
|
|
|
|
mesh->vertex_count = 3;
|
|
|
|
mesh->indices = new unsigned int[3] { 0, 1, 2, };
|
|
|
|
mesh->index_count = 3;
|
|
|
|
m_p_mesh = mesh;
|
2018-09-05 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MyTriangle::~MyTriangle()
|
|
|
|
{
|
2018-09-05 15:47:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2018-09-05 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 20:26:50 +00:00
|
|
|
void MyTriangle::populate_vbo() const
|
|
|
|
{
|
|
|
|
glBufferData(GL_ARRAY_BUFFER, m_p_mesh->vertex_count * sizeof(VertexType), m_p_mesh->vertices, GL_STATIC_DRAW);
|
|
|
|
}
|