pub struct RenderQueue { /* private fields */ }Expand description
render queue resource, collects draw commands each frame.
game logic pushes draw commands into the queue during the update phase. the render engine consumes the queue during the render phase.
§lifecycle
call RenderQueue::clear() at the start of each frame to remove
last frame’s commands before adding new ones.
Implementations§
Source§impl RenderQueue
impl RenderQueue
Sourcepub const fn set_target(&mut self, target: Option<u32>)
pub const fn set_target(&mut self, target: Option<u32>)
set the render target for subsequent draw commands. pass None to render to the main surface.
Sourcepub fn draw_sprite(
&mut self,
texture: &Handle<Texture>,
position: Vec2,
size: Vec2,
)
pub fn draw_sprite( &mut self, texture: &Handle<Texture>, position: Vec2, size: Vec2, )
draw a sprite at the given position and size using a texture handle
Sourcepub fn draw_sprite_on_layer(
&mut self,
texture: &Handle<Texture>,
position: Vec2,
size: Vec2,
layer: i32,
)
pub fn draw_sprite_on_layer( &mut self, texture: &Handle<Texture>, position: Vec2, size: Vec2, layer: i32, )
draw a sprite on a specific layer
Sourcepub fn draw_sprite_atlas(
&mut self,
texture: &Handle<Texture>,
position: Vec2,
size: Vec2,
region: (Vec2, Vec2),
)
pub fn draw_sprite_atlas( &mut self, texture: &Handle<Texture>, position: Vec2, size: Vec2, region: (Vec2, Vec2), )
draw a sprite from a texture atlas by region name.
the uv_rect is automatically set from the atlas region’s UV coordinates.
Sourcepub fn draw_sprite_atlas_on_layer(
&mut self,
texture: &Handle<Texture>,
position: Vec2,
size: Vec2,
region: (Vec2, Vec2),
layer: i32,
)
pub fn draw_sprite_atlas_on_layer( &mut self, texture: &Handle<Texture>, position: Vec2, size: Vec2, region: (Vec2, Vec2), layer: i32, )
draw a sprite from a texture atlas on a specific layer.
Sourcepub fn draw_sprite_transformed(
&mut self,
texture: &Handle<Texture>,
params: SpriteParams,
)
pub fn draw_sprite_transformed( &mut self, texture: &Handle<Texture>, params: SpriteParams, )
draw a sprite with full transform control using a texture handle
Sourcepub fn draw_sprite_transformed_on_layer(
&mut self,
texture: &Handle<Texture>,
params: SpriteParams,
layer: i32,
)
pub fn draw_sprite_transformed_on_layer( &mut self, texture: &Handle<Texture>, params: SpriteParams, layer: i32, )
draw a sprite with full transform control on a specific layer
Sourcepub fn draw_rect_on_layer(
&mut self,
position: Vec2,
size: Vec2,
color: Color,
layer: i32,
)
pub fn draw_rect_on_layer( &mut self, position: Vec2, size: Vec2, color: Color, layer: i32, )
draw a colored rectangle on a specific layer
Sourcepub fn draw_screen_rect(&mut self, position: Vec2, size: Vec2, color: Color)
pub fn draw_screen_rect(&mut self, position: Vec2, size: Vec2, color: Color)
draw a colored rectangle in screen space (post-process layer).
coordinates are in pixels: top-left is (0, 0), bottom-right is (window_w, window_h).
use this from PostEffect::apply implementations.
Sourcepub fn draw_line(
&mut self,
start: Vec2,
end: Vec2,
color: Color,
thickness: f32,
)
pub fn draw_line( &mut self, start: Vec2, end: Vec2, color: Color, thickness: f32, )
draw a line between two points with the given thickness. uses a proper rotated rectangle, not an AABB approximation.
Sourcepub fn draw_line_on_layer(
&mut self,
start: Vec2,
end: Vec2,
color: Color,
thickness: f32,
layer: i32,
)
pub fn draw_line_on_layer( &mut self, start: Vec2, end: Vec2, color: Color, thickness: f32, layer: i32, )
draw a line on a specific layer
Sourcepub fn clear_color(&mut self, color: Color)
pub fn clear_color(&mut self, color: Color)
clear the screen with the given color. this is a convenience that draws a full-screen rect — the render engine’s default clear color is not affected.
Sourcepub fn draw_text(
&mut self,
font: &Handle<Font>,
content: &str,
position: Vec2,
font_size: f32,
color: Color,
)
pub fn draw_text( &mut self, font: &Handle<Font>, content: &str, position: Vec2, font_size: f32, color: Color, )
draw text at the given position using the specified font handle
Sourcepub fn draw_text_on_layer(
&mut self,
font: &Handle<Font>,
content: &str,
position: Vec2,
font_size: f32,
color: Color,
layer: i32,
)
pub fn draw_text_on_layer( &mut self, font: &Handle<Font>, content: &str, position: Vec2, font_size: f32, color: Color, layer: i32, )
draw text on a specific layer
Sourcepub fn draw_ui_text(
&mut self,
font: &Handle<Font>,
text: &str,
screen_pos: Vec2,
font_size: f32,
color: Color,
camera: &Camera,
window_width: u32,
window_height: u32,
)
pub fn draw_ui_text( &mut self, font: &Handle<Font>, text: &str, screen_pos: Vec2, font_size: f32, color: Color, camera: &Camera, window_width: u32, window_height: u32, )
draw text in screen-space coordinates (for UI). internally converts through the camera to world-space. the position is relative to the viewport top-left, y-down.
Sourcepub fn draw_ui_rect(
&mut self,
screen_pos: Vec2,
size: Vec2,
color: Color,
camera: &Camera,
window_width: u32,
window_height: u32,
)
pub fn draw_ui_rect( &mut self, screen_pos: Vec2, size: Vec2, color: Color, camera: &Camera, window_width: u32, window_height: u32, )
draw a colored rectangle in screen-space coordinates (for UI). internally converts through the camera to world-space.
Sourcepub fn draw_text_wrapped(
&mut self,
font: &Handle<Font>,
content: &str,
position: Vec2,
font_size: f32,
color: Color,
max_width: f32,
line_height: f32,
layer: i32,
)
pub fn draw_text_wrapped( &mut self, font: &Handle<Font>, content: &str, position: Vec2, font_size: f32, color: Color, max_width: f32, line_height: f32, layer: i32, )
draw word-wrapped text on the given layer.
max_width is the pixel width at which lines break.
line_height is the vertical spacing per line; 0.0 = font_size * 1.25.
Sourcepub fn draw_ui_sprite(
&mut self,
texture: &Handle<Texture>,
screen_pos: Vec2,
size: Vec2,
camera: &Camera,
window_width: u32,
window_height: u32,
)
pub fn draw_ui_sprite( &mut self, texture: &Handle<Texture>, screen_pos: Vec2, size: Vec2, camera: &Camera, window_width: u32, window_height: u32, )
draw a sprite in screen-space coordinates (for UI). the position is the top-left corner in screen pixels, y-down.
Sourcepub fn draw_immediate(&mut self, f: impl FnOnce(&mut DrawContext<'_>))
pub fn draw_immediate(&mut self, f: impl FnOnce(&mut DrawContext<'_>))
immediate mode drawing API for debug visualization and quick prototyping.
the closure receives a DrawContext with convenience methods for
drawing lines, circles, rects, and text without managing draw commands manually.
§example
queue.draw_immediate(|draw| {
draw.line(Vec2::new(0.0, 0.0), Vec2::new(100.0, 100.0), Color::RED, 2.0);
draw.circle(Vec2::new(50.0, 50.0), 20.0, Color::GREEN, 2.0);
draw.rect(Vec2::new(10.0, 10.0), Vec2::new(40.0, 40.0), Color::BLUE);
draw.text("debug info", Vec2::new(0.0, 0.0), 16.0, Color::WHITE);
});Trait Implementations§
Source§impl Default for RenderQueue
impl Default for RenderQueue
impl Resource for RenderQueue
Auto Trait Implementations§
impl Freeze for RenderQueue
impl RefUnwindSafe for RenderQueue
impl Send for RenderQueue
impl Sync for RenderQueue
impl Unpin for RenderQueue
impl UnsafeUnpin for RenderQueue
impl UnwindSafe for RenderQueue
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> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
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