Aidan63 / linc_imgui

Haxe/hxcpp @:native bindings for Dear ImGui
MIT License
44 stars 7 forks source link

Type not found : imgui.ImGui #9

Closed melMass closed 3 years ago

melMass commented 4 years ago

Hi, Thanks for the Linc initiative. I'm trying to run the CLI Test:

The one from the tests folder ``` haxe import cpp.Pointer; import imgui.ImGui; import imgui.util.ImVec2; class Main { public static function main() { new Main(); } public function new() { ImGui.createContext(); var io = ImGui.getIO(); io.displaySize = ImVec2.create(640, 480); var text = "TextureID"; var atlas = Pointer.fromRaw(io.fonts).ref; var width : Int = 0; var height : Int = 0; var pixels : Array = null; atlas.getTexDataAsRGBA32(pixels, width, height); atlas.texID = Pointer.addressOf(text).rawCast(); // Update ImGui.newFrame(); ImGui.showDemoWindow(); ImGui.render(); ImGui.destroyContext(); } } ```

I've installed the library using:

haxelib git linc_imgui https://github.com/Aidan63/linc_imgui

I'm not sure what I'm missing, here is the reproduction test: imgui_sample.zip

Thanks

Aidan63 commented 4 years ago

Hello! The reason it's not working is because it seems I broke the tests with the last commit. Was working on an automated generator for creating the externs from the latest imgui source but it hasn't got to the point where its as nice as the old hand made externs.

Easiest solution would be to set the haxelib version to the previous commit. It won't be the latest imgui (v1.65 I think) but it will work.

haxelib git linc_imgui https://github.com/Aidan63/linc_imgui c36fc7f7

Just checked and the cli tests work with that commit in haxe 4 and latest hxcpp.

melMass commented 4 years ago

I was about to pick up your work on the generator and I just realized you made a new branch new-parser a week ago ;).

May I ask the status/goal you are expecting?

Thanks

Aidan63 commented 4 years ago

Yes, I finally got around to working on the parser.

This new one generates all the needed code from the cimgui definitions, not half generate then needing to be cleanup by hand like whats in the master. This new parser also generates abstracts for types to avoid having to write loads of boilerplate hxcpp pointer code.

        final id  = 'some text';

        io.fonts.texID = id;
        io.backendRendererName = 'my renderer';

        if (ImGui.begin('window'))
        {
            final ints = [ 1, 2, 3, 4 ];

            ImGui.sliderInt4('multi ints', ints, 0, 10);
        }

So in that example io.fonts.texID is a void*, but in the bindings in an abstract VoidPointer which will do all the pointer handling for you. Same deal with sliderInt4, instead of having to get the pointer for the array manually its extern is generated with an IntPointer abstract which can handle getting a pointer from an array. This way is much easier for users and more flexible, as it opens the door for lots more abstracts as and when needed.

The new generator is almost done, the generator correctly produces the bindings and I've just updated the cli example in that branch. Just need to do some cleanup / documentation which I'll hopefully do over the next few days.

In the future when a new imgui version is released it should just be a case of updating the cimgui submodule then running the build script to generate all the new bindings.

melMass commented 4 years ago

That's amazing, thanks for the work! I'm going to try to implement custom backends based on the sokol project, your work will definitely help in that regards

Aidan63 commented 4 years ago

That branch should now be merged into master, the cli example should also be building. If you want to see a complete rendering example then I updated my engines imgui support to the latest master. That implementation can be found here https://github.com/flurry-engine/flurry/blob/master/src/uk/aidanlee/flurry/modules/imgui/ImGuiImpl.hx.

The void pointer abstract still needs some more work and its better to manually get the pointers for now, but the int, bool, float, etc abstracts are working fine.