[−][src]Trait crevice::std140::AsStd140
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 geometry crates, like cgmath, nalgebra, and
ultraviolet support mint.
Example
uniform CAMERA {
mat4 view;
mat4 projection;
} camera;
use cgmath::prelude::*; use cgmath::{Matrix4, Deg, perspective}; use crevice::std140::{AsStd140, Std140}; #[derive(AsStd140)] struct CameraUniform { view: mint::ColumnMatrix4<f32>, projection: mint::ColumnMatrix4<f32>, } let camera = CameraUniform { view: Matrix4::identity().into(), projection: perspective(Deg(60.0), 16.0/9.0, 0.01, 100.0).into(), }; let camera_std140 = camera.as_std140(); write_to_gpu_buffer(camera_std140.as_bytes());
Associated Types
type Std140Type: Std140
The std140
version of this value.
Required methods
fn as_std140(&self) -> Self::Std140Type
Convert this value into the std140
version of itself.
Provided methods
fn std140_size(&self) -> usize
Returns the size of the std140
version of this type. Useful for
pre-sizing buffers.
Implementations on Foreign Types
impl AsStd140 for Vector2<f32>
[src]
type Std140Type = Vec2
fn as_std140(&self) -> Self::Std140Type
[src]
impl AsStd140 for Vector3<f32>
[src]
type Std140Type = Vec3
fn as_std140(&self) -> Self::Std140Type
[src]
impl AsStd140 for Vector4<f32>
[src]
type Std140Type = Vec4
fn as_std140(&self) -> Self::Std140Type
[src]
impl AsStd140 for ColumnMatrix2<f32>
[src]
type Std140Type = Mat2
fn as_std140(&self) -> Self::Std140Type
[src]
impl AsStd140 for ColumnMatrix3<f32>
[src]
type Std140Type = Mat3
fn as_std140(&self) -> Self::Std140Type
[src]
impl AsStd140 for ColumnMatrix4<f32>
[src]
type Std140Type = Mat4
fn as_std140(&self) -> Self::Std140Type
[src]
Implementors
impl<T> AsStd140 for T where
T: Std140,
[src]
T: Std140,