Skip to main content

RenderEngine

Struct RenderEngine 

Source
pub struct RenderEngine { /* private fields */ }
Expand description

render engine resource, owns all GPU rendering state.

managed by the engine — game code reads it via Res<RenderEngine> when it needs direct GPU access for custom draw calls or render target operations.

Implementations§

Source§

impl RenderEngine

Source

pub fn from_surface( instance: &Instance, surface: Surface<'static>, config: RenderConfig, ) -> Self

create render engine from a surface (native, blocking)

§Panics

panics if no adapter or device can be created.

Source

pub fn save_pipeline_cache(&self)

save the vulkan pipeline cache to disk. call this before shutting down to speed up future launches.

Source

pub fn add_render_pass<P: RenderPass>(&mut self, pass: P)

register a custom render pass. passes are executed in registration order after the default 2D pass.

Source

pub const fn config(&self) -> &RenderConfig

get the current render config

Source

pub const fn device(&self) -> &Device

get the wgpu device

Source

pub const fn queue(&self) -> &Queue

get the wgpu queue

Source

pub fn resize(&mut self, width: u32, height: u32)

resize the render surface

Source

pub fn remove_texture(&mut self, tex_id: u32)

remove a texture and its cached bind group. call this when a texture is no longer needed to free GPU memory.

Source

pub fn create_render_target( &mut self, store: &mut RenderTargetStore, width: u32, height: u32, ) -> (RenderTargetId, Handle<Texture>)

create an offscreen render target of the given pixel dimensions.

returns a (RenderTargetId, Handle<Texture>) pair:

  • use the id in Camera.target to direct a camera at this target.
  • use the texture handle with draw_sprite to display the target’s contents.

also registers the entry in the supplied RenderTargetStore so it can be looked up later via RenderTargetStore::get_texture.

Source

pub fn upload_font(&mut self, font_id: u32, data: &[u8])

register font bytes with the glyph atlas. glyphs are rasterized on demand during render() and the atlas is uploaded then.

Source

pub fn upload_texture(&mut self, handle: &Handle<Texture>, texture: &Texture)

upload a texture to the GPU, returns its handle id. if the texture is already uploaded, this is a no-op.

Source

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

current surface size

Source

pub fn render( &mut self, commands: &[DrawCommand], camera: Option<&Camera>, render_info: &mut RenderInfo, )

render all draw commands for this frame. sprites are batched by texture — one draw call per unique texture. rects (no texture) are drawn in a single additional draw call.

Trait Implementations§

Source§

impl Drop for RenderEngine

Available on non-WebAssembly only.

save the pipeline cache on shutdown so the next launch benefits from it.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Resource for RenderEngine
where Self: Send + Sync + 'static,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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

Source§

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

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts &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)

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

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> Upcast<T> for T

Source§

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

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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