#ifndef GLTEST_GLOBJECT_H
#define GLTEST_GLOBJECT_H

#include "IGLObject.h"
#include "../Shaders/ShaderProgram.h"
#include "vertex.h"

#include <tuple>
#include <memory>
#include <GL/glew.h>

template <typename T>
using ArrayWithSize = std::tuple<std::unique_ptr<T[]>,std::size_t>;

using VertexArray = ArrayWithSize<Vertex>;
using IndexArray = ArrayWithSize<GLuint>;

class GLObject: public IGLObject {
private:
	GLuint _vertexVbo;
	GLuint _indexVbo;
	GLuint _vao;
	glm::mat4 _worldMatrix;
	ShaderProgram* _sp;
	GLuint _trianglesCount;

public:
	GLObject(ShaderProgram *shaderProgram);
	virtual ~GLObject();

	void create() override final;
	void rotate(glm::vec3 angles) override final;
	void scale(glm::vec3 scaleFactor) override final;
	void translate(glm::vec3 point) override final;
	void draw() override final;
	void update() override final;

protected:
	virtual VertexArray generateVertices() const = 0;
	virtual IndexArray generateIndices() const = 0;
};


#endif //GLTEST_GLOBJECT_H
