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