ofxVariableLab/src/LayerComposition.cpp

53 lines
1.4 KiB
C++
Raw Normal View History

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-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>();
atlas->setup(fontPath, settings);
2023-03-25 18:59:58 +01:00
2023-03-26 21:19:37 +02:00
atlasImage = make_shared <ofImage>(atlas->getAtlasImage());
glyphGeometries = atlas->getGlyphGeometries();
2023-03-25 18:59:58 +01:00
msdfShader = make_shared <ofShader>();
#ifdef TARGET_EMSCRIPTEN
msdfShader->load("ofxMsdfgen/shaders/unitRange/ES3/shader");
#else
2023-03-28 17:48:18 +02:00
msdfShader->load("ofxMsdfgen/shaders/unitRange/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
layers.push_back(std::move(layer));
2023-03-26 21:19:37 +02:00
2023-03-25 18:59:58 +01:00
}
void LayerComposition::update(){
}
void LayerComposition::draw() const {
for(const auto & layer : layers){
layer->draw(glm::vec3(0, 200, 0));
2023-03-25 18:59:58 +01:00
}
}
shared_ptr <ofImage> LayerComposition::getAtlasImage(){
return atlasImage;
}
}