Skip to content

Commit

Permalink
Fixed SharedFontAtlas not being used
Browse files Browse the repository at this point in the history
When creating a new imgui context, the optional shared font atlas was not being used.
  • Loading branch information
N3xed committed Aug 18, 2020
1 parent d5be602 commit 7c084ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/fonts/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7c084ca

Please sign in to comment.