Hello people, I have a problem with fullscreen. The thing is that I have created a particle system and everything works fine but when I try to make a full screen of my second fbo the animation of the particle system works slowly but if not the application works fine.
here it-s my code:
int main( ){
ofGLFWWindowSettings settings;
settings.width = 600;
settings.height = 600;
settings.setPosition(ofVec2f(100, 100));
settings.resizable = true;
shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
settings.width = PROJECTOR_RESOLUTION_X;
settings.height = PROJECTOR_RESOLUTION_Y;
settings.setPosition(ofVec2f(0, 40));
settings.resizable = true;
settings.shareContextWith = mainWindow;
shared_ptr<ofAppBaseWindow> secondWindow = ofCreateWindow(settings);
secondWindow->setVerticalSync(true);
shared_ptr<ofApp> mainApp(new ofApp);
ofAddListener(secondWindow->events().draw, mainApp.get(), &ofApp::drawSecondWindow);
ofRunApp(mainWindow, mainApp);
ofRunMainLoop();
}
void ofApp::draw()
{
if(fullScreen)
ofSetFullscreen(modeScreen == SCREENBOTH || modeScreen == SCREENONE);
if (!testmode) {
fbo.begin();
ofClear(backgroundColor);
particleSystem.setupForces();
mesh.clear();
for (int i = 0; i < particleSystem.size(); i++) {
Particle& cur = particleSystem[i];
particleSystem.addRepulsionForce(cur, particleNeighborhood, particleRepulsion, mesh, multiple);
}
particleSystem.update();
mesh.draw();
fbo.end();
fbo2.begin();
shader.begin();
shader.setUniform1f("ksectors", Ksectors);
shader.setUniform1f("kangleRad", ofDegToRad(kangle));
shader.setUniform2f("kcenter", 0.5*currentWithWindow, 0.5*currentHeightWindow);
ofSetColor(ofColor::white);
fbo.draw(0, 0, currentWithWindow, currentHeightWindow);
shader.end();
fbo2.end();
}
gui.setPosition(32, 192);
gui.draw();
glColor3f(0, 0, 0);
ofDrawBitmapString("particles number: " + ofToString(particleSystem.size()), ofVec2f(32.0f, 32.0f));
ofDrawBitmapString("fps: " + to_string((int)ofGetFrameRate()), ofVec2f(32.0f, 52.0f));
ofDrawBitmapString("particleNeighborhood: " + to_string((int)particleNeighborhood), ofVec2f(32.0f, 72.0f));
ofDrawBitmapString("multiple: " + to_string((int)multiple), ofVec2f(32.0f, 92.0f));
ofDrawBitmapString("lifeTime: " + to_string((int)lifeTime), ofVec2f(32.0f, 112.0f));
ofDrawBitmapString("backgroundColor: " + to_string((int)backgroundColor), ofVec2f(32.0f, 132.0f));
ofDrawBitmapString("fullScreen: " + to_string(fullScreen), ofVec2f(32.0f, 152.0f));
ofDrawBitmapString(to_string((int)currentWithWindow) + " x " + to_string((int)currentHeightWindow), ofVec2f(32.0f, 172.0f));
if(modePress> 0) ofDrawBitmapString("PRESS MODE: " + ModePressString[modePress], ofVec2f(ofGetWidth() - 300, 32.0f));
if (modeSet> 0) ofDrawBitmapString("PRESS MODE: " + ModeSetString[modeSet], ofVec2f(ofGetWidth() - 300, 52.0f));
if (modeScreen> 0) ofDrawBitmapString("PRESS MODE SREEN: " + modeScreenString[modeScreen], ofVec2f(ofGetWidth() - 300, 72.0f));
}
void ofApp::drawSecondWindow(ofEventArgs & args) {
if (fullScreen)
ofSetFullscreen(modeScreen == SCREENBOTH || modeScreen == SCREENTWO);
ofBackground(backgroundColor);
if(testmode){
ofBackground(0);
ofSetColor(255);
kinect.draw(0, 0);
ofPushMatrix();
ofTranslate(640, 0);
grayImage.draw(0, 0);
ofTranslate(-640, 480);
contourFinder.draw();
ofTranslate(640, 0);
ofPopMatrix();
}
else {
ofSetColor(255);
fbo2.draw(0, 0, currentWithWindow, currentHeightWindow);
}
}
fullsreen video:
nofullscreen video:
Does anyone know how this happened?
I hope someone can help me