-
Notifications
You must be signed in to change notification settings - Fork 51
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
Support *Scalar functions #74
Comments
I'd say this is not necessary. We could easily create a one based on basic drag int or float. |
Mess with pointer data via CGO is not that pleasant after all. |
agreed, but for certain applications the loss of precision when converting between float and double is unacceptable. we could create |
@AllenDang I think we can make our wrappers public to make *Scalar functions easier to use |
@ptxmac from current code: // InputScalarV parameter default value hint:
// p_step: NULL
// p_step_fast: NULL
// format: NULL
// flags: 0
func InputScalarV(label string, data_type DataType, p_data unsafe.Pointer, p_step unsafe.Pointer, p_step_fast unsafe.Pointer, format string, flags InputTextFl
labelArg, labelFin := WrapString(label)
formatArg, formatFin := WrapString(format)
defer func() {
labelFin()
formatFin()
}()
return C.igInputScalar(labelArg, C.ImGuiDataType(data_type), (p_data), (p_step), (p_step_fast), formatArg, C.ImGuiInputTextFlags(flags)) == C.bool(tru
} So I suppose its fixed |
It looks like this has been broken again, now the code is |
@ptxmac what's wrong with it? |
The code gen doesn't see the value as a pointer, so it's never copied. Current code:
It should be similar to
But where the type of |
Basically the fix mentioned in #74 (comment) have regressed and we're back to the original problem |
yeah. I think there were a problem with |
I had another look, and it actually is possible to use using the current implementation. IT's just not very ergonomic 😄 func Scalar(v *int32) {
vArg, vFin := datautils.WrapNumberPtr[C.int, int32](v)
defer vFin()
imgui.InputScalar("Scalar", imgui.DataTypeS32, uintptr(unsafe.Pointer(vArg)))
}
func ScalarN(v *[3]int32) {
vArg := make([]C.int, len(v))
for i, val := range v {
vArg[i] = C.int(val)
}
defer func() {
for i, val := range vArg {
v[i] = int32(val)
}
}()
imgui.InputScalarN("ScalarN", imgui.DataTypeS32, uintptr(unsafe.Pointer(&vArg[0])), 3)
} |
I was looking for a
DragDouble
widget, but imgui has been implementing new datatypes using the*Scalar
widgets instead.These work just like
DragInt/Float/Etc
but takes an enum declaring the type and a void pointer to the data.For this to work from go we need a way to manually wrap the go pointer, i.e. make
wrapNumberPtr
public.Or perhaps implement
DragScalar
with a switch that will type-cast based on the DataType.something like:
The text was updated successfully, but these errors were encountered: