OpenGL crash

I am trying to use both vtkGenericOpenGLRenderWindow (providing glfw and glad) and vtkRenderWindowInteractor. I get this crash when initializing the interactor:


2023-07-18 22:26:58.653 (   0.178s) [        B65FDB40]     vtkOpenGLState.cxx:83    WARN| Error in cache state for GL_BLEND
2023-07-18 22:26:58.653 (   0.179s) [        B65FDB40]     vtkOpenGLState.cxx:90    WARN| Error in cache state for GL_DEPTH_TEST
2023-07-18 22:26:58.653 (   0.179s) [        B65FDB40]     vtkOpenGLState.cxx:105   WARN| Error in cache state for GL_MULTISAMPLE
2023-07-18 22:26:58.653 (   0.179s) [        B65FDB40]     vtkOpenGLState.cxx:113   WARN| Error in cache state for GL_SCISSOR_TEST
2023-07-18 22:26:58.653 (   0.179s) [        B65FDB40]     vtkOpenGLState.cxx:144   WARN| Error in cache state for GL_VIEWPORT
2023-07-18 22:26:58.653 (   0.179s) [        B65FDB40]     vtkOpenGLState.cxx:152   WARN| Error in cache state for GL_SCISSOR_BOX
2023-07-18 22:26:58.653 (   0.179s) [        B65FDB40]     vtkOpenGLState.cxx:173   WARN| Error in cache state for GL_DEPTH_FUNC
2023-07-18 22:26:58.653 (   0.179s) [        B65FDB40]     vtkOpenGLState.cxx:180   WARN| Error in cache state for GL_BLEND_SRC_RGB
2023-07-18 22:26:58.654 (   0.179s) [        B65FDB40]     vtkOpenGLState.cxx:274   WARN| at stack loc
0x7f4bb7c682c8 : ??? [(???) ???:-1]
0x7f4bb7c62e6c : vtksys::SystemInformation::GetProgramStack[abi:cxx11](int, int) [(libvtksys-9.2.so.1) ???:-1]
0x7f4bb7a19447 : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.2.so.1) ???:-1]
0x7f4bb7a1ebd2 : vtkOpenGLState::SetEnumState(unsigned int, bool) [(libvtkRenderingOpenGL2-9.2.so.1) ???:-1]
0x7f4bb7a1f21b : vtkOpenGLState::vtkglEnable(unsigned int) [(libvtkRenderingOpenGL2-9.2.so.1) ???:-1]
0x7f4bb79e8fe4 : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.2.so.1) ???:-1]
0x7f4bb7ca1fa1 : vtkXRenderWindowInteractor::Initialize() [(libvtkRenderingUI-9.2.so.1) ???:-1]

VTK is built from source so it doesn’t sound like an ABI problem.

Any clue on the possible cause of the problem?

Note: running on debian with VTK-9.2

Looks like a graphics driver issue. Can you run other OpenGL programs?

Yes.

I used glad and glfw. So, I tried to drop them and prefer using “VTK::glew” and “VTK::opengl” (but keeping glfw).

Still crashing but in slightly different way:

0x7ffff790ee6c : vtksys::SystemInformation::GetProgramStack[abi:cxx11](int, int) [(libvtksys-9.2.so.1) ???:-1]
0x7ffff7c19447 : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.2.so.1) ???:-1]
0x7ffff7c1ebd2 : vtkOpenGLState::SetEnumState(unsigned int, bool) [(libvtkRenderingOpenGL2-9.2.so.1) ???:-1]
0x7ffff7c1f21b : vtkOpenGLState::vtkglEnable(unsigned int) [(libvtkRenderingOpenGL2-9.2.so.1) ???:-1]
0x7ffff7be8fe4 : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.2.so.1) ???:-1]
0x7ffff7e82fa1 : vtkXRenderWindowInteractor::Initialize() [(libvtkRenderingUI-9.2.so.1) ???:-1]
...
2023-07-22 10:09:37.956 (   4.947s) [        F5E06B40]     vtkOpenGLState.cxx:1795  WARN| Hardware does not support the number of textures defined.
2023-07-22 10:09:37.956 (   4.947s) [        F5E06B40]   vtkTextureObject.cxx:1759   ERR| vtkTextureObject (0x5555556f8310): failed at glTexImage2D 1 OpenGL errors detected
  0 : (1280) Invalid enum
...
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  3 (X_GetWindowAttributes)
  Resource id in failed request:  0x0
  Serial number of failed request:  8
  Current serial number in output stream:  9

BadWindow (invalid Window parameter)

Am I supposed to pass the GLFW window to vtkXOpenGLRenderWindow::SetWindowId?
If yes how? (not clear to me)

No, VTK creates its own X11 window. Do you have a valid X11 display? On linux, VTK supports XLib as the only own windowing platform for now. If you’d like to bypass creating an X11 window, use offscreen rendering or use vtkExternalOpenGLRenderWindow to render into a GLFW window.