diff --git a/src/Layer.h b/src/Layer.h index 6797073..ab003e0 100644 --- a/src/Layer.h +++ b/src/Layer.h @@ -5,6 +5,8 @@ //uuid #include "random_id.h" +#include "ofxMsdfgen.h" + namespace ofxVariableLab { class Layer { diff --git a/src/LayerComposition.cpp b/src/LayerComposition.cpp new file mode 100644 index 0000000..d18c41a --- /dev/null +++ b/src/LayerComposition.cpp @@ -0,0 +1,53 @@ +#include "LayerComposition.h" + +namespace ofxVariableLab { + +void LayerComposition::setup(){ + ofxMsdfgen::AtlasSettings settings; + settings.characters = "ABCDEFGHIJKL"; + settings.scale = 64; + //string fontName = "RobotoFlex.ttf"; + //string fontPath = "data/fonts/" + fontName; + //string fontPath = "data/celines-fonts/testing2VF.ttf"; + string fontPath = "data/celines-fonts/Version-2-var.ttf"; + //string fontPath = "data/celines-fonts/Cottagecore.ttf"; + atlas.setup(fontPath, settings); + + atlasImage = make_shared (atlas.getAtlasImage()); + glyphGeometries = atlas.getGlyphGeometries(); + msdfShader = make_shared (); + #ifdef TARGET_EMSCRIPTEN + msdfShader->load("ofxMsdfgen/shaders/unitRange/ES3/shader"); + #else + shader->load("ofxMsdfgen/shaders/unitRange/GL3/shader"); + #endif + + auto layer = make_unique (); + layer->atlasImage = atlasImage; + layer->shader = msdfShader; + layer->atlasImage->update(); + + layers.push_back(std::move(layer)); +} + +void LayerComposition::update(){ +} + +void LayerComposition::draw() const { + //ofClear(ofFloatColor( + //ofRandom(0, 1), + //ofRandom(0, 1), + //ofRandom(0, 1) + //)); + for(const auto & layer : layers){ + layer->draw(); + } + ofPushStyle(); + ofPopStyle(); +} + +shared_ptr LayerComposition::getAtlasImage(){ + return atlasImage; +} + +} diff --git a/src/LayerComposition.h b/src/LayerComposition.h new file mode 100644 index 0000000..d0f262a --- /dev/null +++ b/src/LayerComposition.h @@ -0,0 +1,29 @@ +#pragma once + +#include "ofMain.h" +#include "ofxMsdfgen.h" +#include "Layer.h" +#include + +namespace ofxVariableLab { + +class LayerComposition { + public: + void setup(); + void update(); + void draw() const; + shared_ptr getAtlasImage(); + #ifdef TARGET_EMSCRIPTEN + #else + #endif + + private: + ofxMsdfgen::Atlas atlas; + shared_ptr atlasImage; + vector glyphGeometries; + shared_ptr msdfShader; + + vector > layers; +}; + +} diff --git a/src/ofxVariableLab.h b/src/ofxVariableLab.h index 3cc010a..680ddf9 100644 --- a/src/ofxVariableLab.h +++ b/src/ofxVariableLab.h @@ -2,3 +2,4 @@ #include "random_id.h" #include "Layer.h" +#include "LayerComposition.h"