ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.15k stars 10.3k forks source link

How to render a specific Imgui window #5381

Open mintos002 opened 2 years ago

mintos002 commented 2 years ago

Version/Branch of Dear ImGui:

Version: 1.87 Branch:

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glut.cpp + imgui_impl_opengl2.cpp Compiler: C++14 Operating System: Windows 10

My Issue/Question:

I need to have a Main GUI with buttons, the issue is that if I open another openGL window (in my case an Open3D pointcloud viewer), the Main GUI seems to stop rendering even if I close then close the Open3D windw.

Is there any way to sepecifically render a openGL window?

Thanks in advance!

Screenshots/Video

Captura

Standalone, minimal, complete and verifiable example: (see https://github.com/ocornut/imgui/issues/2261)

// Main imgui is started in the main thread and looped with
glutMainLoop();

// If I show any window with Open3D the main GUI stops rendering, this is the open3d part
open3d::visualization::Visualizer vis;
    vis.CreateVisualizerWindow(window_name, width, height);
    if (geometry_ptrs.size() < 1)
        std::cout << "ERROR in ";
    for (int i = 0; i < geometry_ptrs.size(); i++)
    {
        vis.AddGeometry(geometry_ptrs[i]);
    }

    // Run the viewer
    vis.Run();

    // Destroy the viewer
    vis.DestroyVisualizerWindow();
PathogenDavid commented 2 years ago

Thanks for filling out the whole issue template! (Although I'm not sure I would call your example standalone or complete.)

First off, GLUT is utterly ancient. Unless you have a really good reason to use it, you really really shouldn't. (Same goes for OpenGL 2 for that matter. If you're following a tutorial that's recommending either you should probably find a different tutorial.)

I'm assuming your // If I show any window with Open3D the main GUI stops rendering, this is the open3d part code is actually being run in response to a button being pressed in the main window. Judging by the API shape and according to the documentation, vis.Run(); is going to block the thread until the window is closed. Since it doesn't return, your main window isn't going to render simply because the GLUT main loop isn't running anymore.

If that isn't the case (IE: you see your glutDisplayFunc being called in the debugger), then I would guess that GLUT and Open3D are not playing nice together. IE: The OpenGL context might be getting changed.

Is there a reason you aren't using Open3D's support for Dear ImGui?

triplehoon commented 1 year ago

@PathogenDavid How can I find Open3D's support for Dear ImGUI?

It is hard to find open3d support on their repos.