[−][src]Struct pixels::PixelsBuilder
A builder to help create customized pixel buffers.
Methods
impl PixelsBuilder
[src]
pub fn new(
width: u32,
height: u32,
surface_texture: SurfaceTexture
) -> PixelsBuilder
[src]
width: u32,
height: u32,
surface_texture: SurfaceTexture
) -> PixelsBuilder
Create a builder that can be finalized into a Pixels
pixel buffer.
Examples
struct MyRenderPass { // ... }; impl pixels::RenderPass for MyRenderPass { // ... } let mut pixels = PixelsBuilder::new(256, 240, surface_texture) .pixel_aspect_ratio(8.0 / 7.0) .add_render_pass(|device, queue, texture, texture_size| { // Create reources for MyRenderPass here Box::new(MyRenderPass { // ... }) }) .build()?;
Panics
Panics when width
or height
are 0.
pub const fn request_adapter_options(
self,
request_adapter_options: RequestAdapterOptions
) -> PixelsBuilder
[src]
self,
request_adapter_options: RequestAdapterOptions
) -> PixelsBuilder
Add options for requesting a wgpu::Adapter
.
pub const fn device_descriptor(
self,
device_descriptor: DeviceDescriptor
) -> PixelsBuilder
[src]
self,
device_descriptor: DeviceDescriptor
) -> PixelsBuilder
Add options for requesting a wgpu::Device
.
pub fn pixel_aspect_ratio(self, pixel_aspect_ratio: f64) -> PixelsBuilder
[src]
Set the pixel aspect ratio to simulate non-square pixels.
This setting enables a render pass that horizontally scales the pixel buffer by the given factor.
E.g. set this to 8.0 / 7.0
for an 8:7 pixel aspect ratio.
Panics
The aspect ratio must be > 0.
pub const fn texture_format(
self,
texture_format: TextureFormat
) -> PixelsBuilder
[src]
self,
texture_format: TextureFormat
) -> PixelsBuilder
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 add_render_pass(
self,
factory: impl Fn(Device, Queue, &TextureView, &Extent3d) -> BoxedRenderPass + 'static
) -> PixelsBuilder
[src]
self,
factory: impl Fn(Device, Queue, &TextureView, &Extent3d) -> BoxedRenderPass + 'static
) -> PixelsBuilder
Add a render pass.
Render passes are executed in the order they are added.
Factory Arguments
device
- A reference-countedwgpu::Device
which allows you to create GPU resources.queue
- A reference-countedwgpu::Queue
which can execute command buffers.texture
- Awgpu::TextureView
reference that is used as the texture input for the render pass.texture_size
- A [wgpu::Extent3d
] providing the input texture size.
Examples
use pixels::{BoxedRenderPass, Device, PixelsBuilder, Queue, RenderPass}; use pixels::wgpu::{Extent3d, TextureView}; struct MyRenderPass { device: Device, queue: Queue, } impl MyRenderPass { fn factory( device: Device, queue: Queue, texture: &TextureView, texture_size: &Extent3d, ) -> BoxedRenderPass { // Create a bind group, pipeline, etc. and store all of the necessary state... Box::new(MyRenderPass { device, queue }) } } impl RenderPass for MyRenderPass { // ... } let builder = PixelsBuilder::new(320, 240, surface_texture) .add_render_pass(MyRenderPass::factory) .build()?;
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 !Send for PixelsBuilder
impl !Sync for PixelsBuilder
impl Unpin for PixelsBuilder
impl !UnwindSafe for PixelsBuilder
impl !RefUnwindSafe for PixelsBuilder
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,