aboutsummaryrefslogtreecommitdiff
path: root/util/sokol_imgui.h
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2025-10-05 14:41:32 +0200
committerAndre Weissflog <floooh@gmail.com>2025-10-05 14:41:32 +0200
commitae52bb4d84b72bc48dcaf1d57282fad1af7e8c45 (patch)
tree5ecb907db460139d8d9d40e41449d5f7f20bd22c /util/sokol_imgui.h
parent9bbac210b7d31390a714b28a8c2efee4c2152a83 (diff)
sokol_imgui.h: fix assert in simgui_shutdown() when no UI was rendered (fixes #1341)
Diffstat (limited to 'util/sokol_imgui.h')
-rw-r--r--util/sokol_imgui.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h
index fcd232f6..3a1b4a89 100644
--- a/util/sokol_imgui.h
+++ b/util/sokol_imgui.h
@@ -2967,11 +2967,10 @@ SOKOL_API_IMPL void simgui_render(void) {
if (0 == draw_data) {
return;
}
- if (draw_data->CmdListsCount == 0) {
- return;
- }
- // catch up with texture updates
+ // catch up with texture updates (important: this needs to happen before
+ // checking the CmdListsCount, otherwise textures might get stuck in
+ // 'WantCreate' state)
if (draw_data->Textures) {
for (size_t i = 0; i < (size_t)draw_data->Textures->Size; i++) {
ImTextureData* tex = draw_data->Textures->Data[i];
@@ -2981,12 +2980,16 @@ SOKOL_API_IMPL void simgui_render(void) {
}
}
- /* copy vertices and indices into an intermediate buffer so that
- they can be updated with a single sg_update_buffer() call each
- (sg_append_buffer() has performance problems on some GL platforms),
- also keep track of valid number of command lists in case of a
- buffer overflow
- */
+ // early-out if nothing needs to be rendered
+ if (draw_data->CmdListsCount == 0) {
+ return;
+ }
+
+ // copy vertices and indices into an intermediate buffer so that
+ // they can be updated with a single sg_update_buffer() call each
+ // (sg_append_buffer() has performance problems on some GL platforms),
+ // also keep track of valid number of command lists in case of a
+ // buffer overflow
size_t all_vtx_size = 0;
size_t all_idx_size = 0;
int cmd_list_count = 0;