ImGui是一个基于IMGUI的GUI库,它的渲染是通过每一帧的绘制来实现的。在使用ImGui时,你需要在你的主循环中包含ImGui的渲染函数,例如:

while (!glfwWindowShouldClose(window))
{
    glfwPollEvents();

    ImGui_ImplOpenGL3_NewFrame();
    ImGui_ImplGlfw_NewFrame();
    ImGui::NewFrame();

    // 在这里添加你的ImGui代码

    ImGui::Render();
    int display_w, display_h;
    glfwGetFramebufferSize(window, &display_w, &display_h);
    glViewport(0, 0, display_w, display_h);
    glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
    glClear(GL_COLOR_BUFFER_BIT);
    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

    glfwSwapBuffers(window);
}

在这个循环中,ImGui的渲染代码被包含在ImGui::NewFrame()和ImGui::Render()之间。在每一帧中,ImGui会渲染你的UI,并将它们绘制到屏幕上。

如果你的ImGui一直在渲染,可能是因为你的ImGui代码没有正确地放置在主循环中。或者,你的代码可能存在某种循环或递归结构,导致ImGui一直在渲染。检查你的代码并将ImGui的渲染代码正确地放置在主循环中应该可以解决这个问题。

imgui怎么一直渲染

原文地址: https://www.cveoy.top/t/topic/5JD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录