I’ve been using VTK 8.2.0 for a while and had no issues with integrating it into MFC in Visual Studio.
After I upgraded to VTK 9.1d I get the following message in the VTK output window:
“ERROR: In C:\Work\3DMetrix\dev\master\3DLymph\packages\VTK-9.1.0\CMAKE-SRC\Rendering\OpenGL2\vtkOpenGLFramebufferObject.cxx, line 367
vtkOpenGLFramebufferObject (000002651F166E20): 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”
…repeated about 9 times.
It seemed to be linked to using vtkMFCWindow. I have several vtkMFCWindow objects in different panes in my window. If I only have one vtkMFCWindow object then I do not get the errors but anything more than one gives me these errors.
I am experiencing the same issue. This happens when I use ReleaseGraphicsResources()
Do you resolve it?
No, I’m still struggling with it.
I tested the exact same codebase on macos and there is no error. I wonder if this error only shows on Windows platform and it’s not critical so we can ignore it?
From my test, it was only relevant to vtkMFCWindow, which is windows only. I’m not sure if we can ignore this. I wouldn’t.
I’ve managed to create some sort of workaround. I basically have called the SetRenderWindow to null on my main form closing.
No more errors! I think there is still some problem with the VTK library or maybe the way I’m using it.
Finalize() in their destructors.
vtkWin32OpenGLRenderWindow::DestroyWindow() => Clean() => CleanUpRenderers() => ReleaseGraphicsResources()
only happens when WindowIdReferenceCount == 1
It could be worth putting a break point in
DestroyWindow() to see what is happening. I suspect calling
vktMFCWindow::SetRenderWindow(nullptr) reduces WindowIdReferenceCount so that the destructor works correctly.
The problem is that it looks like that ‘Finalize’ is called too late when I do not use the workaround.
I tried to debug the positions you mentioned here and noticed at first glance that wglGetCurrentContext always returns NULL. With my workaround, it does not return NULL.
And what about when you create only one vtkWindow?
I double-checked it. It works fine with only one vtkWindow. No workaround needed then.
Yes I understand that. So a break point in
vtkWin32OpenGLRenderWindow::DestroyWindow() shows an assigned rendering context in that case?
I suggest you break point all occurrences of
wglDeleteContext to see where the context is being destroyed.
The " failed at glDeleteFramebuffers…" errors happen before
DestroyWindow is called or any of the wglDeleteContext methods.
I recommend you log the issue here
https://gitlab.kitware.com/vtk/vtk/-/issues and provide a minimal working project to reproduce the fault.