mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-16 22:40:48 +00:00
Font bug when using multiple instances #591
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#591
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is briefly mentioned in #586 but when I switch state via the
ImGui::SetInternalState()API, the fonts that is the not most recently created instance get corrupted. There is a work around. I run this code before the draw loops (OpenGL renderer):And immediately I bind the texture:
I am essentially reloading the OpenGL textures. Is this because
ImGui::SetInternalState()is moving the font texure around in memory and the OpenGL texture is referencing old memory? I haven't analysed the behaviour between switching internal states yet, but I thought I'd let you be aware of it.SetInternalState() is only assigning to a pointer so isn't affecting anything font related.
Now, I believe you that may be a bug but I would need more detailed information and ideally a repro. What may be obvious/trivial in your context may not be obvious everywhere.
How are you creating the second state? Are you reassigning the font atlas pointer?
I had the same issue few time ago while using 2 different ImGui contexts with their own fonts. After reading the source code I understood that you need to have separate texture atlases too.
So, create an additional atlas for each additional context, and when you SetInternalState you must swap the atlases too. It works perfectly well.
This isn't as intended, you should be able to share the same atlas for two instances.
I do create an additional atlas for each context. In fact, I have a
different OpenGL context per ImGui context. I will look at the code on
Monday and show you how I manage the ImGui contexts.
On Sun, 17 Apr 2016 at 07:08 omar notifications@github.com wrote:
Thanks!
Similarly, you should be able to reuse the same atlas if they are going to be the same (tho obviously you need to upload texture to your two opengl context and find a way to pass textureid that works for both).
This looks fishy so I'll need to give it a closer look.
This worked for me:
BUT I had to fix code in ImGui_ImplGlfw_NewFrame(), added the else statement else:
Maybe the sample code should be more aware of multiple contexts? Are you using this code as is, or something that made more sense for your own use of multiple contexts?
Also the InternalState function names/API sucks (will be renamed).
I will compare what you have to what I have on Monday and will report in!
On Sun, 17 Apr 2016 at 14:11 omar notifications@github.com wrote:
Immediately I notice that you're only using one OpenGL context, but if that
would affect anything, I couldn't tell you.
On Sun, 17 Apr 2016 at 17:22 Matt Davies mattie.davies@gmail.com wrote:
@Cthutu Any news on that?
I still have to admit that contexts are confusing because a) imgui_impl_xxx files aren't very context aware. b) Font Atlas being shared by default makes things confusing.
Would definitively need to clarify the situation with font atlas.
I haven't been able to check this out yet. I'm currently busy at ToJam but
when I get to work I will figure it out. But first I have to port my code
to use your tree nodes :) Sorry I can't be more timely on this but things
are a bit crazy at the moment. Expect a reply towards the end of the week.
On Sun, 8 May 2016 at 11:01 omar notifications@github.com wrote:
FYI, things have been delayed to Monday so I will look at updating my imgui
repo on Tuesday.
On Sun, 8 May 2016 at 12:22 Matt Davies mattie.davies@gmail.com wrote:
@Cthutu Any news of that? Still looking for a repro :)
Could we get to the bottom of this topic?
AFAIK:
@Cthutu The issues discussed here should now be clarified and fixed by the changes discussed in #1565.
Context creation is now explicit, and have a parameter to pass in a font atlas created by the user.
Read #1565 for details.