Trait luminance::backend::shader::Shader [−][src]
pub unsafe trait Shader {
type StageRepr;
type ProgramRepr;
type UniformBuilderRepr;
unsafe fn new_stage(
&mut self,
ty: StageType,
src: &str
) -> Result<Self::StageRepr, StageError>;
unsafe fn new_program(
&mut self,
vertex: &Self::StageRepr,
tess: Option<TessellationStages<'_, Self::StageRepr>>,
geometry: Option<&Self::StageRepr>,
fragment: &Self::StageRepr
) -> Result<Self::ProgramRepr, ProgramError>;
unsafe fn apply_semantics<Sem>(
program: &mut Self::ProgramRepr
) -> Result<Vec<VertexAttribWarning>, ProgramError>
where
Sem: Semantics;
unsafe fn new_uniform_builder(
program: &mut Self::ProgramRepr
) -> Result<Self::UniformBuilderRepr, ProgramError>;
unsafe fn ask_uniform<T>(
uniform_builder: &mut Self::UniformBuilderRepr,
name: &str
) -> Result<Uniform<T>, UniformWarning>
where
Self: for<'u> Uniformable<'u, T>;
unsafe fn unbound<T>(
uniform_builder: &mut Self::UniformBuilderRepr
) -> Uniform<T>
where
Self: for<'u> Uniformable<'u, T>;
}
Expand description
Shader support.
This trait provides several concepts as once, as they all depend on each other:
- Shader stages.
- Shader programs.
- Uniform builders.
The associated type Shader::StageRepr
is the backend representation of a shader stage. They are created with
Shader::new_stage
with a StageType
representing the shader stage type that must be created. Because the
backend might not support this type of shader stage, it might fail with a StageError
.
Associated Types
type ProgramRepr
type ProgramRepr
Backend representation of a shader program.
Backend representation of a uniform builder.
Required methods
Create a new shader stage of type StageType
.
unsafe fn new_program(
&mut self,
vertex: &Self::StageRepr,
tess: Option<TessellationStages<'_, Self::StageRepr>>,
geometry: Option<&Self::StageRepr>,
fragment: &Self::StageRepr
) -> Result<Self::ProgramRepr, ProgramError>
unsafe fn new_program(
&mut self,
vertex: &Self::StageRepr,
tess: Option<TessellationStages<'_, Self::StageRepr>>,
geometry: Option<&Self::StageRepr>,
fragment: &Self::StageRepr
) -> Result<Self::ProgramRepr, ProgramError>
Create a new shader program by combining several shader stages.
The vertex and fragment stages are mandatory. The other ones are optional and then must be inspected to check whether they were provided by the user.
unsafe fn apply_semantics<Sem>(
program: &mut Self::ProgramRepr
) -> Result<Vec<VertexAttribWarning>, ProgramError> where
Sem: Semantics,
unsafe fn apply_semantics<Sem>(
program: &mut Self::ProgramRepr
) -> Result<Vec<VertexAttribWarning>, ProgramError> where
Sem: Semantics,
Apply semantics.
This is a very specific operations that happen right after the shader program got successfully created by the
backend. This function is responsible in setting whatever might be needed by the backend to allocate, prepare or
validate the semantics — i.e. Sem
which implements Semantics
.
unsafe fn new_uniform_builder(
program: &mut Self::ProgramRepr
) -> Result<Self::UniformBuilderRepr, ProgramError>
unsafe fn new_uniform_builder(
program: &mut Self::ProgramRepr
) -> Result<Self::UniformBuilderRepr, ProgramError>
Construct a new uniform builder.
This method must create a uniform builder, which will be used when passed to the user.
unsafe fn ask_uniform<T>(
uniform_builder: &mut Self::UniformBuilderRepr,
name: &str
) -> Result<Uniform<T>, UniformWarning> where
Self: for<'u> Uniformable<'u, T>,
unsafe fn ask_uniform<T>(
uniform_builder: &mut Self::UniformBuilderRepr,
name: &str
) -> Result<Uniform<T>, UniformWarning> where
Self: for<'u> Uniformable<'u, T>,
unsafe fn unbound<T>(
uniform_builder: &mut Self::UniformBuilderRepr
) -> Uniform<T> where
Self: for<'u> Uniformable<'u, T>,
unsafe fn unbound<T>(
uniform_builder: &mut Self::UniformBuilderRepr
) -> Uniform<T> where
Self: for<'u> Uniformable<'u, T>,
Backend representation of an unbound Uniform
(i.e. that is inactive in the shader program).
This is a method taking a uniform builder so that the builder can accumulate a state.