[][src]Trait luminance::vertex::Semantics

pub trait Semantics: Sized + Copy + Clone + Debug {
    fn index(&self) -> usize;
fn name(&self) -> &'static str;
fn semantics_set() -> Vec<SemanticsDesc>; }

Vertex attribute semantics.

Vertex attribute semantics are a mean to make shaders and vertex buffers talk to each other correctly. This is important for several reasons:

  • The memory layout of your vertex buffers might be very different from an ideal case or even the common case. Shaders don’t have any way to know where to pick vertex attributes from, so a mapping is needed.
  • Sometimes, a shader just need a few information from the vertex attributes. You then want to be able to authorize “gaps” in the semantics so that shaders can be used for several varieties of vertex formats.

Vertex attribute semantics are any type that can implement this trait. The idea is that semantics must be unique. The vertex position should have an index that is never used anywhere else in the vertex buffer. Because of the second point above, it’s also highly recommended (even though valid not to) to stick to the same index for a given semantics when you have several tessellations – that allows better composition with shaders. Basically, the best advice to follow: define your semantics once, and keep to them.

Note: feel free to use the [luminance-derive] crate to automatically derive this trait from an enum.

Required methods

fn index(&self) -> usize

Retrieve the semantics index of this semantics.

fn name(&self) -> &'static str

Get the name of this semantics.

fn semantics_set() -> Vec<SemanticsDesc>

Get all available semantics.

Loading content...

Implementations on Foreign Types

impl Semantics for ()[src]

Loading content...

Implementors

Loading content...