Hi
I’m trying to draw a number of moving objects (>300) and show their trails. Every object is a combination of meshes.
I use an FBO and draw in it the objects sequentially from the map where they are stored. This is done in the general update method. The FBO is then drawn to screen in the general draw method.
Is this a good strategy for working with FBOs? Are there other approaches with better performance? WOuld it help if the FBO is a shared pointer passed to every instance so it draws itself to it?
Any tips for improving the performance with this would be appreciated.
VisualManager.cpp
void VisualManager::drawFbo(){
rgbaFbo.begin();
ofEnableAlphaBlending();
for(auto pair:particleMap) {
ofVec2f position = pair.second->getPosition();
ofPushMatrix();
ofTranslate(position.x, position.y);
pair.second->draw();
ofPopMatrix();
}
ofDisableBlendMode();
ofEnableBlendMode(OF_BLENDMODE_ALPHA);
ofFill();
ofSetColor(0,0,0, fadeAmnt);
ofDrawRectangle(0,0,ofGetWidth(),ofGetHeight());
ofDisableBlendMode();
ofDisableAlphaBlending();
rgbaFbo.end();
}
void VisualManager::update(){
for(auto pair:particleMap) {
pair.second->update();
}
drawFbo();
}
void VisualManager::draw(){
ofEnableBlendMode(OF_BLENDMODE_DISABLED);
rgbaFbo.draw(0,0);
ofDisableBlendMode();
}