95 lines
2.5 KiB
C++
95 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "../../core/flags.hpp"
|
|
#include "buffer/Abstract.hpp"
|
|
#include <cassert>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <glm/glm.hpp>
|
|
#include <functional>
|
|
|
|
class Window;
|
|
class Camera;
|
|
namespace render {
|
|
|
|
/// Pass options
|
|
struct passOptions {
|
|
/// Apply light properties
|
|
bool pbr = true;
|
|
/// Triplanar texture mapping
|
|
bool triplanar = false;
|
|
/// Transform texture UV
|
|
bool stochastic = false;
|
|
/// Active geometry pass
|
|
bool geometry = false;
|
|
/// Blend voxel with mixed materials (requires geometry)
|
|
bool blend = true;
|
|
/// Depth fog
|
|
bool fog = true;
|
|
/// Map planets to sphere
|
|
bool curvature = true;
|
|
/// Keep depth in sphere
|
|
bool curv_depth = true;
|
|
};
|
|
|
|
/// Rendering options
|
|
struct renderOptions {
|
|
/// Voxel passes
|
|
passOptions voxel;
|
|
/// Display skybox
|
|
bool skybox = true;
|
|
/// Display only wires
|
|
bool wireframe = false;
|
|
/// Texture pack name
|
|
std::string textures = "1024-realistic";
|
|
/// Textures quality
|
|
float mipMapLOD = -.5;
|
|
/// Textures anisotropic mapping
|
|
int anisotropy = 0;
|
|
/// Depth color
|
|
glm::vec4 clear_color;
|
|
/// Parallel processing frames
|
|
/// Incease FPS but also a bit latency (Vulkan only)
|
|
int inFlightFrames = 2;
|
|
};
|
|
|
|
/// Rendering plateform interface
|
|
class Renderer {
|
|
public:
|
|
virtual ~Renderer() { }
|
|
|
|
glm::vec3 LightInvDir = glm::vec3(0.5f, 2, 2);
|
|
|
|
/// Start new frame and setup
|
|
virtual void beginFrame() = 0;
|
|
/// Get started world program
|
|
virtual std::function<buffer::params(glm::mat4)> beginWorldPass() = 0;
|
|
/// Get started entity program
|
|
virtual std::function<buffer::params(const std::vector<glm::mat4> &)> beginEntityPass() = 0;
|
|
/// Draw cube indicator
|
|
virtual size_t drawIndicatorCube(glm::mat4 model) = 0;
|
|
/// Apply postprocessing
|
|
virtual void endPass() = 0;
|
|
/// Swap displayed image
|
|
virtual void swapBuffer(Window &) = 0;
|
|
|
|
/// Apply camera matrices
|
|
virtual void lookFrom(const Camera &) = 0;
|
|
|
|
virtual void setClearColor(glm::vec4) = 0;
|
|
virtual void setCurvature(glm::vec4, float) = 0;
|
|
virtual void reloadShaders(const passOptions &) = 0;
|
|
virtual void reloadTextures(const std::string &, float mipMapLOD, float anisotropy) = 0;
|
|
|
|
virtual void loadUI(Window&) = 0;
|
|
|
|
static _FORCE_INLINE_ Renderer *Get() {
|
|
assert(sInstance != nullptr && "Uninitialized renderer");
|
|
return sInstance;
|
|
}
|
|
static void Unload();
|
|
|
|
protected:
|
|
static Renderer *sInstance;
|
|
};
|
|
} |