macro_rules! implement_vertex {
    ($struct_name:ident, $($field_name:ident),+) => { ... };
    ($struct_name:ident, $($field_name:ident normalize($should_normalize:expr)),+) => { ... };
    ($struct_name:ident, $($field_name:ident location($location:expr)),+) => { ... };
    ($struct_name:ident, $($field_name:ident),+,) => { ... };
}
Expand description

Implements the glium::vertex::Vertex trait for the given type.

The parameters must be the name of the struct and the names of its fields.

Safety

You must not use this macro on any struct with fields that cannot be zeroed.

Example

#[derive(Copy, Clone)]
struct Vertex {
    position: [f32; 3],
    tex_coords: [f32; 2],
}

implement_vertex!(Vertex, position, tex_coords);

Naming convention

If not using the location option, when it comes to using to using your vertex array in a shader you must make sure that all your attribute variables match the field names in the struct you are calling calling this macro for.

So, if you have a vertex_position attribute/input in your shader, a field named vertex_position must be present in the struct. Otherwise the drawing functions will panic.

Normalize option

You can specify a normalize option for attributes.

implement_vertex!(Vertex, position normalize(false), tex_coords normalize(false));

Location option

You can specify a location option for attributes.

implement_vertex!(Vertex, position location(0), tex_coords location(1));