YoggieEngine/SandboxApplication/Renderable.cpp

51 lines
1.0 KiB
C++
Raw Normal View History

#include "Renderable.h"
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_SHORT, NULL);
VAO.Unbind();
}