Browse Source

Merge branch 'fixToAlignWithOfxPhilosophy' of https://github.com/lobodelmar/ofxPiMapper into lobodelmar-fixToAlignWithOfxPhilosophy

master
Krisjanis Rijnieks 8 years ago
parent
commit
2ead0301ea
  1. 2
      src/MediaServer/MediaServer.cpp
  2. 18
      src/Sources/FboSource.cpp
  3. 6
      src/Sources/FboSource.h
  4. 16
      src/Surfaces/SurfaceManager.cpp

2
src/MediaServer/MediaServer.cpp

@ -340,7 +340,9 @@ void MediaServer::addFboSource(FboSource * fboSource){
// It is important to run the setup of the FBO
// source from outside as we can see here.
fboSource->beginFbo();
fboSource->setup();
fboSource->endFbo();
}
BaseSource * MediaServer::loadFboSource(string & fboSourceName){

18
src/Sources/FboSource.cpp

@ -24,6 +24,22 @@ void FboSource::updateFbo(){
update();
}
void FboSource::beginFbo(){
if(fbo == 0 || !fbo->isAllocated()){
ofLogWarning("FboSource") << "FBO not allocated";
return;
}
fbo->begin();
}
void FboSource::endFbo(){
if(fbo == 0 || !fbo->isAllocated()){
ofLogWarning("FboSource") << "FBO not allocated";
return;
}
fbo->end();
}
void FboSource::drawFbo(){
if(fbo == 0 || !fbo->isAllocated()){
ofLogWarning("FboSource") << "FBO not allocated";
@ -85,4 +101,4 @@ int FboSource::getHeight(){
}
} // namespace piMapper
} // namespace ofx
} // namespace ofx

6
src/Sources/FboSource.h

@ -33,6 +33,10 @@ class FboSource : public BaseSource {
// App listeners
void setDisableDraw(bool b); // Use in cases with external ofFbo
// fbo accessor functions to allow us to wrap any function with begin/end calls to fbo
void beginFbo();
void endFbo();
protected:
ofFbo * fbo;
void allocate(int width, int height);
@ -45,4 +49,4 @@ class FboSource : public BaseSource {
};
} // namespace piMapper
} // namespace ofx
} // namespace ofx

16
src/Surfaces/SurfaceManager.cpp

@ -462,8 +462,24 @@ void SurfaceManager::setPreset(unsigned int i){
_activePresetIndex = i;
//when preset it changed, call reset on all sources, if it's defined
for (int i=0; i<_presets[_activePresetIndex]->getSurfaces().size(); i++){
//if source is of type FBO then cast it from BaseSource to FboSource and call the beginFbo function
if (_presets[_activePresetIndex]->getSurfaces()[i]->getSource()->getType() == SourceType::SOURCE_TYPE_FBO){
FboSource *fboSource;
fboSource = (FboSource*)_presets[_activePresetIndex]->getSurfaces()[i]->getSource();
fboSource->beginFbo();
}
_presets[_activePresetIndex]->getSurfaces()[i]->getSource()->reset();
//if source is of type FBO then cast it from BaseSource to FboSource and call the endFbo function
if (_presets[_activePresetIndex]->getSurfaces()[i]->getSource()->getType() == SourceType::SOURCE_TYPE_FBO){
FboSource *fboSource;
fboSource = (FboSource*)_presets[_activePresetIndex]->getSurfaces()[i]->getSource();
fboSource->endFbo();
}
}
}

Loading…
Cancel
Save