-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenGL error when restoring the state of the OpenGL context #6220
Comments
Interesting find. Thanks for the careful report. I am wondering if it might not be simpler than we call glGetError() once rather than attempt to deal with all possible edge cases here? |
The glGetError() idea might not work for cases where people use the Debug Output Callback feature. Since this bug can only occur for OpenGL objects (shader programs, textures, buffers and a few others), it may be cleaner (but still quick) to just add the handful of necessary |
So it turns out that only |
Thank you! Merged your fix as 66b7625. |
Version/Branch of Dear ImGui:
Version: 1.89
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: MSVC
Operating System: Windows 11
My Issue:
There is a bug in imgui_impl_opengl3.cpp at line 579 that may generate the following OpenGL error:
GL_INVALID_VALUE error generated. Program handle does not refer to an object generated by OpenGL.
This error is caused by the following situation:
123
).In this step, the backend will first backup the currently bound shader using
glGetIntegerv(GL_CURRENT_PROGRAM, ...)
. This will return123
since our shader is not deleted yet (as it is bound), but is pending deletion.The backend will then do its internals, which includes binding its own shaders. This will unbind our shader
123
and since it is pending deletion and no longer used by OpenGL, it will actually be deleted there.Once the backend is done with its tasks, it will attempt to rebind the previously bound shader, which is our shader
123
. The problem is that in the meantime, this shader has been deleted. This call ends up binding a deleted shader and causing the mentionned OpenGL error.A way to fix this is to check if the shader is still valid before trying to rebind it:
Note: This bug may also apply to other resources in the backup/restore steps.
The text was updated successfully, but these errors were encountered: