1
0
Fork 0
Univerxel/src/render/Renderer.hpp

89 lines
2.0 KiB
C++
Raw Normal View History

2020-07-10 17:49:16 +00:00
#pragma once
#include <GL/glew.h>
2020-07-12 13:46:51 +00:00
#include <imgui.h>
2020-07-10 17:49:16 +00:00
#include "pass/MainProgram.hpp"
2020-07-13 16:45:08 +00:00
#include "pass/SkyProgram.hpp"
2020-07-25 16:45:03 +00:00
#include "pass/Context.hpp"
2020-07-10 17:49:16 +00:00
class Camera;
/// Handle rendering passes and params
class Renderer {
public:
2020-07-25 16:45:03 +00:00
/// Rendering options
2020-07-10 17:49:16 +00:00
struct options {
2020-07-25 16:45:03 +00:00
/// Main pass
pass::MainProgram::options main;
/// Display skybox
2020-07-13 16:45:08 +00:00
bool skybox = false;
2020-07-25 16:45:03 +00:00
/// Display only wires
2020-07-10 17:49:16 +00:00
bool wireframe = false;
2020-07-25 16:45:03 +00:00
/// Texture pack name
2020-07-10 17:49:16 +00:00
std::string textures = "1024-realistic";
2020-07-25 16:45:03 +00:00
/// Textures quality
2020-07-10 17:49:16 +00:00
float mipMapLOD = -.5;
2020-07-25 16:45:03 +00:00
/// Depth color
2020-07-12 13:46:51 +00:00
ImVec4 clear_color;
2020-07-10 17:49:16 +00:00
};
Renderer(const options&);
Renderer(Renderer &&) = delete;
Renderer(const Renderer &) = delete;
Renderer &operator=(Renderer &&) = delete;
Renderer &operator=(const Renderer &) = delete;
~Renderer();
glm::vec3 LightInvDir = glm::vec3(0.5f, 2, 2);
2020-07-10 19:37:49 +00:00
glm::vec3 FogColor;
GLfloat FogDepth;
2020-07-10 17:49:16 +00:00
2020-07-13 16:45:08 +00:00
bool SkyEnable;
2020-07-10 17:49:16 +00:00
glm::mat4 getProjectionMatrix() const {
return ProjectionMatrix;
}
glm::mat4 getViewMatrix() const {
return ViewMatrix;
}
GLuint getTextureAtlas() const {
return TextureAtlas;
}
GLuint getNormalAtlas() const {
return NormalAtlas;
}
GLuint getHOSAtlas() const {
return HOSAtlas;
}
2020-07-13 16:45:08 +00:00
GLuint getSkyTexture() const {
return Skybox;
}
2020-07-10 17:49:16 +00:00
2020-07-25 16:45:03 +00:00
/// Get main pass with context
pass::Context getPass();
/// Apply postprocessing
2020-07-13 16:45:08 +00:00
void postProcess();
2020-07-10 17:49:16 +00:00
2020-07-25 16:45:03 +00:00
/// Apply camera matrices
2020-07-10 17:49:16 +00:00
void lookFrom(const Camera&);
2020-07-25 16:45:03 +00:00
void reloadShaders(const pass::MainProgram::options &);
2020-07-10 17:49:16 +00:00
void reloadTextures(const std::string &, float mipMapLOD = 0);
private:
GLuint VertexArrayID;
2020-07-25 16:45:03 +00:00
pass::MainProgram *MainPass;
pass::SkyProgram *SkyPass;
2020-07-10 17:49:16 +00:00
glm::mat4 ProjectionMatrix;
glm::mat4 ViewMatrix;
GLuint TextureAtlas;
GLuint NormalAtlas;
GLuint HOSAtlas;
2020-07-13 16:45:08 +00:00
GLuint Skybox;
2020-07-10 17:49:16 +00:00
void loadTextures(const std::string &, float mipMapLOD = 0);
void unloadTextures();
};