Skip to content

Commit

Permalink
Finish the shader docs
Browse files Browse the repository at this point in the history
  • Loading branch information
17cupsofcoffee committed Jan 6, 2019
1 parent 813cc97 commit bf43c82
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/graphics/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,41 @@ use crate::Context;
pub use crate::graphics::opengl::UniformValue;

/// The default vertex shader.
///
/// The source code for this shader is available in [`src/resources/shader.vert`](https://github.com/17cupsofcoffee/tetra/blob/master/src/resources/shader.vert).
pub static DEFAULT_VERTEX_SHADER: &str = include_str!("../resources/shader.vert");

/// The default fragment shader.
///
/// The source code for this shader is available in [`src/resources/shader.vert`](https://github.com/17cupsofcoffee/tetra/blob/master/src/resources/shader.frag).
pub static DEFAULT_FRAGMENT_SHADER: &str = include_str!("../resources/shader.frag");

/// 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
///
/// 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
///
/// Fragment shaders have a single `vec4` output called `o_color` - this should be set to the desired output color for the
/// fragment.
///
/// # Uniforms
///
/// 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.
#[derive(Debug, Clone, PartialEq)]
pub struct Shader {
pub(crate) handle: Rc<GLProgram>,
Expand Down

0 comments on commit bf43c82

Please sign in to comment.