-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Backends: OpenGL: Reset GL_POLYGON_MODE correctly #6333
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
Conversation
UpdateActually, |
|
What a mess :( On Desktop targets all the defines would be automatically existing with our loader (which needs regeneration, see https://github.com/dearimgui/gl3w_stripped) I am thinking of turning this code into: ImGui_ImplOpenGL3_Data:: GLint GlProfileMask; (Note this is zero-initialized) ImGui_ImplOpenGL3_Init(): #if !defined(IMGUI_IMPL_OPENGL_ES2)
...
#if defined(GL_CONTEXT_PROFILE_MASK)
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &bd->GlProfileMask);
#endif
...
#endif ImGui_ImplOpenGL3_RenderDrawData(): #ifdef IMGUI_IMPL_HAS_POLYGON_MODE
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
if ((bd->GlVersion <= 310) || (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT))
{
glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]);
glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
}
else
{
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
}
#endif // IMGUI_IMPL_HAS_POLYGON_MODE Does it seem equally accurate to you? EDIT sorry mistyped && instead of || in the version & profile mask check. It should be || afaik. |
Sorry mistyped && instead of || in the version && profile mask check. if ((bd->GlVersion <= 310) && (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)) should be if ((bd->GlVersion <= 310) || (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)) By uncommenting the |
Hello, if there are no compile-errors the code should indeed produce equivalent results. However, your version is (currently) error-prone to missing constant definitions. I.e. if a (custom) loader doesn't provide |
…nd back when possible. (#6333)
I have merged d0836aa (yours) + a338b78 (slight amends). I moved the use of #if defined(GL_CONTEXT_PROFILE_MASK)
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &bd->GlProfileMask);
bd->GlProfileIsCompat = (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0;
#endif #ifdef IMGUI_IMPL_HAS_POLYGON_MODE
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
if (bd->GlVersion <= 310 || bd->GlProfileIsCompat)
{
glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]);
glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
}
else
{
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
}
#endif // IMGUI_IMPL_HAS_POLYGON_MODE I believe GL_FRONT and GL_BACK were defined in 1.0 era header and are unlikely to be missing from a custom loader, if it ever does I'm happy to find out and correct. Thanks! |
ImGui_ImplOpenGL3_RenderDrawData()
(in backends/imgui_impl_opengl3.cpp) incorrectly restoresGL_POLYGON_MODE
after rendering. This PR fixes that.Relevant
glGet*
before setting up and rendering:GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);