Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opengl OpenFrameworks中的OfAppNoWindow和ofFbo视频IO行为冲突_Opengl_Framebuffer_Openframeworks_Fbo_Headless - Fatal编程技术网

Opengl OpenFrameworks中的OfAppNoWindow和ofFbo视频IO行为冲突

Opengl OpenFrameworks中的OfAppNoWindow和ofFbo视频IO行为冲突,opengl,framebuffer,openframeworks,fbo,headless,Opengl,Framebuffer,Openframeworks,Fbo,Headless,我正在尝试在无头服务器上使用ofxVideoRecorder渲染视频。视频使用正常窗口正确渲染,即 ofSetupOpenGL(640,420, OF_WINDOW); 然而,我得到了混乱的帧(无法附加图像)与一个应用程序 ofAppNoWindow headless; ofSetupOpenGL(&headless,640,420,OF_WINDOW); ofRunApp(new testApp()); 我也试过,, 没有头的人; 无头.setupOpenGL(640420,OF_

我正在尝试在无头服务器上使用ofxVideoRecorder渲染视频。视频使用正常窗口正确渲染,即

ofSetupOpenGL(640,420, OF_WINDOW);
然而,我得到了混乱的帧(无法附加图像)与一个应用程序

ofAppNoWindow headless;
ofSetupOpenGL(&headless,640,420,OF_WINDOW);
ofRunApp(new testApp());
我也试过,, 没有头的人; 无头.setupOpenGL(640420,OF_窗口); 无头runappviaInfiniteLop(newTestApp())

我在更新方法()中的ofFbo中渲染对象。我试着在有无无头窗口的情况下保存图像。图像无需无头窗口即可正确保存

我认为问题在于FBO使用OFAPPNOWINDOW绘制错误

这是Fbo绘图代码

fbo.begin();
 ofClear( 255, 255, 255, 0 );
 ofEnableAlphaBlending();
 element.draw(); //element is my class
fbo.end();
这是屏幕截图代码

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

如果您能帮助我们实现近实时视频渲染和写入,我们将不胜感激。

回答我的问题。感谢forums.openframeworks.co上的@arturo,希望这能帮助其他人


ofAppNoWindow不会创建OpenGL上下文。因此,OpenGL资源(如FBO)不可用。因此,您无法真正“阅读”FBO。这可以通过检查fbo是否已分配(openFrameworks中的fbo.isAllocated())来验证

我不得不用Rapidswitch的GPU在远程专用服务器上安装Openframeworks,经过几个小时的努力,我终于可以让它工作了

为了使用OpenGL,您必须运行X服务器。Xvfb不是一个选项,因为它不是硬件加速的,所以您必须在不连接屏幕的情况下配置Xserver

我的系统是Ubuntu 14.04.5 LTS

  • 首先,我检查了GPU是否存在:

    $ lspci  | grep NVIDIA
    01:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2)
    
  • <> L> >我安装了英伟达驱动程序(我选择了这个版本,没有特别的理由,在帖子中发表评论)。
  • 我运行
    sudonvidiaxconfig
    ,这是我的/etc/X11/xorg.conf的顶部

    # nvidia-xconfig: X configuration file generated by nvidia-xconfig
    # nvidia-xconfig: version 352.93  (buildmeister@swio-display-x86-rhel47-07)  Tue Apr  5 18:55:28 PDT 2016
    
  • 然后,我修改了/etc/X11/xorg.conf,添加了
    AllowEmptyInitialConfiguration
    选项:

    Section "Device"
        Identifier     "Device0"
        Driver         "nvidia"
        VendorName     "NVIDIA Corporation"
        Option         "AllowEmptyInitialConfiguration"
    EndSection
    
  • 最后,我可以在显示器上启动X服务器:0

    sudo/usr/bin/X:0

如果一切正常,该命令将使用硬件加速启动X服务器。我们可以运行
glxinfo-display:0 | grep renderer
来检查它是否确实在使用GPU。这是我的输出:

$ glxinfo -display :0 | grep renderer
OpenGL renderer string: GeForce GTX 750 Ti/PCIe/SSE2
 $ glxgears
 Running synchronized to the vertical refresh.  
 The framerate should be approximately the same as the monitor refresh rate.
 63388 frames in 5.0 seconds = 12677.544 FPS
 63382 frames in 5.0 seconds = 12676.304 FPS
 ...
最后,您只需导出显示器
export display=:0
并运行任何OPENGL代码。您可以使用玩具示例
glxgears
检查它是否正常工作

这是我的输出:

$ glxinfo -display :0 | grep renderer
OpenGL renderer string: GeForce GTX 750 Ti/PCIe/SSE2
 $ glxgears
 Running synchronized to the vertical refresh.  
 The framerate should be approximately the same as the monitor refresh rate.
 63388 frames in 5.0 seconds = 12677.544 FPS
 63382 frames in 5.0 seconds = 12676.304 FPS
 ...

现在,您已经准备好运行OpenFrameworks项目了您不需要对源代码进行任何更改。

您可以使用此命令配置无头虚拟屏幕
sudo nvidia xconfig-a--使用显示设备=None--virtual=1280x1024
这是论坛中提到的线程: