Batch

Struct Batch 

Source
pub struct Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx> { /* private fields */ }
Expand description

A builder for rendering a chunk of geometry as a batch.

Several values must be assigned before the render method can be called:

  • primitives: A list of primitives, each a tuple of indices into the list of vertices (TODO: handling oob)
  • vertices: A list of vertices
  • shader: The combined vertex and fragment shader used
  • target: The render target to render into
  • context: The rendering context and settings used. (TODO: optional?)

Additionally, setting the following values is optional:

  • uniform: The uniform value passed to the vertex shader
  • viewport: The matrix used for the NDC-to-screen transform.

Implementations§

Source§

impl Batch<(), (), (), (), (), Context>

Source

pub fn new() -> Self

Source§

impl<Prim, Vtx, Uni, Shd, Tgt, Ctx> Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>

Source

pub fn primitives<P: Clone>( self, prims: impl AsRef<[P]>, ) -> Batch<P, Vtx, Uni, Shd, Tgt, Ctx>

Sets the primitives to be rendered.

The primitives are copied into the batch.

Source

pub fn vertices<V: Clone>( self, verts: impl AsRef<[V]>, ) -> Batch<Prim, V, Uni, Shd, Tgt, Ctx>

Sets the vertices to be rendered.

The vertices are cloned into the batch.

Source

pub fn mesh<A: Clone>( self, mesh: &Mesh<A>, ) -> Batch<Tri<usize>, Vertex3<A>, Uni, Shd, Tgt, Ctx>

Clones faces and vertices from a mesh to this batch.

Source

pub fn uniform<U: Copy>(self, uniform: U) -> Batch<Prim, Vtx, U, Shd, Tgt, Ctx>

Sets the uniform data to be passed to the vertex shaders.

Source

pub fn shader<V: Vary, U, S: Shader<Vtx, V, U>>( self, shader: S, ) -> Batch<Prim, Vtx, Uni, S, Tgt, Ctx>

Sets the combined vertex and fragment shader.

Source

pub fn viewport(self, viewport: Mat4x4<NdcToScreen>) -> Self

Sets the viewport matrix.

Source

pub fn target<T>(self, target: T) -> Batch<Prim, Vtx, Uni, Shd, T, Ctx>

Sets the render target.

Source

pub fn context(self, ctx: &Context) -> Batch<Prim, Vtx, Uni, Shd, Tgt, &Context>

Sets the rendering context.

Source§

impl<Prim, Vtx, Uni, Shd, Tgt, Ctx> Batch<Prim, Vtx, Uni, Shd, &mut Tgt, Ctx>

Source

pub fn render<Var>(&mut self)
where Var: Vary, Prim: Render<Var> + Clone, Vtx: Clone, Uni: Copy, [Prim::Clip]: Clip<Item = Prim::Clip>, Shd: Shader<Vtx, Var, Uni>, Tgt: Target, Ctx: Borrow<Context>,

Renders this batch of geometry.

Trait Implementations§

Source§

impl<Prim: Clone, Vtx: Clone, Uni: Clone, Shd: Clone, Tgt: Clone, Ctx: Clone> Clone for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>

Source§

fn clone(&self) -> Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>

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<Prim: Debug, Vtx: Debug, Uni: Debug, Shd: Debug, Tgt: Debug, Ctx: Debug> Debug for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>

Source§

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

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

impl<Prim: Default, Vtx: Default, Uni: Default, Shd: Default, Tgt: Default, Ctx: Default> Default for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>

Source§

fn default() -> Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Prim, Vtx, Uni, Shd, Tgt, Ctx> Freeze for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>
where Uni: Freeze, Shd: Freeze, Tgt: Freeze, Ctx: Freeze,

§

impl<Prim, Vtx, Uni, Shd, Tgt, Ctx> RefUnwindSafe for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>

§

impl<Prim, Vtx, Uni, Shd, Tgt, Ctx> Send for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>
where Uni: Send, Shd: Send, Tgt: Send, Ctx: Send, Prim: Send, Vtx: Send,

§

impl<Prim, Vtx, Uni, Shd, Tgt, Ctx> Sync for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>
where Uni: Sync, Shd: Sync, Tgt: Sync, Ctx: Sync, Prim: Sync, Vtx: Sync,

§

impl<Prim, Vtx, Uni, Shd, Tgt, Ctx> Unpin for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>
where Uni: Unpin, Shd: Unpin, Tgt: Unpin, Ctx: Unpin, Prim: Unpin, Vtx: Unpin,

§

impl<Prim, Vtx, Uni, Shd, Tgt, Ctx> UnwindSafe for Batch<Prim, Vtx, Uni, Shd, Tgt, Ctx>
where Uni: UnwindSafe, Shd: UnwindSafe, Tgt: UnwindSafe, Ctx: UnwindSafe, Prim: UnwindSafe, Vtx: UnwindSafe,

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, 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.