Trait crevice::std140::AsStd140

source ·
pub trait AsStd140 {
    type Output: Std140;

    // Required methods
    fn as_std140(&self) -> Self::Output;
    fn from_std140(val: Self::Output) -> Self;

    // Provided method
    fn std140_size_static() -> usize { ... }
}
Expand description

Trait implemented for all types that can be turned into std140 values.

This trait can often be #[derive]’d instead of manually implementing it. Any struct which contains only fields that also implement AsStd140 can derive AsStd140.

Types from the mint crate implement AsStd140, making them convenient for use in uniform types. Most Rust math crates, like cgmath, nalgebra, and ultraviolet support mint.

§Example

uniform CAMERA {
    mat4 view;
    mat4 projection;
} camera;
use crevice::std140::AsStd140;

#[derive(AsStd140)]
struct CameraUniform {
    view: mint::ColumnMatrix4<f32>,
    projection: mint::ColumnMatrix4<f32>,
}

let view: mint::ColumnMatrix4<f32> = todo!("your math code here");
let projection: mint::ColumnMatrix4<f32> = todo!("your math code here");

let camera = CameraUniform {
    view,
    projection,
};

let camera_std140 = camera.as_std140();
write_to_gpu_buffer(camera_std140.as_bytes());

Required Associated Types§

source

type Output: Std140

The std140 version of this value.

Required Methods§

source

fn as_std140(&self) -> Self::Output

Convert this value into the std140 version of itself.

source

fn from_std140(val: Self::Output) -> Self

Converts from std140 version of self to self.

Provided Methods§

source

fn std140_size_static() -> usize

Returns the size of the std140 version of this type. Useful for pre-sizing buffers.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AsStd140 for bool

§

type Output = Bool

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(val: Self::Output) -> Self

source§

impl AsStd140 for Matrix2<f32>

§

type Output = Mat2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix2<f64>

§

type Output = DMat2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix3<f32>

§

type Output = Mat3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix3<f64>

§

type Output = DMat3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix4<f32>

§

type Output = Mat4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix4<f64>

§

type Output = DMat4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<bool>

§

type Output = BVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<f32>

§

type Output = Vec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<f64>

§

type Output = DVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<i32>

§

type Output = IVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<u32>

§

type Output = UVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<bool>

§

type Output = BVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<f32>

§

type Output = Vec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<f64>

§

type Output = DVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<i32>

§

type Output = IVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<u32>

§

type Output = UVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<bool>

§

type Output = BVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<f32>

§

type Output = Vec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<f64>

§

type Output = DVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<i32>

§

type Output = IVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<u32>

§

type Output = UVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<bool>

§

type Output = BVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<f32>

§

type Output = Vec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<f64>

§

type Output = DVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<i32>

§

type Output = IVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<u32>

§

type Output = UVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<bool>

§

type Output = BVec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<f32>

§

type Output = Vec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<f64>

§

type Output = DVec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<i32>

§

type Output = IVec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<u32>

§

type Output = UVec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Mat3

§

type Output = <ColumnMatrix3<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Mat2

§

type Output = <ColumnMatrix2<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Mat4

§

type Output = <ColumnMatrix4<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vec4

§

type Output = <Vector4<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vec2

§

type Output = <Vector2<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vec3

§

type Output = <Vector3<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for DMat2

§

type Output = <ColumnMatrix2<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for DMat3

§

type Output = <ColumnMatrix3<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for DMat4

§

type Output = <ColumnMatrix4<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for DVec2

§

type Output = <Vector2<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for DVec3

§

type Output = <Vector3<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for DVec4

§

type Output = <Vector4<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for IVec2

§

type Output = <Vector2<i32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for IVec3

§

type Output = <Vector3<i32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for IVec4

§

type Output = <Vector4<i32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for UVec2

§

type Output = <Vector2<u32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for UVec3

§

type Output = <Vector3<u32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for UVec4

§

type Output = <Vector4<u32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for ColumnMatrix2<f32>

§

type Output = Mat2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for ColumnMatrix2<f64>

§

type Output = DMat2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for ColumnMatrix3<f32>

§

type Output = Mat3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for ColumnMatrix3<f64>

§

type Output = DMat3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for ColumnMatrix4<f32>

§

type Output = Mat4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for ColumnMatrix4<f64>

§

type Output = DMat4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<bool>

§

type Output = BVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<f32>

§

type Output = Vec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<f64>

§

type Output = DVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<i32>

§

type Output = IVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<u32>

§

type Output = UVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<bool>

§

type Output = BVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<f32>

§

type Output = Vec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<f64>

§

type Output = DVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<i32>

§

type Output = IVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<u32>

§

type Output = UVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<bool>

§

type Output = BVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<f32>

§

type Output = Vec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<f64>

§

type Output = DVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<i32>

§

type Output = IVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<u32>

§

type Output = UVec2

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<bool>

§

type Output = BVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<f32>

§

type Output = Vec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<f64>

§

type Output = DVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<i32>

§

type Output = IVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<u32>

§

type Output = UVec3

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<bool>

§

type Output = BVec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<f32>

§

type Output = Vec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<f64>

§

type Output = DVec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<i32>

§

type Output = IVec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<u32>

§

type Output = UVec4

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix2<f32>

§

type Output = <ColumnMatrix2<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix2<f64>

§

type Output = <ColumnMatrix2<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix3<f32>

§

type Output = <ColumnMatrix3<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix3<f64>

§

type Output = <ColumnMatrix3<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix4<f32>

§

type Output = <ColumnMatrix4<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Matrix4<f64>

§

type Output = <ColumnMatrix4<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<bool>

§

type Output = <Vector2<bool> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<f32>

§

type Output = <Vector2<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<f64>

§

type Output = <Vector2<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<i32>

§

type Output = <Vector2<i32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector2<u32>

§

type Output = <Vector2<u32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<bool>

§

type Output = <Vector3<bool> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<f32>

§

type Output = <Vector3<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<f64>

§

type Output = <Vector3<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<i32>

§

type Output = <Vector3<i32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector3<u32>

§

type Output = <Vector3<u32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<bool>

§

type Output = <Vector4<bool> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<f32>

§

type Output = <Vector4<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<f64>

§

type Output = <Vector4<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<i32>

§

type Output = <Vector4<i32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Vector4<u32>

§

type Output = <Vector4<u32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<bool>

§

type Output = <Point2<bool> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<f32>

§

type Output = <Point2<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<f64>

§

type Output = <Point2<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<i32>

§

type Output = <Point2<i32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point2<u32>

§

type Output = <Point2<u32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<bool>

§

type Output = <Point3<bool> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<f32>

§

type Output = <Point3<f32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<f64>

§

type Output = <Point3<f64> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<i32>

§

type Output = <Point3<i32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

source§

impl AsStd140 for Point3<u32>

§

type Output = <Point3<u32> as AsStd140>::Output

source§

fn as_std140(&self) -> Self::Output

source§

fn from_std140(value: Self::Output) -> Self

Implementors§