add LayerComposition
This commit is contained in:
parent
aa3be65dae
commit
2de3eeadf2
4 changed files with 85 additions and 0 deletions
|
@ -5,6 +5,8 @@
|
|||
//uuid
|
||||
#include "random_id.h"
|
||||
|
||||
#include "ofxMsdfgen.h"
|
||||
|
||||
namespace ofxVariableLab {
|
||||
|
||||
class Layer {
|
||||
|
|
53
src/LayerComposition.cpp
Normal file
53
src/LayerComposition.cpp
Normal file
|
@ -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 <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->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 <ofImage> LayerComposition::getAtlasImage(){
|
||||
return atlasImage;
|
||||
}
|
||||
|
||||
}
|
29
src/LayerComposition.h
Normal file
29
src/LayerComposition.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include "ofMain.h"
|
||||
#include "ofxMsdfgen.h"
|
||||
#include "Layer.h"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace ofxVariableLab {
|
||||
|
||||
class LayerComposition {
|
||||
public:
|
||||
void setup();
|
||||
void update();
|
||||
void draw() const;
|
||||
shared_ptr <ofImage> getAtlasImage();
|
||||
#ifdef TARGET_EMSCRIPTEN
|
||||
#else
|
||||
#endif
|
||||
|
||||
private:
|
||||
ofxMsdfgen::Atlas atlas;
|
||||
shared_ptr <ofImage> atlasImage;
|
||||
vector <ofxMsdfgen::GlyphGeometry> glyphGeometries;
|
||||
shared_ptr <ofShader> msdfShader;
|
||||
|
||||
vector <unique_ptr <ofxVariableLab::Layer> > layers;
|
||||
};
|
||||
|
||||
}
|
|
@ -2,3 +2,4 @@
|
|||
|
||||
#include "random_id.h"
|
||||
#include "Layer.h"
|
||||
#include "LayerComposition.h"
|
||||
|
|
Loading…
Reference in a new issue