Fixed SharedFontAtlas not being used

When creating a new imgui context, the optional shared font atlas was not being used.
This commit is contained in:
Dominik Gschwind 2020-08-18 12:59:49 +02:00
parent d5be602f73
commit 7c084caa1a
2 changed files with 11 additions and 2 deletions

View File

@ -209,9 +209,18 @@ impl Context {
no_current_context(),
"A new active context cannot be created, because another one already exists"
);
let shared_font_atlas_ptr = match &shared_font_atlas {
Some(shared_font_atlas) => {
let borrowed_font_atlas = shared_font_atlas.borrow();
borrowed_font_atlas.0
}
None => ptr::null_mut(),
};
// Dear ImGui implicitly sets the current context during igCreateContext if the current
// context doesn't exist
let raw = unsafe { sys::igCreateContext(ptr::null_mut()) };
let raw = unsafe { sys::igCreateContext(shared_font_atlas_ptr) };
Context {
raw,
shared_font_atlas,

View File

@ -409,7 +409,7 @@ pub struct FontAtlasTexture<'a> {
/// A font atlas that can be shared between contexts
#[derive(Debug)]
pub struct SharedFontAtlas(*mut sys::ImFontAtlas);
pub struct SharedFontAtlas(pub(crate) *mut sys::ImFontAtlas);
impl SharedFontAtlas {
pub fn create() -> SharedFontAtlas {