2024-08-13 16:25:56 -04:00
|
|
|
#ifndef SCENE_H_
|
|
|
|
#define SCENE_H_
|
|
|
|
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include <glm/glm.hpp>
|
2024-08-15 00:56:29 -04:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2024-08-13 16:25:56 -04:00
|
|
|
|
2024-08-13 17:47:16 -04:00
|
|
|
#include "fbo.h"
|
2024-08-21 17:14:35 -04:00
|
|
|
#include "camera.h"
|
2024-08-26 16:53:49 -04:00
|
|
|
#include "interface.h"
|
2024-08-13 17:47:16 -04:00
|
|
|
|
2024-08-17 12:25:42 -04:00
|
|
|
struct Vertex {
|
|
|
|
glm::vec3 position;
|
|
|
|
glm::vec2 texCoord;
|
|
|
|
};
|
|
|
|
|
2024-08-13 16:25:56 -04:00
|
|
|
class Scene {
|
2024-08-13 18:09:49 -04:00
|
|
|
public:
|
|
|
|
Scene(int width, int height);
|
|
|
|
~Scene();
|
|
|
|
|
|
|
|
void Init();
|
2024-08-17 12:25:42 -04:00
|
|
|
void GenerateGrid(int divisions, std::vector<Vertex>& verts, std::vector<GLuint>& inds);
|
2024-08-13 18:09:49 -04:00
|
|
|
void Display(GLFWwindow* window);
|
|
|
|
void DrawGui(GLFWwindow* window);
|
|
|
|
void Idle();
|
|
|
|
void ReloadShader();
|
2024-08-26 16:53:49 -04:00
|
|
|
void UpdateCamera();
|
2024-08-28 09:45:08 -04:00
|
|
|
void OnScreenResize(Window* viewport);
|
2024-08-26 16:53:49 -04:00
|
|
|
void UpdateViewport();
|
2024-08-15 00:56:29 -04:00
|
|
|
std::vector<int16_t> LoadHGT(const std::string& filename, int width, int height);
|
2024-08-13 18:09:49 -04:00
|
|
|
|
|
|
|
int window_width;
|
|
|
|
int window_height;
|
2024-08-28 09:45:08 -04:00
|
|
|
|
|
|
|
std::vector<Window> windows_;
|
2024-08-13 18:09:49 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
void InitBuffers();
|
2024-08-14 02:16:53 -04:00
|
|
|
void InitQuadBuffers();
|
2024-08-13 18:09:49 -04:00
|
|
|
void InitShaders();
|
2024-08-26 16:53:49 -04:00
|
|
|
void InitUI();
|
2024-08-13 18:09:49 -04:00
|
|
|
|
2024-08-21 17:14:35 -04:00
|
|
|
Camera activeCamera_;
|
2024-08-20 00:47:41 -04:00
|
|
|
Framebuffer geo_fbo_;
|
|
|
|
Framebuffer lht_fbo_;
|
2024-08-13 18:09:49 -04:00
|
|
|
GLuint shader_program_;
|
2024-08-14 02:16:53 -04:00
|
|
|
GLuint quad_shader_program_;
|
2024-08-13 18:09:49 -04:00
|
|
|
GLuint vao_;
|
2024-08-14 02:16:53 -04:00
|
|
|
GLuint quad_vao_;
|
2024-08-13 18:09:49 -04:00
|
|
|
float angle_;
|
|
|
|
float scale_;
|
|
|
|
float aspect_;
|
|
|
|
float near_z_;
|
|
|
|
float far_z_;
|
|
|
|
float fov_;
|
|
|
|
|
|
|
|
glm::mat4 view_matrix_;
|
|
|
|
glm::mat4 projection_matrix_;
|
|
|
|
|
2024-08-15 01:09:37 -04:00
|
|
|
int16_t SwapEndian(int16_t val);
|
2024-08-15 00:56:29 -04:00
|
|
|
GLuint CreateHeightmapTexture(std::vector<int16_t> data, int width, int height);
|
2024-08-13 16:25:56 -04:00
|
|
|
};
|
|
|
|
|
2024-08-13 17:47:16 -04:00
|
|
|
#endif // SCENE_H_
|