ocornut/imgui

Too many vertices in same ImDrawList

Closed this issue · 7 comments

Hi guys,

I have browse a bit over all the post but I still dont have clear how to solve this problem.

Basically I created a profiler for my game, sometimes the profiler is drawing lots of bars by using AddLine (I also tried with AddRectFilled). The problem is that quite often I have this assert.

Does anyone knows what is the best way to do solve this?
I have seem some people with profilers as well. How do you draw it when you have lot of bars?

Yeah, I did it, but when I tried to use the BeginChild/EndChild solution my application starts running super slow because the function FindWindowByName has to iterate over more than 20000 windows.

I guess I will need to call BeginChild/EndChild only when I know my current draw_list is too full or something like that?

Thanks.

Hi,

Thanks! That works! For some reason last time I tried to do that I fail.
Thanks again.

I have now clarified the comments in the code.
The block now says:

// Check that draw_list doesn't use more vertices than indexable in a single draw call (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per window)
// If this assert triggers because you are drawing lots of stuff manually, you can:
// A) Add '#define ImDrawIdx unsigned int' in imconfig.h to set the index size to 4 bytes. You'll need to handle the 4-bytes indices to your renderer.
//    For example, the OpenGL example code detect index size at compile-time by doing:
//    'glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);'
//    Your own engine or render API may use different parameters or function calls to specify index sizes. 2 and 4 bytes indices are generally supported by most API.
// B) If for some reason you cannot use 4 bytes indices or don't want to, a workaround is to call BeginChild()/EndChild() before reaching the 64K limit to split your draw commands in multiple draw lists.
IM_ASSERT((draw_list->_VtxCurrentIdx >> (sizeof(ImDrawIdx)*8)) == 0);  // Too many vertices in same ImDrawList. See comment above.

Hi,

Thanks for all the changes!

Cheers