gl::shader

Struct Shader

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

A raw handle to the underlying Shader object.

Implementations§

source§

impl Shader

source

pub fn new(shader: ShaderKind) -> Self

Creates a new shader handle.

source

pub fn new_checked(shader: ShaderKind) -> Result<Self>

Creates a new shader with full checking for errors.

source

pub fn shader_source_cstr(&mut self, source: &CStr)

Adds the specified shader source to the shader. This is just a thin wrapper around glShaderSource

§Parameters
  • source - The source code as a null-terminated CStr
source

pub fn shader_source(&mut self, source: &str)

Adds the specified shader source to the shader. This is just a thin wrapper around glShaderSource

§Parameters
  • source - The source code of the shader
source

pub fn shader_sources(&mut self, sources: &[&str])

Adds the specified shader sources to the shader.

This function is optimized to handle up to 8 sources without requiring using dynamic memory allocation.

§Parameters
  • sources - a collection of sources
source

pub fn compile(&mut self) -> Result<()>

Attempts to compile the shader.

This must be called after adding shader source(s).

source

pub fn compile_status(&self) -> bool

Gets the compile status for the shader. This is a thin wrapper around glGetShaderiv

Returns true if the shader was compiled successfully.

source

pub fn delete_status(&self) -> bool

Checks if this shader is flagged for deletion. This is a thin wrapper around glGetShaderiv

Returns true if the shader is flagged for deletion.

source

pub fn info_log(&self) -> String

Gets the info log for the shader.

source

pub unsafe fn release(self) -> GLuint

Takes ownership of the underlying shader object. It becomes the responsibility of the caller to call glDeleteShader on the returned shader object.

§Safety

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

Trait Implementations§

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.