settable vFlip

This commit is contained in:
jrkb 2023-04-11 13:17:30 +02:00
parent 454591f2b5
commit 957768cf61
5 changed files with 15 additions and 2 deletions

View file

@ -57,6 +57,7 @@ class Layer {
virtual void setShader(shared_ptr <ofShader> _shader) = 0; virtual void setShader(shared_ptr <ofShader> _shader) = 0;
virtual shared_ptr <ofShader> getShader() const = 0; virtual shared_ptr <ofShader> getShader() const = 0;
virtual const Type & getType() const = 0; virtual const Type & getType() const = 0;
virtual void setVFlip(const VFlipState vFlip) = 0;
static int n_layers; static int n_layers;
}; };
} }

View file

@ -100,6 +100,7 @@ LayerID LayerComposition::addLayer(const ComboIdentifier & identifier,
auto combo = make_shared <MsdfAtlasLayerCombo>(); auto combo = make_shared <MsdfAtlasLayerCombo>();
combo->setup(identifier); // TODO: add here text and variations combo->setup(identifier); // TODO: add here text and variations
auto layer = make_shared <MsdfLayer>(); auto layer = make_shared <MsdfLayer>();
layer->vFlip = vFlipState;
layer->setProps(props); layer->setProps(props);
layer->setup(); layer->setup();
std::vector <ofxMsdfgen::FontVariation> msdfVariations; std::vector <ofxMsdfgen::FontVariation> msdfVariations;
@ -145,4 +146,11 @@ const unordered_map <ComboIdentifier, shared_ptr <AtlasLayerCombo> > & LayerComp
return atlasLayerCombos; return atlasLayerCombos;
} }
void LayerComposition::setVFlip(bool vFlip){
vFlipState = vFlip ? V_FLIP_ON : V_FLIP_OFF;
for(auto & layer : layers){
layer.second->setVFlip(vFlipState);
}
}
} }

View file

@ -100,10 +100,10 @@ class LayerComposition {
shared_ptr <ofxVariableLab::Layer> getLayer(const LayerID & layerID); shared_ptr <ofxVariableLab::Layer> getLayer(const LayerID & layerID);
const std::vector <ComboIdentifier> getAvailableComboIdentifiers() const; const std::vector <ComboIdentifier> getAvailableComboIdentifiers() const;
const unordered_map <ComboIdentifier, shared_ptr <AtlasLayerCombo> > & getAtlasLayerCombos() const; const unordered_map <ComboIdentifier, shared_ptr <AtlasLayerCombo> > & getAtlasLayerCombos() const;
void setVFlip(bool vFlip);
private: private:
VFlipState vFlipState = V_FLIP_UNKNOWN;
unordered_map <LayerID, shared_ptr <ofxVariableLab::Layer> > layers; unordered_map <LayerID, shared_ptr <ofxVariableLab::Layer> > layers;
unordered_map <ComboIdentifier, shared_ptr <AtlasLayerCombo> > atlasLayerCombos; unordered_map <ComboIdentifier, shared_ptr <AtlasLayerCombo> > atlasLayerCombos;
//unordered_map <LayerIdentifier, shared_ptr <ofxVariableLab::Layer> > layers; //unordered_map <LayerIdentifier, shared_ptr <ofxVariableLab::Layer> > layers;

View file

@ -273,6 +273,9 @@ shared_ptr <ofShader> MsdfLayer::getShader() const {
const Layer::Type & MsdfLayer::getType() const { const Layer::Type & MsdfLayer::getType() const {
return type; return type;
} }
void MsdfLayer::setVFlip(const VFlipState vFlip){
this->vFlip = vFlip;
}
void MsdfLayer::setAtlas(shared_ptr <ofxMsdfgen::Atlas> _atlas){ void MsdfLayer::setAtlas(shared_ptr <ofxMsdfgen::Atlas> _atlas){
atlas = _atlas; atlas = _atlas;

View file

@ -27,6 +27,7 @@ class MsdfLayer : public Layer {
void setShader(shared_ptr <ofShader> _shader) override; void setShader(shared_ptr <ofShader> _shader) override;
shared_ptr <ofShader> getShader() const override; shared_ptr <ofShader> getShader() const override;
const Type & getType() const override; const Type & getType() const override;
void setVFlip(const VFlipState vFlip) override;
void setAtlas(shared_ptr <ofxMsdfgen::Atlas> _atlas); void setAtlas(shared_ptr <ofxMsdfgen::Atlas> _atlas);
shared_ptr <ofxMsdfgen::Atlas> getAtlas() const; shared_ptr <ofxMsdfgen::Atlas> getAtlas() const;