pass GPUFont/MsdfAtlasLayerComboSettings as reference
This commit is contained in:
parent
5453e3da0d
commit
3016879e22
7 changed files with 20 additions and 9 deletions
|
@ -25,7 +25,7 @@ struct AtlasLayerComboSettings {
|
|||
class AtlasLayerCombo {
|
||||
public:
|
||||
virtual void setup(const ComboIdentifier & identifier,
|
||||
AtlasLayerComboSettings settings) = 0;
|
||||
const AtlasLayerComboSettings & settings) = 0;
|
||||
virtual void update() = 0;
|
||||
virtual bool hasChildren() = 0;
|
||||
virtual void careForChild(shared_ptr <Layer> layer) = 0;
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
namespace ofxVariableLab {
|
||||
|
||||
void GPUFontAtlasLayerCombo::setup(const ComboIdentifier & identifier,
|
||||
AtlasLayerComboSettings settings){
|
||||
const AtlasLayerComboSettings & settings){
|
||||
this->identifier = identifier;
|
||||
this->settings = static_cast <GPUFontAtlasLayerComboSettings &>(settings);
|
||||
this->settings = static_cast <const GPUFontAtlasLayerComboSettings &>(settings);
|
||||
#ifdef TARGET_EMSCRIPTEN
|
||||
string shaderDir = "data/ofxGPUFont/shaders/ES3";
|
||||
#else
|
||||
|
|
|
@ -69,7 +69,7 @@ class GPUFontAtlasLayerCombo : public AtlasLayerCombo {
|
|||
const Layer::Props & props);
|
||||
public:
|
||||
void setup(const ComboIdentifier & identifier,
|
||||
AtlasLayerComboSettings settings = GPUFontAtlasLayerComboSettings()) override;
|
||||
const AtlasLayerComboSettings & settings = GPUFontAtlasLayerComboSettings()) override;
|
||||
void update() override;
|
||||
void careForChild(shared_ptr <Layer> layer) override;
|
||||
void abandonChild(shared_ptr <Layer> layer) override;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "LayerComposition.h"
|
||||
#include "Atlas.h"
|
||||
#include "AtlasLayerCombo.h"
|
||||
#include "GPUFontAtlasLayerCombo.h"
|
||||
#include "GPUFontLayer.h"
|
||||
#include "MsdfAtlasLayerCombo.h"
|
||||
#include "MsdfLayer.h"
|
||||
#include "Utils.h"
|
||||
#include "ofUtils.h"
|
||||
|
@ -70,9 +72,11 @@ LayerID LayerComposition::addLayer(const Layer::Props & props,
|
|||
ComboIdentifier identifier;
|
||||
identifier.fontPath = props.fontPath;
|
||||
identifier.type = LayerType::GPUFONT;
|
||||
GPUFontAtlasLayerComboSettings s;
|
||||
return addLayer(identifier,
|
||||
props,
|
||||
props.fontVariations,
|
||||
s,
|
||||
layerID);
|
||||
|
||||
}
|
||||
|
@ -80,6 +84,7 @@ LayerID LayerComposition::addLayer(const Layer::Props & props,
|
|||
LayerID LayerComposition::addLayer(const ComboIdentifier & identifier,
|
||||
const string & text,
|
||||
const std::vector <FontVariation> & variations,
|
||||
AtlasLayerComboSettings & s,
|
||||
LayerID layerID){
|
||||
auto props = Layer::Props();
|
||||
props.text = text;
|
||||
|
@ -87,12 +92,14 @@ LayerID LayerComposition::addLayer(const ComboIdentifier & identifier,
|
|||
return addLayer(identifier,
|
||||
props,
|
||||
variations,
|
||||
s,
|
||||
layerID);
|
||||
}
|
||||
|
||||
LayerID LayerComposition::addLayer(const ComboIdentifier & identifier,
|
||||
const Layer::Props & props,
|
||||
const std::vector <FontVariation> & variations,
|
||||
AtlasLayerComboSettings & s,
|
||||
LayerID layerID){
|
||||
switch(identifier.type){
|
||||
case LayerType::GPUFONT: {
|
||||
|
@ -102,7 +109,7 @@ LayerID LayerComposition::addLayer(const ComboIdentifier & identifier,
|
|||
// we don't have one yet
|
||||
// so let's create it
|
||||
combo = make_shared <GPUFontAtlasLayerCombo>();
|
||||
GPUFontAtlasLayerComboSettings settings;
|
||||
GPUFontAtlasLayerComboSettings & settings = static_cast <GPUFontAtlasLayerComboSettings &>(s);
|
||||
combo->setup(identifier, settings);
|
||||
atlasLayerCombos[identifier] = combo;
|
||||
}else{
|
||||
|
@ -129,7 +136,9 @@ LayerID LayerComposition::addLayer(const ComboIdentifier & identifier,
|
|||
case LayerType::MSDFGEN: {
|
||||
// TODO: put most stuff in combo setup
|
||||
auto combo = make_shared <MsdfAtlasLayerCombo>();
|
||||
combo->setup(identifier); // TODO: add here text and variations
|
||||
MsdfAtlasLayerComboSettings settings = static_cast <MsdfAtlasLayerComboSettings &>(s);
|
||||
cout << "LayerComposition::addLayer scale " << settings.scale << endl;
|
||||
combo->setup(identifier, settings); // TODO: add here text and variations
|
||||
auto layer = make_shared <MsdfLayer>();
|
||||
layer->vFlip = vFlipState;
|
||||
layer->setProps(props);
|
||||
|
|
|
@ -20,10 +20,12 @@ class LayerComposition {
|
|||
LayerID addLayer(const ComboIdentifier & identifier,
|
||||
const string & text,
|
||||
const std::vector <FontVariation> & variations,
|
||||
AtlasLayerComboSettings & s,
|
||||
LayerID layerID = "");
|
||||
LayerID addLayer(const ComboIdentifier & identifier,
|
||||
const Layer::Props & props,
|
||||
const std::vector <FontVariation> & variations,
|
||||
AtlasLayerComboSettings & s,
|
||||
LayerID layerID = "");
|
||||
void findOrCreateNewMomForLayer(shared_ptr <Layer> layer,
|
||||
ComboIdentifier idealMom);
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
namespace ofxVariableLab {
|
||||
|
||||
void MsdfAtlasLayerCombo::setup(const ComboIdentifier & layerIdentifier,
|
||||
AtlasLayerComboSettings settings){
|
||||
const AtlasLayerComboSettings & settings){
|
||||
this->identifier = layerIdentifier;
|
||||
this->settings = static_cast <MsdfAtlasLayerComboSettings &>(settings);
|
||||
this->settings = static_cast <const MsdfAtlasLayerComboSettings &>(settings);
|
||||
ofxMsdfgen::AtlasSettings atlasSettings;
|
||||
//settings.characters = "ABCDEFGHIJKL";
|
||||
atlasSettings.scale = this->settings.scale;
|
||||
|
|
|
@ -13,7 +13,7 @@ struct MsdfAtlasLayerComboSettings : public AtlasLayerComboSettings {
|
|||
class MsdfAtlasLayerCombo : public AtlasLayerCombo {
|
||||
public:
|
||||
void setup(const ComboIdentifier & identifier,
|
||||
AtlasLayerComboSettings settings = MsdfAtlasLayerComboSettings()) override;
|
||||
const AtlasLayerComboSettings & settings = MsdfAtlasLayerComboSettings()) override;
|
||||
void update() override;
|
||||
void careForChild(shared_ptr <Layer> layer) override;
|
||||
void abandonChild(shared_ptr <Layer> layer) override;
|
||||
|
|
Loading…
Reference in a new issue