diff --git a/ctru-rs/examples/camera-image.rs b/ctru-rs/examples/camera-image.rs index 010ef95..0042599 100644 --- a/ctru-rs/examples/camera-image.rs +++ b/ctru-rs/examples/camera-image.rs @@ -88,7 +88,7 @@ fn main() { rotate_image_to_screen(&buf, top_screen.raw_framebuffer().ptr, WIDTH, HEIGHT); // We will only flush the "camera" screen, since the other screen is handled by `Console` - top_screen.flush_buffer(); + top_screen.flush_buffers(); top_screen.swap_buffers(); gfx.wait_for_vblank(); diff --git a/ctru-rs/examples/graphics-bitmap.rs b/ctru-rs/examples/graphics-bitmap.rs index 01358ac..df9ce11 100644 --- a/ctru-rs/examples/graphics-bitmap.rs +++ b/ctru-rs/examples/graphics-bitmap.rs @@ -48,7 +48,7 @@ fn main() { } // Flush and swap framebuffers - bottom_screen.flush_buffer(); + bottom_screen.flush_buffers(); bottom_screen.swap_buffers(); //Wait for VBlank diff --git a/ctru-rs/src/services/gfx.rs b/ctru-rs/src/services/gfx.rs index edc1607..59cf829 100644 --- a/ctru-rs/src/services/gfx.rs +++ b/ctru-rs/src/services/gfx.rs @@ -112,18 +112,13 @@ impl Swap for BottomScreen { } pub trait Flush: private::Sealed { - /// Flushes the video buffer for this screen. - fn flush_buffer(&mut self); + /// Flushes the video buffer(s) for this screen. Note that you must still call + /// [`Swap::swap_buffers`] after this method for the buffer contents to be displayed. + fn flush_buffers(&mut self); } -trait FlushableScreen: Screen {} -impl FlushableScreen for TopScreen {} -impl FlushableScreen for BottomScreen {} -impl FlushableScreen for TopScreenLeft {} -impl FlushableScreen for TopScreenRight {} - -impl Flush for S { - fn flush_buffer(&mut self) { +impl Flush for S { + fn flush_buffers(&mut self) { let framebuffer = self.raw_framebuffer(); // Flush the data array. `self.raw_framebuffer` should get the correct parameters for all kinds of screens @@ -136,6 +131,16 @@ impl Flush for S { } } +impl Flush for TopScreen3D<'_> { + /// Unlike most other implementations of [`Flush`], this flushes the buffers for both + /// the left and right sides of the top screen. + fn flush_buffers(&mut self) { + let (mut left, mut right) = self.split_mut(); + left.flush_buffers(); + right.flush_buffers(); + } +} + /// The left side of the top screen, when using 3D mode. #[derive(Debug)] #[non_exhaustive] @@ -248,13 +253,6 @@ impl TopScreen3D<'_> { (&mut screen.left as _, &mut screen.right as _) }) } - - /// Convenient helper to flush the buffers for both the left and right sides of the screen. - pub fn flush_buffers(&mut self) { - let (mut left, mut right) = self.split_mut(); - left.flush_buffer(); - right.flush_buffer(); - } } impl<'top_screen> From<&'top_screen RefCell> for TopScreen3D<'top_screen> {