[][src]Crate crevice

GitHub CI Status crevice on crates.io crevice docs

Crevice creates GLSL-compatible versions of types through the power of derive macros. Generated structs implement a number of traits from other crates:

Crevice is similar to glsl-layout, but supports mint types and explicitly initializes padding to remove one source of undefined behavior.

Examples

This example uses cgmath, but any math crate that works with the mint crate also works.

use crevice::std140::AsStd140;
use cgmath::prelude::*;
use cgmath::{Matrix3, Vector3};

#[derive(AsStd140)]
struct MainUniform {
    orientation: mint::ColumnMatrix3<f32>,
    position: mint::Vector3<f32>,
    scale: f32,
}

let value = MainUniform {
    orientation: Matrix3::identity().into(),
    position: Vector3::new(1.0, 2.0, 3.0).into(),
    scale: 4.0,
};

let value_std140 = value.as_std140();

upload_data_to_gpu(bytemuck::bytes_of(&value_std140));

Minimum Supported Rust Version (MSRV)

Crevice supports Rust 1.46.0 and newer due to use of new const fn features.

Re-exports

pub use bytemuck;
pub use type_layout;

Modules

std140