Offscreen Rendering with VTK 9.4, vtkXOpenGLRenderWindow warnings

I pulled from the release branch yesterday (11-18) and compiled on linux. I didn’t modify any of the OpenGL build settings.

I then compiled the OffscreenRendering example to test out how the runtime-choosing of render window type works.

When I run in batch nodes without X capability, I see this warning:
WARN| vtkXOpenGLRenderWindow (0x47f3b0): bad X server connection.
but the generated screenshot.png is correct, so the offscreen rendering appears to be working.
I also modified the example to comment out the use of the vtkGraphicsFactory. It yielded the same results.
Is there a way to avoid this warning when requesting offscreen rendering?

Hello @biagas

If the generated screenshot is correct, then there’s nothing to worry about. The warning message occurs when VTK is attempting to test whether it can access an X display. There are many reasons for being unable to use X/GLX so in the current version VTK prints them all as warnings. This is kind of helpful in understanding what the issue might be.

Right now, there is no way to avoid the warning. I could refactor it to output messages into a higher verbosity like TRACE or vtkDebugMacro.

Thanks for the quick reply. I would upvote a move to vtkDebugMacro, just to prevent confusion for our users who would assume such a warning meant something is wrong.

Sorry, another quick question. When offscreen rendering is chosen, why is the XOpenGL render window even considered?

Noted.

Right now, the options exposed by vtkGraphicsFactory class are not respected in the window selection process. The only way to make it bypass checks is to set the VTK_DEFAULT_OPENGL_WINDOW environment variable to vtkOSOpenGLRenderWindow.

I think we can revive vtkGraphicsFactory and make it work correctly.

I apologize for not being clearer. I was asking about the use case where vtkRenderWindow::OffScreenRendering was set to true. This is how I am accustomed to requesting offscreen, not through the vtkGraphicsFactory. Possibly due to the gymnastics needed in the past to get a single build supporting onscreen, offscreen and headless modes.
I don’t want to set VTK_DEFAULT_OPENGL_WINDOW to vtkOSOpenGLRenderWindow because that isn’t the mode I want to always use. I like the new runtime setup and am appreciative of the work that went into making it available. I was just curious why the vtkXOpenGLRenderWindow is tried when the vtkRenderWindow’s OffScreenRendering is requested.

Oh.

Since the runtime detection occurs while constructing an instance of vtkRenderWindow, the class cannot know if OffScreenRendering is going to be set or not. This could be solved if VTK C++ classes accepted constructor keyword arguments.

By the way, OffScreenRendering (which is deprecated in favor of UseOffScreenBuffers and ShowWindow) does not mean that VTK will never create a real window. It only means that the geometry will be rendered into a framebuffer which is not related to the window.

As you’re interested in programatically influencing the render window selection, it would be nice if we made use of vtkGraphicsFactory::OffScreenOnlyMode. Then you can benefit from the feature like this:

vtkGraphicsFactory::SetOffScreenOnlyMode(true);
vtkNew<vtkRenderWindow> window;