diff --git a/src/GPUFontAtlasLayerCombo.cpp b/src/GPUFontAtlasLayerCombo.cpp index 6d17139..ac48336 100644 --- a/src/GPUFontAtlasLayerCombo.cpp +++ b/src/GPUFontAtlasLayerCombo.cpp @@ -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 vertices; std::vector 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" diff --git a/src/GPUFontLayer.cpp b/src/GPUFontLayer.cpp index dcc6641..cadb983 100644 --- a/src/GPUFontLayer.cpp +++ b/src/GPUFontLayer.cpp @@ -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(); } diff --git a/src/GPUFontLayer.h b/src/GPUFontLayer.h index 38143a0..8ca88a7 100644 --- a/src/GPUFontLayer.h +++ b/src/GPUFontLayer.h @@ -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; }; } diff --git a/src/Layer.h b/src/Layer.h index 5f4aa58..8e2080f 100644 --- a/src/Layer.h +++ b/src/Layer.h @@ -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; diff --git a/src/MsdfLayer.cpp b/src/MsdfLayer.cpp index dc0cc43..0c8c272 100644 --- a/src/MsdfLayer.cpp +++ b/src/MsdfLayer.cpp @@ -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(); } diff --git a/src/MsdfLayer.h b/src/MsdfLayer.h index 509c687..012e9f9 100644 --- a/src/MsdfLayer.h +++ b/src/MsdfLayer.h @@ -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; }; }