aboutsummaryrefslogtreecommitdiff
path: root/util/sokol_imgui.h
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2024-04-21 16:20:42 +0200
committerAndre Weissflog <floooh@gmail.com>2024-04-21 16:20:42 +0200
commit4fac1bb845c011ed91446f511d86c7ce50e15e42 (patch)
tree1d3d6fc599265add468ec3cbf135fef6bff30270 /util/sokol_imgui.h
parent7e1035cb0dff181ca5ded241914ae128318e7d46 (diff)
parent4534e02d6c83e23fa212ac29c1fd90d8a22f5419 (diff)
Merge branch 'master' into storage-buffers
Diffstat (limited to 'util/sokol_imgui.h')
-rw-r--r--util/sokol_imgui.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h
index e533ad34..810890c0 100644
--- a/util/sokol_imgui.h
+++ b/util/sokol_imgui.h
@@ -2385,6 +2385,9 @@ SOKOL_API_IMPL void simgui_setup(const simgui_desc_t* desc) {
SOKOL_API_IMPL void simgui_create_fonts_texture(const simgui_font_tex_desc_t* desc) {
SOKOL_ASSERT(desc);
+ SOKOL_ASSERT(SG_INVALID_ID == _simgui.font_smp.id);
+ SOKOL_ASSERT(SG_INVALID_ID == _simgui.font_img.id);
+ SOKOL_ASSERT(SIMGUI_INVALID_ID == _simgui.default_font.id);
#if defined(__cplusplus)
ImGuiIO* io = &ImGui::GetIO();
@@ -2434,6 +2437,9 @@ SOKOL_API_IMPL void simgui_destroy_fonts_texture(void) {
sg_destroy_sampler(_simgui.font_smp);
sg_destroy_image(_simgui.font_img);
simgui_destroy_image(_simgui.default_font);
+ _simgui.font_smp.id = SG_INVALID_ID;
+ _simgui.font_img.id = SG_INVALID_ID;
+ _simgui.default_font.id = SIMGUI_INVALID_ID;
}
SOKOL_API_IMPL void simgui_shutdown(void) {
@@ -2519,6 +2525,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;