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

This commit is contained in:
ocornut 2015-04-15 10:14:51 +01:00
parent 17b63d846f
commit f400ea4ec8

View File

@ -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()