Skip to content

Commit

Permalink
Fix test and document select_render_target errs
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-h-chamberlain committed Jan 7, 2024
1 parent 700646e commit 7608d45
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions citro3d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ impl Instance {
render::Target::new(width, height, screen, depth_format, Rc::clone(&self.queue))
}

/// Select the given render target for drawing the frame.
/// Select the given render target for drawing the frame. This must be called
/// as pare of a render call (i.e. within the call to
/// [`render_frame_with`](Self::render_frame_with)).
///
/// # Errors
///
/// Fails if the given target cannot be used for drawing.
/// Fails if the given target cannot be used for drawing, or called outside
/// the context of a frame render.
#[doc(alias = "C3D_FrameDrawOn")]
pub fn select_render_target(&mut self, target: &render::Target<'_>) -> Result<()> {
let _ = self;
Expand Down Expand Up @@ -286,7 +289,9 @@ mod tests {
let mut instance = Instance::new().unwrap();
let target = instance.render_target(10, 10, screen, None).unwrap();

instance.select_render_target(&target).unwrap();
instance.render_frame_with(|instance| {
instance.select_render_target(&target).unwrap();
});

// Check that we don't get a double-free or use-after-free by dropping
// the global instance before dropping the target.
Expand Down

0 comments on commit 7608d45

Please sign in to comment.