Trait glitter::context::program_context::ContextProgramExt
[−]
[src]
pub trait ContextProgramExt: BaseContext { unsafe fn create_program(&self) -> Result<Program, ()> { ... } fn attach_shader(&self, program: &mut Program, shader: &Shader) { ... } fn link_program(&self, program: &mut Program) -> Result<(), GLError> { ... } fn get_program_info_log(&self, program: &Program) -> Option<String> { ... } fn get_attrib_location<'a>(&self, program: &Program, name: &'a str) -> Result<ProgramAttrib, UnknownProgramAttrib<'a>> { ... } fn get_uniform_location<'a>(&self, program: &Program, name: &'a str) -> Result<ProgramUniform, UnknownProgramUniform<'a>> { ... } fn set_uniform<T>(&self, _gl_program: &ProgramBinding, uniform: ProgramUniform, val: T) where T: UniformData { ... } }
An extension trait that includes program-related OpenGL methods.
Provided Methods
unsafe fn create_program(&self) -> Result<Program, ()>
Create a new program object that has no shaders attached, or return an error if a shader object could not be created.
Safety
Most OpenGL function calls assume a program object will have
already had shaders attached and linked using gl.attach_shader
and
gl.link_program
,
respectively. Violating this invariant is considered undefined
behavior in glitter.
See also
glCreateProgram
OpenGL docs
gl.build_program
:
A safe wrapper for creating a program object.
fn attach_shader(&self, program: &mut Program, shader: &Shader)
Attach a shader to a program object.
Panics
This function will panic if the provided shader is already attached to the program object.
See also
glAttachShader
OpenGL docs
fn link_program(&self, program: &mut Program) -> Result<(), GLError>
Link the program object, so that it can be used for rendering. Returns an error if the program could not be linked.
Failures
If the GL_LINK_STATUS
after linking the program was not GL_TRUE
,
then an error object containing the program's info log will
be returned. Refer to the glLinkProgram
OpenGL docs for the possible
causes of failure.
Panics
This function will panic if an OpenGL error is generated and debug assertions are enabled.
See also
glLinkProgram
OpenGL docs
fn get_program_info_log(&self, program: &Program) -> Option<String>
Return the information log for the program object, if any is avaiable.
Note
If the info log returned by the OpenGL driver contained an invalid
UTF-8 sequence, None
will be returned.
See also
glGetProgramInfoLog
OpenGL docs
fn get_attrib_location<'a>(&self, program: &Program, name: &'a str) -> Result<ProgramAttrib, UnknownProgramAttrib<'a>>
Retrieve a program attribute's index by name, or return an error if the attribute was not found in the program.
Panics
This function will panic if an OpenGL error was generated and debug assertions are enabled.
See also
glGetAttribLocation
OpenGL
docs
fn get_uniform_location<'a>(&self, program: &Program, name: &'a str) -> Result<ProgramUniform, UnknownProgramUniform<'a>>
Retrieve a program uniform's index by name, or return an error if the unfirom was not found within the program.
Panics
This function will panic if an OpenGL error was generated and debug assertions are enabled.
See also
glGetUniformLocation
OpenGL docs
fn set_uniform<T>(&self, _gl_program: &ProgramBinding, uniform: ProgramUniform, val: T) where T: UniformData
Set the value of a uniform variable within the provided program object binding.
_gl_program
: The program binding to change.uniform
: The location of the uniform varaible. This value can be retrieved usinggl.get_uniform_location
method.val
: The value to set the uniform varaible to. See theUniformData
docs for more details about the types of uniform data.
Panics
This function will panic if an OpenGL error is generated and debug assertions are enabled.
See also
glUniform
OpenGL docs
Implementors
impl<C: BaseContext> ContextProgramExt for C