retrofire_core::render::batch

Struct Batch

Source
pub struct Batch<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:

  • faces: A list of triangles, each a triplet 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<Vtx, Uni, Shd, Tgt, Ctx> Batch<Vtx, Uni, Shd, Tgt, Ctx>

Source

pub fn faces(self, faces: impl AsRef<[Tri<usize>]>) -> Self

Sets the faces to be rendered.

The faces are copied into the batch.

Source

pub fn vertices<V: Clone>( self, verts: impl AsRef<[V]>, ) -> Batch<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<Vertex<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<Vtx, U, Shd, Tgt, Ctx>

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

Source

pub fn shader<V: Vary, S: Shader<Vtx, V, Uni>>( self, shader: S, ) -> Batch<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<Vtx, Uni, Shd, T, Ctx>

Sets the render target.

Source

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

Sets the rendering context.

Source§

impl<Vtx: Clone, Uni: Copy, Shd, Tgt: Target, Ctx> Batch<Vtx, Uni, Shd, &mut Tgt, Ctx>
where Ctx: Borrow<Context>,

Source

pub fn render<V: Vary>(&mut self)
where Shd: Shader<Vtx, V, Uni>,

Renders this batch of geometry.

Trait Implementations§

Source§

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

Source§

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

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

Source§

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

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

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

Source§

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

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<Vtx, Uni, Shd, Tgt, Ctx> UnwindSafe for Batch<Vtx, Uni, Shd, Tgt, Ctx>
where Uni: UnwindSafe, Shd: UnwindSafe, Tgt: UnwindSafe, Ctx: 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.