Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad code gen for SlideInt2(), etc. #462

Open
noname22 opened this issue Feb 6, 2024 · 2 comments
Open

Bad code gen for SlideInt2(), etc. #462

noname22 opened this issue Feb 6, 2024 · 2 comments

Comments

@noname22
Copy link

noname22 commented Feb 6, 2024

The code generation seems to have failed for the methods that are supposed to accept multiple ints, ie.

bool DragInt2(string label, ref int v)
bool DragInt3(string label, ref int v)
bool DragInt4(string label, ref int v)

bool SliderInt2(string label, ref int v, int v_min, int v_max)
bool SliderInt3(string label, ref int v, int v_min, int v_max)
bool SliderInt4(string label, ref int v, int v_min, int v_max)

etc.

I'm assuming they're supposed to accept multiple ints, not a single one, unless I've gravely misunderstood something.

@NoahStolk
Copy link
Contributor

NoahStolk commented Feb 10, 2024

The generated code is actually correct, although I agree it is a little confusing.

You can use multiple ints because the parameter is a ref int:

static int[] GridColor = [255, 255, 255];

void Render()
{
    // ...
    ImGui.SliderInt3("Grid color", ref GridColor[0], 0, 255);
}

This works correctly in this example, given that the array holds at least 3 items.

@noname22
Copy link
Author

Alright, thanks for pointing that out. It doesn't really sound very "kosher", though. It should probably accept a span or an array rather than a ref to the first element of the array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants