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.
impl<'a> GameRenderContext<'a>
Viewport-local drawing primitives for GameRenderContext.
Sourcepub fn new(bounds: Rect, display_list: &'a mut DisplayList) -> Self
pub fn new(bounds: Rect, display_list: &'a mut DisplayList) -> Self
Sourcepub fn composite_gpu_texture(
&mut self,
rect: Rect,
handle: GpuTextureHandle,
) -> bool
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-truewhen the handle is valid and bound for direct GPU compositing.
Sourcepub fn gpu_composite_target(&self) -> Option<GpuCompositeDescriptor>
pub fn gpu_composite_target(&self) -> Option<GpuCompositeDescriptor>
Sourcepub fn blit_pooled_frame(&mut self, rect: Rect, lease: &PooledFrameLease)
pub fn blit_pooled_frame(&mut self, rect: Rect, lease: &PooledFrameLease)
Blits a pooled CPU fallback frame lease into rect inside this game viewport.
§Arguments
&Self- Mutable render context.Rect- Local destination rectangle.&PooledFrameLease- Rendered pooled RGBA8 frame lease.
Sourcepub fn viewport_size(&self) -> Size
pub fn viewport_size(&self) -> Size
Sourcepub fn clear(&mut self, color: Color)
pub fn clear(&mut self, color: Color)
Fills the entire game viewport with color.
§Arguments
&Self- Mutable render context.Color- Background clear color.
Sourcepub fn fill_rect(&mut self, rect: Rect, color: Color)
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.
Sourcepub fn fill_rounded_rect(&mut self, rect: Rect, color: Color, radius: f32)
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.
Sourcepub fn stroke_rect(&mut self, rect: Rect, stroke_width: f32, color: Color)
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.
Sourcepub fn fill_circle(&mut self, center: Point, radius: f32, color: Color)
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.
Sourcepub fn draw_image(&mut self, rect: Rect, buffer: ImageBuffer)
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.
Sourcepub fn draw_line(&mut self, from: Point, to: Point, width: f32, color: Color)
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.
Sourcepub fn draw_text(
&mut self,
position: Point,
text: String,
font_size: f32,
color: Color,
)
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.
Sourcepub fn blit_framebuffer(&mut self, rect: Rect, buffer: ImageBuffer)
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.
Sourcepub fn fill_triangle(&mut self, p0: Point, p1: Point, p2: Point, color: Color)
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.
Sourcepub fn draw_sprite_frame(
&mut self,
sheet: &SpriteSheet,
frame_index: u32,
rect: Rect,
tint: Color,
)
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.
Sourcepub fn render_tilemap(&mut self, tilemap: &TileMap, camera: &Camera2D)
pub fn render_tilemap(&mut self, tilemap: &TileMap, camera: &Camera2D)
Renders all visible tiles of tilemap through camera using O(visible) frustum culling.
§Arguments
&Self- Mutable render context.&TileMap- Grid tilemap to draw.&Camera2D- Active 2D world camera.
Sourcepub fn render_world(&mut self, world: &GameWorld, camera: &Camera2D) -> usize
pub fn render_world(&mut self, world: &GameWorld, camera: &Camera2D) -> usize
Sourcepub fn render_interpolated_world(
&mut self,
world: &GameWorld,
prev: &World2DSnapshot,
curr: &World2DSnapshot,
alpha: f32,
) -> usize
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.
Sourcepub fn render_particles(
&mut self,
particles: &ParticleSystem,
camera: &Camera2D,
) -> usize
pub fn render_particles( &mut self, particles: &ParticleSystem, camera: &Camera2D, ) -> usize
Sourcepub fn draw_debug_colliders(&mut self, world: &GameWorld, camera: &Camera2D)
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.