#include "gameobject.h"

#include <GL/glew.h>
#include <glm/gtc/type_ptr.hpp>

#include "internal.h"

namespace kek {

GameObject::GameObject() {

}

GameObject::~GameObject() {
	for(Mesh *mesh : meshes) {
		delete mesh;
	}
}

void GameObject::addMesh(Mesh *mesh) {
	meshes.push_back(mesh);
}

void GameObject::draw(Shader *shader) {
	glm::mat4 model = glm::mat4(1.0f);
	model = glm::translate(model, position) * glm::mat4_cast(rotation);
	glUniformMatrix4fv(glGetUniformLocation(kekData.shader->id, "model"), 1, GL_FALSE, glm::value_ptr(model));

	for(Mesh *mesh : meshes) {
		mesh->draw(shader);
	}
}

}
