OpenGL3 backend rendering breaks with GL_PRIMITIVE_RESTART #3544

Closed
opened 2020-10-19 12:21:44 +00:00 by ghost · 3 comments
ghost commented 2020-10-19 12:21:44 +00:00 (Migrated from github.com)

Version: 1.79
Branch: master
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: GCC 10.0.1
Operating System: Ubuntu 20.04

If I take the GLFW/OpenGL3 example and add glEnable(GL_PRIMITIVE_RESTART); just before the main loop, the result looks like this:
Screenshot from 2020-10-19 13-04-57

The problem does not occur if I wrap my own OpenGL calls in glEnable(GL_PRIMITIVE_RESTART); / glDisable(GL_PRIMITIVE_RESTART); each frame. I'm not experienced with OpenGL so I'm not sure if this is supposed to work like that or if it's a bug in the backend implementation.

Version: 1.79 Branch: master Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp Compiler: GCC 10.0.1 Operating System: Ubuntu 20.04 If I take the GLFW/OpenGL3 example and add `glEnable(GL_PRIMITIVE_RESTART);` just before the main loop, the result looks like this: ![Screenshot from 2020-10-19 13-04-57](https://user-images.githubusercontent.com/73113881/96449899-68f9ac80-120d-11eb-9996-ac20f93f3ba3.png) The problem does not occur if I wrap my own OpenGL calls in `glEnable(GL_PRIMITIVE_RESTART);` / `glDisable(GL_PRIMITIVE_RESTART);` each frame. I'm not experienced with OpenGL so I'm not sure if this is supposed to work like that or if it's a bug in the backend implementation.
ocornut commented 2020-10-19 14:15:48 +00:00 (Migrated from github.com)

Thanks for reporting this.

Strictly speaking it technically a “bug” but those are endless as OpenGL is a state machine with hundred of states (made more complicated by the many flavors and versions of GL).

As you can see in the backend code we backup/change/restore many state so it would be a matter of adding this to the list of backed up state. (While carefully only calling it for the appropriate GL version)

Realistically speaking, if your OpenGL code wants to interact with any other OpenGL code it is most likely to need to restore any state that the foreign code is unaware off, so your solution would work just as well. But we’re happy to add more to the list of restored state in the backend if it helps.

Thanks for reporting this. Strictly speaking it technically a “bug” but those are endless as OpenGL is a state machine with hundred of states (made more complicated by the many flavors and versions of GL). As you can see in the backend code we backup/change/restore many state so it would be a matter of adding this to the list of backed up state. (While carefully only calling it for the appropriate GL version) Realistically speaking, if your OpenGL code wants to interact with any other OpenGL code it is most likely to need to restore any state that the foreign code is unaware off, so your solution would work just as well. But we’re happy to add more to the list of restored state in the backend if it helps.
ghost commented 2020-10-20 12:27:10 +00:00 (Migrated from github.com)

Yes, I can see how it would be difficult to cover all such situations. I think you should decide yourself if you want to handle this particular case.

Yes, I can see how it would be difficult to cover all such situations. I think you should decide yourself if you want to handle this particular case.
ocornut commented 2020-10-23 09:25:44 +00:00 (Migrated from github.com)

This is now fixed by ffe8f0177f courtesy of @Xipiryon.

This is now fixed by ffe8f0177fb8ca371e5f3195d8399cadf1596483 courtesy of @Xipiryon.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#3544
No description provided.