I spent about 1/2 an hour trying to work out why the run function wasn't visible. Can you spot why?
#![cfg(not(any(feature = "vulkan", feature = "dx12", feature = "metal")))]
compile_error!("must enable a backend feature");
#[cfg(feature = "dx12")]
use gfx_backend_dx12 as back;
#[cfg(feature = "metal")]
use gfx_backend_metal as back;
#[cfg(feature = "vulkan")]
use gfx_backend_vulkan as back;
use gfx_hal as hal;
pub mod path;
const DIMS: Extent2D = Extent2D {
width: 1024,
height: 768,
};
const ENTRY_NAME: &str = "main";
#[derive(Debug, Clone, Copy)]
#[allow(non_snake_case)]
struct Vertex {
a_Pos: [f32; 2],
}
#[cfg_attr(rustfmt, rustfmt_skip)]
const QUAD: [Vertex; 3] = [
Vertex { a_Pos: [-0.5,-1.0 ] },
Vertex { a_Pos: [ 1.0, 0.0 ] },
Vertex { a_Pos: [ 0.5,-1.0 ] },
];
pub fn run() -> Result<(), failure::Error> {
env_logger::init();
// winit
let mut events_loop = winit::EventsLoop::new();
let wb = winit::WindowBuilder::new()
.with_dimensions(winit::dpi::LogicalSize::new(
DIMS.width as _,
DIMS.height as _,
))
.with_title("quad".to_string());
let window = wb.build(&events_loop).context("creating window")?;
// instance
let instance = back::Instance::create("gfx-rs quad", 1);
let surface = instance.create_surface(&window);
let adapter = instance.enumerate_adapters();
}
Hopefully you won't have to sit for quite as long if you make the same mistake ![]()
EDIT oops had the corrected version of the code. (un)fixed to the broken version now.