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

97 lines
2.5 KiB
C++

#pragma once
#include "../Pipeline.hpp"
#include <functional>
#include <memory>
#include <GL/gl3w.h>
#include "pass/WorldProgram.hpp"
#include "pass/EntityProgram.hpp"
#include "pass/SkyProgram.hpp"
#include "pass/ColorProgram.hpp"
#include "buffer/Colored.hpp"
namespace render::gl {
/// Handle OpenGL rendering passes and params
class Pipeline final: public render::Pipeline {
public:
Pipeline(const options&);
Pipeline(Pipeline &&) = delete;
Pipeline(const Pipeline &) = delete;
Pipeline &operator=(Pipeline &&) = delete;
Pipeline &operator=(const Pipeline &) = delete;
~Pipeline();
glm::vec3 LightInvDir = glm::vec3(0.5f, 2, 2);
glm::vec3 FogColor;
GLfloat FogDepth;
/// Sphere bending
/// offset.xyz radius.w
glm::vec4 SphereProj;
/// Ratio between spherical and cartesian
float Curvature;
bool SkyEnable;
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;
}
GLuint getSkyTexture() const {
return Skybox;
}
/// Start new frame and setup
void beginFrame() override;
/// 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);
/// Apply postprocessing
void endPass() override;
void swapBuffer(GLFWwindow *) override;
void setClearColor(glm::vec4) override;
/// Apply camera matrices
void lookFrom(const Camera&) override;
void reloadShaders(const pass::VoxelProgram::options &);
void reloadTextures(const std::string &, float mipMapLOD, float anisotropy);
private:
GLuint VertexArrayID;
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;
glm::mat4 ProjectionMatrix;
glm::mat4 ViewMatrix;
GLuint TextureAtlas;
GLuint NormalAtlas;
GLuint HOSAtlas;
GLuint Skybox;
void loadTextures(const std::string &, float mipMapLOD, float anisotropy);
void unloadTextures();
};
}