From dec082ff9781b1f0d9401c9ed20bb6378c158fd9 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 12 Jun 2023 11:44:48 +0200 Subject: [PATCH] Backends: OpenGL3: Fixed support for glBindSampler() backup/restore on ES3. (#6375, #6508) Amend dd9db5e8 + 39f7248d4 --- backends/imgui_impl_opengl3.cpp | 19 +++++++++++-------- docs/CHANGELOG.txt | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/backends/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp index 338ed9e2..00bab36b 100644 --- a/backends/imgui_impl_opengl3.cpp +++ b/backends/imgui_impl_opengl3.cpp @@ -283,7 +283,12 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) io.BackendRendererName = "imgui_impl_opengl3"; // Query for GL version (e.g. 320 for GL 3.2) -#if !defined(IMGUI_IMPL_OPENGL_ES2) +#if defined(IMGUI_IMPL_OPENGL_ES2) + // GLES 2 + bd->GlVersion = 200; + bd->GlProfileIsES2 = true; +#else + // Desktop or GLES 3 GLint major = 0; GLint minor = 0; glGetIntegerv(GL_MAJOR_VERSION, &major); @@ -300,6 +305,10 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) bd->GlProfileIsCompat = (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0; #endif +#if defined(IMGUI_IMPL_OPENGL_ES3) + bd->GlProfileIsES3 = true; +#endif + bd->UseBufferSubData = false; /* // Query vendor to enable glBufferSubData kludge @@ -309,16 +318,10 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) bd->UseBufferSubData = true; #endif */ -#elif defined(IMGUI_IMPL_OPENGL_ES2) - bd->GlVersion = 200; // GLES 2 - bd->GlProfileIsES2 = true; -#elif defined(IMGUI_IMPL_OPENGL_ES3) - bd->GlVersion = 200; // Don't raise version as it is intended as a desktop version check for now. - bd->GlProfileIsES3 = true; #endif #ifdef IMGUI_IMPL_OPENGL_DEBUG - printf("GL_MAJOR_VERSION = %d\nGL_MINOR_VERSION = %d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", major, minor, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG] + printf("GlVersion = %d\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2 = %d, GlProfileIsES3 = %d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", bd->GlVersion, bd->GlProfileIsCompat, bd->GlProfileMask, bd->GlProfileIsES2, bd->GlProfileIsES3, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG] #endif #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 7a5a648c..e5fef676 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -38,6 +38,7 @@ Other changes: - Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either ScrollX or ScrollY flags from being impossible to resize. (#6503) +- Backends: OpenGL3: Fixed support for glBindSampler() backup/restore on ES3. (#6375, #6508) [@jsm174] -----------------------------------------------------------------------