diff --git a/backends/imgui_impl_allegro5.cpp b/backends/imgui_impl_allegro5.cpp index cadc4b7f2..db608e020 100644 --- a/backends/imgui_impl_allegro5.cpp +++ b/backends/imgui_impl_allegro5.cpp @@ -206,7 +206,7 @@ bool ImGui_ImplAllegro5_CreateDeviceObjects() return false; // Store our identifier - io.Fonts->TexID = (void*)cloned_img; + io.Fonts->SetTexID((void*)cloned_img); g_Texture = cloned_img; // Create an invisible mouse cursor @@ -222,8 +222,9 @@ void ImGui_ImplAllegro5_InvalidateDeviceObjects() { if (g_Texture) { + ImGuiIO& io = ImGui::GetIO(); + io.Fonts->SetTexID(NULL); al_destroy_bitmap(g_Texture); - ImGui::GetIO().Fonts->TexID = NULL; g_Texture = NULL; } if (g_MouseCursorInvisible) diff --git a/backends/imgui_impl_dx10.cpp b/backends/imgui_impl_dx10.cpp index 75db96a05..422f65290 100644 --- a/backends/imgui_impl_dx10.cpp +++ b/backends/imgui_impl_dx10.cpp @@ -305,7 +305,7 @@ static void ImGui_ImplDX10_CreateFontsTexture() } // Store our identifier - io.Fonts->TexID = (ImTextureID)g_pFontTextureView; + io.Fonts->SetTexID((ImTextureID)g_pFontTextureView); // Create texture sampler { @@ -482,7 +482,7 @@ void ImGui_ImplDX10_InvalidateDeviceObjects() return; if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; } - if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. + if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } diff --git a/backends/imgui_impl_dx11.cpp b/backends/imgui_impl_dx11.cpp index ebb8073c3..3edfeae69 100644 --- a/backends/imgui_impl_dx11.cpp +++ b/backends/imgui_impl_dx11.cpp @@ -317,7 +317,7 @@ static void ImGui_ImplDX11_CreateFontsTexture() } // Store our identifier - io.Fonts->TexID = (ImTextureID)g_pFontTextureView; + io.Fonts->SetTexID((ImTextureID)g_pFontTextureView); // Create texture sampler { @@ -494,7 +494,7 @@ void ImGui_ImplDX11_InvalidateDeviceObjects() return; if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; } - if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. + if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } diff --git a/backends/imgui_impl_dx12.cpp b/backends/imgui_impl_dx12.cpp index 3f9f69653..39ca8f8df 100644 --- a/backends/imgui_impl_dx12.cpp +++ b/backends/imgui_impl_dx12.cpp @@ -395,7 +395,7 @@ static void ImGui_ImplDX12_CreateFontsTexture() // Store our identifier static_assert(sizeof(ImTextureID) >= sizeof(g_hFontSrvGpuDescHandle.ptr), "Can't pack descriptor handle into TexID, 32-bit not supported yet."); - io.Fonts->TexID = (ImTextureID)g_hFontSrvGpuDescHandle.ptr; + io.Fonts->SetTexID((ImTextureID)g_hFontSrvGpuDescHandle.ptr); } bool ImGui_ImplDX12_CreateDeviceObjects() @@ -640,7 +640,7 @@ void ImGui_ImplDX12_InvalidateDeviceObjects() SafeRelease(g_pFontTextureResource); ImGuiIO& io = ImGui::GetIO(); - io.Fonts->TexID = NULL; // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. + io.Fonts->SetTexID(NULL); // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. for (UINT i = 0; i < g_numFramesInFlight; i++) { diff --git a/backends/imgui_impl_dx9.cpp b/backends/imgui_impl_dx9.cpp index 0565ff4f6..2a575e81d 100644 --- a/backends/imgui_impl_dx9.cpp +++ b/backends/imgui_impl_dx9.cpp @@ -253,7 +253,7 @@ static bool ImGui_ImplDX9_CreateFontsTexture() g_FontTexture->UnlockRect(0); // Store our identifier - io.Fonts->TexID = (ImTextureID)g_FontTexture; + io.Fonts->SetTexID((ImTextureID)g_FontTexture); return true; } @@ -273,7 +273,7 @@ void ImGui_ImplDX9_InvalidateDeviceObjects() return; if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } - if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. + if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. } void ImGui_ImplDX9_NewFrame() diff --git a/backends/imgui_impl_marmalade.cpp b/backends/imgui_impl_marmalade.cpp index 805d0c3ea..c4f83a804 100644 --- a/backends/imgui_impl_marmalade.cpp +++ b/backends/imgui_impl_marmalade.cpp @@ -194,7 +194,7 @@ bool ImGui_Marmalade_CreateDeviceObjects() g_FontTexture->Upload(); // Store our identifier - io.Fonts->TexID = (ImTextureID)g_FontTexture; + io.Fonts->SetTexID((ImTextureID)g_FontTexture); return true; } @@ -209,8 +209,8 @@ void ImGui_Marmalade_InvalidateDeviceObjects() if (g_FontTexture) { + ImGui::GetIO().Fonts->SetTexID(0); delete g_FontTexture; - ImGui::GetIO().Fonts->TexID = 0; g_FontTexture = NULL; } } diff --git a/backends/imgui_impl_metal.mm b/backends/imgui_impl_metal.mm index d368daad7..b67c3ef3f 100644 --- a/backends/imgui_impl_metal.mm +++ b/backends/imgui_impl_metal.mm @@ -114,7 +114,7 @@ bool ImGui_ImplMetal_CreateFontsTexture(id device) [g_sharedMetalContext makeFontTextureWithDevice:device]; ImGuiIO& io = ImGui::GetIO(); - io.Fonts->TexID = (__bridge void *)g_sharedMetalContext.fontTexture; // ImTextureID == void* + io.Fonts->SetTexID((__bridge void *)g_sharedMetalContext.fontTexture); // ImTextureID == void* return (g_sharedMetalContext.fontTexture != nil); } @@ -123,7 +123,7 @@ void ImGui_ImplMetal_DestroyFontsTexture() { ImGuiIO& io = ImGui::GetIO(); g_sharedMetalContext.fontTexture = nil; - io.Fonts->TexID = nullptr; + io.Fonts->SetTexID(nullptr); } bool ImGui_ImplMetal_CreateDeviceObjects(id device) diff --git a/backends/imgui_impl_opengl2.cpp b/backends/imgui_impl_opengl2.cpp index cf860d7e1..1419e2d85 100644 --- a/backends/imgui_impl_opengl2.cpp +++ b/backends/imgui_impl_opengl2.cpp @@ -227,7 +227,7 @@ bool ImGui_ImplOpenGL2_CreateFontsTexture() glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // Store our identifier - io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture; + io.Fonts->SetTexID((ImTextureID)(intptr_t)g_FontTexture); // Restore state glBindTexture(GL_TEXTURE_2D, last_texture); @@ -241,7 +241,7 @@ void ImGui_ImplOpenGL2_DestroyFontsTexture() { ImGuiIO& io = ImGui::GetIO(); glDeleteTextures(1, &g_FontTexture); - io.Fonts->TexID = 0; + io.Fonts->SetTexID(0); g_FontTexture = 0; } } diff --git a/backends/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp index cd9e385c3..f3b2a937b 100644 --- a/backends/imgui_impl_opengl3.cpp +++ b/backends/imgui_impl_opengl3.cpp @@ -470,7 +470,7 @@ bool ImGui_ImplOpenGL3_CreateFontsTexture() glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // Store our identifier - io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture; + io.Fonts->SetTexID((ImTextureID)(intptr_t)g_FontTexture); // Restore state glBindTexture(GL_TEXTURE_2D, last_texture); @@ -484,7 +484,7 @@ void ImGui_ImplOpenGL3_DestroyFontsTexture() { ImGuiIO& io = ImGui::GetIO(); glDeleteTextures(1, &g_FontTexture); - io.Fonts->TexID = 0; + io.Fonts->SetTexID(0); g_FontTexture = 0; } } diff --git a/backends/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp index bae3b2b3a..44a555a5d 100644 --- a/backends/imgui_impl_vulkan.cpp +++ b/backends/imgui_impl_vulkan.cpp @@ -661,7 +661,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer) } // Store our identifier - io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontImage; + io.Fonts->SetTexID((ImTextureID)(intptr_t)g_FontImage); return true; } diff --git a/backends/imgui_impl_wgpu.cpp b/backends/imgui_impl_wgpu.cpp index 3be468c70..089dbfd74 100644 --- a/backends/imgui_impl_wgpu.cpp +++ b/backends/imgui_impl_wgpu.cpp @@ -532,7 +532,7 @@ static void ImGui_ImplWGPU_CreateFontsTexture() // Store our identifier static_assert(sizeof(ImTextureID) >= sizeof(g_resources.FontTexture), "Can't pack descriptor handle into TexID, 32-bit not supported yet."); - io.Fonts->TexID = (ImTextureID)g_resources.FontTextureView; + io.Fonts->SetTexID((ImTextureID)g_resources.FontTextureView); } static void ImGui_ImplWGPU_CreateUniformBuffer() @@ -722,7 +722,7 @@ void ImGui_ImplWGPU_InvalidateDeviceObjects() SafeRelease(g_resources); ImGuiIO& io = ImGui::GetIO(); - io.Fonts->TexID = NULL; // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. + io.Fonts->SetTexID(NULL); // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. for (unsigned int i = 0; i < g_numFramesInFlight; i++) SafeRelease(g_pFrameResources[i]); diff --git a/imgui.cpp b/imgui.cpp index 2aeb49bec..48b6f8ca7 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -238,7 +238,7 @@ CODE // After we have created the texture, store its pointer/identifier (_in whichever format your engine uses_) in 'io.Fonts->TexID'. // This will be passed back to your via the renderer. Basically ImTextureID == void*. Read FAQ for details about ImTextureID. MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA32) - io.Fonts->TexID = (void*)texture; + io.Fonts->SetTexID((void*)texture); // Application main loop while (true) @@ -622,9 +622,9 @@ CODE - 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader. - 2015/01/11 (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels. - old: const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); [..Upload texture to GPU..]; - - new: unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); [..Upload texture to GPU..]; io.Fonts->TexId = YourTexIdentifier; + - new: unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); [..Upload texture to GPU..]; io.Fonts->SetTexID(YourTexIdentifier); you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs. It is now recommended that you sample the font texture with bilinear interpolation. - - 2015/01/11 (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID. + - 2015/01/11 (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to call io.Fonts->SetTexID() - 2015/01/11 (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix) - 2015/01/11 (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets - 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver)