ofxVariableLab/src/Layer.h

62 lines
1.9 KiB
C++

#pragma once
#include "ofMain.h"
//uuid
#include "random_id.h"
#include "ofxMsdfgen.h"
#include "Utils.h"
#include <memory>
namespace ofxVariableLab {
using LayerID = string;
struct LayerSettings {
uint32_t maxBufferSize = 100;
VFlipBehaviour vFlipBehaviour = V_FLIP_ONCE_AUTO;
};
class Layer {
public:
enum Type {
MSDFGEN = 0,
GPUFONT
};
struct Props {
float x = 0;
float y = 0;
float rotation = 0;
float fontSize_px = 24;
float color[4];
bool mirror_x = false;
float mirror_x_distance = 0;
bool mirror_y = false;
float mirror_y_distance = 0;
float letterDelay = 0;
string text = "abc";
string fontPath;
};
virtual void setup(const LayerSettings & settings = LayerSettings()) = 0;
virtual void update() = 0;
virtual void draw(glm::vec3 position = glm::vec3(0, 0, 0)) = 0;
virtual void drawCharacter(const char character,
glm::vec3 position = glm::vec3(0, 0, 0),
glm::vec4 color = glm::vec4(1, 1, 1, 1),
float rotation = 0,
float scale = 1,
ofxVariableLab::FontVariation fontVariation = ofxVariableLab::FontVariation()) = 0;
virtual void setProps(const Props & props) = 0;
virtual const Props & getProps() const = 0;
virtual void clearPropsBuffer() = 0;
virtual void setId(const LayerID & id) = 0;
virtual const LayerID & getId() = 0;
virtual void setShader(shared_ptr <ofShader> _shader) = 0;
virtual shared_ptr <ofShader> getShader() const = 0;
virtual const Type & getType() const = 0;
virtual void setVFlip(const VFlipState vFlip) = 0;
static int n_layers;
};
}