From 647a308ad3c72479a3f9dc321ee466b97ea77944 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 10 Feb 2021 17:27:33 +0100 Subject: [PATCH 1/2] Backends: GLFW: Add ImGui_ImplGlfw_InitForOther() instead of ImGui_ImplGlfw_InitForWebGPU() so it can be used for e.g. DX11. (#3632) Amend dff0044 --- backends/imgui_impl_glfw.cpp | 7 +++---- backends/imgui_impl_glfw.h | 2 +- docs/CHANGELOG.txt | 4 +--- examples/example_emscripten_wgpu/main.cpp | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/backends/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp index 0b9ac216..fbc167d6 100644 --- a/backends/imgui_impl_glfw.cpp +++ b/backends/imgui_impl_glfw.cpp @@ -63,8 +63,7 @@ enum GlfwClientApi { GlfwClientApi_Unknown, GlfwClientApi_OpenGL, - GlfwClientApi_Vulkan, - GlfwClientApi_WebGPU + GlfwClientApi_Vulkan }; static GLFWwindow* g_Window = NULL; // Main window static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown; @@ -232,9 +231,9 @@ bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks) return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan); } -bool ImGui_ImplGlfw_InitForWebGPU(GLFWwindow* window, bool install_callbacks) +bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks) { - return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_WebGPU); + return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Unknown); } void ImGui_ImplGlfw_Shutdown() diff --git a/backends/imgui_impl_glfw.h b/backends/imgui_impl_glfw.h index f04ba728..018f1a1e 100644 --- a/backends/imgui_impl_glfw.h +++ b/backends/imgui_impl_glfw.h @@ -23,7 +23,7 @@ struct GLFWwindow; IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); -IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForWebGPU(GLFWwindow* window, bool install_callbacks); +IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks); IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 23a99701..1ab32156 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -107,9 +107,7 @@ Other Changes: - Backends: WebGPU: Added enderer backend for WebGPU support (imgui_impl_wgpu.cpp) (#3632) [@bfierz] Please note that WebGPU is currently experimental, will not run on non-beta browsers, and may break. - Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz] -- Backends: GLFW: Added ImGui_ImplGlfw_InitForWebGPU() init point. It currently has strictly no effect on anything, - but because some multi-viewport renderers require knowledge of the render stack in the Platform back-end, we're - adding it for consistency. (#3632) +- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() init point to use with non OpenGL API. (#3632) ----------------------------------------------------------------------- diff --git a/examples/example_emscripten_wgpu/main.cpp b/examples/example_emscripten_wgpu/main.cpp index b550f9df..9b72ba9b 100644 --- a/examples/example_emscripten_wgpu/main.cpp +++ b/examples/example_emscripten_wgpu/main.cpp @@ -75,7 +75,7 @@ int main(int, char**) //ImGui::StyleColorsClassic(); // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForWebGPU(window, true); + ImGui_ImplGlfw_InitForOther(window, true); ImGui_ImplWGPU_Init(wgpu_device, 3, WGPUTextureFormat_RGBA8Unorm); // Load Fonts From 4df57136e9832327c11e48b5bfe00b0326bd5b63 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 10 Feb 2021 18:47:46 +0100 Subject: [PATCH 2/2] Version 1.81 --- docs/CHANGELOG.txt | 10 +++++----- docs/FONTS.md | 14 +++++++------- docs/README.md | 5 +++-- imgui.cpp | 2 +- imgui.h | 6 +++--- imgui_demo.cpp | 2 +- imgui_draw.cpp | 2 +- imgui_internal.h | 2 +- imgui_tables.cpp | 2 +- imgui_widgets.cpp | 2 +- misc/freetype/README.md | 7 ++++++- 11 files changed, 30 insertions(+), 24 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1ab32156..24f9f40c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -32,7 +32,7 @@ HOW TO UPDATE? ----------------------------------------------------------------------- - VERSION 1.81 WIP (In Progress) + VERSION 1.81 (Released 2021-02-10) ----------------------------------------------------------------------- Breaking Changes: @@ -90,15 +90,15 @@ Other Changes: Note that the rounding of either positions and widths are technically undesirable (e.g. #3437, #791) but variety of code is currently on it so we are first fixing current behavior before we'll eventually change it. - Log/Capture: Fix various new line/spacing issue when logging widgets. [@Xipiryon, @ocornut] -- Log/Capture: Improved the ascii look of various widgets, making large dumps more easily human readable. +- Log/Capture: Improved the ASCII look of various widgets, making large dumps more easily human readable. - ImDrawList: Fixed AddCircle()/AddCircleFilled() with (rad > 0.0f && rad < 1.0f && num_segments == 0). (#3738) Would lead to a buffer read overflow. - ImDrawList: Clarified PathArcTo() need for a_min <= a_max with an assert. - ImDrawList: Fixed PathArcToFast() handling of a_min > a_max. -- Metrics: Backported "Viewports" debug visualizer from 'docking' branch. +- Metrics: Back-ported "Viewports" debug visualizer from 'docking' branch. - Demo: Added 'Examples->Fullscreen Window' demo using GetMainViewport() values. (#3789) - Demo: 'Simple Overlay' demo now moves under main menu-bar (if any) using GetMainViewport()'s work area. -- Backends: Win32: Dynamically loading XInput DLL instead of linking with it, facilite compiling with +- Backends: Win32: Dynamically loading XInput DLL instead of linking with it, facilitate compiling with old WindowSDK versions or running on Windows 7. (#3646, #3645, #3248, #2716) [@Demonese] - Backends: Vulkan: Add support for custom Vulkan function loader and VK_NO_PROTOTYPES. (#3759, #3227) [@Hossein-Noroozpour] User needs to call ImGui_ImplVulkan_LoadFunctions() with their custom loader prior to other functions. @@ -107,7 +107,7 @@ Other Changes: - Backends: WebGPU: Added enderer backend for WebGPU support (imgui_impl_wgpu.cpp) (#3632) [@bfierz] Please note that WebGPU is currently experimental, will not run on non-beta browsers, and may break. - Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz] -- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() init point to use with non OpenGL API. (#3632) +- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() initialization call to use with non OpenGL API. (#3632) ----------------------------------------------------------------------- diff --git a/docs/FONTS.md b/docs/FONTS.md index 62815b82..474a2007 100644 --- a/docs/FONTS.md +++ b/docs/FONTS.md @@ -70,11 +70,13 @@ If you get an assert stating "Could not load font file!", your font filename is **Load multiple fonts:** ```cpp +// Init ImGuiIO& io = ImGui::GetIO(); ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels); ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels); - -// Select font at runtime +``` +```cpp +// In application loop: select font at runtime ImGui::Text("Hello"); // use the default font (which is the first loaded font) ImGui::PushFont(font2); ImGui::Text("Hello with another font"); @@ -145,20 +147,18 @@ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); **Font Atlas too large?** - If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API. The typical result of failing to upload a texture is if every glyphs appears as white rectangles. -- In particular, using a large range such as `GetGlyphRangesChineseSimplifiedCommon()` is not recommended unless you set `OversampleH`/`OversampleV` to 1 and use a small font size. -- Mind the fact that some graphics drivers have texture size limitation. -- If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours. +- Mind the fact that some graphics drivers have texture size limitation. If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours. Some solutions: 1. Reduce glyphs ranges by calculating them from source localization data. - You can use the `ImFontGlyphRangesBuilder` for this purpose, this will be the biggest win! + You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win! 2. You may reduce oversampling, e.g. `font_config.OversampleH = 2`, this will largely reduce your texture size. Note that while OversampleH = 2 looks visibly very close to 3 in most situations, with OversampleH = 1 the quality drop will be noticeable. 3. Set `io.Fonts.TexDesiredWidth` to specify a texture width to minimize texture height (see comment in `ImFontAtlas::Build()` function). 4. Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two. 5. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample). -6. To support the extended range of unicode beyond 0xFFFF (e.g. emoticons, dingbats, symbols, shapes, ancient languages, etc...) add `#define IMGUI_USE_WCHAR32`in your `imconfig.h` +6. To support the extended range of unicode beyond 0xFFFF (e.g. emoticons, dingbats, symbols, shapes, ancient languages, etc...) add `#define IMGUI_USE_WCHAR32`in your `imconfig.h`. ##### [Return to Index](#index) diff --git a/docs/README.md b/docs/README.md index c3d195ca..0da03cdf 100644 --- a/docs/README.md +++ b/docs/README.md @@ -20,7 +20,7 @@ Dear ImGui is designed to **enable fast iterations** and to **empower programmer Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard. -| [Usage](#usage) - [How it works](#how-it-works) - [Releases](#releases) - [Demo](#demo) - [Integration](#integration) | +| [Usage](#usage) - [How it works](#how-it-works) - [Releases & Changelogs](#releases--changelogs) - [Demo](#demo) - [Integration](#integration) | :----------------------------------------------------------: | | [Upcoming changes](#upcoming-changes) - [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](#sponsors) - [Credits](#credits) - [License](#license) | | [Wiki](https://github.com/ocornut/imgui/wiki) - [Languages & frameworks backends/bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) | @@ -93,9 +93,10 @@ Dear ImGui outputs vertex buffers and command lists that you can easily render i _A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._ -### Releases +### Releases & Changelogs See [Releases](https://github.com/ocornut/imgui/releases) page. +Reading the changelogs is a good way to keep up to date with the things Dear ImGui has to offer, and maybe will give you ideas of some features that you've been ignoring until now! ### Demo diff --git a/imgui.cpp b/imgui.cpp index a68aa4e8..0e401332 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.81 WIP +// dear imgui, v1.81 // (main code and documentation) // Help: diff --git a/imgui.h b/imgui.h index 10361646..408969ad 100644 --- a/imgui.h +++ b/imgui.h @@ -1,4 +1,4 @@ -// dear imgui, v1.81 WIP +// dear imgui, v1.81 // (headers) // Help: @@ -59,8 +59,8 @@ Index of this file: // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) -#define IMGUI_VERSION "1.81 WIP" -#define IMGUI_VERSION_NUM 18004 +#define IMGUI_VERSION "1.81" +#define IMGUI_VERSION_NUM 18100 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_HAS_TABLE diff --git a/imgui_demo.cpp b/imgui_demo.cpp index de5fe8da..90e91aa0 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.81 WIP +// dear imgui, v1.81 // (demo code) // Help: diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 6b1ccd0e..5c11a5b3 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.81 WIP +// dear imgui, v1.81 // (drawing and font code) /* diff --git a/imgui_internal.h b/imgui_internal.h index f69c1003..39caf6b6 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,4 +1,4 @@ -// dear imgui, v1.81 WIP +// dear imgui, v1.81 // (internal structures/api) // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 088726e7..61a84f9f 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.81 WIP +// dear imgui, v1.81 // (tables and columns code) /* diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e061694e..d2a4d1dc 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.81 WIP +// dear imgui, v1.81 // (widgets code) /* diff --git a/misc/freetype/README.md b/misc/freetype/README.md index 440fe859..a3db3534 100644 --- a/misc/freetype/README.md +++ b/misc/freetype/README.md @@ -21,5 +21,10 @@ The default Dear ImGui styles will be impacted by this change (alpha values will See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad ### Known issues -- `cfg.OversampleH`, `OversampleV` are ignored (but perhaps not so necessary with this rasterizer). +- Oversampling settins are ignored but also not so much necessary with the higher quality rendering. + +### Comparaison + +Small, thin anti-aliased fonts are typically benefiting a lots from Freetype's hinting: +![comparing_font_rasterizers](https://user-images.githubusercontent.com/8225057/107550178-fef87f00-6bd0-11eb-8d09-e2edb2f0ccfc.gif)