#ifndef GLTEST_MESH_H
#define GLTEST_MESH_H

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

#include <cstddef>
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <vector>
#include <array>


class Mesh: public GLObject {
protected:
	size_t _size;
    std::vector<float> _xs;
    std::vector<float> _ys;
	mutable std::vector<glm::vec3> _normals;
	mutable std::array<glm::vec3, 6> _adjacentTriangles;

public:
	Mesh(ShaderProgram* shader, std::size_t size);
	virtual ~Mesh();

private:
    ptrdiff_t normalIndex(ptrdiff_t x, ptrdiff_t y) const;

protected:
	void generateVertices() const override final;
    void updateVertices() const override final;
	void generateIndices() const override final;

protected:
	virtual float heightMap(std::size_t nx, std::size_t ny) const = 0;
    virtual float heightMap(float fx, float fy) const = 0;
};


#endif //GLTEST_MESH_H
