Skip to content

Commit

Permalink
Examples: OpenGL3: Trying to make the call to glBindSampler optional …
Browse files Browse the repository at this point in the history
…to make the example code easier to use/share with different context version. (#1806)
  • Loading branch information
ocornut committed May 14, 2018
1 parent 78b28d5 commit 1954462
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/opengl3_example/imgui_impl_glfw_gl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void ImGui_ImplGlfwGL3_RenderDrawData(ImDrawData* draw_data)
glUseProgram(g_ShaderHandle);
glUniform1i(g_AttribLocationTex, 0);
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
glBindSampler(0, 0); // Rely on combined texture/sampler state.
if (glBindSampler) glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.

// Recreate the VAO every time
// (This is to easily allow multiple GL contexts. VAO are not shared among GL contexts, and we don't track creation/deletion of windows so we don't have an obvious key to use to cache them.)
Expand Down Expand Up @@ -169,7 +169,7 @@ void ImGui_ImplGlfwGL3_RenderDrawData(ImDrawData* draw_data)
// Restore modified GL state
glUseProgram(last_program);
glBindTexture(GL_TEXTURE_2D, last_texture);
glBindSampler(0, last_sampler);
if (glBindSampler) glBindSampler(0, last_sampler);
glActiveTexture(last_active_texture);
glBindVertexArray(last_vertex_array);
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
Expand Down
4 changes: 2 additions & 2 deletions examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void ImGui_ImplSdlGL3_RenderDrawData(ImDrawData* draw_data)
glUseProgram(g_ShaderHandle);
glUniform1i(g_AttribLocationTex, 0);
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
glBindSampler(0, 0); // Rely on combined texture/sampler state.
if (glBindSampler) glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.

// Recreate the VAO every time
// (This is to easily allow multiple GL contexts. VAO are not shared among GL contexts, and we don't track creation/deletion of windows so we don't have an obvious key to use to cache them.)
Expand Down Expand Up @@ -167,7 +167,7 @@ void ImGui_ImplSdlGL3_RenderDrawData(ImDrawData* draw_data)
// Restore modified GL state
glUseProgram(last_program);
glBindTexture(GL_TEXTURE_2D, last_texture);
glBindSampler(0, last_sampler);
if (glBindSampler) glBindSampler(0, last_sampler);
glActiveTexture(last_active_texture);
glBindVertexArray(last_vertex_array);
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
Expand Down

0 comments on commit 1954462

Please sign in to comment.