2023-03-25 18:59:58 +01:00
|
|
|
#include "LayerComposition.h"
|
2023-03-26 19:42:57 +02:00
|
|
|
#include "ofUtils.h"
|
2023-03-26 21:19:37 +02:00
|
|
|
#include <memory>
|
2023-03-25 18:59:58 +01:00
|
|
|
|
|
|
|
namespace ofxVariableLab {
|
|
|
|
|
|
|
|
void LayerComposition::setup(){
|
|
|
|
ofxMsdfgen::AtlasSettings settings;
|
2023-03-26 21:19:37 +02:00
|
|
|
//settings.characters = "ABCDEFGHIJKL";
|
2023-03-28 17:48:18 +02:00
|
|
|
settings.scale = 64;
|
2023-03-29 20:47:48 +02:00
|
|
|
settings.characters = "";
|
2023-03-25 18:59:58 +01:00
|
|
|
//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";
|
2023-03-28 17:48:18 +02:00
|
|
|
//string fontPath = "data/celines-fonts/Alfarn2.otf";
|
2023-03-25 18:59:58 +01:00
|
|
|
//string fontPath = "data/celines-fonts/Cottagecore.ttf";
|
2023-03-26 21:19:37 +02:00
|
|
|
atlas = make_shared <ofxMsdfgen::Atlas>();
|
2023-03-25 18:59:58 +01:00
|
|
|
|
|
|
|
msdfShader = make_shared <ofShader>();
|
|
|
|
#ifdef TARGET_EMSCRIPTEN
|
2023-03-30 16:22:35 +02:00
|
|
|
msdfShader->load("ofxMsdfgen/shaders/mix/ES3/shader");
|
2023-03-25 18:59:58 +01:00
|
|
|
#else
|
2023-03-30 16:22:35 +02:00
|
|
|
msdfShader->load("ofxMsdfgen/shaders/mix/GL3/shader");
|
2023-03-25 18:59:58 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
auto layer = make_unique <ofxVariableLab::MsdfLayer>();
|
2023-03-26 21:19:37 +02:00
|
|
|
layer->atlas = atlas;
|
2023-03-25 18:59:58 +01:00
|
|
|
layer->shader = msdfShader;
|
2023-03-26 21:19:37 +02:00
|
|
|
|
|
|
|
layer->setProps(Layer::Props());
|
2023-03-25 18:59:58 +01:00
|
|
|
|
2023-03-29 20:47:48 +02:00
|
|
|
settings.characters += layer->getProps().text;
|
2023-03-25 18:59:58 +01:00
|
|
|
layers.push_back(std::move(layer));
|
2023-03-26 21:19:37 +02:00
|
|
|
|
2023-03-29 20:47:48 +02:00
|
|
|
atlas->setup(fontPath, settings);
|
|
|
|
atlas->generate();
|
|
|
|
atlasImage = make_shared <ofImage>(atlas->getAtlasImage());
|
|
|
|
glyphGeometries = atlas->getGlyphGeometries();
|
|
|
|
|
2023-03-25 18:59:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayerComposition::update(){
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerComposition::draw() const {
|
|
|
|
for(const auto & layer : layers){
|
2023-03-30 16:22:35 +02:00
|
|
|
layer->draw(glm::vec3(400, 200, 0));
|
2023-03-25 18:59:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shared_ptr <ofImage> LayerComposition::getAtlasImage(){
|
|
|
|
return atlasImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|