51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#include "LayerComposition.h"
|
|
#include "ofUtils.h"
|
|
#include <memory>
|
|
|
|
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 = make_shared <ofxMsdfgen::Atlas>();
|
|
atlas->setup(fontPath, settings);
|
|
|
|
atlasImage = make_shared <ofImage>(atlas->getAtlasImage());
|
|
glyphGeometries = atlas->getGlyphGeometries();
|
|
msdfShader = make_shared <ofShader>();
|
|
#ifdef TARGET_EMSCRIPTEN
|
|
msdfShader->load("ofxMsdfgen/shaders/unitRange/ES3/shader");
|
|
#else
|
|
shader->load("ofxMsdfgen/shaders/unitRange/GL3/shader");
|
|
#endif
|
|
|
|
auto layer = make_unique <ofxVariableLab::MsdfLayer>();
|
|
layer->atlas = atlas;
|
|
layer->shader = msdfShader;
|
|
|
|
layer->setProps(Layer::Props());
|
|
|
|
layers.push_back(std::move(layer));
|
|
|
|
}
|
|
|
|
void LayerComposition::update(){
|
|
}
|
|
|
|
void LayerComposition::draw() const {
|
|
for(const auto & layer : layers){
|
|
layer->draw();
|
|
}
|
|
}
|
|
|
|
shared_ptr <ofImage> LayerComposition::getAtlasImage(){
|
|
return atlasImage;
|
|
}
|
|
|
|
}
|