From 30c1d7f5a2102fea41fd360e413e286f6b279165 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Sun, 30 Apr 2023 17:40:45 +0200 Subject: [PATCH] allow setting width/height for layerComposition --- src/GPUFontAtlasLayerCombo.cpp | 4 +--- src/GPUFontAtlasLayerCombo.h | 2 +- src/LayerComposition.cpp | 4 ++-- src/LayerComposition.h | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/GPUFontAtlasLayerCombo.cpp b/src/GPUFontAtlasLayerCombo.cpp index bfeba0d..bc6588f 100644 --- a/src/GPUFontAtlasLayerCombo.cpp +++ b/src/GPUFontAtlasLayerCombo.cpp @@ -135,12 +135,10 @@ bool GPUFontAtlasLayerCombo::hasChildren(){ const vector > & GPUFontAtlasLayerCombo::getLayers(){ return layers; } -void GPUFontAtlasLayerCombo::draw(){ +void GPUFontAtlasLayerCombo::draw(int width, int height){ OFX_PROFILER_FUNCTION(); GLuint location; - int width = ofGetWidth(); - int height = ofGetHeight(); glm::vec2 mouse = glm::vec2(ofGetMouseX(), ofGetMouseY()); //glm::mat4 projection = transform.getProjectionMatrix((float)width / height); diff --git a/src/GPUFontAtlasLayerCombo.h b/src/GPUFontAtlasLayerCombo.h index d83e4fc..b67f16e 100644 --- a/src/GPUFontAtlasLayerCombo.h +++ b/src/GPUFontAtlasLayerCombo.h @@ -75,7 +75,7 @@ class GPUFontAtlasLayerCombo : public AtlasLayerCombo { bool hasChildren() override; const vector > & getLayers(); - void draw(); + void draw(int width, int height); shared_ptr font; string mainText = ""; diff --git a/src/LayerComposition.cpp b/src/LayerComposition.cpp index 0d360ba..f98e923 100644 --- a/src/LayerComposition.cpp +++ b/src/LayerComposition.cpp @@ -174,7 +174,7 @@ shared_ptr LayerComposition::getLayer(const LayerID & layerID){ return layers[layerID]; } -void LayerComposition::draw() const { +void LayerComposition::draw(int width, int height) const { for(const auto & layer_it : layers){ if(layer_it.second->getType() == LayerType::MSDFGEN){ layer_it.second->draw(glm::vec3(200, 200, 0)); @@ -184,7 +184,7 @@ void LayerComposition::draw() const { if(combo_it.first.type == LayerType::GPUFONT){ auto combo = static_pointer_cast (combo_it.second); - combo->draw(); + combo->draw(width, height); } } } diff --git a/src/LayerComposition.h b/src/LayerComposition.h index 9c2d3a4..fa405dd 100644 --- a/src/LayerComposition.h +++ b/src/LayerComposition.h @@ -14,7 +14,7 @@ class LayerComposition { public: void setup(); void update(); - void draw() const; + void draw(int width = 0, int height = 0) const; LayerID addLayer(const Layer::Props & props, LayerID layerID = ""); LayerID addLayer(const ComboIdentifier & identifier,