Trait luminance::backend::shader::Uniformable [−][src]
pub unsafe trait Uniformable<'a, T>: Shader {
type Target: 'a;
const SIZE: usize;
unsafe fn ty() -> UniformType;
unsafe fn update(
program: &mut Self::ProgramRepr,
uniform: &'a Uniform<T>,
value: Self::Target
);
}
Expand description
Backend support for uniforms.
When a backend implements Uniformable
, it adds support for the type parameter as being a recognized uniform
type and then can be mapped in a uniform interface via Uniform
.
Implementing such a trait is relatively trivial:
- You must implement
Uniformable::ty
, which reifies the type of the uniform usingUniformType
. If your uniform type is not supported inUniformType
, it means the API doesn’t know about it and then that type cannot be supported. - You must implement
Uniformable::update
, which updates the value of theUniform
in a given shader program. For indirect values such as bound resources (textures, shader data, etc.), uploading will most of the time be a binding update on the backend side. - You must provide an associated type that will be the actual type users will pass. This is needed because some uniform types cannot be expressed directly, such as existentials (think of types with lifetimes, for instance).
Associated Types
Associated Constants
Required methods
unsafe fn ty() -> UniformType
unsafe fn ty() -> UniformType
Reify the type of the uniform as a UniformType
.