ofxVariableLab/src/Layer.cpp

55 lines
1.2 KiB
C++
Raw Normal View History

2023-03-19 12:04:47 +01:00
#include "Layer.h"
2023-03-25 13:51:04 +01:00
#include "ofAppRunner.h"
#include "ofGraphics.h"
namespace ofxVariableLab {
Layer::Layer(){
}
Layer::~Layer(){
}
MsdfLayer::MsdfLayer(){
}
MsdfLayer::~MsdfLayer(){
}
void Layer::update(){
}
void MsdfLayer::draw(float x, float y) const {
ofDisableAlphaBlending();
ofEnableDepthTest();
shader->begin();
shader->setUniformTexture("msdf", atlasImage->getTexture(), 0);
shader->setUniform4f("fontColor", ofFloatColor::white);
float pixelRange = 2;
int atlas_w = atlasImage->getWidth();
int atlas_h = atlasImage->getHeight();
int atlas_x = 0;
int atlas_y = 0;
glm::vec2 unitRange = glm::vec2(pixelRange) / glm::vec2(atlas_w, atlas_h);
shader->setUniform2f("unitRange", unitRange);
//atlasImage->drawSubsection(0, 0, w, h, x, y, w, h);
atlasImage->draw(x, y);
shader->end();
ofDisableDepthTest();
ofEnableAlphaBlending();
}
void Layer::setProps(const Props & props){
while(propsBuffer.size() > max(0, int(settings.maxBufferSize - 1))){
propsBuffer.pop_back();
}
propsBuffer.push_front(props);
}
void Layer::clearPropsBuffer(){
propsBuffer.clear();
}
void Layer::setId(const string & id){
this->id = id;
}
const string & Layer::getId(){
return id;
}
}