From fb1621b773959af38f4d04510d39dd4b63cbbb88 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Thu, 11 Aug 2016 12:45:05 +0300 Subject: [PATCH] Add possibility to disable FboSource::draw() when needed --- src/Sources/FboSource.cpp | 10 ++++++++++ src/Sources/FboSource.h | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Sources/FboSource.cpp b/src/Sources/FboSource.cpp index d21f1c9..ebeb58a 100644 --- a/src/Sources/FboSource.cpp +++ b/src/Sources/FboSource.cpp @@ -8,6 +8,7 @@ FboSource::FboSource() : fbo(0){ loadable = false; loaded = false; type = SourceType::SOURCE_TYPE_FBO; + _disableDraw = false; } FboSource::~FboSource(){ @@ -48,6 +49,11 @@ void FboSource::onAppDraw(ofEventArgs & args){ ofLogWarning("FboSource") << "FBO not allocated"; return; } + + if(_disableDraw){ + return; + } + fbo->begin(); draw(); fbo->end(); @@ -57,6 +63,10 @@ void FboSource::onAppExit(ofEventArgs & args){ exit(); } +void FboSource::setDisableDraw(bool b){ + _disableDraw = b; +} + void FboSource::allocate(int width, int height){ clear(); fbo = new ofFbo(); diff --git a/src/Sources/FboSource.h b/src/Sources/FboSource.h index 54aed6a..b11b6e3 100644 --- a/src/Sources/FboSource.h +++ b/src/Sources/FboSource.h @@ -30,6 +30,7 @@ class FboSource : public BaseSource { void onAppUpdate(ofEventArgs & args); void onAppDraw(ofEventArgs & args); void onAppExit(ofEventArgs & args); + void setDisableDraw(bool b); // Use in cases with external ofFbo protected: ofFbo * fbo; @@ -38,7 +39,8 @@ class FboSource : public BaseSource { // Some handy getters int getWidth(); int getHeight(); - + + bool _disableDraw; }; } // namespace piMapper