From e06114d081ccc6dc0aa19f536aeea349cb801af0 Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Thu, 6 Apr 2023 11:32:28 +0200 Subject: [PATCH] Use usize in RawFrameBuffer --- ctru-rs/examples/gfx-3d-mode.rs | 6 ++++++ ctru-rs/src/services/gfx.rs | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ctru-rs/examples/gfx-3d-mode.rs b/ctru-rs/examples/gfx-3d-mode.rs index 8603a64..d0f77b2 100644 --- a/ctru-rs/examples/gfx-3d-mode.rs +++ b/ctru-rs/examples/gfx-3d-mode.rs @@ -61,6 +61,12 @@ fn main() { buf.copy_from(IMAGE.as_ptr(), IMAGE.len()); } + left.flush_buffer(); + left.swap_buffers(); + + right.flush_buffer(); + right.swap_buffers(); + //Wait for VBlank gfx.wait_for_vblank(); } diff --git a/ctru-rs/src/services/gfx.rs b/ctru-rs/src/services/gfx.rs index a4c5c17..52638c2 100644 --- a/ctru-rs/src/services/gfx.rs +++ b/ctru-rs/src/services/gfx.rs @@ -34,15 +34,15 @@ pub trait Screen: private::Sealed { /// Note that the pointer of the framebuffer returned by this function can /// change after each call to this function if double buffering is enabled. fn raw_framebuffer(&mut self) -> RawFrameBuffer { - let mut width = 0; - let mut height = 0; + let mut width: u16 = 0; + let mut height: u16 = 0; let ptr = unsafe { ctru_sys::gfxGetFramebuffer(self.as_raw(), self.side().into(), &mut width, &mut height) }; RawFrameBuffer { ptr, - width, - height, + width: width.into(), + height: height.into(), screen: PhantomData, } } @@ -62,7 +62,7 @@ pub trait Screen: private::Sealed { let framebuffer = self.raw_framebuffer(); // Flush the data array. `self.raw_framebuffer` should get the correct parameters for all kinds of screens - unsafe { ctru_sys::GSPGPU_FlushDataCache(framebuffer.ptr.cast(), (framebuffer.height * framebuffer.width).into()) }; + unsafe { ctru_sys::GSPGPU_FlushDataCache(framebuffer.ptr.cast(), (framebuffer.height * framebuffer.width) as u32) }; } /// Swaps the video buffers. @@ -113,9 +113,9 @@ pub struct RawFrameBuffer<'screen> { /// Pointer to graphics data to be rendered. pub ptr: *mut u8, /// The width of the framebuffer in pixels. - pub width: u16, + pub width: usize, /// The height of the framebuffer in pixels. - pub height: u16, + pub height: usize, /// Keep a mutable reference to the Screen for which this framebuffer is tied. screen: PhantomData<&'screen mut dyn Screen>, }