easy way to switch to 32-bit vertex indices ?
is there a easy way to switch to 32-bit vertex indices, without changing the package source code at imconfig.h line 96?
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
#define ImDrawIdx unsigned int
I am looking for some solution inside my application code instead of package source code
@francmarx What's your scenario? I think it is necessary to change the source code of imgui-go binding.
@AllenDang I have big data to plot (> 100k points/vertices)
without uncommenting #define ImDrawIdx unsigned int in imconfig.h I get an error:
imgui.cpp:4143: void AddDrawListToDrawData(ImVector<ImDrawList*>*, ImDrawList*): Assertion "draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"' failed.
imconfig.h belongs to plot package, so I have to change this file every time after update plot package
Could this switch to 32-bit indices be done inside my application source code ?
@francmarx To draw a large dataset to diagram, I suggest to use plot library like gonum/plot: A repository for plotting and visualizing datahttps://github.com › gonum › plot to plot data to a RGBA and draw the RGBA via giu.Image. I understand this could be not that interactive, but workable for any size of data.
@AllenDang implot is "the best" lib for plotting, it has many function (zoom, pan, lin/log ...) so I don't want to switch to another lib, I simply need a easy way to use 32-bit indizes
@francmarx Got it. Let me try to enabled it.
@francmarx I've enabled BackendFlagsRendererHasVtxOffset, it should alow large number of draw data, can you update to most recent Master branch and have a try?
@francmarx BTW, implot has lots of update since last intergration. I will do a update later, and you may need to expect some API changes.
@AllenDang it doesn't work, I got the assert error:
imgui.cpp:4143: void AddDrawListToDrawData(ImVector<ImDrawList*>*, ImDrawList*): Assertion `draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"' failed.
SIGABRT: abort
PC=0x7f868c37318b m=0 sigcode=18446744073709551610
signal arrived during cgo execution
goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x805a10, 0xc0000a1d60)
/usr/local/go/src/runtime/cgocall.go:156 +0x5c fp=0xc0000a1d38 sp=0xc0000a1d00 pc=0x47cd1c
github.com/AllenDang/imgui-go._Cfunc_iggRender()
_cgo_gotypes.go:5287 +0x45 fp=0xc0000a1d60 sp=0xc0000a1d38 pc=0x5aeb65
github.com/AllenDang/imgui-go.Render(...)
/home/franc/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui.go:36
Seems this won't work as wanted. I got the same error:
Assertion failed: (draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"), function AddDrawListToDrawData, file imgui.cpp, line 4143. SIGABRT: abort
Or is there any flags we should switch on in go code?
@AllenDang Maybe you called the wrong func? I've read the MasterWindow.go, and see the code below:
io.SetConfigFlags(imgui.ConfigFlagEnablePowerSavingMode | imgui.BackendFlagsRendererHasVtxOffset)
But this is a BackendFlag, not a ConfigFlag!
So I added this line, then app won't crash for the _VtxCurrentIdx.
io.SetBackendFlags(imgui.BackendFlagsRendererHasVtxOffset)
Would please have a check?
@daiwhea I remember I tried this once with no luck, might with other issue from render. But this issue will no longer exists once we changed the backend from imgui-go to cimgui-go.
@daiwhea @AllenDang I added io.SetBackendFlags(imgui.BackendFlagsRendererHasVtxOffset) to MasterWindow.go
=> it works fine :)
I'm using [email protected] . Without this line, it'll crash.
@daiwhea That's a good news, please make a PR.
@AllenDang sorry. I'm using [email protected]. Seems master branch has rewrite NewMasterWindow(). I need to verify it first.
@daiwhea That's a good news, please make a PR.
done. My code crashed for the master branch. So I made a simple app to verify this bug.
I think it is fixed