ofxVariableLab/src/AtlasLayerCombo.h

72 lines
1.8 KiB
C++

#pragma once
#include "ofMain.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include "Layer.h"
#include "Utils.h"
#include <type_traits>
#include <unordered_map>
/*********
*
* plan:
* -> GPUFont has one font per layer
* -> use ofShader
* -> single glyph buffer in AtlasLayerCombo
* -> single curve buffer in AtlasLayerCombo
*
*/
namespace ofxVariableLab {
struct ComboIdentifier {
std::string fontPath = "data/celines-fonts/Version-2-var.ttf";
Layer::Type type = Layer::MSDFGEN;
bool operator==(const ComboIdentifier & other) const {
return (this->fontPath == other.fontPath
&& this->type == other.type);
}
};
class AtlasLayerCombo {
public:
virtual void setup(const ComboIdentifier & identifier) = 0;
virtual void update() = 0;
virtual void careForChild(shared_ptr <Layer> layer) = 0;
virtual const ComboIdentifier & getIdentifier() const = 0;
bool operator==(const AtlasLayerCombo & other) const {
return (this->getIdentifier() == other.getIdentifier());
}
};
}
namespace std {
template <>
struct hash <ofxVariableLab::ComboIdentifier> {
std::size_t operator()(const ofxVariableLab::ComboIdentifier & k) const {
using std::size_t;
using std::hash;
using std::string;
size_t seed = 0;
ofxVariableLab::hash_combine(seed, k.fontPath);
ofxVariableLab::hash_combine(seed, k.type);
return seed;
}
};
template <>
struct hash <ofxVariableLab::AtlasLayerCombo> {
std::size_t operator()(const ofxVariableLab::AtlasLayerCombo & k) const {
using std::size_t;
using std::hash;
using std::string;
size_t seed = 0;
ofxVariableLab::hash_combine(seed, k.getIdentifier());
return seed;
}
};
}