Struct ggez::graphics::GraphicsContext
source · pub struct GraphicsContext { /* private fields */ }
Expand description
A concrete graphics context for WGPU rendering.
Implementations§
source§impl GraphicsContext
impl GraphicsContext
sourcepub fn wgpu(&self) -> &WgpuContext
pub fn wgpu(&self) -> &WgpuContext
Returns a reference to the underlying WGPU context.
sourcepub fn present(&mut self, image: &Image) -> GameResult
pub fn present(&mut self, image: &Image) -> GameResult
Sets the image that will be presented to the screen at the end of the frame.
sourcepub fn drawable_size(&self) -> (f32, f32)
pub fn drawable_size(&self) -> (f32, f32)
Returns the size of the window’s underlying drawable in physical pixels as (width, height).
sourcepub fn set_drawable_size(&mut self, width: f32, height: f32) -> GameResult
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.
sourcepub fn set_window_title(&self, title: &str)
pub fn set_window_title(&self, title: &str)
Sets the window title.
sourcepub fn window_position(&self) -> GameResult<PhysicalPosition<i32>>
pub fn window_position(&self) -> GameResult<PhysicalPosition<i32>>
Returns the position of the system window, including the outer frame.
sourcepub fn set_window_position(&self, position: impl Into<Position>) -> GameResult
pub fn set_window_position(&self, position: impl Into<Position>) -> GameResult
Sets the window position.
sourcepub fn size(&self) -> (f32, f32)
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.
sourcepub fn supported_resolutions(&self) -> impl Iterator<Item = PhysicalSize<u32>>
pub fn supported_resolutions(&self) -> impl Iterator<Item = PhysicalSize<u32>>
Returns an iterator providing all resolutions supported by the current monitor.
sourcepub fn set_window_icon<P: AsRef<Path>>(
&self,
filesystem: &impl Has<Filesystem>,
path: impl Into<Option<P>>
) -> GameResult
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.
sourcepub fn set_fullscreen(&mut self, fullscreen: FullscreenType) -> GameResult
pub fn set_fullscreen(&mut self, fullscreen: FullscreenType) -> GameResult
Sets the window to fullscreen or back.
sourcepub fn set_resizable(&mut self, resizable: bool) -> GameResult
pub fn set_resizable(&mut self, resizable: bool) -> GameResult
Sets whether or not the window is resizable.
sourcepub fn set_mode(&mut self, mode: WindowMode) -> GameResult
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.
sourcepub fn frame(&self) -> &Image
pub fn frame(&self) -> &Image
Returns the default frame image.
This is the image that is rendered to when Canvas::from_frame
is used.
sourcepub fn surface_format(&self) -> ImageFormat
pub fn surface_format(&self) -> ImageFormat
Returns the image format of the window surface.
sourcepub fn commands(&mut self) -> Option<&mut CommandEncoder>
pub fn commands(&mut self) -> Option<&mut CommandEncoder>
Returns the current wgpu::CommandEncoder
if there is a frame in progress.
sourcepub fn begin_frame(&mut self) -> GameResult
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.
sourcepub fn end_frame(&mut self) -> GameResult
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.