AttributeDescriptor

Trait AttributeDescriptor 

Source
pub trait AttributeDescriptor {
    // Required method
    fn get_attributes() -> &'static [Attribute];
}
Expand description

Needed to be implemented for Vertex for using it in Mesh

§Examples

use std::mem::offset_of;
use crystal_api::mesh::{AttributeDescriptor, Attribute};

type Vec3 = [f32; 3];
type Vec2 = [f32; 2];

#[repr(C)]
#[derive(Clone, Copy, Default)]
pub struct VertexTexture {
    pos: Vec3,
    uv: Vec2,
}
impl AttributeDescriptor for VertexTexture {
    fn get_attributes() -> &'static [Attribute] {
        &[
            Attribute {
                size: size_of::<Vec3>(),
                offset: offset_of!(Self, pos),
            },
            Attribute {
                size: size_of::<Vec2>(),
                offset: offset_of!(Self, uv),
            },
        ]
    }
}

Required Methods§

Source

fn get_attributes() -> &'static [Attribute]

Should return attributes of Vertex

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§