pub struct CotisWgpuRenderer { /* private fields */ }Expand description
wgpu-backed renderer implementing the shared cotis render traits.
Owns a winit EventLoop and pumps it on each
cotis::renders::CotisRenderer::draw_frame call and on Self::window_should_close.
GPU resources (surface, geometry batch, text state) are initialized during construction.
Implementations§
Source§impl CotisWgpuRenderer
impl CotisWgpuRenderer
Sourcepub fn auto_start() -> Self
pub fn auto_start() -> Self
Creates a renderer with a default window and background color.
Uses WindowConfig::default and a dark gray background (45, 45, 55) / 255.
§Panics
Panics if GPU initialization or window creation fails. For fallible construction, use
Self::new or Self::new_with_config.
Sourcepub fn new(background: Color) -> Result<Self, WgpuBackendError>
pub fn new(background: Color) -> Result<Self, WgpuBackendError>
Creates a renderer with the default WindowConfig.
§Errors
Returns WgpuBackendError::Init if the event loop cannot be created or the window is
closed during bootstrap, WgpuBackendError::NoAdapter if no GPU adapter is found,
WgpuBackendError::CreateSurface or WgpuBackendError::RequestDevice if wgpu setup
fails.
Sourcepub fn new_with_config(
config: WindowConfig,
background: Color,
) -> Result<Self, WgpuBackendError>
pub fn new_with_config( config: WindowConfig, background: Color, ) -> Result<Self, WgpuBackendError>
Creates a renderer with custom window settings.
Boots the winit event loop and creates the window on the first Resumed event.
§Errors
Same variants as Self::new, plus WgpuBackendError::Init if window creation fails.
Sourcepub fn window_should_close(&mut self) -> bool
pub fn window_should_close(&mut self) -> bool
Returns whether the user requested the window to close.
Pumps pending winit events before checking the close flag, so this method requires
&mut self even though it only reads state.
Sourcepub fn window(&self) -> &Arc<Window>
pub fn window(&self) -> &Arc<Window>
Returns a shared handle to the underlying winit window.
Useful for platform integration or querying window properties directly.
Sourcepub fn set_background(&mut self, background: Color)
pub fn set_background(&mut self, background: Color)
Sets the swapchain clear color for subsequent frames.
Takes a normalized wgpu::Color (0.0..=1.0 per channel), not a cotis
cotis_defaults::colors::Color. Use crate::color::cotis_color_to_wgpu to convert.
Trait Implementations§
Source§impl CotisFrameContext for CotisWgpuRenderer
impl CotisFrameContext for CotisWgpuRenderer
Source§fn get_delta_time(&self) -> f32
fn get_delta_time(&self) -> f32
Source§impl<'b> CotisRenderer<Box<dyn WgpuDrawable + 'b>> for CotisWgpuRenderer
impl<'b> CotisRenderer<Box<dyn WgpuDrawable + 'b>> for CotisWgpuRenderer
fn draw_frame( &mut self, render_commands: impl Iterator<Item = Box<dyn WgpuDrawable + 'b>>, )
Source§impl<T: WgpuDrawable> CotisRenderer<RenderTList<T, ()>> for CotisWgpuRenderer
impl<T: WgpuDrawable> CotisRenderer<RenderTList<T, ()>> for CotisWgpuRenderer
fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, ()>>, )
Source§impl<T: WgpuDrawable, L: WgpuDrawable + IsRenderList> CotisRenderer<RenderTList<T, L>> for CotisWgpuRenderer
impl<T: WgpuDrawable, L: WgpuDrawable + IsRenderList> CotisRenderer<RenderTList<T, L>> for CotisWgpuRenderer
fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, L>>, )
Source§impl<'b> CotisRendererAsync<Box<dyn WgpuDrawable + 'b>> for CotisWgpuRenderer
impl<'b> CotisRendererAsync<Box<dyn WgpuDrawable + 'b>> for CotisWgpuRenderer
async fn draw_frame( &mut self, render_commands: impl Iterator<Item = Box<dyn WgpuDrawable + 'b>>, )
Source§impl<T: WgpuDrawable> CotisRendererAsync<RenderTList<T, ()>> for CotisWgpuRenderer
impl<T: WgpuDrawable> CotisRendererAsync<RenderTList<T, ()>> for CotisWgpuRenderer
async fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, ()>>, )
Source§impl<T: WgpuDrawable, L: WgpuDrawable + IsRenderList> CotisRendererAsync<RenderTList<T, L>> for CotisWgpuRenderer
impl<T: WgpuDrawable, L: WgpuDrawable + IsRenderList> CotisRendererAsync<RenderTList<T, L>> for CotisWgpuRenderer
async fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, L>>, )
Source§impl CotisWindowContext for CotisWgpuRenderer
impl CotisWindowContext for CotisWgpuRenderer
Source§fn window_dimensions(&self) -> Dimensions
fn window_dimensions(&self) -> Dimensions
Source§impl MouseProvider for CotisWgpuRenderer
impl MouseProvider for CotisWgpuRenderer
Source§fn get_mouse_position(&self) -> Vector2
fn get_mouse_position(&self) -> Vector2
Source§fn get_mouse_wheel_move_v(&self) -> Vector2
fn get_mouse_wheel_move_v(&self) -> Vector2
Source§impl<Manager> RenderCompatibleWith<Manager> for CotisWgpuRenderer
impl<Manager> RenderCompatibleWith<Manager> for CotisWgpuRenderer
fn init(&mut self, _layout_manager: &mut Manager)
Source§impl RendererTextMeasuringProvider<TextConfig> for CotisWgpuRenderer
impl RendererTextMeasuringProvider<TextConfig> for CotisWgpuRenderer
Source§fn provide_measurer(&mut self) -> Box<dyn Fn(&str, &TextConfig) -> Dimensions>
fn provide_measurer(&mut self) -> Box<dyn Fn(&str, &TextConfig) -> Dimensions>
Source§impl SimpleKeyboardProvider for CotisWgpuRenderer
impl SimpleKeyboardProvider for CotisWgpuRenderer
Source§fn get_pressed_keys(&self) -> IndexSet<KeyboardKey>
fn get_pressed_keys(&self) -> IndexSet<KeyboardKey>
Source§impl SimpleTextProvider for CotisWgpuRenderer
impl SimpleTextProvider for CotisWgpuRenderer
Source§fn get_pressed_chars(&self) -> Vec<char>
fn get_pressed_chars(&self) -> Vec<char>
Auto Trait Implementations§
impl !Freeze for CotisWgpuRenderer
impl !RefUnwindSafe for CotisWgpuRenderer
impl !Send for CotisWgpuRenderer
impl !Sync for CotisWgpuRenderer
impl !UnwindSafe for CotisWgpuRenderer
impl Unpin for CotisWgpuRenderer
impl UnsafeUnpin for CotisWgpuRenderer
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> CotisRenderContext for Twhere
T: CotisWindowContext + CotisFrameContext,
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<H, TailTarget, Source, Idx> Embed<RenderTList<H, TailTarget>, There<Idx>> for Sourcewhere
TailTarget: IsRenderList,
Source: Embed<TailTarget, Idx>,
impl<H, TailTarget, Source, Idx> Embed<RenderTList<H, TailTarget>, There<Idx>> for Sourcewhere
TailTarget: IsRenderList,
Source: Embed<TailTarget, Idx>,
Source§fn embed(self) -> RenderTList<H, TailTarget>
fn embed(self) -> RenderTList<H, TailTarget>
self into Target.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