Created
February 13, 2019 17:04
-
-
Save Slabity/6b9a2e6f25a48b3f375b8c8ecfcf02da to your computer and use it in GitHub Desktop.
Simple rendy example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate winit; | |
| extern crate rendy; | |
| type Backend = rendy::vulkan::Backend; | |
| type Config = rendy::factory::Config; | |
| type Factory = rendy::factory::Factory<Backend>; | |
| type GraphBuilder = rendy::graph::GraphBuilder<Backend, ()>; | |
| type PresentNode = rendy::graph::present::PresentNode<Backend>; | |
| fn main() { | |
| let mut factory: Factory = Factory::new(Config::default()).unwrap(); | |
| let mut ev_loop = winit::EventsLoop::new(); | |
| let window = std::sync::Arc::new(winit::WindowBuilder::new() | |
| .with_title("Simple Rendy Renderer") | |
| .build(&ev_loop) | |
| .unwrap()); | |
| let surface = factory.create_surface(window.clone()); | |
| let mut graph_builder = GraphBuilder::new(); | |
| let color_image = graph_builder.create_image( | |
| surface.kind(), | |
| 1, | |
| factory.get_surface_format(&surface), | |
| rendy::memory::MemoryUsageValue::Data, | |
| Some(rendy::hal::command::ClearValue::Color([1.0, 0.0, 0.0, 1.0].into())) | |
| ); | |
| let subpass_node = rendy::graph::render::SubpassBuilder::new() | |
| .with_color(color_image) | |
| .into_pass(); | |
| let present_node = PresentNode::builder(surface, color_image); | |
| graph_builder.add_node(subpass_node); | |
| graph_builder.add_node(present_node); | |
| let mut graph = graph_builder.build(&mut factory, &mut ()).unwrap(); | |
| graph.run(&mut factory, &mut ()); | |
| println!("{:#?}", graph); | |
| ev_loop.run_forever(|event| { | |
| match event { | |
| winit::Event::WindowEvent { | |
| event: winit::WindowEvent::CloseRequested, | |
| .. | |
| } => winit::ControlFlow::Break, | |
| _ => winit::ControlFlow::Continue, | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment