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
impl RenderEngine
Sourcepub fn from_surface(
instance: &Instance,
surface: Surface<'static>,
config: RenderConfig,
) -> Self
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.
Sourcepub fn save_pipeline_cache(&self)
pub fn save_pipeline_cache(&self)
save the vulkan pipeline cache to disk. call this before shutting down to speed up future launches.
Sourcepub fn add_render_pass<P: RenderPass>(&mut self, pass: P)
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.
Sourcepub const fn config(&self) -> &RenderConfig
pub const fn config(&self) -> &RenderConfig
get the current render config
Sourcepub fn remove_texture(&mut self, tex_id: u32)
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.
Sourcepub fn create_render_target(
&mut self,
store: &mut RenderTargetStore,
width: u32,
height: u32,
) -> (RenderTargetId, Handle<Texture>)
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.targetto direct a camera at this target. - use the texture handle with
draw_spriteto display the target’s contents.
also registers the entry in the supplied RenderTargetStore so it can be
looked up later via RenderTargetStore::get_texture.
Sourcepub fn upload_font(&mut self, font_id: u32, data: &[u8])
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.
Sourcepub fn upload_texture(&mut self, handle: &Handle<Texture>, texture: &Texture)
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.
Sourcepub fn surface_size(&self) -> (u32, u32)
pub fn surface_size(&self) -> (u32, u32)
current surface size
Sourcepub fn render(
&mut self,
commands: &[DrawCommand],
camera: Option<&Camera>,
render_info: &mut RenderInfo,
)
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.
impl Drop for RenderEngine
save the pipeline cache on shutdown so the next launch benefits from it.
impl Resource for RenderEngine
Auto Trait Implementations§
impl !Freeze for RenderEngine
impl !RefUnwindSafe for RenderEngine
impl !UnwindSafe for RenderEngine
impl Send for RenderEngine
impl Sync for RenderEngine
impl Unpin for RenderEngine
impl UnsafeUnpin for RenderEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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