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