Struct Shader

Source
pub struct Shader { /* private fields */ }
Expand description

Shader

Implementations§

Source§

impl Shader

Source

pub fn locations(&self) -> &[u32]

Shader locations array

Source

pub fn locations_mut(&mut self) -> &mut [u32]

Shader locations array

Source

pub fn from_file( vs_filename: Option<&str>, fs_filename: Option<&str>, ) -> Option<Self>

Load shader from files and bind default locations

Source

pub fn from_memory(vs_code: Option<&str>, fs_code: Option<&str>) -> Option<Self>

Load shader from code strings and bind default locations

Source

pub fn get_location(&self, uniform_name: &str) -> u32

Get shader uniform location

Source

pub fn get_location_attribute(&self, attribute_name: &str) -> u32

Get shader attribute location

Source

pub fn set_value<S: ShaderValue>(&mut self, loc_index: u32, value: S)

Set shader uniform value

Source

pub fn set_value_vec<S: ShaderValue>(&mut self, loc_index: u32, values: &[S])

Set shader uniform value vector

Source

pub fn set_value_matrix(&mut self, loc_index: u32, mat: Matrix)

Set shader uniform value (matrix 4x4)

Source

pub fn set_value_texture(&mut self, loc_index: u32, texture: &Texture2D)

Set shader uniform value for texture (sampler2d)

Source

pub fn as_raw(&self) -> &Shader

Get the ‘raw’ ffi type Take caution when cloning so it doesn’t outlive the original

Source

pub fn as_raw_mut(&mut self) -> &mut Shader

Get the ‘raw’ ffi type Take caution when cloning so it doesn’t outlive the original

Source

pub unsafe fn from_raw(raw: Shader) -> Self

Convert a ‘raw’ ffi object to a safe wrapper

§Safety
  • The raw object must be correctly initialized
  • The raw object should be unique. Otherwise, make sure its clones don’t outlive the newly created object.

Trait Implementations§

Source§

impl Debug for Shader

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Shader

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Shader

§

impl RefUnwindSafe for Shader

§

impl !Send for Shader

§

impl !Sync for Shader

§

impl Unpin for Shader

§

impl UnwindSafe for Shader

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.