GithubHelp home page GithubHelp logo

Comments (54)

dcnieho avatar dcnieho commented on May 22, 2024 1

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

To add, I guess you do not have to add classes like GlfwRenderer in pyimgui, but it would be nice if you could wrap the supported backend, so that you can write code very similar to C++, where i in python could call the equivalent of:

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

That also raises the question if there should perhaps be a bit more hierarchy in the lib, e.g., should imgui_bundle.imgui_internal be imgui_bundle.imgui.internal? Somehow cleaner to me, to have constituents of imgui as a submodule of imgui. Here it would then be imgui_bundle.imgui.implGlfw (or impl_glfw). Its ok of course to only support a subset of backends, but would be very nice to have. Again, final goal here is to be able to use your imgui without hello_imgui, for those wanting to make a switch and more advanced use cases as i am running into.

I can give you access to the now private repo of my program by the way, should you find that helpful.

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Thanks for the detailed comments! This is the kind of feedback I appreciate.

For the moment, I am busy solving a weird windows issue (see last comments in #7).

That said, this naming is not ideal I think and we have some freedom here since in C++ you’d simply directly use ImGuiTableFlags_ScrollX. imgui.TableFlags.scroll_x would be nice, or imgui.table_flags.scroll_x to be more pythonic and have consistent change from camel to snake case. So that’s no double imgui, and no trailing underscore.

Hum, I need to ponder whether it is feasible and/or desirable. In the meantime, I added a warning in the readme, that says
Warning : The API might evolve a bit during the month of November 2022. I'll remove this warning once it is more stable.

Relatedly, autocomplete works very nicely

Thanks, that was definitely one of the main goals, as well as to keep the header file documentation intact (can you see it?)

but is a little confusing as you have each enum twice (e.g. imgui.ImGuiTableFlags and imgui.ImGuiTableFlags_. The former is just an int if I understand correctly. Shall we just have the latter (ideally renamed like above)?

Hum, I think not, since users might want to do flags manipulations like:

flags: ImGuiTableFlags = ImGuiTableFlags_.flag_a | ImGuiTableFlags_.flag_b

I have no equivalent of from imgui.integrations.glfw import GlfwRenderer in imgui_bundle. I use glfw callbacks for my app, but can’t access those.

Hum, this one is not easy. For the moment, glfw is statically linked into the library.
However, I am studying a possibility which would be:

  1. Link glfw dynamically (see this commit )
  2. Use the standard glfw bindings provided by https://github.com/FlorianRhiem/pyGLFW, but somehow force them to use the glfw dynamic library provided by imgui_bundle (this is a tricky point)

Are you planning to also bundle your immvision library? I’m not exactly sure on what it does, but the description is interesting!

Definitely, and I think it will be awesome. I will keep you posted once it is ready.

but it would be nice if you could wrap the supported backend, so that you can write code very similar to C++, where i in python could call the equivalent of ImGui_ImplOpenGL3_NewFrame() and its companions?

Hum, I had not thought of that. Would you be willing to do some tests on this on your side?
For the tests, you can just add the bindings manually into pybind_imgui.cpp at this location:

void py_init_module_imgui_main(py::module& m)
{
// Add your manual bindings there, before the autogenerated code

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

v0.6.6 is out.
Wheels will be available in a few hours. However you can compile it from source right now (on the "main" branch).

Support for callbacks was added
Immvision was added (although it still requires polishing). It is not enabled by default. To have it, you need to pip install from source, after having installed and configured conan

(see links in release notes)

Please tell me if it works.

Have a nice day!

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

Hi Pascal,

I just looked through the diffs a bit, super cool! I really look forward to trying this out, hopefully still today.

A debate: should imgui_backends be imgui.backends? One the one side its part of dear imgui proper, on the other side its a bit like an addon. I'm voting imgui.backends for that first reason.

Feedback soon!

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

I see the enums still have an ImGui prefix. Did you run into some issue changing that?

edit removed the pip install -v . error, worked fine now...

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

However, both pip install -v . and building the visual studio project generated with CMake fail because SDL cannot be found. Errors like C:\Users\huml-dkn\Desktop\imgui_bundle\external\hello_imgui\src\hello_imgui\..\hello_imgui/hello_imgui.h(70): fatal error C1083: Cannot open include file: 'SDL_main.h': No such file or directory

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Did you git submodule update —init?

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Humm.. Once again, I cannot reproduce the issue here.
It does work on my windows virtual machine with msvc.

I messaged you by phone, tell me if you have a few minutes

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

k

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

hmm, with clean clone and new venv it all builds just fine. Maybe some stale cache was left after i pulled the latest version?

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

Should the all in __init__.py be more something like

__all__ = [
"imgui",
"hello_imgui",
"implot",
"imgui_color_text_edit",
"imgui_node_editor",
"imgui_knobs",
"im_file_dialog",
"imspinner",
"imgui_md",
"immvision",
"imgui_backends",
"icons_fontawesome",
"run_anon_block",
"implot_create_global_context",
"ImVec2",
"ImVec4",
"ImColor",
"FLT_MIN",
"FLT_MAX",
"__version__",
]

?
seems a lot is missing. But no idea if that matters.

Further things i ran into (some repeats):

  1. The flag imgui_internal.ImGuiSelectableFlagsPrivate_.im_gui_selectable_flags_select_on_click is a bit over the top, some conversion error? More generally, flag naming is still long (imgui.ImGuiTableFlags_.scroll_x -> imgui.table_flags_.scroll_x)
  2. This should work, but doesn’t:
    from imgui_bundle import imgui as imgui
    imgui.create_context()
    imgui.get_io().ini_filename = str(utils.get_data_path() / "imgui.ini")
    # raises: AttributeError: can't set attribute
    
  3. imgui has a bunch of structs that have explicit or implicit zero argument constructors. Directly wrapping these makes them less convenient to use than is possible in Python (and also c++20 for that matter). E.g. with pyimgui is can do config = imgui.ImFontConfig(merge_mode=True, oversample_h=3, oversample_v=3), whereas now i need to spread this out over four different statements. Would it be possible to wrap these differently (perhaps opt-in), taking advantage of Python's named variable arguments?
  4. Some member functions are missing from ImFontAtlas. Specifically, the code i am porting uses GetTexDataAsRGBA32(), but GetTexDataAsAlpha8(), IsBuilt() and SetTexID() are also missing.
  5. imgui.ImWchar is missing. It is defined in imgui_bundle\imgui\__init__.pyi, but trying to use it in my code nets me AttributeError: module 'imgui_bundle._imgui_bundle.imgui' has no attribute 'ImWchar'
  6. ImFontAtlas.add_font_from_file_ttf() has the wrong signature. The glyph_ranges argument should take a list of ints (ImWchar actually, but see previous item), but only takes a single int. So passing, for instance, [0xf0000, 0xf2000, 0] yields:
    add_font_from_file_ttf(): incompatible function arguments. The following argument types are supported:
       1. (self: imgui_bundle._imgui_bundle.imgui.ImFontAtlas, filename: str, size_pixels: float, font_cfg: imgui_bundle._imgui_bundle.imgui.ImFontConfig = None, glyph_ranges: int = None) -> ImFont
    

6 in particular is a blocking error for me, so i had to stop further porting. I have just committed step 2 (and hey, got a bunch further!) in my private repo that you have access to, so have a look what i did.

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

In imgui_example_glfw_opengl3.py, should imgui.render_platform_windows_default(glfw.make_context_current(backup_current_context)) be

imgui.render_platform_windows_default()
glfw.make_context_current(backup_current_context)

?

thats what imgui example code does

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

In imgui_example_glfw_opengl3.py, should imgui.render_platform_windows_default(glfw.make_context_current(backup_current_context)) be

imgui.render_platform_windows_default()
glfw.make_context_current(backup_current_context)

?

thats what imgui example code does

Yes, I just corrected it; but this commit is on the dev branch

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Should the all in init.py be more something like...

Done in dev branch. all is here to make mypy happy.

  1. The flag imgui_internal.ImGuiSelectableFlagsPrivate_.im_gui_selectable_flags_select_on_click is a bit over the top, some conversion error? More generally, flag naming is still long (imgui.ImGuiTableFlags_.scroll_x -> imgui.table_flags_.scroll_x)

Automatic renaming requires more effort than I originally thought, one has to take care and differentiate variable name, type names, function names, class and enum names when renaming, since they have all different naming conventions...

  1. This should work, but doesn’t: ... imgui.get_io().ini_filename = ...

Well, an automatic generation for `const char * ImGuiIO::IniFilename" is hopeless, since it provides absolutely no storage.
I had to do a manual patch: 6ef5df6

  1. imgui has a bunch of structs that have explicit or implicit zero argument constructors. Directly wrapping these makes them less convenient to use than is possible in Python (and also c++20 for that matter). E.g. with pyimgui is can do config = imgui.ImFontConfig(merge_mode=True, oversample_h=3, oversample_v=3), whereas now i need to spread this out over four different statements. Would it be possible to wrap these differently (perhaps opt-in), taking advantage of Python's named variable arguments?

I did not study this yet, although I am also interested in it.

  1. Some member functions are missing from ImFontAtlas. Specifically, the code i am porting uses GetTexDataAsRGBA32(), but GetTexDataAsAlpha8(),
    IMGUI_API void              GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);  // 1 byte per-pixel
    IMGUI_API void              GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);  

Well, well, well. Those signatures with naked pointers and double pointers are hopeless for an autogenerated binding!
If needed, a manual binding will be required. But what should the signature of the python function be? Should it return a numpy ndarray? If so, what shape?

I wrote a draft commit on the dev branch that adds font_atlas_get_tex_data_as_rgba32_experimental as a global function.

Please try it. I have no client code to test it against on my side. If it works, can you please also add a signature for the Alpha and post it as a PR?

IsBuilt() and SetTexID() are also missing.

   bool                        IsBuilt() const             { return Fonts.Size > 0 && TexReady; } // Bit ambiguous: used to detect when        
   void                        SetTexID(ImTextureID id)    { TexID = id; }

Well, those functions are not marked as part of the ImGui API (they are missing the IMGUI_API marker). So, a manual binding will be required.

imgui.ImWchar is missing. It is defined in imgui_bundle\imgui_init_.pyi, but trying to use it in my code nets me AttributeError: module 'imgui_bundle._imgui_bundle.imgui' has no attribute 'ImWchar'
ImFontAtlas.add_font_from_file_ttf() has the wrong signature. The glyph_ranges argument should take a list of ints (ImWchar actually, but see previous item), but only takes a single int. So passing, for instance, [0xf0000, 0xf2000, 0] yields incompatible function arguments.

I suppose you do not really need ImWchar, but you need to be able to specify glyph ranges when calling add_font_from_file_ttf.

I made a draft commit for this in the dev branch. Can you please test it on your side (and may post a PR where you remove the experimental suffix if all goes well).

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

On small question: what did you mean when you wrote

I decided to port a project from pyimgui to imgui_bundle as I would like to post it to pypi and I can’t do that with direct dependencies (like pyimgui version 2.0)

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Final note for today. If you add this

     // </litgen_pydef> // Autogenerated code end
    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  AUTOGENERATED CODE END !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    pyClassImFontAtlas.def("add_font_from_file_ttf_experimental", fontAtlas_AddFontFromFileTTF);

at the end of pybind_imgui.cpp, then you get an additional method for ImFontAtlas in python.

And if all goes well it might someday be a manual replacement of the autogenerated one.

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

On small question: what did you mean when you wrote

I decided to port a project from pyimgui to imgui_bundle as I would like to post it to pypi and I can’t do that with direct dependencies (like pyimgui version 2.0)

PyPI doesn't accept my current dependencies:
HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/ Invalid value for requires_dist. Error: Can't have direct dependency: 'PyOpenGL-accelerate @ git+https://github.com/mcfletch/pyopengl.git@227f9c66976d9f5dadf62b9a97 e6beaec84831ca#subdirectory=accelerate'
And same would happen for pyimgui as i want to use the 2.0 dev branch, which isn't a package on PyPI.

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

My port is now available publicly at https://github.com/dcnieho/glassesValidator/tree/imgui_bundle

Nice 🚀

Thanks for all the work you did with my comments! I'll have a good look at them in the next few days.

I was happy to help. I look forward to reading your feedback


Some other elements and questions:

  • About ImGuiBundle name: this is a name I selected without too much thinking of it. However, I fear it that it does not sound nice; and may be I should find another one.
    I though of names like "livegui", "imlive", "imlife", "immapp" (for immediate app), or the more controversial "immgui" (where the double m stands for immediate, but would remind of my module immvision). My current preference goes for immapp. What do you think?

(If I do rename the project, I will not remove the existing packages on pypi if you need them, of course, I will simply add a new one and mention the renaming in the readme)

  • immvision is available, as well as a first version of the functions composition I showed. Beware, the function composition API is highly experimental and may be moved into a different repo later (it is in the demo folder).
    I did a quick demo here: https://youtu.be/TLo0vNm0XF8 (sorry for the bad sound)

  • I'm currently working on generating named constructors at the moment, but it goes quite deep in the generator architecture, so it takes some time.

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024
  • About ImGuiBundle name: this is a name I selected without too much thinking of it. However, I fear it that it does not sound nice; and may be I should find another one.
    I though of names like "livegui", "imlive", "imlife", "immapp" (for immediate app), or the more controversial "immgui" (where the double m stands for immediate, but would remind of my module immvision). My current preference goes for immapp. What do you think?

(If I do rename the project, I will not remove the existing packages on pypi if you need them, of course, I will simply add a new one and mention the renaming in the readme)

I think the current name is best. It is clear and it contains imgui, which is the key part. If i see the name, i think "ah, imgui, and more". Isn't that just what you want? My vote is don't change.

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024
  • immvision is available, as well as a first version of the functions composition I showed. Beware, the function composition API is highly experimental and may be moved into a different repo later (it is in the demo folder).
    I did a quick demo here: https://youtu.be/TLo0vNm0XF8 (sorry for the bad sound)

This is so very cool!

  • I'm currently working on generating named constructors at the moment, but it goes quite deep in the generator architecture, so it takes some time.

Thank you, that will be very nice to have.

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

imgui has a bunch of structs that have explicit or implicit zero argument constructors. Directly wrapping these makes them less convenient to use than is possible in Python (and also c++20 for that matter). E.g. with pyimgui is can do config = imgui.ImFontConfig(merge_mode=True, oversample_h=3, oversample_v=3), whereas now i need to spread this out over four different statements. Would it be possible to wrap these differently (perhaps opt-in), taking advantage of Python's named variable arguments?

I will add named constructors when there is no user defined constructor.

However, when there is one such as for ImFontConfig, it is much too dangerous to provide a named constructor:

For example, let's look and ImFontConfig default constructor:

ImFontConfig::ImFontConfig()
{
    memset(this, 0, sizeof(*this));
    FontDataOwnedByAtlas = true;
    OversampleH = 3; // FIXME: 2 may be a better default?
    OversampleV = 1;
    GlyphMaxAdvanceX = FLT_MAX;
    RasterizerMultiply = 1.0f;
    EllipsisChar = (ImWchar)-1;
}

==> If we create a named constructor that use default value for all params types, we end-up overwriting the carefully selected default values. I was bitten hard by this, here and also in the node editor.
Note: the result would be the same if C++20 allowed to used designated designated initializers in the presence of a user defined ctor: we would end-up destroying the initial values.

I know I could may be investigate params being Optional[...], but I decided not to go into it. The generation is already complex and does enough on this side IMHO.

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

The flag imgui_internal.ImGuiSelectableFlagsPrivate_.im_gui_selectable_flags_select_on_click is a bit over the top, some conversion error?

Hum, this is due to a trick in imgui code: ImGuiSelectableFlags_SelectOnClick is not a member of enum ImGuiSelectableFlags_ it is a member of a kind of "extension" defined in imgui_internal.h which defines another enum, but uses the same names prefix (this is legal in C++, since enum value are ints).
This is too much of a hack, I will not be able to adapt the generator to this.

imgui.h says:

// Flags for ImGui::Selectable()
enum ImGuiSelectableFlags_
{
    ImGuiSelectableFlags_None               = 0,
    ImGuiSelectableFlags_DontClosePopups    = 1 << 0,   // Clicking this don't close parent popup window
    ImGuiSelectableFlags_SpanAllColumns     = 1 << 1,   // Selectable frame can span all columns (text will still fit in current column)
    ImGuiSelectableFlags_AllowDoubleClick   = 1 << 2,   // Generate press events on double clicks too
    ImGuiSelectableFlags_Disabled           = 1 << 3,   // Cannot be selected, display grayed out text
    ImGuiSelectableFlags_AllowItemOverlap   = 1 << 4    // (WIP) Hit testing to allow subsequent widgets to overlap this one
};

and imgui_internal says:

// Extend ImGuiSelectableFlags_
enum ImGuiSelectableFlagsPrivate_
{
    // NB: need to be in sync with last value of ImGuiSelectableFlags_
    ImGuiSelectableFlags_NoHoldingActiveID      = 1 << 20,
    ImGuiSelectableFlags_SelectOnNav            = 1 << 21,  // (WIP) Auto-select when moved into. This is not exposed in public API as to handle multi-select and modifiers we will need user to explicitly control focus scope. May be replaced with a BeginSelection() API.
    ImGuiSelectableFlags_SelectOnClick          = 1 << 22,  // Override button behavior to react on Click (default is Click+Release)
    ImGuiSelectableFlags_SelectOnRelease        = 1 << 23,  // Override button behavior to react on Release (default is Click+Release)
    ImGuiSelectableFlags_SpanAvailWidth         = 1 << 24,  // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
    ImGuiSelectableFlags_DrawHoveredWhenHeld    = 1 << 25,  // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
    ImGuiSelectableFlags_SetNavIdOnHover        = 1 << 26,  // Set Nav/Focus ID on mouse hover (used by MenuItem)
    ImGuiSelectableFlags_NoPadWithHalfSpacing   = 1 << 27   // Disable padding each side with ItemSpacing * 0.5f
};

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

More generally, flag naming is still long (imgui.ImGuiTableFlags_.scroll_x -> imgui.table_flags_.scroll_x)

This is solved with:

  • 19ca013: remove ImGui prefix from classes and enums => lots of API changes
  • f921057: ImPlot bindings: remove prefix ImPlot from classes and enums

This should work, but doesn’t:
imgui.get_io().ini_filename = str(utils.get_data_path() / "imgui.ini")
raises: AttributeError: can't set attribute

Solved inn 6ef5df6 : added imgui.set_io_ini_filename() & imgui.set_io_log_filename()

imgui has a bunch of structs that have explicit or implicit zero argument constructors.
Directly wrapping these makes them less convenient to use than is possible in Python (and also c++20 for that matter).
E.g. with pyimgui is can do config = imgui.ImFontConfig(merge_mode=True, oversample_h=3, oversample_v=3),
whereas now i need to spread this out over four different statements.
Would it be possible to wrap these differently (perhaps opt-in),
taking advantage of Python's named variable arguments?

In f6ae207, I added named constructors when there is no user defined constructor. This adds lots of named constructors.

However, when there is a user defined constructor such as for ImFontConfig, it is much too dangerous to provide a named constructor.

For example, let's look and ImFontConfig default constructor:

ImFontConfig::ImFontConfig()
{
    memset(this, 0, sizeof(*this));
    FontDataOwnedByAtlas = true;
    OversampleH = 3; // FIXME: 2 may be a better default?
    OversampleV = 1;
    GlyphMaxAdvanceX = FLT_MAX;
    RasterizerMultiply = 1.0f;
    EllipsisChar = (ImWchar)-1;
}

==> If we create a named constructor that use default value for all params types, we end-up overwriting the carefully
selected default values.
Note: the result would be the same if C++20 allowed to used designated designated initializers in the presence
of a user defined ctor: we would end-up destroying the initial values.

Some member functions are missing from ImFontAtlas. Specifically, the code i am porting uses GetTexDataAsRGBA32(),
but GetTexDataAsAlpha8(), IsBuilt() and SetTexID() are also missing.
imgui.ImWchar is missing. It is defined in imgui_bundle\imgui_init_.pyi, but trying to use it in my code nets me
AttributeError: module 'imgui_bundle._imgui_bundle.imgui' has no attribute 'ImWchar'
ImFontAtlas.add_font_from_file_ttf() has the wrong signature.
The glyph_ranges argument should take a list of ints (ImWchar actually, but see previous item),
but only takes a single int.
IsBuilt() and SetTexID() are also missing.

From these remarks I suppose you want to be able to load custom font, but you actually don't care about IsBuilt,
SetTexID, GetTexDataAsAlpha8 etc.

Support for loading custom fonts was added: see fa91994 and 23871b1

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Hi,

I am fighting with the CI at the time (wheels build fail in the CI). So, to test the version you will have to checkout the dev verison and pip install from sources.

If you want support for immvision, you need to install and setup conan

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

pip install . is failing for me on the dev branch. I get errors like this (different executables, same error) each time i try, also with a completely fresh clone. I am not sure why glfw examples and tests are being built at all for a pip install.

[120/235] Building C object external\glfw\tests\CMakeFiles\glfwinfo.dir\glfwinfo.c.obj
      [121/235] Building C object external\glfw\tests\CMakeFiles\iconify.dir\__\deps\glad_gl.c.obj
      [122/235] Building CXX object CMakeFiles\_imgui_bundle.dir\bindings\pybind_imgui_node_editor.cpp.obj
      [123/235] Linking C executable external\glfw\examples\offscreen.exe
      [124/235] Linking C executable external\glfw\examples\heightmap.exe
      [125/235] Linking C executable external\glfw\examples\gears.exe
      FAILED: external/glfw/examples/gears.exe
      cmd.exe /C "cd . && C:\Users\huml-dkn\AppData\Local\Temp\pip-build-env-e7g00p98\overlay\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_exe --intdir=external\glfw\examples\CMakeFiles\gears.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe --manifests  -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx86\x64\link.exe /nologo external\glfw\examples\CMakeFiles\gears.dir\gears.c.obj external\glfw\examples\CMakeFiles\gears.dir\glfw.rc.res external\glfw\examples\CMakeFiles\gears.dir\__\deps\glad_gl.c.obj  /out:external\glfw\examples\gears.exe /implib:external\glfw\examples\gears.lib /pdb:external\glfw\examples\gears.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:windows  /ENTRY:mainCRTStartup  external\glfw\src\glfw3dll.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
      MT: command "C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe /nologo /manifest external\glfw\examples\gears.exe.manifest /outputresource:external\glfw\examples\gears.exe;#1" failed (exit code 0x1f) with the following output:

      mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file "external\glfw\examples\gears.exe". The process cannot access the file because it is being used by another process.


      [126/235] Linking C executable external\glfw\tests\events.exe
      FAILED: external/glfw/tests/events.exe
      cmd.exe /C "cd . && C:\Users\huml-dkn\AppData\Local\Temp\pip-build-env-e7g00p98\overlay\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_exe --intdir=external\glfw\tests\CMakeFiles\events.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe --manifests  -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx86\x64\link.exe /nologo external\glfw\tests\CMakeFiles\events.dir\events.c.obj external\glfw\tests\CMakeFiles\events.dir\__\deps\getopt.c.obj external\glfw\tests\CMakeFiles\events.dir\__\deps\glad_gl.c.obj  /out:external\glfw\tests\events.exe /implib:external\glfw\tests\events.lib /pdb:external\glfw\tests\events.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console  external\glfw\src\glfw3dll.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
      MT: command "C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe /nologo /manifest external\glfw\tests\events.exe.manifest /outputresource:external\glfw\tests\events.exe;#1" failed (exit code 0x1f) with the following output:

      mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file "external\glfw\tests\events.exe". The process cannot access the file because it is being used by another process.


      [127/235] Linking C executable external\glfw\examples\boing.exe
      FAILED: external/glfw/examples/boing.exe
      ......

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Could you try adding this to cmake/add_hello_imgui.cmake:

    # 2. Build glfw
    if (IMGUI_BUNDLE_BUILD_PYTHON)
        # Build glfw as a *shared* library:
        #   this is required if we want to be able to use python bindings
        #   for glfw, using https://github.com/FlorianRhiem/pyGLFW
        # Note: the rpath is set by a call to
        #     lg_target_set_rpath(${python_native_module_name} ".")
        # (inside add_imgui_bundle_bindings)
        set(BUILD_SHARED_LIBS ON)

        set(GLFW_BUILD_EXAMPLES OFF)      # Add these lines
        set(GLFW_BUILD_TESTS OFF)
        set(GLFW_BUILD_DOCS OFF)
        set(GLFW_INSTALL OFF)

        add_subdirectory(external/glfw)

And tell me if it helps?

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

CMaking and building with visual studio does work fine, only functions_composition_graph fails, because i do not have opencv available (will go there later, my first bridge to cross is getting that glassesValidator app ported, and that doesn't require immvision)

observations:

  1. demo_guizmo_sequencer GUI is a mess at hidpi, placement is not taking some scaling into account and everything overlaps or e.g. input boxes for frame atop the screen are too small
  2. also some hidpi problem with haiku heart: the height of the plot window is too small, making it very horizontally stretched. Also, when making the window wider, the plot stretches horizontally with the window, but not vertically even though there is plenty of space, making it even more horizontally stretched out.
  3. demo_tex_inspect: it gives me a window that is vertically so big it doesn't fit on my screen. It seems to work otherwise, but when running i do get an error:
ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile fragment shader!
ERROR: 1:23: 'function' : is removed in Forward Compatible context texture2D
ERROR: 1:23: 'texture2D' : no matching overloaded function found (using implicit conversion)
ERROR: 1:23: 'texture2D' : function is not known
ERROR: 1:23: '+' : wrong operand types no operation '+' exists that takes a left-hand operand of type '4X4 matrix of highp float' and a right operand of type 'uniform 4-component vector of highp float' (or there is no acceptable conversion)
ERROR: 1:23: '=' :  cannot convert from '4X4 matrix of highp float' to '4-component vector of highp float'


ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link shader program! (with GLSL '#version 130
')
Attached fragment shader is not compiled.

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Thanks!

demo_guizmo_sequencer GUI is a mess at hidpi, placement is not taking some scaling into account and everything overlaps or e.g. input boxes for frame atop the screen are too small

Argh... I hope this is not in the library code. If so, I might disable the sequencer for a while.

also some hidpi problem with haiku heart: the height of the plot window is too small, making it very horizontally stretched. Also, when making the window wider, the plot stretches horizontally with the window, but not vertically even though there is plenty of space, making it even more horizontally stretched out.

This one should be easy. I just need to find a way to change the implot's plot size

demo_tex_inspect: it gives me a window that is vertically so big it doesn't fit on my screen. It seems to work otherwise, but when running i do get an error:

I had a very similar same shader error when using imgui_tex_inspect on my Mac. I thought this was a mac only issue.
Either I disable it or I contact the library author and hope he has a solution.


Did you try demo_guizmo (the one with the 3D gizmo manipulator). Does it work?

Please keep me informed about the pip building process :-)

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

Could you try adding this to cmake/add_hello_imgui.cmake:

    # 2. Build glfw
    if (IMGUI_BUNDLE_BUILD_PYTHON)
        # Build glfw as a *shared* library:
        #   this is required if we want to be able to use python bindings
        #   for glfw, using https://github.com/FlorianRhiem/pyGLFW
        # Note: the rpath is set by a call to
        #     lg_target_set_rpath(${python_native_module_name} ".")
        # (inside add_imgui_bundle_bindings)
        set(BUILD_SHARED_LIBS ON)

        set(GLFW_BUILD_EXAMPLES OFF)      # Add these lines
        set(GLFW_BUILD_TESTS OFF)
        set(GLFW_BUILD_DOCS OFF)
        set(GLFW_INSTALL OFF)

        add_subdirectory(external/glfw)

And tell me if it helps?

That works! I have now run imgui_bundle_demo after a successful pip install. observations:

  1. on the imgui bundle screen the list of libraries under about/batteries included needs to be updated
  2. the text editor with code under immediate mode gui is too small on my hidpi screen. Same for the ones under basic code advices (which should be advice by the way), and the other nodes under that
  3. should the log buttons under advanced create items in some log? I don't see any log listing anywhere there. Oh wait, now i get it, those are not buttons to create some fake items, but for filtering the log. running the glfw callback demo creates some entries. Works fine, just didn't understand it.
  4. in demo apps, clicking imgui_example_glfw_opengl3 works, but opens a window that is not DPI scaled, everything is tiny. Not sure if you want to fix that. It also opens a popup with app code that i can't close again, only collapse
  5. demo_custom_fonts works nicely and is correctly scaled
  6. Docking demo button: demo works nicely, only one small thing is that the progress bar when launching the rocket seems to not be dpi scaled, this is what i get:
    image
    also, not all GUI elements work in some of the color schemes (try light) but that might not be something you can do anythign about.
  7. implot tab: all works well, but like the haiku, all the plots are not tall enough. Screenshot:
    image
  8. Markdown spacing isn't great (hidpi problem?), see e.g.:
    image
    and also the spacing after the full stop between sentences in the implot screenshot above (seems not enough space after full stop)
  9. editor demo: link not parsed correctly?
    image
    also, clicking ´test glfw link´ takes the window almost offscreen (top left), can hardly access the Windows window bar to drag it back. maybe set window pos 100,100 instead of 10,10?
  10. additional widgets: all works, but imfiledialog widgets open way too small, guess another hidpi thing. Spinners are possibly a bit small:
    image

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

I had a very similar same shader error when using imgui_tex_inspect on my Mac. I thought this was a mac only issue. Either I disable it or I contact the library author and hope he has a solution.

Well it does work and is nice to have (i see a popup indicating pixel color under my mouse), so despite shader error keep it? By the way, this is not in the pip-installed imgui_bundle_demo, right?

Did you try demo_guizmo (the one with the 3D gizmo manipulator). Does it work?

Yes, works fine. Takes a little (tiny) bit of getting used to, but that's imguizmo's UI itself.

Hopefully today i can try continuing my port, we should be very close if not all the way there now :)

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

Ah, i just see that something while running the imgui_bundle_demo also put ImGuiMd::OnOpenLink_Default url "images/world.jpg" should start with http! on the command line. Perhaps you know what triggered that.

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

I ran into the next problem when porting my app. I manually modify the default style by modifying the values in the ImGuiStyle::Colors (imgui.get_style().colors in pyimgui). This doesn't seem to exist in your port. How do i set specific colors/modify my current style?

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

And what would make the library a bit nicer to use would be some implicit conversions. For instance, i had imgui.get_style().item_spacing = (5,5) which worked fine with pyimgui, but now i need to assign a imgui.ImVec2(5,5) instead. It would be nice if such vectors would be transparently handled so users don't have to sprinkle ImVec2s all over the code. I guess i'll run into a similar thing soon with colors. Right now my pyimgui code is imgui.get_style().colors[imgui.Col_.modal_window_dim_bg] = (0, 0, 0, 0.5), I guess the RHS will also be affected by need for some explicit construction of an ImVec4?

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

I wanted to test font_atlas_get_tex_data_as_rgba32 but i notice that it is only present (commented out) in the .pyi file. Have you nixed it?

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

I ran into the next problem when porting my app. I manually modify the default style by modifying the values in the ImGuiStyle::Colors (imgui.get_style().colors in pyimgui). This doesn't seem to exist in your port. How do i set specific colors/modify my current style?

Same for KeysDown (should be imgui.get_io().keys_down) and a bunch of other arrays in the ImGuiIO struct. As these have known size, i guess there is a bigger chance they may be wrappable?

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

Another thing i ran into, might be user error. I have an image i want to draw. It is uploaded through OpenGL and i have a texture id. I then call draw_list.add_image_rounded(texture_id, pos, pos2, *args, flags=flags, **kwargs) and get the following error

TypeError: add_image_rounded(): incompatible function arguments. The following argument types are supported:
    1. (self: imgui_bundle._imgui_bundle.imgui.ImDrawList, user_texture_id: capsule, p_min: imgui_bundle._imgui_bundle.imgui.ImVec2, p_max: imgui_bundle._imgui_bundle.imgui.ImVec2, uv_min: imgui_bundle._imgui_bundle.imgui.ImVec2, uv_max: imgui_bundle._imgui_bundle.imgui.ImVec2, col: int, rounding: float, flags: int = 0) -> None

Invoked with: <imgui_bundle._imgui_bundle.imgui.ImDrawList object at 0x000001973685C630>, 2, <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x000001973685C0F0>, <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x000001973685C1B0>; kwargs: flags=<ImDrawFlags_.round_corners_all: 240>, rounding=6.0

Removing *args from the call (its an empty tuple) and explicitly naming the other two arguments as p_min and p_max doesn't change this, same incompatible arguments error.

type(self.texture_id) returns <class 'numpy.uintc'>, as is (apparently) returned by gl.glGenTextures(1) (import OpenGL.GL as gl)

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

I think ImGuiTableSortSpecs isn't wrapped correctly. specs should be a list of TableColumnSortSpecs, not a single one. My pyimgui code has for sort_spec in sort_specs_in.specs, where sort_specs_in is a ImGuiTableSortSpecs gotten from imgui.table_get_sort_specs().

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

Ok, last comment for now. Nice work man on the wrapper, i got my first windows to show even though not everything works yet. Anyway, what i run in now is that there are two versions of ´imgui.selectable´ (and i guess there are more like this one) where one takes a bool and returns a bool, and the other takes a pointer to bool and returns a tuple of two bools. Here i made it error so you can see the signatures:

TypeError: selectable(): incompatible function arguments. The following argument types are supported:
    1. (label: str, selected: bool = False, flags: int = 0, size: imgui_bundle._imgui_bundle.imgui.ImVec2 = <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x00000285EAB525F0>) -> bool
    2. (label: str, p_selected: bool, flags: int = 0, size: imgui_bundle._imgui_bundle.imgui.ImVec2 = <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x00000285EA6D2770>) -> Tuple[bool, bool]

I want to use the latter, but get the former. Even though both are defined in the generated pybind code. I guess that is because their python function syntax is identical? Both just take a bool. Perhaps this is user error. How do i call the latter one with signature returning -> Tuple[bool, bool]?

By the way, it would be nice to provide __str__() for imgui.ImVec2 and co, would make the above output much nicer. And given how much ImVec2 is used and returned throughout the code, much more legible and usable.

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

Well, some more:
ini = imgui.save_ini_settings_to_memory() fails even though the one input argument is optional:

TypeError: save_ini_settings_to_memory(): incompatible function arguments. The following argument types are supported:
    1. (out_ini_size: int = None) -> str

Invoked with:

calling it with e.g. 1000 as argument works fine.

And in my port i don't get font loading to work. That is, my icons show up as question marks. I have tried adding

imgui_backends.opengl3_destroy_fonts_texture()
imgui_backends.opengl3_create_fonts_texture()

after the calls to imgui.font_atlas_add_font_from_file_ttf which i think should be needed because else the new font texture doesn't get built (not needed in your demo though, as you call these before the very first frame is rendered, and fonts are set up in ImGui_ImplOpenGL3_CreateDeviceObjects() which is called the first frame). So adding those calls didn't help. Guess i am doing something wrong as your demo does work. But what i have now worked with pyimgui, so i am wondering what the difference/my oversight is...

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

Ok, last comment for now. Nice work man on the wrapper, i got my first windows to show even though not everything works yet. Anyway, what i run in now is that there are two versions of ´imgui.selectable´ (and i guess there are more like this one) where one takes a bool and returns a bool, and the other takes a pointer to bool and returns a tuple of two bools. Here i made it error so you can see the signatures:

TypeError: selectable(): incompatible function arguments. The following argument types are supported:
    1. (label: str, selected: bool = False, flags: int = 0, size: imgui_bundle._imgui_bundle.imgui.ImVec2 = <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x00000285EAB525F0>) -> bool
    2. (label: str, p_selected: bool, flags: int = 0, size: imgui_bundle._imgui_bundle.imgui.ImVec2 = <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x00000285EA6D2770>) -> Tuple[bool, bool]

I want to use the latter, but get the former. Even though both are defined in the generated pybind code. I guess that is because their python function syntax is identical? Both just take a bool. Perhaps this is user error. How do i call the latter one with signature returning -> Tuple[bool, bool]?

We had a closely related discussion about this before, IIRC. The two functions are redundant for the python binding, so we have to choose one style. for pyimgui compatibility (and because i know of no other good reason) and additional flexibility (this form is more informative) i vote to only expose version 2. I'm not sure if this case can be automatically detected (that two different c++ function lead to a python function with the same arguments) and the choice automated.

By the way, I'll go through all this and make separate issues of each thing, so its possible to track them. Right now its become a mess thanks to me.

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

I think i have now poored all this into separate issues. Hope i didn't miss anything. Thanks again for the hard work, i'm excited where this is heading!

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

Thanks for taking the time to separate this into issues, this is helpful!

I will answer in those

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

It should be solved now. I don't know why suddenly this include became necessary, but it is cleaner with it.

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

If you want to test immvision, install like this:

# - when building wheels for windows, the env variable
#   IMGUIBUNDLE_OPENCV_WIN_USE_OFFICIAL_PREBUILT_460 is set before running pip.
#   This way, an official release from OpenCV 4.6.0 for windows will be downloaded.
#   It includes an "opencv_world.dll" (a dll that groups all the code for all OpenCV modules).
#   This dll is deployed into imgui_bundle package (under windows)
#   "Funny" note on how to set this env var under windows: choose your poison
#     * with PowerShell
#	      Set-Item -Path 'Env:IMGUIBUNDLE_OPENCV_WIN_USE_OFFICIAL_PREBUILT_460' -Value 'ON'
#     * With bash:
#	      export IMGUIBUNDLE_OPENCV_WIN_USE_OFFICIAL_PREBUILT_460=ON
#      * With dos:
#         set IMGUIBUNDLE_OPENCV_WIN_USE_OFFICIAL_PREBUILT_460=ON

from imgui_bundle.

dcnieho avatar dcnieho commented on May 22, 2024

from imgui_bundle.

pthom avatar pthom commented on May 22, 2024

I will transfer this issue to discussions. This will be a good way for to exchange on the subject.

from imgui_bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.