Macro rustic_gl::buffer_layout[][src]

macro_rules! buffer_layout {
    ($($t:ty),*) => { ... };
}

Specify the layout of a single OpenGL buffer.

After optimization should be equivalent to calling glEnableVertexAttribArray and glVertexAttribPointer manually.

To activate this layout manually you must call the "declare" method with the location of the first attribute. All following attributes are assumed to be at consecutive locations.

Note: There may be bugs regarding alignment and non-trivial types haven't been tested. The author has so far used this macro successfully a number of times, however. If it gives you an issue, please open an issue. A tool like RenderDoc may be useful for debugging.

Examples

use rustic_gl::attributes::Normalized;
pub type StaticMeshFormat = buffer_layout!([f32; 3], [Normalized<u8>; 4]);
// When you're ready to call `glVertexAttribPointer`, just do
// StaticMeshFormat::declare(0);
// which will set vertex attribute 0 to be a vec3<f32>, and attribute 2 to be a vec4<f32>.