Skip to main content

GameRenderContext

Struct GameRenderContext 

Source
pub struct GameRenderContext<'a> { /* private fields */ }
Expand description

Viewport-local immediate-mode 2D/framebuffer drawing surface passed to GameScene::render.

Implementations§

Source§

impl<'a> GameRenderContext<'a>

Viewport-local drawing primitives for GameRenderContext.

Source

pub fn new(bounds: Rect, display_list: &'a mut DisplayList) -> Self

Creates a GameRenderContext bound to bounds and display_list.

§Arguments
  • Rect - Viewport bounds in root logical coordinates.
  • &'a mut DisplayList - Target display list.
§Returns
  • Self - Constructed viewport render context.
Source

pub fn composite_gpu_texture( &mut self, rect: Rect, handle: GpuTextureHandle, ) -> bool

Binds a shared same-device GPU render target texture to be composited directly beneath EUV HUD overlays in a single present without CPU readback.

§Arguments
  • &Self - Mutable render context.
  • Rect - Local destination rectangle inside the viewport.
  • GpuTextureHandle - Valid same-device GPU render target handle.
§Returns
  • bool - true when the handle is valid and bound for direct GPU compositing.
Source

pub fn gpu_composite_target(&self) -> Option<GpuCompositeDescriptor>

Returns the bound GPU composite descriptor emitted during this frame, if any.

§Arguments
  • &Self - Render context reference.
§Returns
  • Option<GpuCompositeDescriptor> - Bound GPU composite target descriptor.
Source

pub fn take_gpu_composite_target(&mut self) -> Option<GpuCompositeDescriptor>

Consumes and returns the bound GPU composite descriptor emitted during this frame for direct single-pass UI+3D compositing.

§Arguments
  • &Self - Mutable render context.
§Returns
  • Option<GpuCompositeDescriptor> - Bound GPU composite target descriptor if one was attached.
Source

pub fn compose_shared_gpu_surface( &mut self, surface: &mut GpuSharedSurface, compositor_device_id: u64, ) -> SharedGpuCompositeReceipt

Composes a GpuSharedSurface directly onto the shared GPU present chain with zero CPU readback.

§Arguments
  • &Self - Mutable render context.
  • &mut GpuSharedSurface - Shared 3D+HUD GPU presentation surface.
  • u64 - Active compositor logical GPU device identifier.
§Returns
  • SharedGpuCompositeReceipt - Honest receipt reporting zero-readback GPU compositing telemetry.
Source

pub fn blit_pooled_frame(&mut self, rect: Rect, lease: &PooledFrameLease)

Blits a pooled CPU fallback frame lease into rect inside this game viewport with zero per-frame pixel copy.

§Arguments
  • &Self - Mutable render context.
  • Rect - Local destination rectangle.
  • &PooledFrameLease - Rendered pooled RGBA8 frame lease.
Source

pub fn blit_pooled_frame_ref(&mut self, rect: Rect, frame: &PooledFrameRef)

Blits a zero-copy PooledFrameRef handle into rect inside this game viewport via Arc sharing without pixel copy.

§Arguments
  • &Self - Mutable render context.
  • Rect - Local destination rectangle.
  • &PooledFrameRef - Shared pooled RGBA8 frame reference.
Source

pub fn viewport_size(&self) -> Size

Returns the logical width and height of the game viewport.

§Arguments
  • &Self - Render context reference.
§Returns
  • Size - Viewport size in logical pixels.
Source

pub fn scale_factor(&self) -> f32

Returns the active display DPI scale factor of the target DisplayList (>= 0.5).

§Arguments
  • &Self - Render context reference.
§Returns
  • f32 - Active display DPI scale factor.
Source

pub fn clear(&mut self, color: Color)

Fills the entire game viewport with color.

§Arguments
  • &Self - Mutable render context.
  • Color - Background clear color.
Source

pub fn fill_rect(&mut self, rect: Rect, color: Color)

Draws an axis-aligned solid rectangle in viewport-local coordinates.

§Arguments
  • &Self - Mutable render context.
  • Rect - Local rectangle bounds.
  • Color - Fill color.
Source

pub fn fill_rounded_rect(&mut self, rect: Rect, color: Color, radius: f32)

Draws a rounded solid rectangle in viewport-local coordinates.

§Arguments
  • &Self - Mutable render context.
  • Rect - Local rectangle bounds.
  • Color - Fill color.
  • f32 - Corner radius in logical pixels.
Source

pub fn stroke_rect(&mut self, rect: Rect, stroke_width: f32, color: Color)

Draws an outlined rectangle in viewport-local coordinates.

§Arguments
  • &Self - Mutable render context.
  • Rect - Local rectangle bounds.
  • f32 - Stroke thickness in logical pixels.
  • Color - Stroke color.
Source

pub fn fill_circle(&mut self, center: Point, radius: f32, color: Color)

Draws a filled circle in viewport-local coordinates.

§Arguments
  • &Self - Mutable render context.
  • Point - Circle center in viewport-local coordinates.
  • f32 - Circle radius in logical pixels.
  • Color - Fill color.
Source

pub fn draw_image(&mut self, rect: Rect, buffer: ImageBuffer)

Draws an RGBA8 ImageBuffer stretched into rect inside this game viewport (ideal for 3D render targets).

§Arguments
  • &Self - Mutable render context.
  • Rect - Local destination rectangle inside the viewport.
  • ImageBuffer - Source RGBA8 pixel buffer.
Source

pub fn draw_line(&mut self, from: Point, to: Point, width: f32, color: Color)

Draws an anti-aliased line segment in viewport-local coordinates.

§Arguments
  • &Self - Mutable render context.
  • Point - Segment start point.
  • Point - Segment end point.
  • f32 - Line width in logical pixels.
  • Color - Line color.
Source

pub fn draw_text( &mut self, position: Point, text: String, font_size: f32, color: Color, )

Draws HUD or debug text inside the game viewport.

§Arguments
  • &Self - Mutable render context.
  • Point - Top-left local position.
  • String - Text string.
  • f32 - Font size in logical pixels.
  • Color - Text color.
Source

pub fn draw_text_str( &mut self, position: Point, text: &str, font_size: f32, color: Color, )

Draws HUD or debug text from a borrowed slice using the display list’s recycled string pool for zero steady-state allocations.

§Arguments
  • &Self - Mutable render context.
  • Point - Top-left local position.
  • &str - Borrowed UTF-8 text slice.
  • f32 - Font size in logical pixels.
  • Color - Text color.
Source

pub fn blit_framebuffer(&mut self, rect: Rect, buffer: ImageBuffer)

Blits an external 2D/3D engine RGBA8 ImageBuffer directly into the viewport.

§Arguments
  • &Self - Mutable render context.
  • Rect - Local destination rectangle.
  • ImageBuffer - External engine rendered frame or sprite sheet.
Source

pub fn fill_triangle(&mut self, p0: Point, p1: Point, p2: Point, color: Color)

Draws a filled triangle in viewport-local coordinates.

§Arguments
  • &Self - Mutable render context.
  • Point - First vertex.
  • Point - Second vertex.
  • Point - Third vertex.
  • Color - Fill color.
Source

pub fn draw_sprite_frame( &mut self, sheet: &SpriteSheet, frame_index: u32, rect: Rect, tint: Color, )

Draws a cropped frame from a SpriteSheet into rect with multiplicative tint.

§Arguments
  • &Self - Mutable render context.
  • &SpriteSheet - Source sprite sheet.
  • u32 - Zero-based animation frame index.
  • Rect - Destination viewport-local rectangle.
  • Color - Multiplicative tint color.
Source

pub fn render_tilemap(&mut self, tilemap: &TileMap, camera: &Camera2D)

Renders all visible tiles of tilemap through camera using hoisted camera shake, cached static chunk batches, and horizontal run merging.

§Arguments
  • &Self - Mutable render context.
  • &TileMap - Grid tilemap to draw.
  • &Camera2D - Active 2D world camera.
Source

pub fn render_world(&mut self, world: &GameWorld, camera: &Camera2D) -> usize

Renders all visible sprite entities in world through camera, sorted by z_order with frustum culling and hoisted camera shake.

§Arguments
  • &Self - Mutable render context.
  • &GameWorld - Active ECS world.
  • &Camera2D - Active 2D world camera.
§Returns
  • usize - Number of visible entities drawn after frustum culling.
Source

pub fn render_snapshot_world( &mut self, world: &GameWorld, snapshot: &World2DSnapshot, ) -> usize

Renders all visible 2D entities in world using a pre-sampled World2DSnapshot with zero heap allocation for <= 128 entities.

§Arguments
  • &Self - Mutable render context.
  • &GameWorld - Authoritative ECS world providing sprite appearance metadata.
  • &World2DSnapshot - Pre-interpolated world snapshot.
§Returns
  • usize - Number of visible interpolated entities drawn.
Source

pub fn render_interpolated_world( &mut self, world: &GameWorld, prev: &World2DSnapshot, curr: &World2DSnapshot, alpha: f32, ) -> usize

Renders all visible 2D entities in world using discontinuity-safe render-time interpolation between prev and curr snapshots at alpha.

§Arguments
  • &Self - Mutable render context.
  • &GameWorld - Authoritative ECS world providing sprite appearance metadata.
  • &World2DSnapshot - Previous fixed-step immutable snapshot.
  • &World2DSnapshot - Current fixed-step immutable snapshot.
  • f32 - Normalized interpolation factor in [0.0, 1.0].
§Returns
  • usize - Number of visible interpolated entities drawn.
Source

pub fn render_particles( &mut self, particles: &ParticleSystem, camera: &Camera2D, ) -> usize

Renders all active pooled particles in particles through camera with frustum culling and lifetime interpolation.

§Arguments
  • &Self - Mutable render context.
  • &ParticleSystem - Active particle system.
  • &Camera2D - Active 2D world camera.
§Returns
  • usize - Number of visible particles rendered.
Source

pub fn draw_debug_colliders(&mut self, world: &GameWorld, camera: &Camera2D)

Draws wireframe collider bounds for debugging physics shapes inside world.

§Arguments
  • &Self - Mutable render context.
  • &GameWorld - Active ECS world.
  • &Camera2D - Active 2D world camera.

Trait Implementations§

Source§

impl<'a> Debug for GameRenderContext<'a>

Source§

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

Formats the struct fields as a debug struct, skipping excluded fields.

§Arguments
  • &mut ::std::fmt::Formatter<'_> - The formatter to write the representation into.
§Returns
  • ::std::fmt::Result - Success or failure of the formatting operation.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for GameRenderContext<'a>

§

impl<'a> Forget for GameRenderContext<'a>

§

impl<'a> Freeze for GameRenderContext<'a>
where &'a mut DisplayList: Freeze,

§

impl<'a> Move for GameRenderContext<'a>

§

impl<'a> RefUnwindSafe for GameRenderContext<'a>

§

impl<'a> Send for GameRenderContext<'a>
where RawVecInner: Send, Arc<[u8]>: Send, Arc<Vec<u8>>: Send,

§

impl<'a> Sync for GameRenderContext<'a>
where RawVecInner: Sync, Arc<[u8]>: Sync, Arc<Vec<u8>>: Sync,

§

impl<'a> Unpin for GameRenderContext<'a>
where &'a mut DisplayList: Unpin,

§

impl<'a> UnsafeUnpin for GameRenderContext<'a>
where &'a mut DisplayList: UnsafeUnpin,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.