#ifndef SCENE_H_
#define SCENE_H_

#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <vector>
#include <string>

#include "fbo.h"

struct Vertex {
    glm::vec3 position;
    glm::vec2 texCoord;
};

class Scene {
    public:
        Scene(int width, int height);
        ~Scene();

        void Init();
        void GenerateGrid(int divisions, std::vector<Vertex>& verts, std::vector<GLuint>& inds);
        void Display(GLFWwindow* window);
        void DrawGui(GLFWwindow* window); 
        void Idle();
        void ReloadShader();
        std::vector<int16_t> LoadHGT(const std::string& filename, int width, int height);

        int window_width;
        int window_height;

    private:
        void InitBuffers();
        void InitQuadBuffers();
        void InitShaders();

        FBO fbo_;
        FBO post_fbo_;
        GLuint shader_program_;
        GLuint quad_shader_program_;
        GLuint vao_;
        GLuint quad_vao_;
        float angle_;
        float scale_;
        float aspect_;
        float near_z_;
        float far_z_;
        float fov_;

        glm::mat4 view_matrix_;
        glm::mat4 projection_matrix_;

        void UpdateCamera();
        int16_t SwapEndian(int16_t val);
        GLuint CreateHeightmapTexture(std::vector<int16_t> data, int width, int height);
};

#endif // SCENE_H_