#pragma once

#include <vector>

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#include "Shader.h"

class MeshRenderer
{
public:
	MeshRenderer();
	~MeshRenderer();

	void Setup
	(
		std::vector<float> vertices,
		std::vector<float> normals,
		std::vector<float> colors,
		std::vector<unsigned int> indices,
		Shader* lit_shader
	);

	void Render(Shader &shader);

	void Render(glm::mat4 projection, glm::mat4 view, glm::vec3 light_position, glm::vec3 light_color, glm::vec3 view_position);
	void Render(glm::mat4 projection, glm::mat4 view, glm::vec3 light_position, glm::vec3 light_color, glm::vec3 view_position, glm::vec3 position, glm::vec3 scale, glm::vec3 rotation);
private:
	std::vector<float> vertices;
	std::vector<float> normals;
	std::vector<float> colors;
	std::vector<unsigned int> indices;

	unsigned int VAO;
	unsigned int depth_map;
	unsigned int depth_map_FBO;

	unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
	int SCR_WIDTH = 1600;
	int SCR_HEIGHT = 900;

	Shader *shader;
	Shader *lit_shader;
	Shader *shadow_shader;

	void SetupBuffers();
	void SetupLighting();

	void RenderObject(glm::mat4 projection, glm::mat4 view, glm::mat4 model, glm::vec3 light_position, glm::vec3 light_color, glm::vec3 view_position);
	void RenderShadows(glm::mat4 projection, glm::mat4 view, glm::mat4 model, glm::vec3 light_position);
};

