add color in BufferVertex
This commit is contained in:
parent
74fed4e1f4
commit
8fe23edc1f
6 changed files with 27 additions and 18 deletions
|
@ -50,6 +50,7 @@ void GPUFontAtlasLayerCombo::setup(const ComboIdentifier & identifier,
|
|||
}
|
||||
void GPUFontAtlasLayerCombo::update(){
|
||||
for(const auto & layer : layers){
|
||||
layer->update();
|
||||
if(layer->isDirtyDirty()){
|
||||
isDirty = true;
|
||||
break;
|
||||
|
@ -195,8 +196,6 @@ void GPUFontAtlasLayerCombo::draw(){
|
|||
location = glGetUniformLocation(fontShaderProgram, "z");
|
||||
glUniform1f(location, z);
|
||||
|
||||
location = glGetUniformLocation(fontShaderProgram, "color");
|
||||
glUniform4f(location, 1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
location = glGetUniformLocation(fontShaderProgram, "antiAliasingWindowSize");
|
||||
glUniform1f(location, (float)antiAliasingWindowSize);
|
||||
|
@ -205,9 +204,6 @@ void GPUFontAtlasLayerCombo::draw(){
|
|||
location = glGetUniformLocation(fontShaderProgram, "enableControlPointsVisualization");
|
||||
glUniform1i(location, enableControlPointsVisualization);
|
||||
|
||||
|
||||
//mouse.x = 0;
|
||||
//mouse.y = 0;
|
||||
std::vector <ofxGPUFont::Font::BufferVertex> vertices;
|
||||
std::vector <int32_t> indices;
|
||||
|
||||
|
@ -219,31 +215,21 @@ void GPUFontAtlasLayerCombo::draw(){
|
|||
0));
|
||||
font->collectVerticesAndIndices(node,
|
||||
layer->getVariationText(),
|
||||
vertices, indices, true,
|
||||
vertices, indices,
|
||||
layer->getColor(),
|
||||
true,
|
||||
layer->getProps().fontSize_px);
|
||||
}
|
||||
vertices.resize(totalCharacters * 4);
|
||||
indices.resize(totalCharacters * 6);
|
||||
//cx = 0.5f * (bb.minX + bb.maxX);
|
||||
//cy = 0.5f * (bb.minY + bb.maxY);
|
||||
|
||||
font->draw(vertices, indices);
|
||||
//ofRectangle rectangle(0, 0, width, height);
|
||||
//ofDrawRectangle(rectangle);
|
||||
//font->draw(mouse.x, mouse.y - (200 * sin(ofGetElapsedTimef() * 0.25)), 0, "what", vFlip == V_FLIP_ON, 42.0f);
|
||||
//location = glGetUniformLocation(fontShaderProgram, "color");
|
||||
//glUniform4f(location, 0.0f, 1.0f, 0.0f, 0.5f);
|
||||
//font->draw(mouse.x, mouse.y, 0, "ever", vFlip == V_FLIP_ON, 420.0f);
|
||||
|
||||
glUseProgram(currentProgram);
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
//ofDrawBitmapStringHighlight(
|
||||
//(ofToString("and we know:") + ofToString("everything"))
|
||||
//, 100 + mouse.x, mouse.y, ofFloatColor::pink, ofFloatColor::black);
|
||||
|
||||
ofDrawBitmapStringHighlight(
|
||||
"fps: " + ofToString(ofGetFrameRate()) + "\n"
|
||||
+ "font: " + this->identifier.fontPath + "\n"
|
||||
|
|
|
@ -18,6 +18,12 @@ void GPUFontLayer::setup(const LayerSettings & settings){
|
|||
}
|
||||
|
||||
void GPUFontLayer::update(){
|
||||
if(propsBuffer.size() > 0){
|
||||
color = glm::vec4(propsBuffer[0].color[0],
|
||||
propsBuffer[0].color[1],
|
||||
propsBuffer[0].color[2],
|
||||
propsBuffer[0].color[3]);
|
||||
}
|
||||
}
|
||||
|
||||
void GPUFontLayer::draw(glm::vec3 position){
|
||||
|
@ -90,6 +96,9 @@ void GPUFontLayer::setProps(const Props & props){
|
|||
const Layer::Props & GPUFontLayer::getProps() const {
|
||||
return propsBuffer[0]; // gets newest
|
||||
}
|
||||
const glm::vec4 & GPUFontLayer::getColor() const {
|
||||
return color;
|
||||
}
|
||||
void GPUFontLayer::clearPropsBuffer(){
|
||||
propsBuffer.clear();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class GPUFontLayer : public Layer {
|
|||
ofxVariableLab::FontVariation fontVariation = ofxVariableLab::FontVariation()) override;
|
||||
void setProps(const Props & props) override;
|
||||
const Props & getProps() const override;
|
||||
const glm::vec4 & getColor() const;
|
||||
void clearPropsBuffer() override;
|
||||
void setId(const LayerID & id) override;
|
||||
const LayerID & getId() override;
|
||||
|
@ -63,5 +64,6 @@ class GPUFontLayer : public Layer {
|
|||
ComboIdentifier momsComboIdentifier;
|
||||
bool notHappyWithMom = false;
|
||||
LayerType type = GPUFONT;
|
||||
glm::vec4 color;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ class Layer {
|
|||
ofxVariableLab::FontVariation fontVariation = ofxVariableLab::FontVariation()) = 0;
|
||||
virtual void setProps(const Props & props) = 0;
|
||||
virtual const Props & getProps() const = 0;
|
||||
virtual const glm::vec4 & getColor() const = 0;
|
||||
virtual void clearPropsBuffer() = 0;
|
||||
virtual void setId(const LayerID & id) = 0;
|
||||
virtual const LayerID & getId() = 0;
|
||||
|
|
|
@ -16,6 +16,12 @@ void MsdfLayer::setup(const LayerSettings & settings){
|
|||
}
|
||||
|
||||
void MsdfLayer::update(){
|
||||
if(propsBuffer.size() > 0){
|
||||
color = glm::vec4(propsBuffer[0].color[0],
|
||||
propsBuffer[0].color[1],
|
||||
propsBuffer[0].color[2],
|
||||
propsBuffer[0].color[3]);
|
||||
}
|
||||
}
|
||||
|
||||
void MsdfLayer::draw(glm::vec3 position){
|
||||
|
@ -314,6 +320,9 @@ void MsdfLayer::setProps(const Props & props){
|
|||
const Layer::Props & MsdfLayer::getProps() const {
|
||||
return propsBuffer[0];
|
||||
}
|
||||
const glm::vec4 & MsdfLayer::getColor() const {
|
||||
return color;
|
||||
}
|
||||
void MsdfLayer::clearPropsBuffer(){
|
||||
propsBuffer.clear();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ class MsdfLayer : public Layer {
|
|||
ofxVariableLab::FontVariation fontVariation = ofxVariableLab::FontVariation()) override;
|
||||
void setProps(const Props & props) override;
|
||||
const Props & getProps() const override;
|
||||
const glm::vec4 & getColor() const;
|
||||
void clearPropsBuffer() override;
|
||||
void setId(const LayerID & id) override;
|
||||
const LayerID & getId() override;
|
||||
|
@ -54,5 +55,6 @@ class MsdfLayer : public Layer {
|
|||
bool notHappyWithMom = false;
|
||||
ComboIdentifier momsComboIdentifier;
|
||||
LayerType type = MSDFGEN;
|
||||
glm::vec4 color;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue