From 61a093635c1c26e85be3e4dca8b322533f552bde Mon Sep 17 00:00:00 2001 From: Brenton Bostick Date: Thu, 16 Jul 2026 13:53:51 -0400 Subject: [PATCH] Backends: OpenGL3: fixed updating textures. (#9478, #9477, #9473, #8802) Fixed 0ff4a8a. --- backends/imgui_impl_opengl3.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backends/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp index f1f2bc93c..ff9980035 100644 --- a/backends/imgui_impl_opengl3.cpp +++ b/backends/imgui_impl_opengl3.cpp @@ -670,7 +670,8 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex) // Backup GL_UNPACK state that we modify, restore on exit. GLint last_unpack_row_length = 0; (void)last_unpack_row_length; GLint last_unpack_alignment = 0; (void)last_unpack_alignment; - if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates) + const bool last_unpack_state_save_and_restore = (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates); + if (last_unpack_state_save_and_restore) { #ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &last_unpack_row_length)); @@ -744,7 +745,7 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex) ImGui_ImplOpenGL3_DestroyTexture(tex); // Restore GL_UNPACK state - if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates) + if (last_unpack_state_save_and_restore) { #ifdef GL_UNPACK_ROW_LENGTH GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, last_unpack_row_length));