Browse Source

Minor example updates / address comments

pull/4/head
Ian Chamberlain 2 years ago
parent
commit
748e34e5f1
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 21
      citro3d/examples/triangle.rs

21
citro3d/examples/triangle.rs

@ -1,4 +1,4 @@
use citro3d::render::ClearFlags; use citro3d::render::{ClearFlags, Target};
use citro3d::{include_aligned_bytes, shader}; use citro3d::{include_aligned_bytes, shader};
use citro3d_sys::C3D_Mtx; use citro3d_sys::C3D_Mtx;
use ctru::gfx::{Gfx, Screen}; use ctru::gfx::{Gfx, Screen};
@ -64,7 +64,7 @@ fn main() {
let mut instance = citro3d::Instance::new().expect("failed to initialize Citro3D"); let mut instance = citro3d::Instance::new().expect("failed to initialize Citro3D");
let mut render_target = citro3d::render::Target::new(width, height, top_screen, None) let mut top_target = citro3d::render::Target::new(width, height, top_screen, None)
.expect("failed to create render target"); .expect("failed to create render target");
let mut bottom_screen = gfx.bottom_screen.borrow_mut(); let mut bottom_screen = gfx.bottom_screen.borrow_mut();
@ -88,25 +88,20 @@ fn main() {
break; break;
} }
let mut render_to = |target: &mut Target| {
instance.render_frame_with(|instance| { instance.render_frame_with(|instance| {
instance instance
.select_render_target(&render_target) .select_render_target(target)
.expect("failed to set render target"); .expect("failed to set render target");
let clear_color: u32 = 0x7F_7F_7F_FF; let clear_color: u32 = 0x7F_7F_7F_FF;
render_target.clear(ClearFlags::ALL, clear_color, 0); target.clear(ClearFlags::ALL, clear_color, 0);
scene_render(uloc_projection.into(), &projection); scene_render(uloc_projection.into(), &projection);
}); });
};
instance.render_frame_with(|instance| { render_to(&mut top_target);
instance render_to(&mut bottom_target);
.select_render_target(&bottom_target)
.expect("failed to set render target");
let clear_color: u32 = 0x7F_7F_7F_FF;
bottom_target.clear(ClearFlags::ALL, clear_color, 0);
scene_render(uloc_projection.into(), &projection);
});
} }
scene_exit(vbo_data); scene_exit(vbo_data);

Loading…
Cancel
Save