pub struct Program { /* private fields */ }
Expand description
A combination of shaders linked together.
Implementations§
Source§impl Program
impl Program
Sourcepub fn new<'a, F, I>(
facade: &F,
input: I,
) -> Result<Program, ProgramCreationError>
pub fn new<'a, F, I>( facade: &F, input: I, ) -> Result<Program, ProgramCreationError>
Builds a new program.
Sourcepub fn from_source<'a, F>(
facade: &F,
vertex_shader: &'a str,
fragment_shader: &'a str,
geometry_shader: Option<&'a str>,
) -> Result<Program, ProgramCreationError>
pub fn from_source<'a, F>( facade: &F, vertex_shader: &'a str, fragment_shader: &'a str, geometry_shader: Option<&'a str>, ) -> Result<Program, ProgramCreationError>
Builds a new program from GLSL source code.
A program is a group of shaders linked together.
§Parameters
vertex_shader
: Source code of the vertex shader.fragment_shader
: Source code of the fragment shader.geometry_shader
: Source code of the geometry shader.
§Example
let program = glium::Program::from_source(&display, vertex_source, fragment_source,
Some(geometry_source));
Sourcepub fn get_binary(&self) -> Result<Binary, GetBinaryError>
pub fn get_binary(&self) -> Result<Binary, GetBinaryError>
Returns the program’s compiled binary.
You can store the result in a file, then reload it later. This avoids having to compile the source code every time.
Sourcepub fn get_frag_data_location(&self, name: &str) -> Option<u32>
pub fn get_frag_data_location(&self, name: &str) -> Option<u32>
Returns the location of an output fragment, if it exists.
The location is low-level information that is used internally by glium. You probably don’t need to call this function.
You can declare output fragments in your shaders by writing:
out vec4 foo;
Sourcepub fn get_uniform(&self, name: &str) -> Option<&Uniform>
pub fn get_uniform(&self, name: &str) -> Option<&Uniform>
Returns informations about a uniform variable, if it exists.
Sourcepub fn uniforms(&self) -> Iter<'_, String, Uniform>
pub fn uniforms(&self) -> Iter<'_, String, Uniform>
Returns an iterator to the list of uniforms.
§Example
for (name, uniform) in program.uniforms() {
println!("Name: {} - Type: {:?}", name, uniform.ty);
}
Sourcepub fn get_uniform_blocks(
&self,
) -> &HashMap<String, UniformBlock, BuildHasherDefault<FnvHasher>>
pub fn get_uniform_blocks( &self, ) -> &HashMap<String, UniformBlock, BuildHasherDefault<FnvHasher>>
Returns a list of uniform blocks.
§Example
for (name, uniform) in program.get_uniform_blocks() {
println!("Name: {}", name);
}
Sourcepub fn get_transform_feedback_buffers(&self) -> &[TransformFeedbackBuffer]
pub fn get_transform_feedback_buffers(&self) -> &[TransformFeedbackBuffer]
Returns the list of transform feedback varyings.
Sourcepub fn transform_feedback_matches(
&self,
format: &Cow<'static, [(Cow<'static, str>, usize, AttributeType, bool)]>,
stride: usize,
) -> bool
pub fn transform_feedback_matches( &self, format: &Cow<'static, [(Cow<'static, str>, usize, AttributeType, bool)]>, stride: usize, ) -> bool
True if the transform feedback output of this program matches the specified VertexFormat
and stride
.
The stride
is the number of bytes between two vertices.
Sourcepub fn get_output_primitives(&self) -> Option<OutputPrimitives>
pub fn get_output_primitives(&self) -> Option<OutputPrimitives>
Returns the type of geometry that transform feedback would generate, or None
if it
depends on the vertex/index data passed when drawing.
This corresponds to GL_GEOMETRY_OUTPUT_TYPE
or GL_TESS_GEN_MODE
. If the program doesn’t
contain either a geometry shader or a tessellation evaluation shader, returns None
.
Sourcepub fn has_tessellation_shaders(&self) -> bool
pub fn has_tessellation_shaders(&self) -> bool
Returns true if the program contains a tessellation stage.
Sourcepub fn has_tessellation_control_shader(&self) -> bool
pub fn has_tessellation_control_shader(&self) -> bool
Returns true if the program contains a tessellation control stage.
Sourcepub fn has_tessellation_evaluation_shader(&self) -> bool
pub fn has_tessellation_evaluation_shader(&self) -> bool
Returns true if the program contains a tessellation evaluation stage.
Sourcepub fn has_geometry_shader(&self) -> bool
pub fn has_geometry_shader(&self) -> bool
Returns true if the program contains a geometry shader.
Sourcepub fn get_attribute(&self, name: &str) -> Option<&Attribute>
pub fn get_attribute(&self, name: &str) -> Option<&Attribute>
Returns informations about an attribute, if it exists.
Sourcepub fn attributes(&self) -> Iter<'_, String, Attribute>
pub fn attributes(&self) -> Iter<'_, String, Attribute>
Returns an iterator to the list of attributes.
§Example
for (name, attribute) in program.attributes() {
println!("Name: {} - Type: {:?}", name, attribute.ty);
}
Sourcepub fn has_srgb_output(&self) -> bool
pub fn has_srgb_output(&self) -> bool
Returns true if the program has been configured to output sRGB instead of RGB.
Sourcepub fn get_shader_storage_blocks(
&self,
) -> &HashMap<String, UniformBlock, BuildHasherDefault<FnvHasher>>
pub fn get_shader_storage_blocks( &self, ) -> &HashMap<String, UniformBlock, BuildHasherDefault<FnvHasher>>
Returns the list of shader storage blocks.
§Example
for (name, uniform) in program.get_shader_storage_blocks() {
println!("Name: {}", name);
}
Sourcepub fn get_subroutine_uniforms(
&self,
) -> &HashMap<(String, ShaderStage), SubroutineUniform, BuildHasherDefault<FnvHasher>>
pub fn get_subroutine_uniforms( &self, ) -> &HashMap<(String, ShaderStage), SubroutineUniform, BuildHasherDefault<FnvHasher>>
Returns the subroutine uniforms of this program.
Since subroutine uniforms are unique per shader and not per program,
the keys of the HashMap
are in the format ("subroutine_name", ShaderStage)
.
§Example
for (&(ref name, shader), uniform) in program.get_subroutine_uniforms() {
println!("Name: {}", name);
}
Sourcepub fn uses_point_size(&self) -> bool
pub fn uses_point_size(&self) -> bool
Returns true if the program has been configured to use the gl_PointSize
variable.
If the program uses gl_PointSize
without having been configured appropriately, then
setting the value of gl_PointSize
will have no effect.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Program
impl !RefUnwindSafe for Program
impl !Send for Program
impl !Sync for Program
impl Unpin for Program
impl !UnwindSafe for Program
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SetParameter for T
impl<T> SetParameter for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.