# OpenGL crash

**URL:** https://discourse.vtk.org/t/opengl-crash/11965
**Category:** Support
**Created:** [July 18, 2023, 8:30pm UTC](https://discourse.vtk.org/t/opengl-crash/11965 "2023-07-18T20:30:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![fghoussen](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/ecd19e/32.png) [@fghoussen](https://discourse.vtk.org/u/fghoussen)
#### Post date: [July 18, 2023, 8:30pm UTC](https://discourse.vtk.org/t/opengl-crash/11965/1 "2023-07-18T20:30:35Z")

</div>

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

```auto

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

---

<div class="post-metadata">

### Author: ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)
#### Post date: [July 21, 2023, 1:37pm UTC](https://discourse.vtk.org/t/opengl-crash/11965/2 "2023-07-21T13:37:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![fghoussen](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/ecd19e/32.png) [@fghoussen](https://discourse.vtk.org/u/fghoussen)
#### Post date: [July 22, 2023, 8:13am UTC](https://discourse.vtk.org/t/opengl-crash/11965/3 "2023-07-22T08:13:31Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

### Author: ![fghoussen](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/ecd19e/32.png) [@fghoussen](https://discourse.vtk.org/u/fghoussen)
#### Post date: [July 22, 2023, 8:23am UTC](https://discourse.vtk.org/t/opengl-crash/11965/4 "2023-07-22T08:23:31Z")

</div>

> BadWindow (invalid Window parameter)

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

---

<div class="post-metadata">

### Author: ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)
#### Post date: [July 22, 2023, 11:54am UTC](https://discourse.vtk.org/t/opengl-crash/11965/5 "2023-07-22T11:54:58Z")

</div>

> [@fghoussen](#):
>
> 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](https://vtk.org/doc/nightly/html/classvtkWindow.html#a193ffdb82bfd6c54b6830250dd06e4d7) or use [vtkExternalOpenGLRenderWindow](https://vtk.org/doc/nightly/html/classvtkExternalOpenGLRenderWindow.html#details) to render into a GLFW window.
