Browse Source

Add wide screen mode support to Gfx

pull/12/head
AzureMarker 3 years ago
parent
commit
07fe052d9a
No known key found for this signature in database
GPG Key ID: 47A133F3BF9D03D3
  1. 33
      ctru-rs/examples/gfx_wide_mode.rs
  2. 12
      ctru-rs/src/gfx.rs

33
ctru-rs/examples/gfx_wide_mode.rs

@ -0,0 +1,33 @@
extern crate ctru;
use ctru::console::Console;
use ctru::Gfx;
use ctru::gfx::Screen;
use ctru::services::{Apt, Hid};
use ctru::services::hid::KeyPad;
fn main() {
ctru::init();
let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap();
let gfx = Gfx::default();
let _console = Console::init(Screen::Top);
println!("Press A to enable/disable wide screen mode.");
while apt.main_loop() {
hid.scan_input();
if hid.keys_down().contains(KeyPad::KEY_START) {
break
}
if hid.keys_down().contains(KeyPad::KEY_A) {
gfx.set_wide_mode(!gfx.get_wide_mode());
}
gfx.flush_buffers();
gfx.swap_buffers();
gfx.wait_for_vblank();
}
}

12
ctru-rs/src/gfx.rs

@ -49,6 +49,18 @@ impl Gfx {
} }
} }
/// Enable or disable the wide screen mode (top screen).
///
/// This only works when 3D is disabled.
pub fn set_wide_mode(&self, enabled: bool) {
unsafe { libctru::gfxSetWide(enabled) };
}
/// Get the status of wide screen mode.
pub fn get_wide_mode(&self) -> bool {
unsafe { libctru::gfxIsWide() }
}
/// Sets whether to use double buffering. Enabled by default. /// Sets whether to use double buffering. Enabled by default.
/// ///
/// Note that even when double buffering is disabled, one should still use the `swap_buffers` /// Note that even when double buffering is disabled, one should still use the `swap_buffers`

Loading…
Cancel
Save