add vFlip detection, and therefore un-const draw calls
This commit is contained in:
parent
14072ce026
commit
96f9248edc
4 changed files with 36 additions and 11 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include "random_id.h"
|
#include "random_id.h"
|
||||||
|
|
||||||
#include "ofxMsdfgen.h"
|
#include "ofxMsdfgen.h"
|
||||||
|
#include "Utils.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace ofxVariableLab {
|
namespace ofxVariableLab {
|
||||||
|
@ -31,14 +32,15 @@ class Layer {
|
||||||
};
|
};
|
||||||
struct Settings {
|
struct Settings {
|
||||||
uint32_t maxBufferSize = 100;
|
uint32_t maxBufferSize = 100;
|
||||||
|
VFlipBehaviour vFlipBehaviour = V_FLIP_ONCE_AUTO;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void setup(const Settings & settings) = 0;
|
virtual void setup(const Settings & settings) = 0;
|
||||||
virtual void update() = 0;
|
virtual void update() = 0;
|
||||||
virtual void draw(glm::vec3 position = glm::vec3(0, 0, 0)) const = 0;
|
virtual void draw(glm::vec3 position = glm::vec3(0, 0, 0)) = 0;
|
||||||
virtual void drawCharacter(const char character,
|
virtual void drawCharacter(const char character,
|
||||||
glm::vec3 position = glm::vec3(0, 0, 0),
|
glm::vec3 position = glm::vec3(0, 0, 0),
|
||||||
ofxMsdfgen::FontVariation fontVariation = ofxMsdfgen::FontVariation()) const = 0;
|
ofxMsdfgen::FontVariation fontVariation = ofxMsdfgen::FontVariation()) = 0;
|
||||||
virtual void setProps(const Props & props) = 0;
|
virtual void setProps(const Props & props) = 0;
|
||||||
virtual const Props & getProps() const = 0;
|
virtual const Props & getProps() const = 0;
|
||||||
virtual void clearPropsBuffer() = 0;
|
virtual void clearPropsBuffer() = 0;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "LayerComposition.h"
|
#include "LayerComposition.h"
|
||||||
#include "Atlas.h"
|
#include "Atlas.h"
|
||||||
#include "MsdfLayer.h"
|
#include "MsdfLayer.h"
|
||||||
|
#include "Utils.h"
|
||||||
#include "ofUtils.h"
|
#include "ofUtils.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ void MsdfAtlasLayerCombo::setup(const ComboIdentifier & layerIdentifier){
|
||||||
atlasSettings.scale = 64;
|
atlasSettings.scale = 64;
|
||||||
atlasSettings.minimumScale = 64;
|
atlasSettings.minimumScale = 64;
|
||||||
atlasSettings.characters = "";
|
atlasSettings.characters = "";
|
||||||
|
atlasSettings.maxInterpolationStepSize = 50.0;
|
||||||
|
|
||||||
//string fontName = "RobotoFlex.ttf";
|
//string fontName = "RobotoFlex.ttf";
|
||||||
//string fontPath = "data/fonts/" + fontName;
|
//string fontPath = "data/fonts/" + fontName;
|
||||||
|
@ -32,6 +34,8 @@ void MsdfAtlasLayerCombo::setup(const ComboIdentifier & layerIdentifier){
|
||||||
msdfShader->load("ofxMsdfgen/shaders/mix/GL3/shader");
|
msdfShader->load("ofxMsdfgen/shaders/mix/GL3/shader");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
cout << "settings scale before " << atlasSettings.scale << endl
|
||||||
|
<< "minimum scale before " << atlasSettings.minimumScale << endl;
|
||||||
atlas->setup(fontPath, atlasSettings);
|
atlas->setup(fontPath, atlasSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,15 +93,15 @@ void LayerComposition::addLayer(const ComboIdentifier & identifier,
|
||||||
auto props = Layer::Props();
|
auto props = Layer::Props();
|
||||||
props.text = text;
|
props.text = text;
|
||||||
layer->setProps(props);
|
layer->setProps(props);
|
||||||
ofxMsdfgen::AtlasSettings as;
|
//ofxMsdfgen::AtlasSettings as;
|
||||||
as.characters = "";
|
//as.characters = "";
|
||||||
//for(const char c : text){
|
//for(const char c : text){
|
||||||
//if(as.characters.find(c) == std::string::npos){
|
//if(as.characters.find(c) == std::string::npos){
|
||||||
//// not found
|
//// not found
|
||||||
//as.characters += c;
|
//as.characters += c;
|
||||||
//}
|
//}
|
||||||
//}
|
//}
|
||||||
combo->atlas->setup(identifier.fontPath, as);
|
//combo->atlas->setup(identifier.fontPath, as);
|
||||||
std::vector <ofxMsdfgen::FontVariation> msdfVariations;
|
std::vector <ofxMsdfgen::FontVariation> msdfVariations;
|
||||||
for(const auto & v : variations){
|
for(const auto & v : variations){
|
||||||
msdfVariations.push_back({v.name, v.value});
|
msdfVariations.push_back({v.name, v.value});
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
#include "MsdfLayer.h"
|
#include "MsdfLayer.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
#include "fwd.hpp"
|
||||||
|
#include "ofGraphics.h"
|
||||||
|
#include "ofUtils.h"
|
||||||
|
|
||||||
namespace ofxVariableLab {
|
namespace ofxVariableLab {
|
||||||
|
|
||||||
|
@ -12,7 +16,7 @@ void MsdfLayer::update(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MsdfLayer::draw(glm::vec3 position) const {
|
void MsdfLayer::draw(glm::vec3 position){
|
||||||
const ofImage & atlasImage = atlas->getAtlasImage();
|
const ofImage & atlasImage = atlas->getAtlasImage();
|
||||||
ofDisableAlphaBlending();
|
ofDisableAlphaBlending();
|
||||||
ofEnableDepthTest();
|
ofEnableDepthTest();
|
||||||
|
@ -86,11 +90,24 @@ void MsdfLayer::draw(glm::vec3 position) const {
|
||||||
|
|
||||||
ofPushMatrix();
|
ofPushMatrix();
|
||||||
float magic = atlas->settings.scale;
|
float magic = atlas->settings.scale;
|
||||||
cout << "magic number << " << magic << endl;
|
|
||||||
ofSetColor(ofFloatColor(1, 1, 1, 1));
|
ofSetColor(ofFloatColor(1, 1, 1, 1));
|
||||||
ofTranslate(pl * magic, 0, 0);
|
ofTranslate(pl * magic, 0, 0);
|
||||||
|
getVFlip(settings.vFlipBehaviour,
|
||||||
|
ofGetCurrentOrientationMatrix(),
|
||||||
|
vFlip);
|
||||||
|
if(vFlip == V_FLIP_OFF){
|
||||||
|
ofTranslate(pl * magic, (pt * magic) + (-1 * h), 0);
|
||||||
|
}else{
|
||||||
|
ofTranslate(pl * magic, -1 * pt * magic, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(settings.vFlip){
|
||||||
//ofTranslate(0, -1 * pt * magic, 0);
|
//ofTranslate(0, -1 * pt * magic, 0);
|
||||||
ofTranslate(0, 1 * pt * magic, 0);
|
//}else{
|
||||||
|
//ofTranslate(0, -1 * h, 0);
|
||||||
|
//ofTranslate(0, 1 * pt * magic, 0);
|
||||||
|
//}
|
||||||
|
|
||||||
if(!firstLetter){
|
if(!firstLetter){
|
||||||
//cout << "this is being printed" << endl;
|
//cout << "this is being printed" << endl;
|
||||||
auto & fontGeometry = atlas->getFontGeometry();
|
auto & fontGeometry = atlas->getFontGeometry();
|
||||||
|
@ -140,7 +157,7 @@ void MsdfLayer::draw(glm::vec3 position) const {
|
||||||
}
|
}
|
||||||
void MsdfLayer::drawCharacter(const char character,
|
void MsdfLayer::drawCharacter(const char character,
|
||||||
glm::vec3 position,
|
glm::vec3 position,
|
||||||
ofxMsdfgen::FontVariation fontVariation) const {
|
ofxMsdfgen::FontVariation fontVariation){
|
||||||
const ofImage & atlasImage = atlas->getAtlasImage();
|
const ofImage & atlasImage = atlas->getAtlasImage();
|
||||||
ofDisableAlphaBlending();
|
ofDisableAlphaBlending();
|
||||||
ofEnableDepthTest();
|
ofEnableDepthTest();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "ofxMsdfgen.h"
|
#include "ofxMsdfgen.h"
|
||||||
#include "Atlas.h"
|
#include "Atlas.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
namespace ofxVariableLab {
|
namespace ofxVariableLab {
|
||||||
|
|
||||||
|
@ -11,10 +12,10 @@ class MsdfLayer : public Layer {
|
||||||
public:
|
public:
|
||||||
void setup(const Settings & settings);
|
void setup(const Settings & settings);
|
||||||
void update() override;
|
void update() override;
|
||||||
void draw(glm::vec3 position = glm::vec3(0, 0, 0)) const override;
|
void draw(glm::vec3 position = glm::vec3(0, 0, 0)) override;
|
||||||
void drawCharacter(const char character,
|
void drawCharacter(const char character,
|
||||||
glm::vec3 position = glm::vec3(0, 0, 0),
|
glm::vec3 position = glm::vec3(0, 0, 0),
|
||||||
ofxMsdfgen::FontVariation fontVariation = ofxMsdfgen::FontVariation()) const override;
|
ofxMsdfgen::FontVariation fontVariation = ofxMsdfgen::FontVariation()) override;
|
||||||
void setProps(const Props & props) override;
|
void setProps(const Props & props) override;
|
||||||
const Props & getProps() const override;
|
const Props & getProps() const override;
|
||||||
void clearPropsBuffer() override;
|
void clearPropsBuffer() override;
|
||||||
|
@ -36,6 +37,7 @@ class MsdfLayer : public Layer {
|
||||||
bool isDirty = true;
|
bool isDirty = true;
|
||||||
/// \brief hashed id
|
/// \brief hashed id
|
||||||
string id;
|
string id;
|
||||||
|
VFlipState vFlip = V_FLIP_UNKNOWN;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Layer::Type type = MSDFGEN;
|
Layer::Type type = MSDFGEN;
|
||||||
|
|
Loading…
Reference in a new issue