Struct frenderer::frenderer::Immediate

source ·
pub struct Immediate { /* private fields */ }
Expand description

Immediate wraps a Renderer with an immediate-mode API with functions like Immediate::draw_sprite. This API is less modular and may be less efficient, but is simpler for some use cases.

Implementations§

source§

impl Immediate

source

pub fn new(renderer: Renderer) -> Self

Permanently converts a Renderer into an Immediate.

source

pub fn auto_clear(&mut self, c: bool)

Whether this renderer should clear its counters/state during rendering. If set to false, it will accumulate drawing commands from multiple frames until Immediate::clear is called.

source

pub fn clear(&mut self)

Clear the render state. If done in the middle of a frame this cancels out earlier draw commands, and if done between frames (when auto_clear is false) will set up the renderer for the next frame.

source

pub fn set_present_mode(&mut self, mode: PresentMode)

Changes the present mode for this renderer

source

pub fn surface(&self) -> Option<&Surface<'static>>

Returns the current surface

source

pub fn create_surface(&mut self, window: Arc<Window>)

Creates a new surface for this renderer

source

pub fn resize_surface(&mut self, w: u32, h: u32)

Resize the internal surface texture (typically called when the window or canvas size changes).

source

pub fn resize_render(&mut self, w: u32, h: u32)

Resize the internal color and depth targets (the actual rendering resolution).

source

pub fn render(&mut self)

Acquire the next frame, create a wgpu::RenderPass, draw into it, and submit the encoder. This also queues uploads of mesh, sprite, or other instance data, so if you don’t use Renderer::render in your code be sure to call Renderer::do_uploads if you’re using the built-in mesh, flat, or sprite renderers.

source

pub fn surface_size(&self) -> (u32, u32)

Returns the size of the surface onto which the rendered image is stretched

source

pub fn render_size(&self) -> (u32, u32)

Returns the size of the internal rendering texture (i.e., the rendering resolution)

source

pub fn create_array_texture( &self, images: &[&[u8]], format: TextureFormat, (width, height): (u32, u32), label: Option<&str> ) -> Texture

Creates an array texture on the renderer’s GPU.

source

pub fn create_texture( &self, image: &[u8], format: TextureFormat, (width, height): (u32, u32), label: Option<&str> ) -> Texture

Creates a single texture on the renderer’s GPU.

source

pub fn sprite_group_add( &mut self, tex: &Texture, count_estimate: usize, camera: Camera2D ) -> usize

Create a new sprite group sized to fit count_estimate. Returns the sprite group index corresponding to this group.

source

pub fn sprite_group_count(&self) -> usize

Returns the number of sprite groups (including placeholders for removed groups).

source

pub fn sprite_group_remove(&mut self, which: usize)

Deletes a sprite group, leaving an empty group slot behind (this might get recycled later).

source

pub fn sprite_group_size(&self, which: usize) -> usize

Reports the size of the given sprite group. Panics if the given sprite group is not populated.

source

pub fn ensure_sprites_size(&mut self, which: usize, num: usize)

Makes sure that the size of the given sprite group is at least as large as num.

source

pub fn sprite_group_set_camera(&mut self, which: usize, camera: Camera2D)

Set the given camera transform on a specific sprite group. Uploads to the GPU. Panics if the given sprite group is not populated.

source

pub fn draw_sprite( &mut self, group: usize, transform: Transform, sheet_region: SheetRegion )

Draws a sprite with the given transform and sheet region

source

pub fn draw_sprites( &mut self, group: usize, howmany: usize ) -> (&mut [Transform], &mut [SheetRegion])

Gets a block of howmany sprites to draw into, as per [Renderer::get_sprites_mut]

source

pub fn draw_text<B: RangeBounds<char>>( &mut self, group: usize, bitfont: &BitFont<B>, text: &str, screen_pos: [f32; 2], depth: u16, char_height: f32 ) -> ([f32; 2], usize)

Draws a line of text with the given crate::bitfont::BitFont.

source

pub fn draw_nineslice( &mut self, group: usize, ninesl: &NineSlice, x: f32, y: f32, w: f32, h: f32, z_offset: u16 ) -> usize

Draws the sprites of a crate::nineslice::NineSlice.

source

pub fn mesh_set_camera(&mut self, camera: Camera3D)

Sets the given camera for all textured mesh groups.

source

pub fn mesh_group_add( &mut self, texture: &Texture, vertices: Vec<Vertex>, indices: Vec<u32>, mesh_info: Vec<MeshEntry> ) -> MeshGroup

Add a mesh group with the given array texture. All meshes in the group pull from the same vertex buffer, and each submesh is defined in terms of a range of indices within that buffer. When loading your mesh resources from whatever format they’re stored in, fill out vertex and index vecs while tracking the beginning and end of each mesh and submesh (see crate::meshes::MeshEntry for details). Sets the given camera for all flat mesh groups.

source

pub fn mesh_group_remove(&mut self, which: MeshGroup)

Deletes a mesh group, leaving an empty placeholder.

source

pub fn mesh_group_count(&self) -> usize

Returns how many mesh groups there are.

source

pub fn mesh_group_size(&self, which: MeshGroup) -> usize

Returns how many meshes there are in the given mesh group.

source

pub fn ensure_meshes_size(&mut self, which: MeshGroup, idx: usize, num: usize)

Makes sure that the mesh instance slice for the given mesh group and index is at least big enough to hold num.

source

pub fn draw_mesh(&mut self, which: MeshGroup, idx: usize, trf: Transform3D)

Draws a textured, unlit mesh with the given crate::meshes::Transform3D.

source

pub fn draw_meshes( &mut self, group: MeshGroup, idx: usize, howmany: usize ) -> &mut [Transform3D]

Gets a block of howmany mesh instances to draw into, as per [Renderer::get_meshes_mut]

source

pub fn flat_set_camera(&mut self, camera: Camera3D)

Sets the given camera for all flat mesh groups.

source

pub fn flat_group_add( &mut self, material_colors: &[[f32; 4]], vertices: Vec<FlatVertex>, indices: Vec<u32>, mesh_info: Vec<MeshEntry> ) -> MeshGroup

Add a flat mesh group with the given color materials. All meshes in the group pull from the same vertex buffer, and each submesh is defined in terms of a range of indices within that buffer. When loading your mesh resources from whatever format they’re stored in, fill out vertex and index vecs while tracking the beginning and end of each mesh and submesh (see crate::meshes::MeshEntry for details).

source

pub fn flat_group_remove(&mut self, which: MeshGroup)

Deletes a mesh group, leaving an empty placeholder.

source

pub fn flat_group_count(&self) -> usize

Returns how many mesh groups there are.

source

pub fn flat_group_size(&self, which: MeshGroup) -> usize

Returns how many meshes there are in the given mesh group.

source

pub fn ensure_flats_size(&mut self, which: MeshGroup, idx: usize, num: usize)

Makes sure that the flats instance slice for the given mesh group and index is at least big enough to hold num.

source

pub fn draw_flat(&mut self, which: MeshGroup, idx: usize, trf: Transform3D)

Draws a flat mesh (of the given group and mesh index) with the given crate::meshes::Transform3D.

source

pub fn draw_flats( &mut self, group: MeshGroup, idx: usize, howmany: usize ) -> &mut [Transform3D]

Gets a block of howmany flatmesh instances to draw into, as per [Renderer::get_flats_mut]

source

pub fn post_transform(&self) -> [f32; 16]

Returns the current geometric transform used in postprocessing (a 4x4 column-major homogeneous matrix)

source

pub fn post_color_transform(&self) -> [f32; 16]

Returns the current color transform used in postprocessing (a 4x4 column-major homogeneous matrix)

source

pub fn post_saturation(&self) -> f32

Returns the current saturation value in postprocessing (a value between -1 and 1, with 0.0 meaning an identity transformation)

source

pub fn post_set(&mut self, trf: [f32; 16], color_trf: [f32; 16], sat: f32)

Sets all postprocessing parameters

source

pub fn post_set_transform(&mut self, trf: [f32; 16])

Sets the postprocessing geometric transform (a 4x4 column-major homogeneous matrix)

source

pub fn post_set_color_transform(&mut self, trf: [f32; 16])

Sets the postprocessing color transform (a 4x4 column-major homogeneous matrix)

source

pub fn post_set_saturation(&mut self, sat: f32)

Sets the postprocessing saturation value (a number between -1 and 1, with 0.0 meaning an identity transformation)

source

pub fn post_set_lut(&mut self, lut: &Texture)

Sets the postprocessing color lookup table texture

source

pub fn config(&self) -> &SurfaceConfiguration

Gets the surface configuration

source

pub fn depth_texture(&self) -> &Texture

Gets a reference to the active depth texture

source

pub fn depth_texture_view(&self) -> &TextureView

Gets a view on the active depth texture

source

pub fn gpu(&self) -> &WGPU

Get the GPU from the inner renderer

Trait Implementations§

source§

impl Frenderer for Immediate

source§

fn render(&mut self)

source§

impl<T> FrendererEvents<T> for Immediate

source§

fn handle_event( &mut self, clock: &mut Clock, window: &Arc<Window>, evt: &Event<T>, target: &EventLoopWindowTarget<T>, input: &mut Input ) -> EventPhase

Call handle_event on your crate::frenderer::Renderer with a given crate::clock::Clock to let Frenderer figure out “the right thing to do” for the current winit event. See crate::clock::Clock for details on the timestep computation.
source§

impl From<Renderer> for Immediate

source§

fn from(rend: Renderer) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.
source§

impl<T> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WasmNotSend for T
where T: Send,

source§

impl<T> WasmNotSendSync for T

source§

impl<T> WasmNotSync for T
where T: Sync,