| 5181 | } |
| 5182 | |
| 5183 | static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list) |
| 5184 | { |
| 5185 | if (draw_list->CmdBuffer.Size == 0) |
| 5186 | return; |
| 5187 | if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL) |
| 5188 | return; |
| 5189 | |
| 5190 | // Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc. |
| 5191 | // May trigger for you if you are using PrimXXX functions incorrectly. |
| 5192 | IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size); |
| 5193 | IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size); |
| 5194 | if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset)) |
| 5195 | IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size); |
| 5196 | |
| 5197 | // Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window) |
| 5198 | // If this assert triggers because you are drawing lots of stuff manually: |
| 5199 | // - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds. |
| 5200 | // Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents. |
| 5201 | // - If you want large meshes with more than 64K vertices, you can either: |
| 5202 | // (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'. |
| 5203 | // Most example backends already support this from 1.71. Pre-1.71 backends won't. |
| 5204 | // Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them. |
| 5205 | // (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h. |
| 5206 | // Most example backends already support this. For example, the OpenGL example code detect index size at compile-time: |
| 5207 | // glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset); |
| 5208 | // Your own engine or render API may use different parameters or function calls to specify index sizes. |
| 5209 | // 2 and 4 bytes indices are generally supported by most graphics API. |
| 5210 | // - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching |
| 5211 | // the 64K limit to split your draw commands in multiple draw lists. |
| 5212 | if (sizeof(ImDrawIdx) == 2) |
| 5213 | IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"); |
| 5214 | |
| 5215 | out_list->push_back(draw_list); |
| 5216 | } |
| 5217 | |
| 5218 | static void AddWindowToDrawData(ImGuiWindow* window, int layer) |
| 5219 | { |
no test coverage detected