diff --git a/addon_config.mk b/addon_config.mk index c98e274..0c500f7 100644 --- a/addon_config.mk +++ b/addon_config.mk @@ -24,7 +24,7 @@ meta: common: # dependencies with other addons, a list of them separated by spaces # or use += in several lines - ADDON_DEPENDENCIES = ofxMsdfgen + ADDON_DEPENDENCIES = ofxMsdfgen ofxGPUFont # include search paths, this will be usually parsed from the file system # but if the addon or addon libraries need special search paths they can be diff --git a/example/addons.make b/example/addons.make index 24228d8..91fa38f 100644 --- a/example/addons.make +++ b/example/addons.make @@ -1,2 +1,3 @@ ofxMsdfgen +ofxGPUFont ofxVariableLab diff --git a/src/Layer.h b/src/Layer.h index 6341445..130e7b4 100644 --- a/src/Layer.h +++ b/src/Layer.h @@ -1,6 +1,5 @@ #pragma once -#include "Atlas.h" #include "ofMain.h" //uuid diff --git a/src/LayerComposition.cpp b/src/LayerComposition.cpp index c957e82..8c6c821 100644 --- a/src/LayerComposition.cpp +++ b/src/LayerComposition.cpp @@ -134,14 +134,6 @@ void LayerComposition::draw() const { } } -const std::vector LayerComposition::getAvailableComboIdentifiers() const { - std::vector combos; - for(const auto & combo : atlasLayerCombos){ - combos.push_back(combo.first); - } - return combos; -} - const unordered_map > & LayerComposition::getAtlasLayerCombos() const { return atlasLayerCombos; } diff --git a/src/LayerComposition.h b/src/LayerComposition.h index 127a61f..e98f046 100644 --- a/src/LayerComposition.h +++ b/src/LayerComposition.h @@ -5,9 +5,19 @@ #include "ofxMsdfgen.h" #include "Layer.h" #include "MsdfLayer.h" +#include "GPUFontLayer.h" #include "Utils.h" #include #include +/********* + * + * plan: + * -> GPUFont has one font per layer + * -> use ofShader + * -> single glyph buffer in AtlasLayerCombo + * -> single curve buffer in AtlasLayerCombo + * + */ namespace ofxVariableLab { @@ -85,6 +95,24 @@ class MsdfAtlasLayerCombo : public AtlasLayerCombo { bool isDirty = false; }; +class GPUFontAtlasLayerCombo : public AtlasLayerCombo { + public: + void setup(const ComboIdentifier & identifier) override; + void update() override; + void careForChild(shared_ptr layer) override; + const ComboIdentifier & getIdentifier() const override; + const ofImage & getAtlasImage() override; + string getAtlasImagePath() override; + shared_ptr getLayer(); + shared_ptr atlas; + + private: + vector > layers; + shared_ptr gpuFontShader; + ComboIdentifier identifier; + bool isDirty = false; +}; + class LayerComposition { public: void setup(); @@ -98,7 +126,6 @@ class LayerComposition { const Layer::Props & props, const std::vector & variations); shared_ptr getLayer(const LayerID & layerID); - const std::vector getAvailableComboIdentifiers() const; const unordered_map > & getAtlasLayerCombos() const; void setVFlip(bool vFlip); diff --git a/src/MsdfLayer.cpp b/src/MsdfLayer.cpp index 4ba1966..f2fed8f 100644 --- a/src/MsdfLayer.cpp +++ b/src/MsdfLayer.cpp @@ -100,6 +100,7 @@ void MsdfLayer::draw(glm::vec3 position){ getVFlip(settings.vFlipBehaviour, ofGetCurrentOrientationMatrix(), vFlip); + if(vFlip == V_FLIP_OFF){ ofTranslate(pl * magic, (pt * magic) + (-1 * h), 0); }else{ diff --git a/src/ofxVariableLab.h b/src/ofxVariableLab.h index 5679503..806b201 100644 --- a/src/ofxVariableLab.h +++ b/src/ofxVariableLab.h @@ -4,4 +4,7 @@ #include "Utils.h" #include "Layer.h" #include "MsdfLayer.h" +#include "GPUFontLayer.h" #include "LayerComposition.h" + +// TODO: save characterset with atlasses when saving image on disk