Skip to main content

CotisWgpuRenderer

Struct CotisWgpuRenderer 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn window(&self) -> &Arc<Window>

Returns a shared handle to the underlying winit window.

Useful for platform integration or querying window properties directly.

Source

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

Source§

fn get_delta_time(&self) -> f32

Returns delta time in seconds since the previous frame.
Source§

impl<'b> CotisRenderer<Box<dyn WgpuDrawable + 'b>> for CotisWgpuRenderer

Source§

fn draw_frame( &mut self, render_commands: impl Iterator<Item = Box<dyn WgpuDrawable + 'b>>, )

Source§

impl<T: WgpuDrawable> CotisRenderer<RenderTList<T, ()>> for CotisWgpuRenderer

Source§

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

Source§

fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, L>>, )

Source§

impl<'b> CotisRendererAsync<Box<dyn WgpuDrawable + 'b>> for CotisWgpuRenderer

Source§

async fn draw_frame( &mut self, render_commands: impl Iterator<Item = Box<dyn WgpuDrawable + 'b>>, )

Source§

impl<T: WgpuDrawable> CotisRendererAsync<RenderTList<T, ()>> for CotisWgpuRenderer

Source§

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

Source§

async fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, L>>, )

Source§

impl CotisWindowContext for CotisWgpuRenderer

Source§

fn window_dimensions(&self) -> Dimensions

Returns the current drawable window dimensions. Read more
Source§

impl MouseProvider for CotisWgpuRenderer

Source§

fn get_mouse_position(&self) -> Vector2

Returns mouse position in pixel coordinates.
Source§

fn mouse_button_down(&self, button: MouseButton) -> bool

Returns whether the button is currently down.
Source§

fn get_mouse_wheel_move_v(&self) -> Vector2

Returns mouse wheel delta for the current frame. Read more
Source§

impl<Manager> RenderCompatibleWith<Manager> for CotisWgpuRenderer

Source§

fn init(&mut self, _layout_manager: &mut Manager)

Source§

impl RendererTextMeasuringProvider<TextConfig> for CotisWgpuRenderer

Source§

fn provide_measurer(&mut self) -> Box<dyn Fn(&str, &TextConfig) -> Dimensions>

Returns a measuring function used by layout code.
Source§

impl SimpleKeyboardProvider for CotisWgpuRenderer

Source§

fn get_pressed_keys(&self) -> IndexSet<KeyboardKey>

Returns keys currently pressed.
Source§

impl SimpleTextProvider for CotisWgpuRenderer

Source§

fn get_pressed_chars(&self) -> Vec<char>

Returns entered characters in backend-provided order.

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> CotisRenderContext for T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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<H, TailTarget, Source, Idx> Embed<RenderTList<H, TailTarget>, There<Idx>> for Source
where TailTarget: IsRenderList, Source: Embed<TailTarget, Idx>,

Source§

fn embed(self) -> RenderTList<H, TailTarget>

Converts self into Target.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more