Browse Source

Render to the bottom screen in triangle example

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

30
citro3d/examples/triangle.rs

@ -59,12 +59,13 @@ fn main() { @@ -59,12 +59,13 @@ fn main() {
let mut top_screen = gfx.top_screen.borrow_mut();
let frame_buffer = top_screen.get_raw_framebuffer(Side::Left);
let (width, height) = (frame_buffer.width, frame_buffer.height);
let mut instance = citro3d::Instance::new().expect("failed to initialize Citro3D");
let mut render_target = citro3d::render::Target::new(
frame_buffer.width,
frame_buffer.height,
width,
height,
&mut *top_screen,
DepthFormat::Depth24Stencil8,
)
@ -72,6 +73,20 @@ fn main() { @@ -72,6 +73,20 @@ fn main() {
render_target.set_output(Side::Left);
let mut bottom_screen = gfx.bottom_screen.borrow_mut();
let frame_buffer = bottom_screen.get_raw_framebuffer();
let (width, height) = (frame_buffer.width, frame_buffer.height);
let mut bottom_target = citro3d::render::Target::new(
width,
height,
&mut *bottom_screen,
DepthFormat::Depth24Stencil8,
)
.expect("failed to create bottom screen render target");
bottom_target.set_output(Side::Left);
let shader = shader::Library::from_bytes(SHADER_BYTES).unwrap();
let vertex_shader = shader.get(0).unwrap();
@ -87,13 +102,22 @@ fn main() { @@ -87,13 +102,22 @@ fn main() {
}
instance.render_frame_with(|instance| {
instance
.select_render_target(&render_target)
.expect("failed to set render target");
let clear_color: u32 = 0x7F_7F_7F_FF;
render_target.clear(ClearFlags::ALL, clear_color, 0);
scene_render(uloc_projection.into(), &projection);
});
instance.render_frame_with(|instance| {
instance
.select_render_target(&render_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);
});
}

Loading…
Cancel
Save