aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md7
-rw-r--r--util/sokol_imgui.h23
2 files changed, 20 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b88926d..ba5e8e38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
## Updates
+### 05-Oct-2025
+
+sokol_imgui.h: fix a bug where an assert would be triggered in `simgui_shutdown()`
+when no Dear ImGui UI was ever rendered.
+
+Details: https://github.com/floooh/sokol/issues/1341
+
### 04-Oct-2025
sokol_gfx.h: a new function `sg_draw_ex()` has been added with additional parameters
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;