pub struct GeometryRenderer { /* private fields */ }Expand description
GPU-accelerated geometry renderer.
Renders 2D shapes and paths using tessellation and instanced rendering.
Implementations§
Source§impl GeometryRenderer
impl GeometryRenderer
Sourcepub fn new(context: Arc<GraphicsContext>) -> Self
pub fn new(context: Arc<GraphicsContext>) -> Self
Create a new geometry renderer with default configuration.
Sourcepub fn from_window(context: Arc<GraphicsContext>, window: &RenderWindow) -> Self
pub fn from_window(context: Arc<GraphicsContext>, window: &RenderWindow) -> Self
Create renderer from a RenderWindow, matching its format configuration.
This is the recommended constructor as it ensures the renderer’s pipelines are compatible with the window’s render pass configuration.
Sourcepub fn with_descriptor(
context: Arc<GraphicsContext>,
descriptor: GeometryRendererDescriptor,
) -> Self
pub fn with_descriptor( context: Arc<GraphicsContext>, descriptor: GeometryRendererDescriptor, ) -> Self
Create renderer with explicit configuration.
Sourcepub fn descriptor(&self) -> &GeometryRendererDescriptor
pub fn descriptor(&self) -> &GeometryRendererDescriptor
Get the current renderer configuration.
Sourcepub fn reconfigure(&mut self, descriptor: GeometryRendererDescriptor)
pub fn reconfigure(&mut self, descriptor: GeometryRendererDescriptor)
Reconfigure the renderer with new format settings.
This recreates all pipelines with the new configuration. Buffers and non-format-dependent resources are preserved.
§Use Case
When a window is moved to a different monitor, the surface format may change. Call this method to update the renderer to match.
Sourcepub fn reconfigure_from_window(&mut self, window: &RenderWindow)
pub fn reconfigure_from_window(&mut self, window: &RenderWindow)
Reconfigure from a window, inheriting its format configuration.
Convenience method equivalent to:
renderer.reconfigure(GeometryRendererDescriptor::from_window(window));Sourcepub fn set_tolerance(&mut self, tolerance: f32)
pub fn set_tolerance(&mut self, tolerance: f32)
Set the tessellation tolerance.
Sourcepub fn draw_shape(&mut self, shape: &Shape, style: &Style)
pub fn draw_shape(&mut self, shape: &Shape, style: &Style)
Draw a shape with the given style.
Sourcepub fn draw_circle(&mut self, center: Vec2, radius: f32, color: Color)
pub fn draw_circle(&mut self, center: Vec2, radius: f32, color: Color)
Draw a filled circle.
Sourcepub fn draw_rect_stroke(&mut self, position: Vec2, size: Vec2, stroke: &Stroke)
pub fn draw_rect_stroke(&mut self, position: Vec2, size: Vec2, stroke: &Stroke)
Draw a stroked rectangle.
Sourcepub fn draw_circle_stroke(&mut self, center: Vec2, radius: f32, stroke: &Stroke)
pub fn draw_circle_stroke(&mut self, center: Vec2, radius: f32, stroke: &Stroke)
Draw a stroked circle.
Sourcepub fn draw_shape_fill(&mut self, shape: &Shape, color: Color)
pub fn draw_shape_fill(&mut self, shape: &Shape, color: Color)
Draw a filled shape directly.
Sourcepub fn draw_shape_stroke(&mut self, shape: &Shape, stroke: &Stroke)
pub fn draw_shape_stroke(&mut self, shape: &Shape, stroke: &Stroke)
Draw a stroked shape directly.
Sourcepub fn draw_path_fill(&mut self, path: &Path, color: Color, fill_rule: FillRule)
pub fn draw_path_fill(&mut self, path: &Path, color: Color, fill_rule: FillRule)
Draw a path with fill only.
Sourcepub fn draw_path_stroke(&mut self, path: &Path, stroke: &Stroke)
pub fn draw_path_stroke(&mut self, path: &Path, stroke: &Stroke)
Draw a path with stroke only.
Sourcepub fn set_scissor(&mut self, scissor: ScissorRect)
pub fn set_scissor(&mut self, scissor: ScissorRect)
Set a scissor rectangle to clip subsequent drawing.
All geometry drawn after this call will be clipped to the specified rectangle.
Call reset_scissor() to restore full viewport rendering.
Sourcepub fn reset_scissor(&mut self)
pub fn reset_scissor(&mut self)
Reset scissor to full viewport (no clipping).
Sourcepub fn render(&mut self, pass: &mut RenderPass<'_>, viewport: Viewport)
pub fn render(&mut self, pass: &mut RenderPass<'_>, viewport: Viewport)
Render all queued geometry.
Auto Trait Implementations§
impl Freeze for GeometryRenderer
impl !RefUnwindSafe for GeometryRenderer
impl Send for GeometryRenderer
impl Sync for GeometryRenderer
impl Unpin for GeometryRenderer
impl UnsafeUnpin for GeometryRenderer
impl !UnwindSafe for GeometryRenderer
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
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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