Flix01 / imgui

Dear ImGui Addons Branch = plain unmodified dear imgui plus some extra addon.
https://github.com/Flix01/imgui/wiki/ImGui-Addons-Branch-Home
MIT License
396 stars 34 forks source link

How to use the imguidock addon in visual studio #58

Closed zhouxs1023 closed 3 years ago

zhouxs1023 commented 3 years ago

I want to use imguidock in visual studio.

I used the following code in the main loop:

// Windowed:
ImGui::SetNextWindowSize(ImVec2(500, 500),ImGuiCond_Once);        
if (ImGui::Begin("imguidock window (= lumix engine's dock system)",NULL,ImGuiWindowFlags_NoScrollbar)) {
        ImGui::BeginDockspace();
        static char tmp[128];
        for (int i=0;i<10;i++)  {
                sprintf(tmp,"Dock %d",i);
                if (i==9) ImGui::SetNextDock(ImGuiDockSlot_Bottom);// optional
                if(ImGui::BeginDock(tmp))  {
                    ImGui::Text("Content of dock window %d goes here",i);
                }
            ImGui::EndDock();
        }
        ImGui::EndDockspace();
 }
 ImGui::End();

but I got the following errors:

Severity    Code    Description Project File    Line    Suppression State
Error (active)      namespace "ImGui" has no member "BeginDockspace"    example_win32_directx9  d:\Demo\Flix01-imgui\examples\example_win32_directx9\main.cpp   141 
Error (active)      identifier "sprintf" is undefined   example_win32_directx9  d:\Demo\Flix01-imgui\examples\example_win32_directx9\main.cpp   144 
Error (active)      namespace "ImGui" has no member "SetNextDock"   example_win32_directx9  d:\Demo\Flix01-imgui\examples\example_win32_directx9\main.cpp   145 
Error (active)      identifier "ImGuiDockSlot_Bottom" is undefined  example_win32_directx9  d:\Demo\Flix01-imgui\examples\example_win32_directx9\main.cpp   145 
Error (active)      namespace "ImGui" has no member "BeginDock" example_win32_directx9  d:\Demo\Flix01-imgui\examples\example_win32_directx9\main.cpp   146 
Error (active)      namespace "ImGui" has no member "EndDock"   example_win32_directx9  d:\Demo\Flix01-imgui\examples\example_win32_directx9\main.cpp   149 
Error (active)      namespace "ImGui" has no member "EndDockspace"  example_win32_directx9  d:\Demo\Flix01-imgui\examples\example_win32_directx9\main.cpp   151 
Error   C2039   'BeginDockspace': is not a member of 'ImGui'    example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   141 
Error   C3861   'BeginDockspace': identifier not found  example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   141 
Error   C3861   'sprintf': identifier not found example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   144 
Error   C2039   'SetNextDock': is not a member of 'ImGui'   example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   145 
Error   C2065   'ImGuiDockSlot_Bottom': undeclared identifier   example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   145 
Error   C3861   'SetNextDock': identifier not found example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   145 
Error   C2039   'BeginDock': is not a member of 'ImGui' example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   146 
Error   C3861   'BeginDock': identifier not found   example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   146 
Error   C2039   'EndDock': is not a member of 'ImGui'   example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   149 
Error   C3861   'EndDock': identifier not found example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   149 
Error   C2039   'EndDockspace': is not a member of 'ImGui'  example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   151 
Error   C3861   'EndDockspace': identifier not found    example_win32_directx9  d:\demo\flix01-imgui\examples\example_win32_directx9\main.cpp   151 

What can I do to recognize the addons file? Thanks

Flix01 commented 3 years ago

Well, I'm on Linux and I can't help much.

That should work, because you're simply adding imguidock.h and imguidock.cpp to a "regular" Dear ImGui project (without using any imgui_addon binding).

P.S. I've edited your post a bit, adding some corrections and formatting.

Flix01 commented 3 years ago

Closing this.

zhouxs1023 commented 3 years ago

I had done what you say,Copy imguidock.cpp and imguidock.h to the project, it can be compiled successfully, but exe file cannot run. The error as follows error

There should be no definition of dockcontext, but I don't know how to define it,hope your help!

Flix01 commented 3 years ago

Yes, this is probably caused by this pull request https://github.com/Flix01/imgui/pull/43. But if you read imguidock.h a bit more, you can find this:

// Create, destroy and change dock contexts (*).

// EXAMPLE USAGE:
/* ImGui::DockContext* myDockContext=NULL; // global variable
   // When you init your application:
   myDockContext = ImGui::CreateDockContext();
   ImGui::SetCurrentDockContext(myDockContext);
   // From now on you can use imguidock [calling BeginDockspace()/EndDockspace() and so on].
   // When you destroy your application:
   ImGui::DestroyDockContext(myDockContext);myDockContext=NULL;
*/

// (*)  This is really mandatory only if you're not using an IMGUI_USE_XXX_BINDING, or if you don't know
//      what IMGUI_USE_XXX_BINDING is (because otherwise the code above is already called for you in addons/imguibindings/imguibindings.cpp).

You're not using any imgui_addon binding, so you need that piece of code.

Flix01 commented 3 years ago

Closing this.