pub struct Graphics {
pub camera: Camera2D,
pub camera3d: Camera3D,
/* private fields */
}Fields§
§camera: Camera2D§camera3d: Camera3DPerspective camera for 3D meshes. Set its fields to move the view.
Implementations§
Source§impl Graphics
impl Graphics
pub async fn new( window: Arc<Window>, vsync: bool, depth_format: Option<TextureFormat>, msaa_samples: u32, ) -> Result<Graphics, Error>
pub fn resize(&mut self, width: u32, height: u32)
pub fn window(&self) -> &Arc<Window>
pub fn size(&self) -> (u32, u32)
pub fn surface_format(&self) -> TextureFormat
pub fn device(&self) -> &Device
pub fn queue(&self) -> &Queue
pub fn load_texture( &mut self, path: impl AsRef<Path>, ) -> Result<TextureId, Error>
Sourcepub fn refresh_textures<I, P>(&mut self, changed_paths: I) -> usize
pub fn refresh_textures<I, P>(&mut self, changed_paths: I) -> usize
Re-decode any texture whose backing file is in changed_paths and update its bind
group in place. Returns the number of textures actually reloaded.
pub fn create_texture_rgba( &mut self, width: u32, height: u32, rgba: &[u8], label: Option<&str>, ) -> TextureId
pub fn white_texture(&self) -> TextureId
Sourcepub fn create_mesh(
&mut self,
vertices: &[MeshVertex],
indices: &[u16],
) -> MeshId
pub fn create_mesh( &mut self, vertices: &[MeshVertex], indices: &[u16], ) -> MeshId
Upload a static mesh (positions + normals, indexed) and return its handle. Meshes are
drawn depth-tested via Graphics::draw_mesh using the perspective Self::camera3d.
Sourcepub fn draw_mesh(&mut self, mesh: MeshId, instance: MeshInstance)
pub fn draw_mesh(&mut self, mesh: MeshId, instance: MeshInstance)
Queue one instance of mesh for this frame. Meshes render before the 2D layers, so
2D sprites, primitives and text draw on top of them.
Sourcepub fn request_screenshot(&mut self, path: impl Into<PathBuf>)
pub fn request_screenshot(&mut self, path: impl Into<PathBuf>)
Save a PNG of the next presented frame to path. The read-back stalls that frame, so
this is for debug/dev use. A no-op (with a warning) if the surface lacks COPY_SRC.
pub fn begin_frame(&mut self) -> Result<Frame, Error>
pub fn present(&mut self, frame: Frame)
Sourcepub fn flush_pending(&mut self, frame: &mut Frame)
pub fn flush_pending(&mut self, frame: &mut Frame)
Flush all queued 2D layers (sprites + primitives + text) into the current frame.
Called automatically when a crate::Painter is dropped; call manually before
stacking other passes (e.g. egui) when no painter was created.
Auto Trait Implementations§
impl !Freeze for Graphics
impl !RefUnwindSafe for Graphics
impl Send for Graphics
impl Sync for Graphics
impl Unpin for Graphics
impl UnsafeUnpin for Graphics
impl !UnwindSafe for Graphics
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.