From d0836aa89a5e72e7cdaa165da6831740f97a053e Mon Sep 17 00:00:00 2001 From: Gereon V <72784429+GereonV@users.noreply.github.com> Date: Fri, 14 Apr 2023 22:49:50 +0200 Subject: [PATCH] Backends: OpenGL3: reset GL_POLYGON_MODE separately for front and back when possible. (#6333) --- backends/imgui_impl_opengl3.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp index 0a01a5f79..b4b4fc0a1 100644 --- a/backends/imgui_impl_opengl3.cpp +++ b/backends/imgui_impl_opengl3.cpp @@ -613,8 +613,24 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data) #endif #ifdef IMGUI_IMPL_HAS_POLYGON_MODE - glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]); +// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons +#if defined(GL_FRONT) && defined(GL_BACK) // possibly Desktop OpenGL 3.0, 3.1 or 3.2+ compatibility profile +#ifdef GL_CONTEXT_PROFILE_MASK // Desktop OpenGL 3.2+ + GLint profile_mask; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile_mask); + if (profile_mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) +#else + if (bd->GlVersion <= 310) #endif + { + glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); + glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]); + } + else +#endif // GL_FRONT & GL_BACK + glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]); +#endif // IMGUI_IMPL_HAS_POLYGON_MODE + glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]); glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); (void)bd; // Not all compilation paths use this