# Create multiple render windows and got "failed at glDeleteFramebuffers 16 OpenGL errors detected" error when closing application

**URL:** https://discourse.vtk.org/t/create-multiple-render-windows-and-got-failed-at-gldeleteframebuffers-16-opengl-errors-detected-error-when-closing-application/14682
**Category:** Support
**Created:** [October 9, 2024, 4:08am UTC](https://discourse.vtk.org/t/create-multiple-render-windows-and-got-failed-at-gldeleteframebuffers-16-opengl-errors-detected-error-when-closing-application/14682 "2024-10-09T04:08:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cyfgod](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cyfgod/32/9338_2.png) [@cyfgod](https://discourse.vtk.org/u/cyfgod)
#### Post date: [October 9, 2024, 4:08am UTC](https://discourse.vtk.org/t/create-multiple-render-windows-and-got-failed-at-gldeleteframebuffers-16-opengl-errors-detected-error-when-closing-application/14682/1 "2024-10-09T04:08:08Z")

</div>

Hello everyone,

In our scenario, we use StackLayout to switch different user’s DICOM render image in QML.  
For example:

```auto
StackLayout {
    id: multi_viewer
    Layout.preferredWidth: 800
    Layout.preferredHeight: 768
    Layout.alignment: Qt.AlignTop | Qt.AlignLeft
    currentIndex: 0

    GridLayout {
        columns: 1
        rows: 1
        columnSpacing: 10

        VTKRenderWindow {
            id: renderWin_0
            objectName: "renderWin_0"
        }

        VTKRenderItem {
            width: 395
            height: 368
            id: renderItem_0_0
            objectName: "renderItem_0_0"
            renderWindow: renderWin_0
        }

        Component.onCompleted : {
            viewerPresenter.init(0, renderWin_0, renderItem_0_0)
        }
    }

    GridLayout {
        columns: 1
        rows: 1
        columnSpacing: 10

        VTKRenderWindow {
            id: renderWin_1
            objectName: "renderWin_1"
        }

        VTKRenderItem {
            width: 395
            height: 368
            id: renderItem_1_0
            objectName: "renderItem_1_0"
            renderWindow: renderWin_1
        }

        Component.onCompleted : {
            viewerPresenter.init(1, renderWin_1, renderItem_1_0)
        }
    }

```

And use a button to switch card

```auto
Button {
    text: "Switch card"

    onClicked: {
        var index = multi_viewer.currentIndex
        multi_viewer.currentIndex = index === 0 ? 1 : 0
    }
}

```

It works fine. Once click button to switch render window and then close application, got error in VTK console. If don’t switch render window, no error thrown.

```auto
“OperationWorkbench.exe”(Win32): 已加载“C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_60b8b9eb71f62e16\comctl32.dll”。
ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (000002458F367290): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (000002458F368B00): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (000002458F366D40): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (000002458F368390): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

ERROR: In vtkOpenGLFramebufferObject.cxx, line 356
vtkOpenGLFramebufferObject (00000245929E1130): failed at glDeleteFramebuffers 16 OpenGL errors detected
  0 : (1282) Invalid operation
  1 : (1282) Invalid operation
  2 : (1282) Invalid operation
  3 : (1282) Invalid operation
  4 : (1282) Invalid operation
  5 : (1282) Invalid operation
  6 : (1282) Invalid operation
  7 : (1282) Invalid operation
  8 : (1282) Invalid operation
  9 : (1282) Invalid operation
  10 : (1282) Invalid operation
  11 : (1282) Invalid operation
  12 : (1282) Invalid operation
  13 : (1282) Invalid operation
  14 : (1282) Invalid operation
  15 : (1282) Invalid operation

```

Any suggestions？

Thanks a lot!

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [October 9, 2024, 2:45pm UTC](https://discourse.vtk.org/t/create-multiple-render-windows-and-got-failed-at-gldeleteframebuffers-16-opengl-errors-detected-error-when-closing-application/14682/2 "2024-10-09T14:45:34Z")

</div>

@sankhesh
