From f400ea4ec8d07b1d040222d698ad60a496255b1b Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 15 Apr 2015 10:14:51 +0100 Subject: [PATCH] Examples: OpenGL3: backup/restore current program and texture #195 --- examples/opengl3_example/imgui_impl_glfw_gl3.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp index 958854a6..dba7e13a 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp @@ -35,6 +35,9 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawList** const cmd_lists, int return; // 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); glBlendEquation(GL_FUNC_ADD); 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 glBindVertexArray(0); - glUseProgram(0); + glUseProgram(last_program); glDisable(GL_SCISSOR_TEST); - glBindTexture(GL_TEXTURE_2D, 0); + glBindTexture(GL_TEXTURE_2D, last_texture); } static const char* ImGui_ImplGlfwGL3_GetClipboardText()