Kaynağa Gözat

Merge branch 'elloramir-master'

Andre Weissflog 1 yıl önce
ebeveyn
işleme
7d13a6715c
2 değiştirilmiş dosya ile 16 ekleme ve 0 silme
  1. 10 0
      CHANGELOG.md
  2. 6 0
      util/sokol_imgui.h

+ 10 - 0
CHANGELOG.md

@@ -1,5 +1,15 @@
 ## Updates
 
+### 21-Mar-2024:
+
+- sokol_imgui.h: merged PR https://github.com/floooh/sokol/pull/1010, this will automatically
+  re-create the sokol-gfx font texture resources in the `simgui_new_frame()` call
+  when the Dear ImGui texture atlas has changed. This is an alternative to calling the
+  functions `simgui_create_fonts_texture()` and `simgui_destroy_fonts_texture()` manually.
+  One important reason why you'd want to call those functions manually is to create the fonts texture
+  with custom texture sampler attributes (the new implicit re-creation inside `simgui_new_frame()`
+  calls `sg_make_sampler()` with default attributes).
+
 ### 02-Mar-2024:
 
 - sokol_app.h emscripten: two new flags in `sapp_desc` to configure the Emscripten main loop:

+ 6 - 0
util/sokol_imgui.h

@@ -2521,6 +2521,12 @@ SOKOL_API_IMPL void simgui_new_frame(const simgui_frame_desc_t* desc) {
     #else
         ImGuiIO* io = igGetIO();
     #endif
+    if (!io->Fonts->TexReady) {
+        simgui_destroy_fonts_texture();
+        simgui_font_tex_desc_t simgui_font_smp_desc;
+        _simgui_clear(&simgui_font_smp_desc, sizeof(simgui_font_smp_desc));
+        simgui_create_fonts_texture(&simgui_font_smp_desc);
+    }
     io->DisplaySize.x = ((float)desc->width) / _simgui.cur_dpi_scale;
     io->DisplaySize.y = ((float)desc->height) / _simgui.cur_dpi_scale;
     io->DeltaTime = (float)desc->delta_time;