Search code examples
openglframebufferopenframeworksfboheadless

OfAppNoWindow and ofFbo video IO behaviour conflict in OpenFrameworks


I am trying to render a video using ofxVideoRecorder on a headless server. The video renders correctly with a normal window, i.e.

ofSetupOpenGL(640,420, OF_WINDOW);

However, I get messed up frames (could not attach image) with a ofAppNoWindow.

ofAppNoWindow headless;
ofSetupOpenGL(&headless,640,420,OF_WINDOW);
ofRunApp(new testApp());

I have also tried, ofAppNoWindow headless; headless.setupOpenGL(640,420,OF_WINDOW); headless.runAppViaInfiniteLoop(new testApp());

I render objects in ofFbo in update method(). I tried saving image with and without headless window. The image saves correctly without headless window.

I think the issue is with FBO drawing incorrectly with ofApppNoWindow

This is the Fbo draw code

fbo.begin();
 ofClear( 255, 255, 255, 0 );
 ofEnableAlphaBlending();
 element.draw(); //element is my class
fbo.end();

Here is the screen capture code.

fbo.readToPixels(pixels);
pixels.setNumChannels(3);
vidRecorder.addFrame(pixels); //ofxVideoRecorder object

Would appreciate any help to enable near realtime video rendering and writing.


Solution

  • Answering my question. Thanks to @arturo at forums.openframeworks.co Hope this helps others.

    The ofAppNoWindow does not create a OpenGL context. Hence OpenGL resources such as FBO are unavailable. Therefore you cannot really "read" the FBO. This can be verified by checking if the fbo is allocated (fbo.isAllocated() in openFrameworks).