From ccfd6b636a452acf2e1631b23abeae3ce069138e Mon Sep 17 00:00:00 2001 From: maik klein Date: Fri, 23 Dec 2016 02:45:47 +0100 Subject: [PATCH] Updated triangle for xlib loader --- examples/triangle/src/main.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/triangle/src/main.rs b/examples/triangle/src/main.rs index 615a74e..5a1e3d2 100644 --- a/examples/triangle/src/main.rs +++ b/examples/triangle/src/main.rs @@ -29,7 +29,10 @@ macro_rules! offset_of{ // Cross platform surface creation with GLFW #[cfg(all(unix, not(target_os = "android")))] -fn create_surface(instance: &Instance, window: &Window) -> Result { +fn create_surface(instance: &Instance, + entry: &Entry, + window: &Window) + -> Result { let x11_display = window.glfw.get_x11_display(); let x11_window = window.get_x11_window(); let x11_create_info = vk::XlibSurfaceCreateInfoKHR { @@ -39,7 +42,8 @@ fn create_surface(instance: &Instance, window: &Window) -> Result Some((*pdevice, index)), _ => None, @@ -205,7 +210,7 @@ fn main() { .unwrap(); let present_queue = device.get_device_queue(queue_family_index as u32, 0); - let surface_formats = instance.get_physical_device_surface_formats_khr(pdevice, surface) + let surface_formats = surface_loader.get_physical_device_surface_formats_khr(pdevice, surface) .unwrap(); let surface_format = surface_formats.iter() .map(|sfmt| { @@ -222,7 +227,7 @@ fn main() { .nth(0) .expect("Unable to find suitable surface format."); let surface_capabilities = - instance.get_physical_device_surface_capabilities_khr(pdevice, surface).unwrap(); + surface_loader.get_physical_device_surface_capabilities_khr(pdevice, surface).unwrap(); let desired_image_count = surface_capabilities.min_image_count + 1; assert!(surface_capabilities.min_image_count <= desired_image_count && surface_capabilities.max_image_count >= desired_image_count, @@ -243,8 +248,9 @@ fn main() { } else { surface_capabilities.current_transform }; - let present_modes = instance.get_physical_device_surface_present_modes_khr(pdevice, surface) - .unwrap(); + let present_modes = + surface_loader.get_physical_device_surface_present_modes_khr(pdevice, surface) + .unwrap(); let present_mode = present_modes.iter() .cloned() .find(|&mode| mode == vk::PresentModeKHR::Mailbox) @@ -927,7 +933,7 @@ fn main() { device.destroy_command_pool(pool); swapchain_loader.destroy_swapchain_khr(swapchain); device.destroy_device(); - instance.destroy_surface_khr(surface); + surface_loader.destroy_surface_khr(surface); instance.destroy_debug_report_callback_ext(debug_call_back); instance.destroy_instance(); }