diff --git a/.github/ISSUE_TEMPLATE/issue_template.yml b/.github/ISSUE_TEMPLATE/issue_template.yml index 46ed826d5..6ed62493a 100644 --- a/.github/ISSUE_TEMPLATE/issue_template.yml +++ b/.github/ISSUE_TEMPLATE/issue_template.yml @@ -4,7 +4,7 @@ body: - type: markdown attributes: value: | - FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions) + FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions) For anything else: **we are happy to use 'GitHub Issues' for many types of open-ended questions**. We are encouraging 'Issues' becoming a large, centralized, tagged, cross-referenced database of Dear ImGui contents. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users. diff --git a/docs/FONTS.md b/docs/FONTS.md index 7ed8fe026..95538f97d 100644 --- a/docs/FONTS.md +++ b/docs/FONTS.md @@ -105,6 +105,7 @@ io.Fonts->AddFontDefault(); ``` **Load .TTF/.OTF file with:** + 🆕 **Since 1.92, with an up to date backend: passing a size is not necessary** ```cpp ImGuiIO& io = ImGui::GetIO(); @@ -377,7 +378,7 @@ TL;DR; With the new system, it is recommended that you create a custom `ImFontLo You can ask questions in [#8466](https://github.com/ocornut/imgui/issues/8466). -🆕 **Before 1.92:** +**Before 1.92:** As an alternative to rendering colorful glyphs using imgui_freetype with `ImGuiFreeTypeBuilderFlags_LoadColor`, you may allocate your own space in the texture atlas and write yourself into it. **(This is a BETA api, use if you are familiar with dear imgui and with your rendering backend)** diff --git a/imgui.cpp b/imgui.cpp index f57c305b4..f7d2e7441 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -21,9 +21,10 @@ // - Issues & support ........... https://github.com/ocornut/imgui/issues // - Test Engine & Automation ... https://github.com/ocornut/imgui_test_engine (test suite, test engine to automate your apps) -// For first-time users having issues compiling/linking/running/loading fonts: +// For first-time users having issues compiling/linking/running: // please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above. // Everything else should be asked in 'Issues'! We are building a database of cross-linked knowledge there. +// Since 1.92, we encourage font loading question to also be posted in 'Issues'. // Copyright (c) 2014-2025 Omar Cornut // Developed by Omar Cornut and every direct or indirect contributors to the GitHub. @@ -347,12 +348,12 @@ CODE ImGui::Render(); // Update textures - for (ImTextureData* tex : ImGui::GetPlatformIO().Textures) + ImDrawData* draw_data = ImGui::GetDrawData(); + for (ImTextureData* tex : *draw_data->Textures) if (tex->Status != ImTextureStatus_OK) MyImGuiBackend_UpdateTexture(tex); // Render dear imgui contents, swap buffers - ImDrawData* draw_data = ImGui::GetDrawData(); MyImGuiBackend_RenderDrawData(draw_data); SwapBuffers(); } @@ -372,25 +373,32 @@ CODE { if (tex->Status == ImTextureStatus_WantCreate) { - // create texture based on tex->Width/Height/Pixels - // call tex->SetTexID() to specify backend-specific identifiers - // tex->Status = ImTextureStatus_OK; + // Width/Height/Pixels> + tex->SetTexID(xxxx); // specify backend-specific ImTextureID identifier + tex->SetStatus(ImTextureStatus_OK); + tex->BackendUserData = xxxx; // store more backend data } if (tex->Status == ImTextureStatus_WantUpdates) { - // update texture blocks based on tex->UpdateRect - // tex->Status = ImTextureStatus_OK; + // UpdateRect> + tex->SetStatus(ImTextureStatus_OK); } if (tex->Status == ImTextureStatus_WantDestroy) { - // destroy texture - // call tex->SetTexID(ImTextureID_Invalid) - // tex->Status = ImTextureStatus_Destroyed; + // + tex->SetTexID(ImTextureID_Invalid); + tex->SetStatus(ImTextureStatus_Destroyed); } } void MyImGuiBackend_RenderDrawData(ImDrawData* draw_data) { + if (draw_data->Textures != nullptr) + for (ImTextureData* tex : *draw_data->Textures) + if (tex->Status != ImTextureStatus_OK) + MyImGuiBackend_UpdateTexture(tex); + + // TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled // TODO: Setup texture sampling state: sample with bilinear filtering (NOT point/nearest filtering). Use 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines;' to allow point/nearest filtering. // TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize @@ -407,7 +415,10 @@ CODE const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; if (pcmd->UserCallback) { - pcmd->UserCallback(cmd_list, pcmd); + if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) + MyEngineResetRenderState(); + else + pcmd->UserCallback(cmd_list, pcmd); } else {