Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the imguidock addon in visual studio #58

Closed
zhouxs1023 opened this issue Aug 21, 2020 · 5 comments
Closed

How to use the imguidock addon in visual studio #58

zhouxs1023 opened this issue Aug 21, 2020 · 5 comments

Comments

@zhouxs1023
Copy link

zhouxs1023 commented Aug 21, 2020

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
Copy link
Owner

Flix01 commented Aug 22, 2020

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

  • For sprintf you should include#include <stdio.h> (also see here). However sprintf is only present in the piece of code you posted: you probably don't need it if you remove the for loop and use hard-coded dock names.

  • For all the other errors, you should #include "addons/imguidock/imguidock.h" and add addons/imguidock/imguidock.cpp to your source files.

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
Copy link
Owner

Flix01 commented Aug 24, 2020

Closing this.

@Flix01 Flix01 closed this as completed Aug 24, 2020
@zhouxs1023
Copy link
Author

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
Copy link
Owner

Flix01 commented Aug 25, 2020

Yes, this is probably caused by this pull request #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 Flix01 reopened this Aug 25, 2020
@Flix01 Flix01 changed the title How to use this addons for visual studio? How to use the imguidock addon in visual studio? Aug 25, 2020
@Flix01 Flix01 changed the title How to use the imguidock addon in visual studio? How to use the imguidock addon in visual studio Aug 25, 2020
@Flix01
Copy link
Owner

Flix01 commented Aug 26, 2020

Closing this.

@Flix01 Flix01 closed this as completed Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants