Browse Source

Merge pull request #12 from AzureMarker/feature/gfx-wide-mode

pull/13/head
Meziu 3 years ago committed by GitHub
parent
commit
2fd19e68dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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 @@ @@ -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 { @@ -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.
///
/// Note that even when double buffering is disabled, one should still use the `swap_buffers`

Loading…
Cancel
Save