Skip to main content

RenderQueue

Struct RenderQueue 

Source
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

Source

pub fn new() -> Self

create a new empty render queue

Source

pub fn clear(&mut self)

clear all pending draw commands

Source

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.

Source

pub const fn target(&self) -> Option<u32>

get the current render target

Source

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

Source

pub fn draw_sprite_on_layer( &mut self, texture: &Handle<Texture>, position: Vec2, size: Vec2, layer: i32, )

draw a sprite on a specific layer

Source

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.

Source

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.

Source

pub fn draw_sprite_transformed( &mut self, texture: &Handle<Texture>, params: SpriteParams, )

draw a sprite with full transform control using a texture handle

Source

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

Source

pub fn draw_rect(&mut self, position: Vec2, size: Vec2, color: Color)

draw a colored rectangle

Source

pub fn draw_rect_on_layer( &mut self, position: Vec2, size: Vec2, color: Color, layer: i32, )

draw a colored rectangle on a specific layer

Source

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.

Source

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.

Source

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

Source

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.

Source

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

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Resource for RenderQueue
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> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

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,