[−][src]Crate glsl_layout
This crates provides data types to build structures ready to upload into UBO.
Data layout will match one for uniform blocks declared with layout(std140).
See specs for alignment rules.
Examples
#[derive(Debug, Default, Clone, Copy, Uniform)] struct Foo { x: int, y: vec3, z: float, w: mat4x4, a: [f32; 3], b: f32, } type UFoo = <Foo as Uniform>::Std140; assert_eq!( offset_of!(UFoo: y), round_up_to(size_of::<int>(), 16), // `vec3` has alignment of size `vec4` "Offset of field `y` must be equal of size of `x` rounded up to the alignment", ); assert_eq!( offset_of!(UFoo: z), round_up_to(offset_of!(UFoo: y) + size_of::<vec3>(), 4), "Field `z` must follow `y`. `y` should not have padding at the end", ); assert_eq!( offset_of!(UFoo: b), offset_of!(UFoo: a) + size_of::<[[f32; 4]; 3]>(), "Field `b` must follow `a`. But `a` has padding at the end.", ); let foo_uniform = Foo { x: 2, y: [0.0; 3].into(), z: 0.0, w: [[0.0; 4]; 4].into(), a: [0.0; 3].into(), b: 0.0, }.std140();
Structs
| Array | Array of |
| ArrayIter | Array ref iterator Iterate over references to inner values. |
| Element | Aligning wrapper. Elements for array are aligned to 16 bytes (size of vec4) at least. |
| boolean | Boolean value. |
| bvec2 | Vector of 2 |
| bvec3 | Vector of 3 |
| bvec4 | Vector of 4 |
| dvec2 | Vector of 2 |
| dvec3 | Vector of 3 |
| dvec4 | Vector of 4 |
| ivec2 | Vector of 2 |
| ivec3 | Vector of 3 |
| ivec4 | Vector of 4 |
| uvec2 | Vector of 2 |
| uvec3 | Vector of 3 |
| uvec4 | Vector of 4 |
| vec2 | Vector of 2 |
| vec3 | Vector of 3 |
| vec4 | Vector of 4 |
Traits
| Std140 | Special marker trait implemented only for |
| Uniform | Structure to transform data from rust's structure to the raw data ready to upload to UBO.
Users should prepfer to use |
Type Definitions
| bmat2 | Matrix of 2 x 2 boolean values. |
| bmat2x2 | Matrix of 2 x 2 boolean values. |
| bmat2x3 | Matrix of 2 x 3 boolean values. |
| bmat2x4 | Matrix of 2 x 4 boolean values. |
| bmat3 | Matrix of 3 x 3 boolean values. |
| bmat3x2 | Matrix of 3 x 2 boolean values. |
| bmat3x3 | Matrix of 3 x 3 boolean values. |
| bmat3x4 | Matrix of 3 x 4 boolean values. |
| bmat4 | Matrix of 4 x 4 boolean values. |
| bmat4x2 | Matrix of 4 x 2 boolean values. |
| bmat4x3 | Matrix of 4 x 3 boolean values. |
| bmat4x4 | Matrix of 4 x 4 boolean values. |
| dmat2 | Matrix of 2 x 2 double-precision floating-point values. |
| dmat2x2 | Matrix of 2 x 2 double-precision floating-point values. |
| dmat2x3 | Matrix of 2 x 3 double-precision floating-point values. |
| dmat2x4 | Matrix of 2 x 4 double-precision floating-point values. |
| dmat3 | Matrix of 3 x 3 double-precision floating-point values. |
| dmat3x2 | Matrix of 3 x 2 double-precision floating-point values. |
| dmat3x3 | Matrix of 3 x 3 double-precision floating-point values. |
| dmat3x4 | Matrix of 3 x 4 double-precision floating-point values. |
| dmat4 | Matrix of 4 x 4 double-precision floating-point values. |
| dmat4x2 | Matrix of 4 x 2 double-precision floating-point values. |
| dmat4x3 | Matrix of 4 x 3 double-precision floating-point values. |
| dmat4x4 | Matrix of 4 x 4 double-precision floating-point values. |
| double | Double-precision floating-point value. |
| float | floating-point value. |
| imat2 | Matrix of 2 x 2 signed integer values. |
| imat2x2 | Matrix of 2 x 2 signed integer values. |
| imat2x3 | Matrix of 2 x 3 signed integer values. |
| imat2x4 | Matrix of 2 x 4 signed integer values. |
| imat3 | Matrix of 3 x 3 signed integer values. |
| imat3x2 | Matrix of 3 x 2 signed integer values. |
| imat3x3 | Matrix of 3 x 3 signed integer values. |
| imat3x4 | Matrix of 3 x 4 signed integer values. |
| imat4 | Matrix of 4 x 4 signed integer values. |
| imat4x2 | Matrix of 4 x 2 signed integer values. |
| imat4x3 | Matrix of 4 x 3 signed integer values. |
| imat4x4 | Matrix of 4 x 4 signed integer values. |
| int | Signed integer value. |
| mat2 | Matrix of 2 x 2 floating-point values. |
| mat2x2 | Matrix of 2 x 2 floating-point values. |
| mat2x3 | Matrix of 2 x 3 floating-point values. |
| mat2x4 | Matrix of 2 x 4 floating-point values. |
| mat3 | Matrix of 3 x 3 floating-point values. |
| mat3x2 | Matrix of 3 x 2 floating-point values. |
| mat3x3 | Matrix of 3 x 3 floating-point values. |
| mat3x4 | Matrix of 3 x 4 floating-point values. |
| mat4 | Matrix of 4 x 4 floating-point values. |
| mat4x2 | Matrix of 4 x 2 floating-point values. |
| mat4x3 | Matrix of 4 x 3 floating-point values. |
| mat4x4 | Matrix of 4 x 4 floating-point values. |
| uint | Unsigned integer value. |
| umat2 | Matrix of 2 x 2 unsiged integer values. |
| umat2x2 | Matrix of 2 x 2 unsiged integer values. |
| umat2x3 | Matrix of 2 x 3 unsiged integer values. |
| umat2x4 | Matrix of 2 x 4 unsiged integer values. |
| umat3 | Matrix of 3 x 3 unsiged integer values. |
| umat3x2 | Matrix of 3 x 2 unsiged integer values. |
| umat3x3 | Matrix of 3 x 3 unsiged integer values. |
| umat3x4 | Matrix of 3 x 4 unsiged integer values. |
| umat4 | Matrix of 4 x 4 unsiged integer values. |
| umat4x2 | Matrix of 4 x 2 unsiged integer values. |
| umat4x3 | Matrix of 4 x 3 unsiged integer values. |
| umat4x4 | Matrix of 4 x 4 unsiged integer values. |