pub struct Shader { /* fields omitted */ }
A shader program, consisting of a vertex shader and a fragment shader.
This type acts as a lightweight handle to the associated graphics hardware data,
and so can be cloned with little overhead.
Vertex shaders take in data via three attributes:
a_position
- A vec2
representing the position of the vertex in world space.
a_uv
- A vec2
representing the texture co-ordinates that are associated with the vertex.
a_color
- A vec4
representing a color to multiply the output by.
Fragment shaders have a single vec4
output called o_color
- this should be set to the desired output color for the
fragment.
By default, the shader is provided with two uniform variables:
u_projection
- A mat4
which can be used to translate world space co-ordinates into screen space.
u_texture
- A sampler2D
which can be used to access color data from the currently active texture.
You can also set data into your own uniform variables via the set_uniform
method.
Creates a new shader program from the given files.
If the file could not be read, a TetraError::Io
will be returned.
If the shader could not be compiled, a TetraError::OpenGl
will be returned.
Creates a new shader program from the given vertex shader file.
The default fragment shader will be used.
If the file could not be read, a TetraError::Io
will be returned.
If the shader could not be compiled, a TetraError::OpenGl
will be returned.
Creates a new shader program from the given fragment shader file.
The default vertex shader will be used.
If the file could not be read, a TetraError::Io
will be returned.
If the shader could not be compiled, a TetraError::OpenGl
will be returned.
Creates a new shader program from the given strings.
If the shader could not be compiled, a TetraError::OpenGl
will be returned.
Sets the value of the specifed uniform parameter.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<SS, SP> SupersetOf for SP where SS: SubsetOf<SP>, | |
The inverse inclusion map: attempts to construct self
from the equivalent element of its superset. Read more
Checks if self
is actually part of its subset T
(and can be converted to it).
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
The inclusion map: converts self
to the equivalent element of its superset.
impl<T> SetParameter for T | |
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where T: Parameter<Self>, | |
Sets value
as a parameter of self
.