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

Add ImGuizmo and ImGuiPlot to Nuget #247

Open
Pastor111 opened this issue Apr 3, 2021 · 22 comments
Open

Add ImGuizmo and ImGuiPlot to Nuget #247

Pastor111 opened this issue Apr 3, 2021 · 22 comments

Comments

@Pastor111
Copy link

Can you add ImGuizmo and ImGuiPlot to the Nuget version or show a tutorial of how to add them?

@Kayzaks
Copy link

Kayzaks commented Apr 9, 2021

For now, you can simply:

  1. clone TillAlex's Branch of ImGui.NET-nativebuild and build that. This will give you all 4 DLL's (cimgui, cimplot, cimnodes, cimgizmos) for your project.

  2. Reference the ImPlot.NET/ImGuizmo.NET projects in your project and be sure to put the cimgui.dll/... where your exectuable will find them.

  3. An Example for ImPlot.NET:

using ImGuiNET;
using ImPlotNET;
using System.Runtime.InteropServices;

// More code

IntPtr context = ImGui.CreateContext();
IntPtr implotContext = ImPlot.CreateContext(); 
ImPlot.SetCurrentContext(implotContext); 
ImPlot.SetImGuiContext(context);

// Other code

if (ImPlot.BeginPlot("Some Plot")) 
{
        Span<double> xVals = new Span<double>(new double[]{0.0, 1.0, 2.0});
        Span<double> yVals = new Span<double>(new double[]{1.0, 0.0, 1.0});
        
        ImPlot.PlotLine("Test", ref MemoryMarshal.GetReference(xVals), ref MemoryMarshal.GetReference(yVals), xVals.Length);

    ImPlot.EndPlot();
}

// More code

ImPlot.DestroyContext();
ImGui.DestroyContext();

NOTE: If you are getting access violations, be sure to use all 4 DLL's that were generated by the nativebuild. Otherwise you will have mismatching ImGui versions.

@Pastor111
Copy link
Author

Oh thank wil this all work with Other render apis like OpenTK?

@Pastor111
Copy link
Author

Oh and also i cant seem to get the build correctly for some reason

@Kayzaks
Copy link

Kayzaks commented Apr 10, 2021

Oh thank wil this all work with Other render apis like OpenTK?

I sadly don't know.

Oh and also i cant seem to get the build correctly for some reason

Did you init/update all submodules first? What type of error/problem are you running into?

This is what I did to build it:

git submodule update --init --recursive
.\build-native.cmd

works fine on my machine™.

@Pastor111
Copy link
Author

It only compiles for the imgui folder the implot, imguizmo and imnodes dont compile apparently

@Kayzaks
Copy link

Kayzaks commented Apr 10, 2021

You'll need to provide more information. What you did, Compiler Output, etc.

@Pastor111
Copy link
Author

When i git clone the repository it only comes with the cimgui folder and in the .gitmodules it does not include the other stuff just the cimgui and i also tried downloading the zip it comes with everything but when i try to compile it with cmake it says that there is an error with the cmakeList.txt

@sonoro1234
Copy link

sonoro1234 commented Apr 11, 2021

when i try to compile it with cmake it says that there is an error with the cmakeList.txt

@Pastor111
When @Kayzaks is asking you for more information you cant expect that with the info provided above you get your problems solved!!

Your guide should be the first post from @Kayzaks where is telling you to clone https://github.com/TillAlex/ImGui.NET-nativebuild/tree/additional_libraries. You should clone this one and not any other (as it seems to be happening).

If you download the zip the submodules will be missing.

You should do the clone with git clone --recursive https://github.com/TillAlex/ImGui.NET-nativebuild

where recursive makes sure that all submodules are cloned also (cimgui, cimplot, etc)

Then you should do checkout to additional_libraries branch (this is done in you git client)

Then you will have to build with cmake.

If something fails dont forget to provide the informations of all the commands used in the process and the output messages.


Also: this message #218 (comment) is telling you where to find compiled binaries.

@Pastor111
Copy link
Author

I think i got it correct now but when i try to link it cimguizmo and the other libraries it says that the reference is unvalid or unsopported

@Kayzaks
Copy link

Kayzaks commented Apr 12, 2021

I think i got it correct now but when i try to link it cimguizmo and the other libraries it says that the reference is unvalid or unsopported

Cool. Please re-read and re-follow the steps in our previous comments, it should be working. If not I would like to emphasize the following comments:

NOTE: If you are getting access violations, be sure to use all 4 DLL's that were generated by the nativebuild. Otherwise you will have mismatching ImGui versions.

and

You'll need to provide more information. What you did, Compiler Output, etc.

and

[...] you cant expect that with the info provided above you get your problems solved!!

@shlifedev
Copy link

@Pastor111
Copy link
Author

Thanks, i will see if it works in a moment

@Pastor111
Copy link
Author

I have a question when i add the 4 dlls in my project should i unistall the Imgui.NET package or should i keep it?

@shlifedev
Copy link

shlifedev commented Jul 2, 2021

if you want use imgui,implot then,

and add your .exe build folder cimgui.dll, cimplot.dll

@parzivail
Copy link

parzivail commented May 1, 2022

Is there any update on making these available through NuGet? I'm aware of the manual compilation option but NuGet is much more convenient

@1181719061
Copy link

按照上面[sonoro1234] (https://github.com/sonoro1234)[native](https://github.com/TillAlex/ImGui.NET-nativebuild/tree/additional_libraries) 编译后,调用cimplot.dll,并按照时[Kayzaks]方法使用时,总是报“Attempted to read or write protected memory. ”错误。然后他这个版本匹配很重要,ImGui.Net使用的版本和cimgui的版本要对应上,像TillAlax里是cimgui 1.82+ cimplot 0.9,他提供的deps里或者编译完成的dll版本,自然而然是基于1.82的,而我当时使用的ImGui.Net是1.87版本,我直接拷贝了TiilAlax的编译dll就发生了这个错误,而我后来的解决方法就是,直接在Tillax的0.9 cimplot基础上,拷贝1.87的cimgui覆盖并重新编译,就能正常使用cimplot.dll了。 其实最好的方法是重写各个版本对应的CodeGenerator里的definitions和cimgui.cpp\h包装,一一对应。但是他们这个json当时写的时候不会都是全手写,一个个对函数的吧?没有直接更新的工具吗?

@aybe
Copy link

aybe commented Oct 25, 2022

@sonoro1234

In order to get the ImPlot binaries for using ImPlot.NET, I've been trying to follow your instructions but without success thus far...

Cloning the repository works:

C:\Users\aybe\source\repos>git clone --recursive https://github.com/TillAlex/ImGui.NET-nativebuild
Cloning into 'ImGui.NET-nativebuild'...
remote: Enumerating objects: 90, done.
remote: Counting objects: 100% (49/49), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 90 (delta 33), reused 28 (delta 28), pack-reused 41
Receiving objects: 100% (90/90), 22.67 KiB | 967.00 KiB/s, done.
Resolving deltas: 100% (39/39), done.
Submodule 'cimgui' (https://github.com/extrawurst/cimgui) registered for path 'cimgui'
Cloning into 'C:/Users/aybe/source/repos/ImGui.NET-nativebuild/cimgui'...
remote: Enumerating objects: 4058, done.
remote: Counting objects: 100% (789/789), done.
remote: Compressing objects: 100% (306/306), done.
remote: Total 4058 (delta 580), reused 635 (delta 482), pack-reused 3269
Receiving objects: 100% (4058/4058), 9.97 MiB | 16.18 MiB/s, done.
Resolving deltas: 100% (2955/2955), done.
Submodule path 'cimgui': checked out '9cb4b4f63cd41508db8b43ad10f131013669ed7d'
Submodule 'imgui' (https://github.com/ocornut/imgui.git) registered for path 'cimgui/imgui'
Cloning into 'C:/Users/aybe/source/repos/ImGui.NET-nativebuild/cimgui/imgui'...
remote: Enumerating objects: 45919, done.
remote: Counting objects: 100% (127/127), done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 45919 (delta 82), reused 90 (delta 62), pack-reused 45792
Receiving objects: 100% (45919/45919), 87.56 MiB | 21.88 MiB/s, done.
Resolving deltas: 100% (34929/34929), done.
Submodule path 'cimgui/imgui': checked out '682249396f02b8c21e5ff333ab4a1969c89387ad'

Switching to the branch works:

C:\Users\aybe\source\repos\ImGui.NET-nativebuild>git switch additional_libraries
Switched to a new branch 'additional_libraries'
M       cimgui
branch 'additional_libraries' set up to track 'origin/additional_libraries'.

Building the stuff does not work, unfortunately:

C:\Users\aybe\source\repos\ImGui.NET-nativebuild>build-native.cmd
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.33.31630.0
-- The CXX compiler identification is MSVC 19.33.31630.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:9 (add_library):
  Cannot find source file:

    cimgui/imgui/imgui_tables.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc


CMake Error at CMakeLists.txt:9 (add_library):
  No SOURCES given to target: cimgui


CMake Error at CMakeLists.txt:21 (add_library):
  No SOURCES given to target: cimplot


CMake Error at CMakeLists.txt:36 (add_library):
  No SOURCES given to target: cimnodes


CMake Error at CMakeLists.txt:49 (add_library):
  No SOURCES given to target: cimguizmo


CMake Generate step failed.  Build files cannot be regenerated correctly.
Calling cmake --build . --config Debug
CMake is re-running because C:/Users/aybe/source/repos/ImGui.NET-nativebuild/build/x64/CMakeFiles/generate.stamp dependency file is missing.
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- Configuring done
CMake Error at CMakeLists.txt:9 (add_library):
  Cannot find source file:

    cimgui/imgui/imgui_tables.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc


CMake Error at CMakeLists.txt:9 (add_library):
  No SOURCES given to target: cimgui


CMake Error at CMakeLists.txt:21 (add_library):
  No SOURCES given to target: cimplot


CMake Error at CMakeLists.txt:36 (add_library):
  No SOURCES given to target: cimnodes


CMake Error at CMakeLists.txt:49 (add_library):
  No SOURCES given to target: cimguizmo


CMake Generate step failed.  Build files cannot be regenerated correctly.

By looking at the folder, cimgui/imgui/imgui_tables.cpp does not exist.

So, next, I've followed the instructions in repository README to initialize submodules:

C:\Users\aybe\source\repos\ImGui.NET-nativebuild>git submodule update --init
Submodule 'cimguizmo' (https://github.com/cimgui/cimguizmo.git) registered for path 'cimguizmo'
Submodule 'cimnodes' (https://github.com/cimgui/cimnodes.git) registered for path 'cimnodes'
Submodule 'cimplot' (https://github.com/cimgui/cimplot.git) registered for path 'cimplot'
Cloning into 'C:/Users/aybe/source/repos/ImGui.NET-nativebuild/cimguizmo'...
Cloning into 'C:/Users/aybe/source/repos/ImGui.NET-nativebuild/cimnodes'...
Cloning into 'C:/Users/aybe/source/repos/ImGui.NET-nativebuild/cimplot'...
Submodule path 'cimgui': checked out 'ccdae842e40f35ebf40167918175deb9af8c2a16'
Submodule path 'cimguizmo': checked out 'fcf76e389ef7e88bcf05340b14d031e1111caf32'
Submodule path 'cimnodes': checked out 'e7d42e5e8bcd8b7307a8faf6961d64296d3c9408'
Submodule path 'cimplot': checked out '43e46831c58c85a16bff1f460121baae2bf7f96c'
C:\Users\aybe\source\repos\ImGui.NET-nativebuild>git submodule update --remote
Submodule path 'cimgui': checked out '9ce2c32dada1e1fcb90f2c9bab2568895db719f5'
Submodule path 'cimguizmo': checked out '993ac0e192800c16c4ad60b249e8a4bb446047ed'
Submodule path 'cimnodes': checked out 'bf28b4d00878a9d81a9b9dc8c2d2a8412482f9de'
Submodule path 'cimplot': checked out 'ff39c9236c4d37bbccacbc7aa92a5af670f53c46'

These do work but cimgui/imgui/imgui_tables.cpp is still nowhere to be found and thus, build-native.cmd fails again.

Following your next step suggesting to look at #218 (comment), I'm greeted with the following:

Artifacts older than 1 month are automatically deleted.

So yeah, the binaries are long gone since it's been a while they've been published...

Any ideas to get hold of ImPlot binaries are more than welcome.

Thanks for your time!

@sonoro1234
Copy link

sonoro1234 commented Oct 25, 2022

When looking at https://github.com/TillAlex/ImGui.NET-nativebuild on the branch additional_libraries with the web interface of github, it is possible to see that imbui_tables.cpp is present, so that should not happen.

You could try using checkout instead of switch for accesing the branch (and then use git submodule update --init --recursive) before calling cmake

But if you succed, you will be on tag 1.82 of imgui (2 years ago). It has not been updated since then.
Your best bet would be to have it updated by @mellinoe which seem to be done in 2a842d8

@aybe
Copy link

aybe commented Oct 26, 2022

Yes, TillAlex fork is really outdated by now...

Unless I'm mistaken, yesterday's commit indeed does include changes to the managed side of implot but unfortunately still no cimplot.dll.

I've just forked cimplot in order to build it by myself and see how it goes🤞

@LucoseGlucose
Copy link

Can you please just make a nuget package for them? I am really new to git and would definitely mess up in attempting to build and link everything myself. Having a nuget package for the other libraries would be a massive help for me and others.

@AdamJamesNaylor
Copy link

Seconding the request for this. Installing the C++ tooling required to get the cimplot library built and referencing everything correctly is sufficiently complicated compared to pulling it down from Nuget.

@cmdexecutor
Copy link

Would be really good to have it. Also, as Silk.NET.OpenGL.Extensions.ImGui already uses Imgui.NET, replacing the libraries makes a mess

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

10 participants