diff options
| author | Andre Weissflog <floooh@gmail.com> | 2020-01-24 16:27:46 +0100 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2020-01-24 16:27:46 +0100 |
| commit | 08a325d83a8a2c7cb4e1491c66030f329599b861 (patch) | |
| tree | 5abe705a37eea3303f745422980b28a737bc6926 | |
| parent | c54fdf95159e5ae63a21a79f46b4365ce4e2644a (diff) | |
sokol_imgui.h: allow draw commands without vertices
| -rw-r--r-- | util/sokol_imgui.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h index 908e4633..ccd1345d 100644 --- a/util/sokol_imgui.h +++ b/util/sokol_imgui.h @@ -1015,6 +1015,8 @@ SOKOL_API_IMPL void simgui_render(void) { bind.index_buffer = _simgui.ibuf; ImTextureID tex_id = io->Fonts->TexID; bind.fs_images[0].id = (uint32_t)(uintptr_t)tex_id; + uint32_t vb_offset = 0; + uint32_t ib_offset = 0; for (int cl_index = 0; cl_index < draw_data->CmdListsCount; cl_index++) { ImDrawList* cl = draw_data->CmdLists[cl_index]; @@ -1030,8 +1032,12 @@ SOKOL_API_IMPL void simgui_render(void) { const ImDrawVert* vtx_ptr = cl->VtxBuffer.Data; const ImDrawIdx* idx_ptr = cl->IdxBuffer.Data; #endif - const uint32_t vb_offset = sg_append_buffer(bind.vertex_buffers[0], vtx_ptr, vtx_size); - const uint32_t ib_offset = sg_append_buffer(bind.index_buffer, idx_ptr, idx_size); + if (vtx_ptr) { + vb_offset = sg_append_buffer(bind.vertex_buffers[0], vtx_ptr, vtx_size); + } + if (idx_ptr) { + ib_offset = sg_append_buffer(bind.index_buffer, idx_ptr, idx_size); + } /* don't render anything if the buffer is in overflow state (this is also checked internally in sokol_gfx, draw calls that attempt to draw with overflowed buffers will be silently dropped) |