Mode

Enum Mode 

Source
pub enum Mode {
    Point,
    Line,
    LineStrip,
    Triangle,
    TriangleFan,
    TriangleStrip,
    Patch(usize),
}
Expand description

Primitive mode.

Some modes allow for primitive restart. Primitive restart is a cool feature that allows to break the building of a primitive to start over again. For instance, when making a curve, you can imagine gluing segments next to each other. If at some point, you want to start a new curve, you have two choices:

  • Either you stop your draw call and make another one.
  • Or you just use the primitive restart feature to ask to create another line from scratch.

Primitive restart should be used as much as possible as it will decrease the number of GPU commands you have to issue.

Deprecation notice: the next version of luminance will not support setting the primitive restart index: you will then must provide the maximum value of index type.

That feature is encoded with a special vertex index. You can setup the value of the primitive restart index with TessBuilder::set_primitive_restart_index. Whenever a vertex index is set to the same value as the primitive restart index, the value is not interpreted as a vertex index but just a marker / hint to start a new primitive.

Variants§

§

Point

A single point.

Points are left unconnected from each other and represent a point cloud. This is the typical primitive mode you want to do, for instance, particles rendering.

§

Line

A line, defined by two points.

Every pair of vertices are connected together to form a straight line.

§

LineStrip

A strip line, defined by at least two points and zero or many other ones.

The first two vertices create a line, and every new vertex flowing in the graphics pipeline (starting from the third, then) well extend the initial line, making a curve composed of several segments.

This kind of primitive mode allows the usage of primitive restart.

§

Triangle

A triangle, defined by three points.

§

TriangleFan

A triangle fan, defined by at least three points and zero or many other ones.

Such a mode is easy to picture: a cooling fan is a circular shape, with blades. Mode::TriangleFan is kind of the same. The first vertex is at the center of the fan, then the second vertex creates the first edge of the first triangle. Every time you add a new vertex, a triangle is created by taking the first (center) vertex, the very previous vertex and the current vertex. By specifying vertices around the center, you actually create a fan-like shape.

This kind of primitive mode allows the usage of primitive restart.

§

TriangleStrip

A triangle strip, defined by at least three points and zero or many other ones.

This mode is a bit different from Mode::TriangleFan. The first two vertices define the first edge of the first triangle. Then, for each new vertex, a new triangle is created by taking the very previous vertex and the last to very previous vertex. What it means is that every time a triangle is created, the next vertex will share the edge that was created to spawn the previous triangle.

This mode is useful to create long ribbons / strips of triangles.

This kind of primitive mode allows the usage of primitive restart.

§

Patch(usize)

A general purpose primitive with n vertices, for use in tessellation shaders. For example, Mode::Patch(3) represents triangle patches, so every three vertices in the buffer form a patch.

If you want to employ tessellation shaders, this is the only primitive mode you can use.

Trait Implementations§

Source§

impl Clone for Mode

Source§

fn clone(&self) -> Mode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Mode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Mode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Mode

Source§

fn eq(&self, other: &Mode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Mode

Source§

impl Eq for Mode

Source§

impl StructuralPartialEq for Mode

Auto Trait Implementations§

§

impl Freeze for Mode

§

impl RefUnwindSafe for Mode

§

impl Send for Mode

§

impl Sync for Mode

§

impl Unpin for Mode

§

impl UnwindSafe for Mode

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.