From 41ab3643840f46a512e5f80e8975b01deafbc1a8 Mon Sep 17 00:00:00 2001 From: Jack Mac Date: Sun, 26 Sep 2021 21:11:39 -0400 Subject: [PATCH] and added the thorn in this method --- imgui/src/context.rs | 16 ++++++++++++++-- imgui/src/lib.rs | 20 -------------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/imgui/src/context.rs b/imgui/src/context.rs index e8f3e09..b9e97cc 100644 --- a/imgui/src/context.rs +++ b/imgui/src/context.rs @@ -10,8 +10,8 @@ use crate::clipboard::{ClipboardBackend, ClipboardContext}; use crate::fonts::atlas::{FontAtlas, FontAtlasRefMut, FontId, SharedFontAtlas}; use crate::io::Io; use crate::style::Style; -use crate::sys; use crate::Ui; +use crate::{sys, DrawData}; /// An imgui-rs context. /// @@ -518,7 +518,6 @@ impl Context { } /// Starts a new frame. - #[deprecated(since = "0.9.0", note = "use `new_frame` instead")] pub fn frame(&mut self) -> &mut Ui { self.new_frame() } @@ -547,4 +546,17 @@ impl Context { &mut self.ui } + + /// Renders the frame and returns a reference to the resulting draw data. + /// + /// This should only be called after calling [`new_frame`]. + /// + /// [`new_frame`]: Self::new_frame + #[doc(alias = "Render", alias = "GetDrawData")] + pub fn render(&mut self) -> &DrawData { + unsafe { + sys::igRender(); + &*(sys::igGetDrawData() as *mut DrawData) + } + } } diff --git a/imgui/src/lib.rs b/imgui/src/lib.rs index 34a7154..4c2d040 100644 --- a/imgui/src/lib.rs +++ b/imgui/src/lib.rs @@ -196,28 +196,8 @@ impl Ui { pub fn clone_style(&self) -> Style { unsafe { *self.style() } } - // /// Renders the frame and returns a reference to the resulting draw data - // #[doc(alias = "Render", alias = "GetDrawData")] - // pub fn render(self) -> &DrawData { - // unsafe { - // sys::igRender(); - // &*(sys::igGetDrawData() as *mut DrawData) - // } - // } } -// TODO JACK YOU NEED TO MOVE THIS! -// impl Drop for Ui { -// #[doc(alias = "EndFrame")] -// fn drop(&mut self) { -// if !std::thread::panicking() { -// unsafe { -// sys::igEndFrame(); -// } -// } -// } -// } - /// # Demo, debug, information impl Ui { /// Renders a demo window (previously called a test window), which demonstrates most