Trait gfx_hal::Instance[][src]

pub trait Instance<B: Backend>: Any + Send + Sync + Sized {
    fn create(name: &str, version: u32) -> Result<Self, UnsupportedBackend>;
fn enumerate_adapters(&self) -> Vec<Adapter<B>>;
unsafe fn create_surface(
        &self,
        raw_window_handle: &impl HasRawWindowHandle
    ) -> Result<B::Surface, InitError>;
unsafe fn destroy_surface(&self, surface: B::Surface); }

An instantiated backend.

Any startup the backend needs to perform will be done when creating the type that implements Instance.

Examples

use gfx_backend_empty as backend;
use gfx_hal::Instance;

// Create a concrete instance of our backend (this is backend-dependent and may be more
// complicated for some backends).
let instance = backend::Instance::create("My App", 1).unwrap();
// We can get a list of the available adapters, which are either physical graphics
// devices, or virtual adapters. Because we are using the dummy `empty` backend,
// there will be nothing in this list.
for (idx, adapter) in instance.enumerate_adapters().iter().enumerate() {
    println!("Adapter {}: {:?}", idx, adapter.info);
}

Required methods

fn create(name: &str, version: u32) -> Result<Self, UnsupportedBackend>[src]

Create a new instance.

Arguments

  • name - name of the application using the API.
  • version - free form representation of the application's version.

This metadata is passed further down the graphics stack.

Errors

Returns an Err variant if the requested backend is not supported on the current platform.

fn enumerate_adapters(&self) -> Vec<Adapter<B>>[src]

Return all available graphics adapters.

unsafe fn create_surface(
    &self,
    raw_window_handle: &impl HasRawWindowHandle
) -> Result<B::Surface, InitError>
[src]

Create a new surface.

Surfaces can be used to render to windows.

Safety

This method can cause undefined behavior if raw_window_handle isn't a handle to a valid window for the current platform.

unsafe fn destroy_surface(&self, surface: B::Surface)[src]

Destroy a surface, freeing the resources associated with it and releasing it from this graphics API.

Safety

Loading content...

Implementors

Loading content...