diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index fb83a837..099f8009 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1539,6 +1539,9 @@ impl Context { /// The total number of completed passes (usually there is one pass per rendered frame). /// /// Starts at zero, and is incremented for each completed pass inside of [`Self::run`] (usually once). + /// + /// If you instead want to know which pass index this is within the current frame, + /// use [`Self::current_pass_index`]. pub fn cumulative_pass_nr(&self) -> u64 { self.cumulative_pass_nr_for(self.viewport_id()) } @@ -1554,6 +1557,18 @@ impl Context { }) } + /// The index of the current pass in the current frame, starting at zero. + /// + /// Usually this is zero, but if something called [`Self::request_discard`] to do multi-pass layout, + /// then this will be incremented for each pass. + /// + /// This just reads the value of [`PlatformOutput::num_completed_passes`]. + /// + /// To know the total number of passes ever completed, use [`Self::cumulative_pass_nr`]. + pub fn current_pass_index(&self) -> usize { + self.output(|o| o.num_completed_passes) + } + /// Call this if there is need to repaint the UI, i.e. if you are showing an animation. /// /// If this is called at least once in a frame, then there will be another frame right after this. @@ -1726,7 +1741,7 @@ impl Context { /// This means the first pass will look glitchy, and ideally should not be shown to the user. /// So [`crate::Grid`] calls [`Self::request_discard`] to cover up this glitches. /// - /// There is a limit to how many passes egui will perform, set by [`Options::max_passes`]. + /// There is a limit to how many passes egui will perform, set by [`Options::max_passes`] (default=2). /// Therefore, the request might be declined. /// /// You can check if the current pass will be discarded with [`Self::will_discard`].