[][src]Struct pixels::PixelsBuilder

pub struct PixelsBuilder<'req> { /* fields omitted */ }

A builder to help create customized pixel buffers.

Implementations

impl<'req> PixelsBuilder<'req>[src]

pub fn new(
    width: u32,
    height: u32,
    surface_texture: SurfaceTexture
) -> PixelsBuilder<'req>
[src]

Create a builder that can be finalized into a Pixels pixel buffer.

Examples

let mut pixels = PixelsBuilder::new(256, 240, surface_texture)
    .request_adapter_options(wgpu::RequestAdapterOptions {
        power_preference: wgpu::PowerPreference::HighPerformance,
        compatible_surface: None,
    })
    .enable_vsync(false)
    .build()?;

Panics

Panics when width or height are 0.

pub const fn request_adapter_options(
    self,
    request_adapter_options: RequestAdapterOptions<'req>
) -> PixelsBuilder
[src]

Add options for requesting a wgpu::Adapter.

pub const fn device_descriptor(
    self,
    device_descriptor: DeviceDescriptor
) -> PixelsBuilder<'req>
[src]

Add options for requesting a wgpu::Device.

pub const fn wgpu_backend(self, backend: BackendBit) -> PixelsBuilder<'req>[src]

Set which backends wgpu will attempt to use.

The default value of this is [wgpu::BackendBit::PRIMARY], which enables the well supported backends for wgpu.

pub fn enable_vsync(self, enable_vsync: bool) -> PixelsBuilder<'req>[src]

Enable or disable Vsync.

Vsync is enabled by default.

The wgpu present mode will be set to Fifo when Vsync is enabled, or Immediate when Vsync is disabled. To set the present mode to Mailbox or another value, use the PixelsBuilder::present_mode method.

pub fn present_mode(self, present_mode: PresentMode) -> PixelsBuilder<'req>[src]

Set the wgpu present mode.

This differs from PixelsBuilder::enable_vsync by allowing the present mode to be set to any value.

pub const fn texture_format(
    self,
    texture_format: TextureFormat
) -> PixelsBuilder<'req>
[src]

Set the texture format.

The default value is [wgpu::TextureFormat::Rgba8UnormSrgb], which is 4 unsigned bytes in RGBA order using the SRGB color space. This is typically what you want when you are working with color values from popular image editing tools or web apps.

pub fn build(self) -> Result<Pixels, Error>[src]

Create a pixel buffer from the options builder.

Errors

Returns an error when a wgpu::Adapter cannot be found.

Auto Trait Implementations

impl<'req> RefUnwindSafe for PixelsBuilder<'req>

impl<'req> Send for PixelsBuilder<'req>

impl<'req> Sync for PixelsBuilder<'req>

impl<'req> Unpin for PixelsBuilder<'req>

impl<'req> UnwindSafe for PixelsBuilder<'req>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.