Crevice creates GLSL-compatible versions of types through the power of derive macros. Generated structs implement a number of traits from other crates:
bytemuck::Zeroable and bytemuck::Pod to ease packing
data into buffers for uploading.type_layout::TypeLayout to debug the layout generated by the
crate.Crevice is similar to glsl-layout, but supports mint types
and explicitly initializes padding to remove one source of undefined behavior.
This example uses cgmath, but any math crate that works with the mint crate
also works.
```rust use crevice::std140::AsStd140; use cgmath::prelude::*; use cgmath::{Matrix3, Vector3};
struct MainUniform {
orientation: mint::ColumnMatrix3
let value = MainUniform { orientation: Matrix3::identity().into(), position: Vector3::new(1.0, 2.0, 3.0).into(), scale: 4.0, };
let valuestd140 = value.asstd140();
uploaddatatogpu(bytemuck::bytesof(&value_std140)); ```
Crevice supports Rust 1.46.0 and newer due to use of new const fn features.
Licensed under either of
at your option.
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.