gl::shader

Struct Program

source
pub struct Program(/* private fields */);
Expand description

A self-disposing handle to a Program object.

Implementations§

source§

impl Program

source

pub fn new() -> Self

Creates a new program handle.

source

pub fn new_checked() -> Result<Self>

Creates a new program with full checking for errors.

source

pub fn attach_shader(&mut self, shader: &Shader)

Attaches the specified shader to the program. This is a thin wrapper around glAttachShader.

§Parameters
  • shader - The shader to attach to the program

Links the program, returning whether the link was successful.

Gets the link status for the program. This is a thin wrapper around glGetProgramiv

Returns true if the program was linked successfully.

source

pub fn info_log(&self) -> String

Gets the info log for the program. This is a thin wrapper around glGetProgramInfoLog

source

pub unsafe fn release(self) -> GLuint

Takes ownership of the underlying program object. It becomes the responsibility of the caller to call glDeleteProgram on the returned program object.

§Safety

The caller must ensure that the program object is deleted after calling this function, otherwise there will be a resource-leak.

source

pub fn bind(&self)

Binds the program. This is a thin wrapper around glUseProgram

source

pub fn reset_binding()

Unbinds the program.

source

pub fn uniform_location(&self, name: &str) -> UniformLocation

Gets the location of the specified uniform.

source

pub fn uniform_location_cstr(&self, name: &CStr) -> UniformLocation

Gets the location of the specified uniform.

source

pub fn attribute_location(&self, name: &str) -> AttribLocation

Gets the location of the specified attribute.

source

pub fn attribute_location_cstr(&self, name: &CStr) -> AttribLocation

Gets the location of the specified attribute.

source

pub unsafe fn set_uniform_vector4_unchecked( &self, location: UniformLocation, count: usize, vec: *const f32, )

Provides the contents of a single f32 to the specified uniform location.

§Safety

The uniform location must be valid and the value must be a valid pointer to a 4-element array of f32.

§Parameters
  • location - The location of the uniform
  • count - The number of values to provide
  • vec - A pointer to a 4-element array of f32
source

pub unsafe fn set_uniform_matrix4_unchecked( &self, location: UniformLocation, count: usize, mat: *const f32, )

Provides the contents of a 4x4 matrix to the specified uniform location.

§Safety

The uniform location must be valid and the matrix must be a valid pointer to a 16-element array of f32.

§Parameters
  • location - The location of the uniform
  • count - The number of matrices to provide
  • mat - A pointer to a 16-element array of f32

Trait Implementations§

source§

impl Drop for Program

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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.