pub struct Program(/* private fields */);Expand description
A self-disposing handle to a Program object.
Implementations§
source§impl Program
impl Program
sourcepub fn new_checked() -> Result<Self>
pub fn new_checked() -> Result<Self>
Creates a new program with full checking for errors.
sourcepub fn attach_shader(&mut self, shader: &Shader)
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
sourcepub fn link(&mut self) -> Result<()>
pub fn link(&mut self) -> Result<()>
Links the program, returning whether the link was successful.
sourcepub fn link_status(&self) -> bool
pub fn link_status(&self) -> bool
Gets the link status for the program.
This is a thin wrapper around glGetProgramiv
Returns true if the program was linked successfully.
sourcepub fn info_log(&self) -> String
pub fn info_log(&self) -> String
Gets the info log for the program.
This is a thin wrapper around glGetProgramInfoLog
sourcepub unsafe fn release(self) -> GLuint
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.
sourcepub fn bind(&self)
pub fn bind(&self)
Binds the program.
This is a thin wrapper around glUseProgram
sourcepub fn reset_binding()
pub fn reset_binding()
Unbinds the program.
sourcepub fn uniform_location(&self, name: &str) -> UniformLocation
pub fn uniform_location(&self, name: &str) -> UniformLocation
Gets the location of the specified uniform.
sourcepub fn uniform_location_cstr(&self, name: &CStr) -> UniformLocation
pub fn uniform_location_cstr(&self, name: &CStr) -> UniformLocation
Gets the location of the specified uniform.
sourcepub fn attribute_location(&self, name: &str) -> AttribLocation
pub fn attribute_location(&self, name: &str) -> AttribLocation
Gets the location of the specified attribute.
sourcepub fn attribute_location_cstr(&self, name: &CStr) -> AttribLocation
pub fn attribute_location_cstr(&self, name: &CStr) -> AttribLocation
Gets the location of the specified attribute.
sourcepub unsafe fn set_uniform_vector4_unchecked(
&self,
location: UniformLocation,
count: usize,
vec: *const f32,
)
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 uniformcount- The number of values to providevec- A pointer to a 4-element array off32
sourcepub unsafe fn set_uniform_matrix4_unchecked(
&self,
location: UniformLocation,
count: usize,
mat: *const f32,
)
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 uniformcount- The number of matrices to providemat- A pointer to a 16-element array off32