Uniform

Struct Uniform 

Source
pub struct Uniform<T>
where T: ?Sized,
{ /* private fields */ }
Expand description

A GPU shader program environment variable.

A uniform is a special variable that can be used to send data to a GPU. Several forms exist, but the idea is that T represents the data you want to send. Some exceptions exist that allow to pass shared data — such as ShaderDataBinding to pass a ShaderData, or TextureBinding to pass a Texture in order to fetch from it in a shader stage.

You will never be able to store them by your own. Instead, you must use a UniformInterface, which provides a contravariant interface for you. Creation is unsafe and should be avoided. The UniformInterface is the only safe way to create those.

§Parametricity

  • T is the type of data you want to be able to set in a shader program.

Implementations§

Source§

impl<T> Uniform<T>
where T: ?Sized,

Source

pub unsafe fn new(index: i32) -> Self

Create a new Uniform.

§Safety

This method must be used only by backends. If you end up using it, then you’re doing something wrong. Read on UniformInterface for further information.

Source

pub fn index(&self) -> i32

Retrieve the internal index.

Even though that function is safe, you have no reason to use it. Read on UniformInterface for further details.

Trait Implementations§

Source§

impl<T> Debug for Uniform<T>
where T: ?Sized + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Uniform<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for Uniform<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> !Send for Uniform<T>

§

impl<T> !Sync for Uniform<T>

§

impl<T> Unpin for Uniform<T>
where T: ?Sized,

§

impl<T> UnwindSafe for Uniform<T>
where T: RefUnwindSafe + ?Sized,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.