ofxVariableLab/src/GPUFontLayer.h

76 lines
3 KiB
C++

#pragma once
#include "ofxProfiler.h"
#include "AtlasLayerCombo.h"
#include "font.hpp"
#include "ofMain.h"
#include "ofxGPUFont.h"
#include "Atlas.h"
#include "Layer.h"
#include "Utils.h"
namespace ofxVariableLab {
class GPUFontLayer : public Layer {
public:
void setup(const LayerSettings & settings = LayerSettings()) override;
void update() override;
void draw(glm::vec3 position = glm::vec3(0, 0, 0)) override;
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()) override;
void setProps(const Props & props) override;
const Props & getProps(float delay = 0) override;
void clearPropsBuffer() override;
void setId(const LayerID & id) override;
const LayerID & getId() override;
void setShader(shared_ptr <ofShader> _shader) override {
ofLogError("GPUFontLayer") << "using OpenGL shaders directly, no ofShader implemented";
}
shared_ptr <ofShader> getShader() const override {
ofLogError("GPUFontLayer") << "using OpenGL shaders directly, no ofShader implemented";
return NULL; // evil?
}
const LayerType & getType() const override;
void setVFlip(const VFlipState vFlip) override;
bool isDirtyDirty() const override;
void setDirtyDirty(bool dirtyDirty) override;
bool wantsNewMom() override;
void isWithNewMom() override;
const ComboIdentifier & getMomsComboIdentifier() const override;
void setMomsComboIdentifier(const ComboIdentifier & identifier) override;
ofNode & getOuterNode() override;
ofNode & getInnerNode() override;
const Layer::BoundingBox & getBoundingBox() override;
void setBoundingBox(const Layer::BoundingBox & boundingBox) override;
void setBoundingBox(const ofxGPUFont::Font::BoundingBox & boundingBox);
const vector <ofxGPUFont::GlyphIdentity> & getVariationText();
const vector <ofxGPUFont::GlyphAppearance> & getVariationTextAppearance();
LayerSettings settings;
/// \brief are props updated but not drawn yet
bool isDirty = true;
/// \brief hashed id, or just counting up
string id = "";
VFlipState vFlip = V_FLIP_UNKNOWN;
vector <ofxGPUFont::GlyphIdentity> variationText;
vector <ofxGPUFont::GlyphAppearance> variationTextAppearance;
private:
std::deque <Props> propsBuffer;
Props lastProps;
Props delayProps;
ComboIdentifier momsComboIdentifier;
bool notHappyWithMom = false;
LayerType type = GPUFONT;
ofNode outerNode;
ofNode innerNode;
int letterDelayBufferSize = 0;
Layer::BoundingBox boundingBox;
};
}