2022-05-28 11:32:17 +00:00
|
|
|
#include "Graphics/Renderable.h"
|
|
|
|
#include "AssetManager/ModelImporter.h"
|
|
|
|
|
|
|
|
|
2022-05-27 20:47:36 +00:00
|
|
|
|
|
|
|
Renderable Renderable::Load()
|
|
|
|
{
|
|
|
|
return Renderable();
|
|
|
|
}
|
|
|
|
|
|
|
|
Renderable::Renderable()
|
|
|
|
{
|
|
|
|
|
|
|
|
meshes = ModelImporter::Test();
|
|
|
|
|
|
|
|
transform.Scale = glm::vec3(1.0f);
|
|
|
|
transform.Rotation = glm::vec3(0.0f, 90.0f, 0.0f);
|
|
|
|
transform.Position = glm::vec3(0.0f, 0.0f, -10.0f);
|
|
|
|
|
|
|
|
|
|
|
|
VAO.Create();
|
|
|
|
VAO.Bind();
|
|
|
|
|
|
|
|
|
|
|
|
vertexBuffer.createBuffer();
|
|
|
|
vertexBuffer.Bind(false);
|
|
|
|
vertexBuffer.setBufferData(&meshes[0].vertices[0], meshes[0].vertices.size() * sizeof(glm::vec3), false);
|
|
|
|
|
|
|
|
|
|
|
|
elementBuffer.createBuffer();
|
|
|
|
elementBuffer.Bind(true);
|
|
|
|
elementBuffer.setBufferData(&meshes[0].elements[0], meshes[0].elements.size() * sizeof(unsigned int), true);
|
|
|
|
|
|
|
|
VAO.AttachAttribute(0, 3, 0);
|
|
|
|
|
|
|
|
vertexBuffer.Unbind(false);
|
|
|
|
VAO.Unbind();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Renderable::~Renderable()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Renderable::Draw()
|
|
|
|
{
|
|
|
|
VAO.Bind();
|
|
|
|
elementBuffer.Bind(true);
|
|
|
|
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(meshes[0].elements.size()), GL_UNSIGNED_INT, NULL);
|
|
|
|
VAO.Unbind();
|
|
|
|
|
|
|
|
}
|