2022-06-04 23:44:54 +00:00
|
|
|
#include "Graphics/Renderable.h"
|
|
|
|
#include "AssetManager/ModelImporter.h"
|
|
|
|
#include "PerfCounter.h"
|
|
|
|
|
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
BarinkEngine::Renderable::Renderable()
|
2022-06-04 23:44:54 +00:00
|
|
|
{
|
2022-07-08 19:35:14 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
VAO.Create();
|
|
|
|
VAO.Bind();
|
2022-06-04 23:44:54 +00:00
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
|
|
|
|
vertexBuffer.createBuffer();
|
|
|
|
vertexBuffer.Bind(false);
|
|
|
|
vertexBuffer.setBufferData(&meshes[0].vertices[0], meshes[0].vertices.size() * sizeof(BarinkEngine::Vertex), false);
|
2022-06-04 23:44:54 +00:00
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
elementBuffer.createBuffer();
|
|
|
|
elementBuffer.Bind(true);
|
|
|
|
elementBuffer.setBufferData(&meshes[0].elements[0], meshes[0].elements.size() * sizeof(unsigned int), true);
|
2022-06-04 23:44:54 +00:00
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
VAO.AttachAttribute(0, 3, sizeof(BarinkEngine::Vertex));
|
|
|
|
|
|
|
|
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(BarinkEngine::Vertex),(void* )offsetof(BarinkEngine::Vertex, vertices));
|
|
|
|
glEnableVertexAttribArray(1);
|
2022-06-04 23:44:54 +00:00
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
//vertexBuffer.Unbind(false);
|
2022-06-04 23:44:54 +00:00
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
VAO.Unbind();
|
|
|
|
*/
|
2022-06-04 23:44:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
BarinkEngine::Renderable::~Renderable()
|
2022-06-04 23:44:54 +00:00
|
|
|
{
|
2022-07-08 19:35:14 +00:00
|
|
|
// glDeleteBuffers(1, &UV_id);
|
2022-06-04 23:44:54 +00:00
|
|
|
}
|
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
// Draw call Example !!
|
|
|
|
/*
|
|
|
|
VAO.Bind();
|
|
|
|
elementBuffer.Bind(true);
|
2022-06-04 23:44:54 +00:00
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
glActiveTexture(GL_TEXTURE0);
|
|
|
|
glUniform1i(glGetUniformLocation(shader->id, "Texture"), GL_TEXTURE0);
|
|
|
|
texture->Bind();
|
2022-06-04 23:44:54 +00:00
|
|
|
|
2022-07-08 19:35:14 +00:00
|
|
|
ES->verts = meshes[0].vertices.size();
|
|
|
|
ES->DC++;
|
|
|
|
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(meshes[0].elements.size()), GL_UNSIGNED_INT, NULL);
|
|
|
|
VAO.Unbind();
|
|
|
|
*/
|
|
|
|
|