Преглед изворни кода

Examples: OpenGL3: backup/restore current program and texture #195

ocornut пре 10 година
родитељ
комит
f400ea4ec8
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      examples/opengl3_example/imgui_impl_glfw_gl3.cpp

+ 5 - 2
examples/opengl3_example/imgui_impl_glfw_gl3.cpp

@@ -35,6 +35,9 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawList** const cmd_lists, int
         return;
         return;
 
 
     // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
     // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
+    GLint last_program, last_texture;
+    glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
+    glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
     glEnable(GL_BLEND);
     glEnable(GL_BLEND);
     glBlendEquation(GL_FUNC_ADD);
     glBlendEquation(GL_FUNC_ADD);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -108,9 +111,9 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawList** const cmd_lists, int
 
 
     // Restore modified state
     // Restore modified state
     glBindVertexArray(0);
     glBindVertexArray(0);
-    glUseProgram(0);
+    glUseProgram(last_program);
     glDisable(GL_SCISSOR_TEST);
     glDisable(GL_SCISSOR_TEST);
-    glBindTexture(GL_TEXTURE_2D, 0);
+    glBindTexture(GL_TEXTURE_2D, last_texture);
 }
 }
 
 
 static const char* ImGui_ImplGlfwGL3_GetClipboardText()
 static const char* ImGui_ImplGlfwGL3_GetClipboardText()