Hexa.NET.ImGui icon indicating copy to clipboard operation
Hexa.NET.ImGui copied to clipboard

[Feature Request] Implicit converting between `IntPtr` and `ImTextureID`

Open wolfcomp opened this issue 9 months ago • 4 comments

It would be nice to have an implicit conversion between IntPtr and ImTextureID to not have to call the constructor where ever the texture is loaded in for certain cases.

I already see there is one for the type ulong but not from IntPtr when looking at https://github.com/HexaEngine/Hexa.NET.ImGui/blob/master/Hexa.NET.ImGui/ImTextureID.cs

wolfcomp avatar Apr 28 '25 13:04 wolfcomp

Hi, thanks for the suggestion! I’ve added the implicit operators, along with a few additions for void* and nuint. It will be published on NuGet together with #43 once I’m done with that.

JunaMeinhold avatar Apr 28 '25 14:04 JunaMeinhold

It looks like commit e9db85f1 gives me an error related to the implicit conversion change

7>ImGuiD3D11Renderer.cs(531,46): Error CS0457 : Ambiguous user defined conversions 'ImTextureID.implicit operator ImTextureID(ulong)' and 'ImTextureID.implicit operator ImTextureID(nint)' when converting from 'int' to 'ImTextureID'

I rolled back to the commit before that and the project has no problems running

Cidolfas avatar May 11 '25 00:05 Cidolfas

Hi, the c# imgui backends are deprecated anyway, use the native backends from the Hexa.NET.ImGui.Backends package

JunaMeinhold avatar May 11 '25 07:05 JunaMeinhold

I pulled down and tried out this package for the first time yesterday and this error was preventing me from using the ExampleD3D11 or ExampleOpenGL3 projects. I'll make a new issue about the example projects not working out-of-the-box.

Passing a literal into anything expecting an ImTextureID will still cause this compiler error for me, though I also can't think of a reason to use a literal.

Cidolfas avatar May 11 '25 22:05 Cidolfas