Skip to content

How to use vertex_attr_array ? #1790

Answered by kvark
rokonio asked this question in Q&A
Aug 11, 2021 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Rust is confused and doesn't realize this macro invocation returns a constant expression.
You can work around by doing this following:

impl Vertex {
    const ATTRIBS: [wgpu::VertexAttribute; 2] = wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3];
    pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
        wgpu::VertexBufferLayout {
            array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
            step_mode: wgpu::VertexStepMode::Vertex,
            attributes: &Self::ATTRIBS,
        }
    }
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@CaesarXInsanium
Comment options

@matthewgapp
Comment options

@tpkee
Comment options

Answer selected by rokonio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants