Browse Source

Fix test and document `select_render_target` errs

pull/38/head
Ian Chamberlain 12 months ago
parent
commit
7608d45c35
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 11
      citro3d/src/lib.rs

11
citro3d/src/lib.rs

@ -107,11 +107,14 @@ impl Instance {
render::Target::new(width, height, screen, depth_format, Rc::clone(&self.queue)) 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 /// # 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")] #[doc(alias = "C3D_FrameDrawOn")]
pub fn select_render_target(&mut self, target: &render::Target<'_>) -> Result<()> { pub fn select_render_target(&mut self, target: &render::Target<'_>) -> Result<()> {
let _ = self; let _ = self;
@ -286,7 +289,9 @@ mod tests {
let mut instance = Instance::new().unwrap(); let mut instance = Instance::new().unwrap();
let target = instance.render_target(10, 10, screen, None).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 // Check that we don't get a double-free or use-after-free by dropping
// the global instance before dropping the target. // the global instance before dropping the target.

Loading…
Cancel
Save