@ -81,20 +81,32 @@ pub struct TopScreen3D<'top_screen> {
}
}
pub trait Swap : private ::Sealed {
pub trait Swap : private ::Sealed {
/// Swaps the video buffers.
///
/// This should be used even if double buffering is disabled.
fn swap_buffers ( & mut self ) ;
fn swap_buffers ( & mut self ) ;
}
}
trait SwappableScreen : Screen { }
impl Swap for TopScreen3D < ' _ > {
impl SwappableScreen for TopScreen { }
fn swap_buffers ( & mut self ) {
impl SwappableScreen for BottomScreen { }
unsafe {
ctru_sys ::gfxScreenSwapBuffers ( ctru_sys ::GFX_TOP , true ) ;
}
}
}
impl < S : SwappableScreen > Swap for S {
impl Swap for TopScreen {
/// Swaps the video buffers.
fn swap_buffers ( & mut self ) {
///
unsafe {
/// This should be used even if double buffering is disabled.
ctru_sys ::gfxScreenSwapBuffers ( ctru_sys ::GFX_TOP , false ) ;
}
}
}
impl Swap for BottomScreen {
fn swap_buffers ( & mut self ) {
fn swap_buffers ( & mut self ) {
unsafe {
unsafe {
ctru_sys ::gfxScreenSwapBuffers ( self . side ( ) . into ( ) , false ) ;
ctru_sys ::gfxScreenSwapBuffers ( ctru_sys ::GFX_BOTTOM , false ) ;
}
}
}
}
}
}
@ -124,23 +136,6 @@ impl<S: FlushableScreen> Flush for S {
}
}
}
}
impl Swap for TopScreen3D < ' _ > {
fn swap_buffers ( & mut self ) {
unsafe {
ctru_sys ::gfxScreenSwapBuffers ( Side ::Left . into ( ) , true ) ;
}
}
}
impl TopScreen3D < ' _ > {
/// 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 ( ) ;
}
}
/// The left side of the top screen, when using 3D mode.
/// The left side of the top screen, when using 3D mode.
#[ derive(Debug) ]
#[ derive(Debug) ]
#[ non_exhaustive ]
#[ non_exhaustive ]
@ -253,6 +248,13 @@ impl TopScreen3D<'_> {
( & mut screen . left as _ , & mut screen . right as _ )
( & 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 < TopScreen > > for TopScreen3D < ' top_screen > {
impl < ' top_screen > From < & ' top_screen RefCell < TopScreen > > for TopScreen3D < ' top_screen > {
@ -296,7 +298,7 @@ impl TopScreen {
impl Screen for TopScreen {
impl Screen for TopScreen {
fn as_raw ( & self ) -> ctru_sys ::gfxScreen_t {
fn as_raw ( & self ) -> ctru_sys ::gfxScreen_t {
self . left . as_raw ( )
ctru_sys ::GFX_TOP
}
}
fn side ( & self ) -> Side {
fn side ( & self ) -> Side {