pub struct Shader(/* private fields */);Expand description
A raw handle to the underlying Shader object.
Implementations§
source§impl Shader
impl Shader
sourcepub fn new(shader: ShaderKind) -> Self
pub fn new(shader: ShaderKind) -> Self
Creates a new shader handle.
sourcepub fn new_checked(shader: ShaderKind) -> Result<Self>
pub fn new_checked(shader: ShaderKind) -> Result<Self>
Creates a new shader with full checking for errors.
sourcepub fn shader_source_cstr(&mut self, source: &CStr)
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-terminatedCStr
sourcepub fn shader_source(&mut self, source: &str)
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
sourcepub fn shader_sources(&mut self, sources: &[&str])
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
sourcepub fn compile(&mut self) -> Result<()>
pub fn compile(&mut self) -> Result<()>
Attempts to compile the shader.
This must be called after adding shader source(s).
sourcepub fn compile_status(&self) -> bool
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.
sourcepub fn delete_status(&self) -> bool
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.
sourcepub unsafe fn release(self) -> GLuint
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.