Skip to content

Commit

Permalink
Merge pull request #348 from anasrar/main
Browse files Browse the repository at this point in the history
 refactor(glfwbackend): move clear buffer before render loop
  • Loading branch information
gucio321 authored Oct 19, 2024
2 parents c39c7e5 + 066975c commit 25d6b87
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions backend/glfwbackend/glfw_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ GLFWwindow *igCreateGLFWWindow(const char *title, int width, int height,

// Install extra callback
glfwSetWindowRefreshCallback(window, glfw_window_refresh_callback);
glfwMakeContextCurrent(NULL);
return window;
}

Expand All @@ -129,19 +128,20 @@ void glfw_render(GLFWwindow *window, VoidCallback renderLoop) {

glfwSetWindowUserPointer(window, (void *)renderLoop);

int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w,
clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);

// Do ui stuff here
if (renderLoop != NULL) {
renderLoop();
}

// Rendering
igRender();
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w,
clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());

ImGuiIO *io = igGetIO();
Expand Down

0 comments on commit 25d6b87

Please sign in to comment.