Browse Source

Add wait_for_vblank function

Also change gfx methods to take &self instead of unnecessarily taking &mut self
pull/10/head
Fenrir 7 years ago committed by FenrirWolf
parent
commit
224ed678db
  1. 23
      ctru-rs/src/gfx.rs

23
ctru-rs/src/gfx.rs

@ -60,14 +60,13 @@ impl From<Side> for ::libctru::gfx3dSide_t {
} }
impl Gfx { impl Gfx {
pub fn set_3d_enabled(&mut self, enabled: bool) { pub fn set_3d_enabled(&self, enabled: bool) {
unsafe { unsafe {
::libctru::gfxSet3D(enabled) ::libctru::gfxSet3D(enabled)
} }
} }
pub fn get_framebuffer(&mut self, screen: Screen, side: Side) -> (&'static mut [u8], u16, u16) { pub fn get_framebuffer(&self, screen: Screen, side: Side) -> (&'static mut [u8], u16, u16) {
use std::convert::Into;
unsafe { unsafe {
use std::slice::from_raw_parts_mut; use std::slice::from_raw_parts_mut;
@ -84,34 +83,38 @@ impl Gfx {
} }
} }
pub fn flush_buffers(&mut self) { pub fn flush_buffers(&self) {
unsafe { ::libctru::gfxFlushBuffers() }; unsafe { ::libctru::gfxFlushBuffers() };
} }
pub fn swap_buffers(&mut self) { pub fn swap_buffers(&self) {
unsafe { ::libctru::gfxSwapBuffers() }; unsafe { ::libctru::gfxSwapBuffers() };
} }
pub fn swap_buffers_gpu(&mut self) { pub fn swap_buffers_gpu(&self) {
unsafe { ::libctru::gfxSwapBuffersGpu() }; unsafe { ::libctru::gfxSwapBuffersGpu() };
} }
pub fn get_framebuffer_format(&self, screen: Screen) -> FramebufferFormat { pub fn get_framebuffer_format(&self, screen: Screen) -> FramebufferFormat {
use std::convert::Into;
unsafe { ::libctru::gfxGetScreenFormat(screen.into()).into() } unsafe { ::libctru::gfxGetScreenFormat(screen.into()).into() }
} }
pub fn set_framebuffer_format(&mut self, screen: Screen, pub fn set_framebuffer_format(&self, screen: Screen,
fmt: FramebufferFormat) { fmt: FramebufferFormat) {
use std::convert::Into;
unsafe { ::libctru::gfxSetScreenFormat(screen.into(), fmt.into()) } unsafe { ::libctru::gfxSetScreenFormat(screen.into(), fmt.into()) }
} }
pub fn set_double_buffering(&mut self, screen: Screen, enabled: bool) { pub fn set_double_buffering(&self, screen: Screen, enabled: bool) {
unsafe { unsafe {
::libctru::gfxSetDoubleBuffering(screen.into(), enabled) ::libctru::gfxSetDoubleBuffering(screen.into(), enabled)
} }
} }
pub fn wait_for_vblank(&self) {
unsafe {
::libctru::gspWaitForEvent(::libctru::GSPGPU_EVENT_VBlank0, true)
}
}
} }
impl Default for Gfx { impl Default for Gfx {

Loading…
Cancel
Save