Fixed AddConvexPolyFilled and AddPolyLine parameters#345
Fixed AddConvexPolyFilled and AddPolyLine parameters#345img02 wants to merge 1 commit intoImGuiNET:masterfrom
Conversation
|
as the name suggests |
|
Oh, I don't really know how that works, but wouldn't this at least fix it temporarily? either way, currently those 2 functions don't work. |
|
yeah, same here, no idea. I would suggest reading/understanding/debugging this project: https://github.com/mellinoe/ImGui.NET/tree/master/src/CodeGenerator As a workaround do the following: |
|
@zaafar Is that safe to do? i.e. is .NET not free to arbitrarily allocate the array in non-contiguous memory space? |
|
I know this is an old PR, but I'd just like to state that even if we were to change the code generator, I'm pretty sure this is by design and does not need fixing / should not be changed. You're expected to invoke these methods as follows: private static readonly Vector2[] _points =
{
new(300, 300),
new(600, 600),
new(300, 600),
new(300, 300),
};
void Render()
{
...
drawList.AddPolyline(ref _points[0], points.Length, ...);
}Works perfectly fine for me. I don't think it's a workaround.
@gsuberland I think it should be safe? But to be sure you could also pin the memory like this to prevent that from happening (requires fixed (Vector2* p = _points)
drawList.AddPolyline(ref p[0], _points.Length, ...);Maybe it should be made clear somewhere how to properly use these methods though. |
Changed params from
ref Vector2to array
Vector2[]Fixed result:

previous result: (could only pass single vec2)
