Crate euc[][src]

crates.io crates.io

Utah teapot, rendered with Euc

Example

struct Example;

impl Pipeline for Example {
    type Vertex = [f32; 2];
    type VsOut = ();
    type Pixel = [u8; 4];

    // Vertex shader
    fn vert(&self, pos: &Self::Vertex) -> ([f32; 3], Self::VsOut) {
        ([pos[0], pos[1], 0.0], ())
    }

    // Fragment shader
    fn frag(&self, _: &Self::VsOut) -> Self::Pixel {
        [255, 0, 0, 255] // Red
    }
}

fn main() {
    let mut color = Buffer2d::new([640, 480], [0; 4]);
    Example.draw::<Triangles<(f32,)>, _>(
        &[
            [-1.0, -1.0],
            [ 1.0, -1.0],
            [ 0.0,  1.0],
        ],
        &mut color,
        None,
    );
}

Re-exports

pub use self::interpolate::Interpolate;
pub use self::rasterizer::DepthStrategy;
pub use self::rasterizer::Rasterizer;

Modules

buffer
interpolate
rasterizer

Traits

Pipeline

Represents the high-level structure of a rendering pipeline.

Target

Represents a 2-dimensional rendering target that can have pixel data read and written to it.