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

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.

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

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

Return the information log for the program object, if any is available.

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

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

Retrieve a program uniform's index by name, or return an error if the uniform 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

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 variable. This value can be retrieved using gl.get_uniform_location method.
  • val: The value to set the uniform variable to. See the UniformData 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