pub fn run(mut self) {
        // Start the winit window event loop.
        let events_loop = winit::EventsLoop::new();

        // Keep track of whether or not a debug cb was specified so we know what default extensions
        // and layers are necessary.
        let debug_callback_specified = self.vk_debug_callback.is_some();

        #[cfg(all(target_os = "macos", not(test)))]
        let moltenvk_settings = self.moltenvk_settings;

        // The vulkan instance necessary for graphics.
        let vk_instance = self.vk_instance.take().unwrap_or_else(|| {
            if debug_callback_specified {
                let vk_builder = vk::InstanceBuilder::new();

                #[cfg(all(target_os = "macos", not(test)))]
                let vk_builder = vk::check_moltenvk(vk_builder, moltenvk_settings);

                #[cfg(any(not(target_os = "macos"), test))]
                let vk_builder = vk_builder.extensions(vk::required_windowing_extensions());

                vk_builder
                    .add_extensions(vk::InstanceExtensions {
                        ext_debug_utils: true,
                        ..vk::InstanceExtensions::none()
                    })
                    .layers(vec!["VK_LAYER_LUNARG_standard_validation"])
                    .build()
                    .expect("failed to create vulkan instance")
            } else {
                let vk_builder = vk::InstanceBuilder::new();

                #[cfg(all(target_os = "macos", not(test)))]
                let vk_builder = vk::check_moltenvk(vk_builder, moltenvk_settings);

                #[cfg(any(not(target_os = "macos"), test))]
                let vk_builder = vk_builder.extensions(vk::required_windowing_extensions());

                vk_builder
                    .build()
                    .expect("failed to create vulkan instance")
            }
        });

        // If a callback was specified, build it with the created instance.
        let _vk_debug_callback = self.vk_debug_callback.take().map(|builder| {
            builder
                .build(&vk_instance)
                .expect("failed to build vulkan debug callback")
        });

        // Initialise the app.
        let app = App::new(events_loop, vk_instance).expect("failed to construct `App`");

        // Create the default window if necessary
        if self.create_default_window {
            let window_id = app
                .new_window()
                .build()
                .expect("could not build default app window");
            *app.focused_window.borrow_mut() = Some(window_id);
        }

        // Call the user's model function.
        let model = (self.model)(&app);

        // If there is not yet some default window in "focus" check to see if one has been created.
        if app.focused_window.borrow().is_none() {
            if let Some(id) = app.windows.borrow().keys().next() {
                *app.focused_window.borrow_mut() = Some(id.clone());
            }
        }

        // If the loop mode was set in the user's model function, ensure all window swapchains are
        // re-created appropriately.
        let loop_mode = app.loop_mode();
        if loop_mode != LoopMode::default() {
            let mut windows = app.windows.borrow_mut();
            for window in windows.values_mut() {
                let capabilities = window
                    .surface
                    .capabilities(window.swapchain.device().physical_device())
                    .expect("failed to get surface capabilities");
                let min_image_count = capabilities.min_image_count;
                let user_specified_present_mode = window.user_specified_present_mode;
                let user_specified_image_count = window.user_specified_image_count;
                let (present_mode, image_count) = window::preferred_present_mode_and_image_count(
                    &loop_mode,
                    min_image_count,
                    user_specified_present_mode,
                    user_specified_image_count,
                    &capabilities.present_modes,
                );
                if window.swapchain.present_mode() != present_mode
                    || window.swapchain.num_images() != image_count
                {
                    change_loop_mode_for_window(window, &loop_mode);
                }
            }
        }

        run_loop(
            app,
            model,
            self.event,
            self.update,
            self.default_view,
            self.exit,
        );
    }
/// Build and run an `App` with the specified parameters.
///
/// This function will not return until the application has exited.
///
/// If you wish to remain cross-platform frienly, we recommend that you call this on the main
/// thread as some platforms require that their application event loop and windows are
/// initialised on the main thread.
Build and run an `App` with the specified parameters.
This function will not return until the application has exited.

If you wish to remain cross-platform frienly, we recommend that you call this on the main
thread as some platforms require that their application event loop and windows are
initialised on the main thread.
Build and run an ` App ` with the specified parameters . This function will not return until the application has exited . If you wish to remain cross - platform frienly we recommend that you call this on the main thread as some platforms require that their application event loop and windows are initialised on the main thread .
pub fn run(mut self) {
        // Start the winit window event loop.
        let events_loop = winit::EventsLoop::new();
        // Keep track of whether or not a debug cb was specified so we know what default extensions
        // and layers are necessary.
        let debug_callback_specified = self.vk_debug_callback.is_some();
        #[cfg(all(target_os = "macos", not(test)))]
        let moltenvk_settings = self.moltenvk_settings;
        // The vulkan instance necessary for graphics.
        let vk_instance = self.vk_instance.take().unwrap_or_else(|| {
            if debug_callback_specified {
                let vk_builder = vk::InstanceBuilder::new();
                #[cfg(all(target_os = "macos", not(test)))]
                let vk_builder = vk::check_moltenvk(vk_builder, moltenvk_settings);
                #[cfg(any(not(target_os = "macos"), test))]
                let vk_builder = vk_builder.extensions(vk::required_windowing_extensions());
                vk_builder
                    .add_extensions(vk::InstanceExtensions {
                        ext_debug_utils: true,
                        ..vk::InstanceExtensions::none()
                    })
                    .layers(vec!["VK_LAYER_LUNARG_standard_validation"])
                    .build()
                    .expect("failed to create vulkan instance")
            } else {
                let vk_builder = vk::InstanceBuilder::new();
                #[cfg(all(target_os = "macos", not(test)))]
                let vk_builder = vk::check_moltenvk(vk_builder, moltenvk_settings);
                #[cfg(any(not(target_os = "macos"), test))]
                let vk_builder = vk_builder.extensions(vk::required_windowing_extensions());
                vk_builder
                    .build()
                    .expect("failed to create vulkan instance")
            }
        });
        // If a callback was specified, build it with the created instance.
        let _vk_debug_callback = self.vk_debug_callback.take().map(|builder| {
            builder
                .build(&vk_instance)
                .expect("failed to build vulkan debug callback")
        });
        // Initialise the app.
        let app = App::new(events_loop, vk_instance).expect("failed to construct `App`");
        // Create the default window if necessary
        if self.create_default_window {
            let window_id = app
                .new_window()
                .build()
                .expect("could not build default app window");
            *app.focused_window.borrow_mut() = Some(window_id);
        }
        // Call the user's model function.
        let model = (self.model)(&app);
        // If there is not yet some default window in "focus" check to see if one has been created.
        if app.focused_window.borrow().is_none() {
            if let Some(id) = app.windows.borrow().keys().next() {
                *app.focused_window.borrow_mut() = Some(id.clone());
            }
        }
        // If the loop mode was set in the user's model function, ensure all window swapchains are
        // re-created appropriately.
        let loop_mode = app.loop_mode();
        if loop_mode != LoopMode::default() {
            let mut windows = app.windows.borrow_mut();
            for window in windows.values_mut() {
                let capabilities = window
                    .surface
                    .capabilities(window.swapchain.device().physical_device())
                    .expect("failed to get surface capabilities");
                let min_image_count = capabilities.min_image_count;
                let user_specified_present_mode = window.user_specified_present_mode;
                let user_specified_image_count = window.user_specified_image_count;
                let (present_mode, image_count) = window::preferred_present_mode_and_image_count(
                    &loop_mode,
                    min_image_count,
                    user_specified_present_mode,
                    user_specified_image_count,
                    &capabilities.present_modes,
                );
                if window.swapchain.present_mode() != present_mode
                    || window.swapchain.num_images() != image_count
                {
                    change_loop_mode_for_window(window, &loop_mode);
                }
            }
        }
        run_loop(
            app,
            model,
            self.event,
            self.update,
            self.default_view,
            self.exit,
        );
    }
pub fn run ( mut self ) { // Start the winit window event loop. let events_loop = winit :: EventsLoop :: new ( ) ; // Keep track of whether or not a debug cb was specified so we know what default extensions // and layers are necessary. let debug_callback_specified = self . vk_debug_callback . is_some ( ) ; # [ cfg ( all ( target_os " " not ( test ) ) ) ] let moltenvk_settings = self . moltenvk_settings ; // The vulkan instance necessary for graphics. let vk_instance = self . vk_instance . take ( ) . unwrap_or_else ( | | { if debug_callback_specified { let vk_builder = vk :: InstanceBuilder :: new ( ) ; # [ cfg ( all ( target_os " " not ( test ) ) ) ] let vk_builder = vk :: check_moltenvk ( vk_builder , moltenvk_settings ) ; # [ cfg ( any ( not ( target_os " " ) test ) ) ] let vk_builder = vk_builder . extensions ( vk :: required_windowing_extensions ( ) ) ; vk_builder . add_extensions ( vk :: InstanceExtensions { ext_debug_utils : true , .. vk :: InstanceExtensions :: none ( ) } ) . layers ( vec ! [ " " ] ) . build ( ) . expect ( " " ) } else { let vk_builder = vk :: InstanceBuilder :: new ( ) ; # [ cfg ( all ( target_os " " not ( test ) ) ) ] let vk_builder = vk :: check_moltenvk ( vk_builder , moltenvk_settings ) ; # [ cfg ( any ( not ( target_os " " ) test ) ) ] let vk_builder = vk_builder . extensions ( vk :: required_windowing_extensions ( ) ) ; vk_builder . build ( ) . expect ( " " ) } } ) ; // If a callback was specified, build it with the created instance. let _vk_debug_callback = self . vk_debug_callback . take ( ) . map ( | builder | { builder . build ( & vk_instance ) . expect ( " " ) } ) ; // Initialise the app. let app = App :: new ( events_loop , vk_instance ) . expect ( " " ) ; // Create the default window if necessary if self . create_default_window { let window_id = app . new_window ( ) . build ( ) . expect ( " " ) ; * app . focused_window . borrow_mut ( ) = Some ( window_id ) ; } // Call the user's model function. let model = ( self . model ) ( & app ) ; // If there is not yet some default window in "focus" check to see if one has been created. if app . focused_window . borrow ( ) . is_none ( ) { if let Some ( id ) = app . windows . borrow ( ) . keys ( ) . next ( ) { * app . focused_window . borrow_mut ( ) = Some ( id . clone ( ) ) ; } } // If the loop mode was set in the user's model function, ensure all window swapchains are // re-created appropriately. let loop_mode = app . loop_mode ( ) ; if loop_mode != LoopMode :: default ( ) { let mut windows = app . windows . borrow_mut ( ) ; for window in windows . values_mut ( ) { let capabilities = window . surface . capabilities ( window . swapchain . device ( ) . physical_device ( ) ) . expect ( " " ) ; let min_image_count = capabilities . min_image_count ; let user_specified_present_mode = window . user_specified_present_mode ; let user_specified_image_count = window . user_specified_image_count ; let ( present_mode , image_count ) = window :: preferred_present_mode_and_image_count ( & loop_mode , min_image_count , user_specified_present_mode , user_specified_image_count , & capabilities . present_modes , ) ; if window . swapchain . present_mode ( ) != present_mode || window . swapchain . num_images ( ) != image_count { change_loop_mode_for_window ( window , & loop_mode ) ; } } } run_loop ( app , model , self . event , self . update , self . default_view , self . exit , ) ; }
Build and run an `App` with the specified parameters.
Build and run an ` App ` with the specified parameters .
mut self
mut self