瀏覽代碼

sokol_imgui.h: fix for cimgui 1.89.9 (fixes #879)

Andre Weissflog 2 年之前
父節點
當前提交
d4ac122f36
共有 2 個文件被更改,包括 17 次插入2 次删除
  1. 7 0
      CHANGELOG.md
  2. 10 2
      util/sokol_imgui.h

+ 7 - 0
CHANGELOG.md

@@ -1,5 +1,12 @@
 ## Updates
 
+#### 09-Sep-2023
+
+- a small PR has been merged which fixes a redundant glBindFramebuffer() in the GLES3 backend
+  in `sg_end_pass()` (see: https://github.com/floooh/sokol/pull/878), many thanks to @danielchasehooper
+  for catching that issue!
+- sokol_imgui.h has been fixed for cimgui 1.89.9 (see https://github.com/floooh/sokol/issues/879)
+
 #### 28-Aug-2023
 
 **sokol_gfx.h metal**: A new attempt at fixing a rare Metal validation layer

+ 10 - 2
util/sokol_imgui.h

@@ -2573,6 +2573,14 @@ static void _simgui_bind_image_sampler(sg_bindings* bindings, ImTextureID tex_id
     }
 }
 
+static ImDrawList* _simgui_imdrawlist_at(ImDrawData* draw_data, int cl_index) {
+    #if defined(__cplusplus)
+        return draw_data->CmdLists[cl_index];
+    #else
+        return draw_data->CmdLists.Data[cl_index];
+    #endif
+}
+
 SOKOL_API_IMPL void simgui_render(void) {
     SOKOL_ASSERT(_SIMGUI_INIT_COOKIE == _simgui.init_cookie);
     #if defined(__cplusplus)
@@ -2600,7 +2608,7 @@ SOKOL_API_IMPL void simgui_render(void) {
     size_t all_idx_size = 0;
     int cmd_list_count = 0;
     for (int cl_index = 0; cl_index < draw_data->CmdListsCount; cl_index++, cmd_list_count++) {
-        ImDrawList* cl = draw_data->CmdLists[cl_index];
+        ImDrawList* cl = _simgui_imdrawlist_at(draw_data, cl_index);
         const size_t vtx_size = (size_t)cl->VtxBuffer.Size * sizeof(ImDrawVert);
         const size_t idx_size = (size_t)cl->IdxBuffer.Size * sizeof(ImDrawIdx);
 
@@ -2664,7 +2672,7 @@ SOKOL_API_IMPL void simgui_render(void) {
     int vb_offset = 0;
     int ib_offset = 0;
     for (int cl_index = 0; cl_index < cmd_list_count; cl_index++) {
-        const ImDrawList* cl = draw_data->CmdLists[cl_index];
+        ImDrawList* cl = _simgui_imdrawlist_at(draw_data, cl_index);
 
         bind.vertex_buffer_offsets[0] = vb_offset;
         bind.index_buffer_offset = ib_offset;