Crate dacite_winit [] [src]

This is a small interoperability library for dacite and winit, which allows the creation of Vulkan surfaces in an easy and platform-independent manner.

The main entry point to this crate is the WindowExt trait, through which Vulkan surfaces can be created for winit Windows.

This crate deals only with Vulkan surfaces. Window and EventsLoop must be created and managed manually.

extern crate dacite;
extern crate dacite_winit;
extern crate winit;

// Import the `WindowExt` trait:
use dacite_winit::WindowExt;

// Create an `EventsLoop` and a `Window`:
let events_loop = winit::EventsLoop::new();
let window = winit::Window::new(&events_loop).unwrap();

// Determine required extensions before a Vulkan instance is created:
let required_extensions = match window.get_required_extensions() {
    Ok(required_extensions) => required_extensions,
    Err(error) => {
        // This error can mean either, that the windowing system is not supported, or that
        // a Vulkan error occurred.

        // Other functions from the `WindowExt` trait can also return errors, which should be
        // handled appropriately.

// Create a Vulkan instance and enable at least the extensions required for the window:
let create_info = dacite::core::InstanceCreateInfo {
    // ...
    enabled_extensions: required_extensions.to_extensions(),
    // ...

let instance = dacite::core::Instance::create(&create_info, None).unwrap();

// While searching for a suitable physical device, use
// WindowExt::is_presentation_supported() to determine if the physical device has a queue
// family, that can present to the window.
let physical_device = // ...

// And finally, create a `Surface` from the window:
let surface = window.create_surface(&instance,



Flags used for surface creation.



Error type used throughout this crate.



Extension trait for Vulkan surface creation.