50 lines
1 KiB
C++
50 lines
1 KiB
C++
#ifndef _H_DRAWABLE_H
|
|
#define _H_DRAWABLE_H
|
|
|
|
#include <vector>
|
|
#include <variant>
|
|
#include <glm/glm.hpp>
|
|
#include <string>
|
|
|
|
using UniformValue = std::variant<
|
|
int,
|
|
bool,
|
|
float,
|
|
double,
|
|
glm::mat4,
|
|
glm::vec2
|
|
>;
|
|
|
|
struct Uniform {
|
|
std::string name;
|
|
UniformValue value;
|
|
};
|
|
|
|
class Drawable
|
|
{
|
|
public:
|
|
virtual void draw() = 0;
|
|
const unsigned getShaderID() const { return shaderID; }
|
|
const std::vector<Uniform>& getUniforms() { return uniforms; }
|
|
const std::vector<Uniform>& getOneShotUniforms() { return oneShotUniforms; }
|
|
void clearOneShot() { oneShotUniforms.clear(); }
|
|
void clearUniforms() { uniforms.clear(); }
|
|
protected:
|
|
unsigned shaderID;
|
|
template <typename T>
|
|
void editUniform(const std::string& name, T value)
|
|
{
|
|
uniforms.emplace_back(Uniform {name, value});
|
|
}
|
|
|
|
template <typename T>
|
|
void editUniformOnce(const std::string& name, T value)
|
|
{
|
|
oneShotUniforms.emplace_back(Uniform {name, value});
|
|
}
|
|
private:
|
|
std::vector<Uniform> uniforms;
|
|
std::vector<Uniform> oneShotUniforms;
|
|
};
|
|
|
|
#endif // _H_DRAWABLE_H
|