Browse Source

Fix gfx nits

pull/137/head
Andrea Ciliberti 1 year ago
parent
commit
73aac708f1
  1. 27
      ctru-rs/src/services/gfx.rs

27
ctru-rs/src/services/gfx.rs

@ -321,21 +321,7 @@ impl Gfx {
top_fb_fmt: FramebufferFormat, top_fb_fmt: FramebufferFormat,
bottom_fb_fmt: FramebufferFormat, bottom_fb_fmt: FramebufferFormat,
) -> Result<Self> { ) -> Result<Self> {
let handler = ServiceReference::new( Self::with_configuration(top_fb_fmt, bottom_fb_fmt, false)
&GFX_ACTIVE,
|| unsafe {
ctru_sys::gfxInit(top_fb_fmt.into(), bottom_fb_fmt.into(), false);
Ok(())
},
|| unsafe { ctru_sys::gfxExit() },
)?;
Ok(Self {
top_screen: RefCell::new(TopScreen::new()),
bottom_screen: RefCell::new(BottomScreen),
_service_handler: handler,
})
} }
/// Initialize a new service handle with the chosen framebuffer formats on the VRAM for the top and bottom screens. /// Initialize a new service handle with the chosen framebuffer formats on the VRAM for the top and bottom screens.
@ -371,11 +357,20 @@ impl Gfx {
pub unsafe fn with_formats_vram( pub unsafe fn with_formats_vram(
top_fb_fmt: FramebufferFormat, top_fb_fmt: FramebufferFormat,
bottom_fb_fmt: FramebufferFormat, bottom_fb_fmt: FramebufferFormat,
) -> Result<Self> {
Self::with_configuration(top_fb_fmt, bottom_fb_fmt, true)
}
// Internal function to handle the initialization of `Gfx`.
fn with_configuration(
top_fb_fmt: FramebufferFormat,
bottom_fb_fmt: FramebufferFormat,
vram_buffer: bool,
) -> Result<Self> { ) -> Result<Self> {
let handler = ServiceReference::new( let handler = ServiceReference::new(
&GFX_ACTIVE, &GFX_ACTIVE,
|| unsafe { || unsafe {
ctru_sys::gfxInit(top_fb_fmt.into(), bottom_fb_fmt.into(), true); ctru_sys::gfxInit(top_fb_fmt.into(), bottom_fb_fmt.into(), vram_buffer);
Ok(()) Ok(())
}, },

Loading…
Cancel
Save