add gpufont

This commit is contained in:
jrkb 2023-04-12 09:28:47 +02:00
parent 957768cf61
commit 09e2bb63c7
7 changed files with 34 additions and 11 deletions

View file

@ -24,7 +24,7 @@ meta:
common:
# dependencies with other addons, a list of them separated by spaces
# or use += in several lines
ADDON_DEPENDENCIES = ofxMsdfgen
ADDON_DEPENDENCIES = ofxMsdfgen ofxGPUFont
# include search paths, this will be usually parsed from the file system
# but if the addon or addon libraries need special search paths they can be

View file

@ -1,2 +1,3 @@
ofxMsdfgen
ofxGPUFont
ofxVariableLab

View file

@ -1,6 +1,5 @@
#pragma once
#include "Atlas.h"
#include "ofMain.h"
//uuid

View file

@ -134,14 +134,6 @@ void LayerComposition::draw() const {
}
}
const std::vector <ComboIdentifier> LayerComposition::getAvailableComboIdentifiers() const {
std::vector <ComboIdentifier> combos;
for(const auto & combo : atlasLayerCombos){
combos.push_back(combo.first);
}
return combos;
}
const unordered_map <ComboIdentifier, shared_ptr <AtlasLayerCombo> > & LayerComposition::getAtlasLayerCombos() const {
return atlasLayerCombos;
}

View file

@ -5,9 +5,19 @@
#include "ofxMsdfgen.h"
#include "Layer.h"
#include "MsdfLayer.h"
#include "GPUFontLayer.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 {
@ -85,6 +95,24 @@ class MsdfAtlasLayerCombo : public AtlasLayerCombo {
bool isDirty = false;
};
class GPUFontAtlasLayerCombo : public AtlasLayerCombo {
public:
void setup(const ComboIdentifier & identifier) override;
void update() override;
void careForChild(shared_ptr <Layer> layer) override;
const ComboIdentifier & getIdentifier() const override;
const ofImage & getAtlasImage() override;
string getAtlasImagePath() override;
shared_ptr <Layer> getLayer();
shared_ptr <ofxGPUFont::Atlas> atlas;
private:
vector <shared_ptr <GPUFontLayer> > layers;
shared_ptr <ofShader> gpuFontShader;
ComboIdentifier identifier;
bool isDirty = false;
};
class LayerComposition {
public:
void setup();
@ -98,7 +126,6 @@ class LayerComposition {
const Layer::Props & props,
const std::vector <FontVariation> & variations);
shared_ptr <ofxVariableLab::Layer> getLayer(const LayerID & layerID);
const std::vector <ComboIdentifier> getAvailableComboIdentifiers() const;
const unordered_map <ComboIdentifier, shared_ptr <AtlasLayerCombo> > & getAtlasLayerCombos() const;
void setVFlip(bool vFlip);

View file

@ -100,6 +100,7 @@ void MsdfLayer::draw(glm::vec3 position){
getVFlip(settings.vFlipBehaviour,
ofGetCurrentOrientationMatrix(),
vFlip);
if(vFlip == V_FLIP_OFF){
ofTranslate(pl * magic, (pt * magic) + (-1 * h), 0);
}else{

View file

@ -4,4 +4,7 @@
#include "Utils.h"
#include "Layer.h"
#include "MsdfLayer.h"
#include "GPUFontLayer.h"
#include "LayerComposition.h"
// TODO: save characterset with atlasses when saving image on disk