1
0
Fork 0
Univerxel/src/client/render/gl/Pipeline.hpp

97 lines
2.5 KiB
C++
Raw Normal View History

2020-07-10 17:49:16 +00:00
#pragma once
2020-09-14 16:03:21 +00:00
#include "../Pipeline.hpp"
2020-08-30 16:35:45 +00:00
#include <functional>
#include <memory>
2020-09-13 09:30:48 +00:00
#include <GL/gl3w.h>
2020-08-30 16:35:45 +00:00
#include "pass/WorldProgram.hpp"
#include "pass/EntityProgram.hpp"
2020-07-13 16:45:08 +00:00
#include "pass/SkyProgram.hpp"
2020-08-30 16:35:45 +00:00
#include "pass/ColorProgram.hpp"
#include "buffer/Colored.hpp"
2020-07-10 17:49:16 +00:00
2020-09-14 16:03:21 +00:00
namespace render::gl {
/// Handle OpenGL rendering passes and params
class Pipeline final: public render::Pipeline {
2020-07-10 17:49:16 +00:00
public:
2020-09-14 16:03:21 +00:00
Pipeline(const options&);
Pipeline(Pipeline &&) = delete;
Pipeline(const Pipeline &) = delete;
Pipeline &operator=(Pipeline &&) = delete;
Pipeline &operator=(const Pipeline &) = delete;
~Pipeline();
2020-07-10 17:49:16 +00:00
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-08-14 16:56:28 +00:00
/// Sphere bending
/// offset.xyz radius.w
glm::vec4 SphereProj;
/// Ratio between spherical and cartesian
float Curvature;
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-08-30 16:35:45 +00:00
/// Start new frame and setup
2020-09-14 16:03:21 +00:00
void beginFrame() override;
2020-08-30 16:35:45 +00:00
/// Get started world program
std::function<buffer::params(glm::mat4)> beginWorldPass();
/// Get started entity program
std::function<buffer::params(const std::vector<glm::mat4>&)> beginEntityPass();
/// Draw cube indicator
size_t drawIndicatorCube(glm::mat4 model);
2020-07-25 16:45:03 +00:00
/// Apply postprocessing
2020-09-14 16:03:21 +00:00
void endPass() override;
void swapBuffer(GLFWwindow *) override;
void setClearColor(glm::vec4) override;
2020-07-10 17:49:16 +00:00
2020-07-25 16:45:03 +00:00
/// Apply camera matrices
2020-09-14 16:03:21 +00:00
void lookFrom(const Camera&) override;
2020-08-30 16:35:45 +00:00
void reloadShaders(const pass::VoxelProgram::options &);
void reloadTextures(const std::string &, float mipMapLOD, float anisotropy);
2020-07-10 17:49:16 +00:00
private:
GLuint VertexArrayID;
2020-08-30 16:35:45 +00:00
std::unique_ptr<pass::WorldProgram> WorldPass;
std::unique_ptr<pass::EntityProgram> EntityPass;
std::unique_ptr<pass::SkyProgram> SkyPass;
std::unique_ptr<pass::ColorProgram> IndicatorPass;
buffer::Colored IndicatorCubeBuffer;
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, float anisotropy);
2020-07-10 17:49:16 +00:00
void unloadTextures();
};
2020-09-14 16:03:21 +00:00
}