pub struct GraphicsContext { /* private fields */ }
Expand description

A concrete graphics context for WGPU rendering.

Implementations§

source§

impl GraphicsContext

source

pub fn wgpu(&self) -> &WgpuContext

Returns a reference to the underlying WGPU context.

source

pub fn present(&mut self, image: &Image) -> GameResult

Sets the image that will be presented to the screen at the end of the frame.

source

pub fn add_font(&mut self, name: &str, font: FontData)

Adds a new font with a given name.

source

pub fn drawable_size(&self) -> (f32, f32)

Returns the size of the window’s underlying drawable in physical pixels as (width, height).

source

pub fn set_drawable_size(&mut self, width: f32, height: f32) -> GameResult

Sets the window size (in physical pixels) / resolution to the specified width and height.

Note: These dimensions are only interpreted as resolutions in true fullscreen mode. If the selected resolution is not supported this function will return an Error.

source

pub fn set_window_title(&self, title: &str)

Sets the window title.

source

pub fn window_position(&self) -> GameResult<PhysicalPosition<i32>>

Returns the position of the system window, including the outer frame.

source

pub fn set_window_position(&self, position: impl Into<Position>) -> GameResult

Sets the window position.

source

pub fn size(&self) -> (f32, f32)

Returns the size of the window in pixels as (width, height), including borders, titlebar, etc. Returns zeros if the window doesn’t exist.

source

pub fn supported_resolutions(&self) -> impl Iterator<Item = PhysicalSize<u32>>

Returns an iterator providing all resolutions supported by the current monitor.

source

pub fn window(&self) -> &Window

Returns a reference to the Winit window.

source

pub fn set_window_icon<P: AsRef<Path>>( &self, filesystem: &impl Has<Filesystem>, path: impl Into<Option<P>> ) -> GameResult

Sets the window icon. None for path removes the icon.

source

pub fn set_fullscreen(&mut self, fullscreen: FullscreenType) -> GameResult

Sets the window to fullscreen or back.

source

pub fn set_resizable(&mut self, resizable: bool) -> GameResult

Sets whether or not the window is resizable.

source

pub fn set_mode(&mut self, mode: WindowMode) -> GameResult

Sets the window mode, such as the size and other properties.

Setting the window mode may have side effects, such as clearing the screen or setting the screen coordinates viewport to some undefined value (for example, the window was resized). It is recommended to call set_screen_coordinates() after changing the window size to make sure everything is what you want it to be.

source

pub fn frame(&self) -> &Image

Returns the default frame image.

This is the image that is rendered to when Canvas::from_frame is used.

source

pub fn surface_format(&self) -> ImageFormat

Returns the image format of the window surface.

source

pub fn commands(&mut self) -> Option<&mut CommandEncoder>

Returns the current wgpu::CommandEncoder if there is a frame in progress.

source

pub fn begin_frame(&mut self) -> GameResult

Begins a new frame.

The only situation you need to call this in is when you are rolling your own event loop.

source

pub fn end_frame(&mut self) -> GameResult

Ends the current frame.

The only situation you need to call this in is when you are rolling your own event loop.

Trait Implementations§

source§

impl Has<GraphicsContext> for Context

source§

fn retrieve(&self) -> &GraphicsContext

Method to retrieve the context type.
source§

impl HasMut<GraphicsContext> for Context

source§

fn retrieve_mut(&mut self) -> &mut GraphicsContext

Method to retrieve the context type as mutable.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T> Has<T> for T

source§

fn retrieve(&self) -> &T

Method to retrieve the context type.
source§

impl<T> HasMut<T> for T

source§

fn retrieve_mut(&mut self) -> &mut T

Method to retrieve the context type as mutable.
source§

impl<T, U> Into<U> for Twhere 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.

§

impl<F, T> IntoSample<T> for Fwhere T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,