Aidan63 / linc_imgui

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

Pointer.addressOf() Sprite in an array? #2

Closed 01010111 closed 6 years ago

01010111 commented 6 years ago

When trying to access a FlxSprite in an array: ImGui.image(Pointer.addressOf(tiles[0]).rawCast(), ImVec2.create(32, 32)); I get an error when compiling:

Error: ./src/elements/ClickableArea.cpp:99:31: error: no matching function for call to 'addressOf'
HXDLIN(  37)            void* _hx_tmp = ::cpp::Pointer_obj::addressOf(this->tiles->__get((int)0).StaticCast<  ::flixel::FlxSprite >())->rawCast();
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/lib/haxe/lib/hxcpp/3,4,64/include/cpp/Pointer.h:514:27: note: candidate function [with T = hx::ObjectPtr<flixel::FlxSprite_obj>] not viable: expects an l-value for 1st argument
        inline static Pointer<T> addressOf(T &value)  { return Pointer<T>(&value); }
                                 ^

Is there any way to get an image from an array?

Aidan63 commented 6 years ago

Just ran a quick test on my OSX machine and get the same, I was able to solve it using the Pointer.arrayElem() function instead of addressOf.

ImGui.image(Pointer.arrayElem(array, 0).rawCast(), ImVec2.create(128, 128));

Interestingly enough using the array access like you have works fine in Windows.