vtkOpenGLState error

I’m writing a DLL to use in C# WPF, but when I run the DLL’s render function, I get the following error.

2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:57    WARN| Error in cache state for GL_DEPTH_WRITEMASK
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:65    WARN| Error in cache state for GL_COLOR_WRITEMASK
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:86    WARN| Error in cache state for GL_CULL_FACE
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:109   WARN| Error in cache state for GL_STENCIL_TEST
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:117   WARN| Error in cache state for GL_TEXTURE_CUBE_MAP_SEAMLESS
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:133   WARN| Error in cache state for GL_VIEWPORT
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:141   WARN| Error in cache state for GL_SCISSOR_BOX
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:148   WARN| Error in cache state for GL_CULL_FACE_MODE
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:155   WARN| Error in cache state for GL_ACTIVE_TEXTURE
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:162   WARN| Error in cache state for GL_DEPTH_FUNC
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:169   WARN| Error in cache state for GL_BLEND_SRC_RGB
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:176   WARN| Error in cache state for GL_BLEND_SRC_ALPHA
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:183   WARN| Error in cache state for GL_BLEND_DST_RGB
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:190   WARN| Error in cache state for GL_BLEND_DST_ALPHA
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:197   WARN| Error in cache state for GL_DRAW_FRAMEBUFFER_BINDING
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:204   WARN| Error in cache state for GL_READ_FRAMEBUFFER_BINDING
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:222   WARN| Error in cache state for GL_DRAW_BUFFER got -1329294848 expected1026
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:241   WARN| Error in cache state for GL_READ_BUFFER
2024-12-09 10:50:49.643 (   3.722s) [    7FC9116B0740]     vtkOpenGLState.cxx:255   WARN| Error in cache state for GL_COLOR_CLEAR_VALUE
2024-12-09 10:50:49.650 (   3.728s) [    7FC9116B0740]     vtkOpenGLState.cxx:263   WARN| at stack loc
0x7fc8fbe6bba1 : ??? [(???) ???:-1]
0x7fc8fbe661db : vtksys::SystemInformation::GetProgramStack[abi:cxx11](int, int) [(libvtksys-9.4.so.1) ???:-1]
0x7f87e110fa56 : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e1115bb9 : vtkOpenGLState::SetEnumState(unsigned int, bool) [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e11162bd : vtkOpenGLState::vtkglEnable(unsigned int) [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e10d3c24 : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e11fbe20 : vtkXOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e0ad6e5c : vtkRenderWindow::Render() [(libvtkRenderingCore-9.4.so.1) ???:-1]
0x7f87e10d8065 : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e11ffa76 : vtkXOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7fc904617ae9 : Model::ChangeLayer(int, int) [(libOptomoVTK.so) ???:-1]
0x7fc904610ed1 : ChangeLayer [(libOptomoVTK.so) ???:-1]
0x7fc8941aa9b6 : ??? [(???) ???:-1]

2024-12-09 10:50:49.650 (   3.728s) [    7FC9116B0740]     vtkOpenGLState.cxx:57    WARN| Error in cache state for GL_DEPTH_WRITEMASK
2024-12-09 10:50:49.650 (   3.728s) [    7FC9116B0740]     vtkOpenGLState.cxx:65    WARN| Error in cache state for GL_COLOR_WRITEMASK
2024-12-09 10:50:49.650 (   3.728s) [    7FC9116B0740]     vtkOpenGLState.cxx:86    WARN| Error in cache state for GL_CULL_FACE
2024-12-09 10:50:49.650 (   3.728s) [    7FC9116B0740]     vtkOpenGLState.cxx:109   WARN| Error in cache state for GL_STENCIL_TEST
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:117   WARN| Error in cache state for GL_TEXTURE_CUBE_MAP_SEAMLESS
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:133   WARN| Error in cache state for GL_VIEWPORT
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:141   WARN| Error in cache state for GL_SCISSOR_BOX
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:148   WARN| Error in cache state for GL_CULL_FACE_MODE
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:155   WARN| Error in cache state for GL_ACTIVE_TEXTURE
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:162   WARN| Error in cache state for GL_DEPTH_FUNC
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:169   WARN| Error in cache state for GL_BLEND_SRC_RGB
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:176   WARN| Error in cache state for GL_BLEND_SRC_ALPHA
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:183   WARN| Error in cache state for GL_BLEND_DST_RGB
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:190   WARN| Error in cache state for GL_BLEND_DST_ALPHA
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:197   WARN| Error in cache state for GL_DRAW_FRAMEBUFFER_BINDING
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:204   WARN| Error in cache state for GL_READ_FRAMEBUFFER_BINDING
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:222   WARN| Error in cache state for GL_DRAW_BUFFER got -1329294864 expected1026
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:241   WARN| Error in cache state for GL_READ_BUFFER
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:255   WARN| Error in cache state for GL_COLOR_CLEAR_VALUE
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:263   WARN| at stack loc
0x7fc8fbe6bba1 : ??? [(???) ???:-1]
0x7fc8fbe661db : vtksys::SystemInformation::GetProgramStack[abi:cxx11](int, int) [(libvtksys-9.4.so.1) ???:-1]
0x7f87e110fa56 : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e111477a : vtkOpenGLState::vtkglBlendFuncSeparate(unsigned int, unsigned int, unsigned int, unsigned int) [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e10d3c5a : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e11fbe20 : vtkXOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e0ad6e5c : vtkRenderWindow::Render() [(libvtkRenderingCore-9.4.so.1) ???:-1]
0x7f87e10d8065 : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e11ffa76 : vtkXOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7fc904617ae9 : Model::ChangeLayer(int, int) [(libOptomoVTK.so) ???:-1]
0x7fc904610ed1 : ChangeLayer [(libOptomoVTK.so) ???:-1]
0x7fc8941aa9b6 : ??? [(???) ???:-1]

2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:57    WARN| Error in cache state for GL_DEPTH_WRITEMASK
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:65    WARN| Error in cache state for GL_COLOR_WRITEMASK
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:86    WARN| Error in cache state for GL_CULL_FACE
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:109   WARN| Error in cache state for GL_STENCIL_TEST
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:117   WARN| Error in cache state for GL_TEXTURE_CUBE_MAP_SEAMLESS
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:133   WARN| Error in cache state for GL_VIEWPORT
2024-12-09 10:50:49.650 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:141   WARN| Error in cache state for GL_SCISSOR_BOX
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:148   WARN| Error in cache state for GL_CULL_FACE_MODE
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:155   WARN| Error in cache state for GL_ACTIVE_TEXTURE
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:162   WARN| Error in cache state for GL_DEPTH_FUNC
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:169   WARN| Error in cache state for GL_BLEND_SRC_RGB
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:176   WARN| Error in cache state for GL_BLEND_SRC_ALPHA
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:183   WARN| Error in cache state for GL_BLEND_DST_RGB
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:190   WARN| Error in cache state for GL_BLEND_DST_ALPHA
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:222   WARN| Error in cache state for GL_DRAW_BUFFER got 0 expected1026
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:241   WARN| Error in cache state for GL_READ_BUFFER
2024-12-09 10:50:49.651 (   3.729s) [    7FC9116B0740]     vtkOpenGLState.cxx:255   WARN| Error in cache state for GL_COLOR_CLEAR_VALUE
2024-12-09 10:50:49.652 (   3.730s) [    7FC9116B0740]     vtkOpenGLState.cxx:263   WARN| at stack loc
0x7fc8fbe6bba1 : ??? [(???) ???:-1]
0x7fc8fbe661db : vtksys::SystemInformation::GetProgramStack[abi:cxx11](int, int) [(libvtksys-9.4.so.1) ???:-1]
0x7f87e110fa56 : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e111178d : vtkOpenGLState::vtkglBindFramebuffer(unsigned int, unsigned int) [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e1111749 : vtkOpenGLState::vtkBindFramebuffer(unsigned int, vtkOpenGLFramebufferObject*) [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e0fd44ca : vtkOpenGLFramebufferObject::Bind(unsigned int) [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e0fd4265 : vtkOpenGLFramebufferObject::Bind() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e10d3cea : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e11fbe20 : vtkXOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e0ad6e5c : vtkRenderWindow::Render() [(libvtkRenderingCore-9.4.so.1) ???:-1]
0x7f87e10d8065 : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7f87e11ffa76 : vtkXOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.4.so.1) ???:-1]
0x7fc904617ae9 : Model::ChangeLayer(int, int) [(libOptomoVTK.so) ???:-1]
0x7fc904610ed1 : ChangeLayer [(libOptomoVTK.so) ???:-1]
0x7fc8941aa9b6 : ??? [(???) ???:-1]

terminate called after throwing an instance of 'std::bad_array_new_length'
  what():  std::bad_array_new_length

There are 4 vtkRenderers in vtkRenderWindow.