From daea4e42459ba77838184456913d4e77bc1984f9 Mon Sep 17 00:00:00 2001 From: Tamara Schmitz Date: Tue, 29 Aug 2023 01:14:54 +0200 Subject: [PATCH] fix triangle example --- citro3d/examples/triangle.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/citro3d/examples/triangle.rs b/citro3d/examples/triangle.rs index 50831e0..3817b07 100644 --- a/citro3d/examples/triangle.rs +++ b/citro3d/examples/triangle.rs @@ -3,7 +3,7 @@ use citro3d::render::{ClearFlags, Target}; use citro3d::{include_aligned_bytes, shader}; use citro3d_sys::C3D_Mtx; -use ctru::gfx::{Gfx, RawFrameBuffer, Screen}; +use ctru::services::gfx::{Gfx, RawFrameBuffer, Screen}; use ctru::services::apt::Apt; use ctru::services::hid::{Hid, KeyPad}; use ctru::services::soc::Soc; @@ -51,27 +51,25 @@ static SHADER_BYTES: &[u8] = include_aligned_bytes!(concat!(env!("OUT_DIR"), "/examples/assets/vshader.shbin")); fn main() { - ctru::init(); - - let mut soc = Soc::init().expect("failed to get SOC"); + let mut soc = Soc::new().expect("failed to get SOC"); drop(soc.redirect_to_3dslink(true, true)); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID controller"); - let apt = Apt::init().expect("Couldn't obtain APT controller"); + let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); let mut top_screen = gfx.top_screen.borrow_mut(); - let RawFrameBuffer { width, height, .. } = top_screen.get_raw_framebuffer(); + let RawFrameBuffer { width, height, .. } = top_screen.raw_framebuffer(); let mut instance = citro3d::Instance::new().expect("failed to initialize Citro3D"); - let mut top_target = citro3d::render::Target::new(width, height, top_screen, None) + let mut top_target = citro3d::render::Target::new(width.try_into().unwrap(), height.try_into().unwrap(), top_screen, None) .expect("failed to create render target"); let mut bottom_screen = gfx.bottom_screen.borrow_mut(); - let RawFrameBuffer { width, height, .. } = bottom_screen.get_raw_framebuffer(); + let RawFrameBuffer { width, height, .. } = bottom_screen.raw_framebuffer(); - let mut bottom_target = citro3d::render::Target::new(width, height, bottom_screen, None) + let mut bottom_target = citro3d::render::Target::new(width.try_into().unwrap(), height.try_into().unwrap(), bottom_screen, None) .expect("failed to create bottom screen render target"); let shader = shader::Library::from_bytes(SHADER_BYTES).unwrap(); @@ -87,7 +85,7 @@ fn main() { while apt.main_loop() { hid.scan_input(); - if hid.keys_down().contains(KeyPad::KEY_START) { + if hid.keys_down().contains(KeyPad::START) { break; }