Skip to main content

ShaderPass

Struct ShaderPass 

Source
pub struct ShaderPass<S>
where S: SequoiShader,
{ /* private fields */ }
Expand description

A configured shader draw that can be handed to a canvas or reused.

Inputs are optional: Painter samples transparent white for textures the pass does not bind. Self::primary_input binds the shader’s first declared texture, which is what most single-input effects need.

Implementations§

Source§

impl<S> ShaderPass<S>
where S: SequoiShader,

Source

pub fn new(shader: S) -> ShaderPass<S>

Source

pub fn at(self, rect: Rect) -> ShaderPass<S>

Draws into rect. Without it the canvas bounds are used.

Source

pub fn uv(self, uv: [f32; 4]) -> ShaderPass<S>

Samples the shader inputs with an explicit UV window.

Source

pub fn blend(self, blend: BlendMode) -> ShaderPass<S>

Overrides the blend mode for this pass only.

Source

pub fn input(self, name: &'static str, input: TexInput) -> ShaderPass<S>

Binds input to the shader texture parameter name.

Source

pub fn primary_input(self, input: TexInput) -> ShaderPass<S>

Binds the first texture declared by the shader, unless already bound.

This removes the need to repeat the parameter name at every call site.

Source

pub fn layers(self, first: TexInput, second: TexInput) -> ShaderPass<S>

Binds the first two declared textures in order.

Source

pub fn name(&self) -> &'static str

Source

pub fn target_rect(&self) -> Option<Rect>

Source

pub fn draw(&self, g: &mut Painter<'_, '_>) -> bool
where S: Copy,

Records the draw. Returns false when the shader is not registered on the runtime or the rectangle is empty.

Trait Implementations§

Source§

impl<S> Clone for ShaderPass<S>
where S: Clone + SequoiShader,

Source§

fn clone(&self) -> ShaderPass<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S> Freeze for ShaderPass<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for ShaderPass<S>
where S: RefUnwindSafe,

§

impl<S> Send for ShaderPass<S>
where S: Send,

§

impl<S> Sync for ShaderPass<S>
where S: Sync,

§

impl<S> Unpin for ShaderPass<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for ShaderPass<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for ShaderPass<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.