|
@ -2,12 +2,14 @@ |
|
|
|
|
|
|
|
|
namespace ofx { |
|
|
namespace ofx { |
|
|
namespace piMapper { |
|
|
namespace piMapper { |
|
|
|
|
|
|
|
|
FboSource::FboSource() : fbo(NULL) { |
|
|
FboSource::FboSource() : fbo(NULL) { |
|
|
name = PIMAPPER_FBO_SOURCE_DEF_NAME; |
|
|
name = PIMAPPER_FBO_SOURCE_DEF_NAME; |
|
|
loadable = false; |
|
|
loadable = false; |
|
|
loaded = false; |
|
|
loaded = false; |
|
|
type = SourceType::SOURCE_TYPE_FBO; |
|
|
type = SourceType::SOURCE_TYPE_FBO; |
|
|
ofAddListener(ofEvents().setup, this, &FboSource::onAppSetup, OF_EVENT_ORDER_BEFORE_APP); |
|
|
ofAddListener(ofEvents().setup, this, |
|
|
|
|
|
&FboSource::onAppSetup, OF_EVENT_ORDER_BEFORE_APP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
FboSource::~FboSource() { |
|
|
FboSource::~FboSource() { |
|
@ -17,27 +19,36 @@ namespace ofx { |
|
|
|
|
|
|
|
|
void FboSource::addAppListeners() { |
|
|
void FboSource::addAppListeners() { |
|
|
ofLogNotice("FboSource") << "Adding app listeners"; |
|
|
ofLogNotice("FboSource") << "Adding app listeners"; |
|
|
ofAddListener(ofEvents().update, this, &FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); |
|
|
ofAddListener(ofEvents().update, this, |
|
|
ofAddListener(ofEvents().draw, this, &FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); |
|
|
&FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); |
|
|
ofAddListener(ofEvents().exit, this, &FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); |
|
|
ofAddListener(ofEvents().draw, this, |
|
|
|
|
|
&FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); |
|
|
|
|
|
ofAddListener(ofEvents().exit, this, |
|
|
|
|
|
&FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void FboSource::removeAppListeners() { |
|
|
void FboSource::removeAppListeners() { |
|
|
ofLogNotice("FboSource") << "Removing app listeners"; |
|
|
ofLogNotice("FboSource") << "Removing app listeners"; |
|
|
ofRemoveListener(ofEvents().update, this, &FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); |
|
|
ofRemoveListener(ofEvents().update, this, |
|
|
ofRemoveListener(ofEvents().draw, this, &FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); |
|
|
&FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); |
|
|
ofRemoveListener(ofEvents().exit, this, &FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); |
|
|
ofRemoveListener(ofEvents().draw, this, |
|
|
|
|
|
&FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); |
|
|
|
|
|
ofRemoveListener(ofEvents().exit, this, |
|
|
|
|
|
&FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void FboSource::onAppSetup(ofEventArgs &args) { |
|
|
void FboSource::onAppSetup(ofEventArgs &args) { |
|
|
ofRemoveListener(ofEvents().setup, this, &FboSource::onAppSetup, OF_EVENT_ORDER_BEFORE_APP); |
|
|
ofRemoveListener(ofEvents().setup, this, |
|
|
|
|
|
&FboSource::onAppSetup, OF_EVENT_ORDER_BEFORE_APP); |
|
|
setup(); |
|
|
setup(); |
|
|
|
|
|
|
|
|
// Check if FBO was allocated in user defined setup
|
|
|
// Check if FBO was allocated in user defined setup
|
|
|
// If not, show warning and alocate to avoid panic
|
|
|
// If not, show warning and alocate to avoid panic
|
|
|
if (!fbo->isAllocated()) { |
|
|
if (!fbo->isAllocated()) { |
|
|
ofLogWarning("FboSource::onAppSetup") << "FBO not allocated, allocating with default values"; |
|
|
ofLogWarning("FboSource::onAppSetup") << |
|
|
allocate(PIMAPPER_FBO_SOURCE_DEF_WIDTH, PIMAPPER_FBO_SOURCE_DEF_HEIGHT); |
|
|
"FBO not allocated, allocating with default values"; |
|
|
|
|
|
allocate(PIMAPPER_FBO_SOURCE_DEF_WIDTH, |
|
|
|
|
|
PIMAPPER_FBO_SOURCE_DEF_HEIGHT); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -84,5 +95,21 @@ namespace ofx { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int FboSource::getWidth() { |
|
|
|
|
|
if (fbo->isAllocated()) { |
|
|
|
|
|
return fbo->getWidth(); |
|
|
|
|
|
} else { |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int FboSource::getHeight() { |
|
|
|
|
|
if (fbo->isAllocated()) { |
|
|
|
|
|
return fbo->getHeight(); |
|
|
|
|
|
} else { |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} // namespace piMapper
|
|
|
} // namespace piMapper
|
|
|
} // namespace ofx
|
|
|
} // namespace ofx
|