#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>

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

protected:
	std::unique_ptr<Vertex[]> _vertices;
	std::unique_ptr<GLuint[]> _indices;
	std::size_t _vertexCount;
	std::size_t _indexCount;

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 void generateVertices() const = 0;
    virtual void updateVertices() const = 0;
	virtual void generateIndices() const = 0;
};


#endif //GLTEST_GLOBJECT_H
