Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update only all UV(s) of texts in all drawlist(s) after fonts change? #4637

Closed
mandaxyzw opened this issue Oct 7, 2021 · 1 comment

Comments

@mandaxyzw
Copy link

mandaxyzw commented Oct 7, 2021

Version/Branch of Dear ImGui:

Version: v1.84
Branch:

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
Compiler: Visual Studio 2015
Operating System: Windows 10

My Issue/Question:
How to update only all UV(s) of texts in all drawlist(s) after fonts change?

I want to build a big project using dynamic fonts like resizing fonts at any time, for example zooming a node editor containing texts. And when I do that, the fonts list will be change a lot then all the other texts that are already drawn become expired.

The texture of the font atlas (before / after)
texture

Imagery explanation of the problem which is just a theory image but not a real screenshot
Zoom
The reason of the glitch in the image above: The texts on the right are already drawn in the beginning with old UV(s)'s locations, but when there is a new added font, then those UV(s) become expired because all texture atlases are packed into one texture, and only the new added font's UV(s) are updated to the latest UV(s).

The reason it's important for me to ask the question is it's a big decision for the entire project on UI, because if I don't ask the question then when there's a fonts change, I will re-draw all drawlist(s) including drawlist(s) that don't literally need update.

So, does updating only UV(s) of texts in all drawlist(s) exist? Or how to fix my issue? Thanks.

@mandaxyzw mandaxyzw changed the title How to update only all UV(s) in all drawlist(s) after fonts change? How to update only all UV(s) of texts in all drawlist(s) after fonts change? Oct 7, 2021
@ocornut
Copy link
Owner

ocornut commented Oct 7, 2021

Your two sections "The texture of the font atlas (before / after)" and "Imagery explanation of the problem which is just a theory image" are contradicting themselves. In the first, the previous fonts are still loaded, in the second, they aren't.

I'm going to go for the first thing because the later makes less sense.

I guess you could attempt to build a list/map of font+character to UV for both old and new state, then iterate all windows, find active draw lists, parse every vertices, find UV values in the "old" map and replace them with UV value in the "new" map.

As part of #3761 + #3471 we expect to do something like that to cover the rare case of mid-frame atlas compaction.

Right now if you are trying to do something that fancy you are on your own (I don't think anyone will write the code for you and it's not going to be simple, you have all the data at your disposal to do it).

@ocornut ocornut closed this as completed Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants