crevice 0.1.0

Create GLSL-compatible versions of structs with explicitly-initialized padding
Documentation

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.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.