From 1e62fdf069db5687be510e1cc375260bbff318a7 Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 27 Jan 2022 04:00:53 -0300 Subject: Introduce `Error::ContextCreationFailed` --- graphics/src/error.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'graphics/src') diff --git a/graphics/src/error.rs b/graphics/src/error.rs index c86e326a..77758f54 100644 --- a/graphics/src/error.rs +++ b/graphics/src/error.rs @@ -1,7 +1,19 @@ -/// A graphical error that occurred while running an application. +/// An error that occurred while creating an application's graphical context. #[derive(Debug, thiserror::Error)] pub enum Error { - /// A suitable graphics adapter or device could not be found + /// The requested backend version is not supported. + #[error("the requested backend version is not supported")] + VersionNotSupported, + + /// Failed to find any pixel format that matches the criteria. + #[error("failed to find any pixel format that matches the criteria")] + NoAvailablePixelFormat, + + /// A suitable graphics adapter or device could not be found. #[error("a suitable graphics adapter or device could not be found")] - AdapterNotFound, + GraphicsAdapterNotFound, + + /// An error occured in the context's internal backend + #[error("an error occured in the context's internal backend")] + BackendError(String), } -- cgit From e23e4b8db20f3910bb6617a6931c9a8906791f8e Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 17 Mar 2022 00:25:00 -0300 Subject: Introduce `GraphicsInformation` to `iced_graphics` --- graphics/src/window.rs | 2 +- graphics/src/window/compositor.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'graphics/src') diff --git a/graphics/src/window.rs b/graphics/src/window.rs index 67ec3322..c73c8c53 100644 --- a/graphics/src/window.rs +++ b/graphics/src/window.rs @@ -4,7 +4,7 @@ mod compositor; #[cfg(feature = "opengl")] mod gl_compositor; -pub use compositor::{Compositor, SurfaceError}; +pub use compositor::{Compositor, GraphicsInformation, SurfaceError}; #[cfg(feature = "opengl")] pub use gl_compositor::GLCompositor; diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs index 9ea040cd..5987b118 100644 --- a/graphics/src/window/compositor.rs +++ b/graphics/src/window/compositor.rs @@ -71,3 +71,12 @@ pub enum SurfaceError { #[error("There is no more memory left to allocate a new frame")] OutOfMemory, } + +/// Contains informations about the graphics (e.g. graphics adapter, graphics backend). +#[derive(Debug)] +pub struct GraphicsInformation { + /// Contains the graphics adapter. + pub adapter: String, + /// Contains the graphics backend. + pub backend: String, +} -- cgit From 83fec2f5f6231f3871ecfccf594a555253f8286c Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 17 Mar 2022 00:34:42 -0300 Subject: Implement `GraphicsInformation` for `iced_wgpu` --- graphics/src/window/compositor.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'graphics/src') diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs index 5987b118..035101c9 100644 --- a/graphics/src/window/compositor.rs +++ b/graphics/src/window/compositor.rs @@ -38,6 +38,9 @@ pub trait Compositor: Sized { height: u32, ); + /// Returns [`GraphicsInformation`] used by this [`Compositor`]. + fn get_information(&self) -> GraphicsInformation; + /// Presents the [`Renderer`] primitives to the next frame of the given [`Surface`]. /// /// [`SwapChain`]: Self::SwapChain -- cgit From 2b4d8a7b2653f51ae83009257c4ec1dc4201d5ff Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 17 Mar 2022 00:41:43 -0300 Subject: Implement `GraphicsInformation` for `iced_glow` --- graphics/src/window/gl_compositor.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'graphics/src') diff --git a/graphics/src/window/gl_compositor.rs b/graphics/src/window/gl_compositor.rs index b1b995f1..23c6d3f8 100644 --- a/graphics/src/window/gl_compositor.rs +++ b/graphics/src/window/gl_compositor.rs @@ -1,3 +1,4 @@ +use crate::window::GraphicsInformation; use crate::{Color, Error, Size, Viewport}; use core::ffi::c_void; @@ -48,6 +49,9 @@ pub trait GLCompositor: Sized { /// Resizes the viewport of the [`GLCompositor`]. fn resize_viewport(&mut self, physical_size: Size); + /// Returns [`GraphicsInformation`] used by this [`Compositor`]. + fn get_information(&self) -> GraphicsInformation; + /// Presents the primitives of the [`Renderer`] to the next frame of the /// [`GLCompositor`]. /// -- cgit From 5be1ac18fe1757d31386f98774d823bd1137eea4 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 26 Apr 2022 19:09:09 -0300 Subject: Rename `GraphicsInformation` to `Information` --- graphics/src/window.rs | 2 +- graphics/src/window/compositor.rs | 4 ++-- graphics/src/window/gl_compositor.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'graphics/src') diff --git a/graphics/src/window.rs b/graphics/src/window.rs index c73c8c53..35a9f06a 100644 --- a/graphics/src/window.rs +++ b/graphics/src/window.rs @@ -4,7 +4,7 @@ mod compositor; #[cfg(feature = "opengl")] mod gl_compositor; -pub use compositor::{Compositor, GraphicsInformation, SurfaceError}; +pub use compositor::{Compositor, Information, SurfaceError}; #[cfg(feature = "opengl")] pub use gl_compositor::GLCompositor; diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs index 035101c9..8a851773 100644 --- a/graphics/src/window/compositor.rs +++ b/graphics/src/window/compositor.rs @@ -39,7 +39,7 @@ pub trait Compositor: Sized { ); /// Returns [`GraphicsInformation`] used by this [`Compositor`]. - fn get_information(&self) -> GraphicsInformation; + fn get_information(&self) -> Information; /// Presents the [`Renderer`] primitives to the next frame of the given [`Surface`]. /// @@ -77,7 +77,7 @@ pub enum SurfaceError { /// Contains informations about the graphics (e.g. graphics adapter, graphics backend). #[derive(Debug)] -pub struct GraphicsInformation { +pub struct Information { /// Contains the graphics adapter. pub adapter: String, /// Contains the graphics backend. diff --git a/graphics/src/window/gl_compositor.rs b/graphics/src/window/gl_compositor.rs index 23c6d3f8..65761fe8 100644 --- a/graphics/src/window/gl_compositor.rs +++ b/graphics/src/window/gl_compositor.rs @@ -1,4 +1,4 @@ -use crate::window::GraphicsInformation; +use crate::window::Information; use crate::{Color, Error, Size, Viewport}; use core::ffi::c_void; @@ -50,7 +50,7 @@ pub trait GLCompositor: Sized { fn resize_viewport(&mut self, physical_size: Size); /// Returns [`GraphicsInformation`] used by this [`Compositor`]. - fn get_information(&self) -> GraphicsInformation; + fn get_information(&self) -> Information; /// Presents the primitives of the [`Renderer`] to the next frame of the /// [`GLCompositor`]. -- cgit From 984d1f375ecec301dd42b049eecd1b88e3bca32a Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 26 Apr 2022 19:18:18 -0300 Subject: Move `compositor` module access from `window` to `crate` --- graphics/src/lib.rs | 1 + graphics/src/window.rs | 6 +++--- graphics/src/window/compositor.rs | 2 ++ graphics/src/window/gl_compositor.rs | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) (limited to 'graphics/src') diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs index b3be62af..4364695f 100644 --- a/graphics/src/lib.rs +++ b/graphics/src/lib.rs @@ -39,6 +39,7 @@ pub use primitive::Primitive; pub use renderer::Renderer; pub use transformation::Transformation; pub use viewport::Viewport; +pub use window::compositor; pub use iced_native::alignment; pub use iced_native::{ diff --git a/graphics/src/window.rs b/graphics/src/window.rs index 35a9f06a..a38b81f3 100644 --- a/graphics/src/window.rs +++ b/graphics/src/window.rs @@ -1,10 +1,10 @@ //! Draw graphics to window surfaces. -mod compositor; +pub mod compositor; #[cfg(feature = "opengl")] -mod gl_compositor; +pub mod gl_compositor; -pub use compositor::{Compositor, Information, SurfaceError}; +pub use compositor::Compositor; #[cfg(feature = "opengl")] pub use gl_compositor::GLCompositor; diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs index 8a851773..3f1165d4 100644 --- a/graphics/src/window/compositor.rs +++ b/graphics/src/window/compositor.rs @@ -1,3 +1,5 @@ +//! A compositor is responsible for initializing a renderer and managing window +//! surfaces. use crate::{Color, Error, Viewport}; use raw_window_handle::HasRawWindowHandle; diff --git a/graphics/src/window/gl_compositor.rs b/graphics/src/window/gl_compositor.rs index 65761fe8..3adde8e6 100644 --- a/graphics/src/window/gl_compositor.rs +++ b/graphics/src/window/gl_compositor.rs @@ -1,4 +1,6 @@ -use crate::window::Information; +//! A compositor is responsible for initializing a renderer and managing window +//! surfaces. +use crate::compositor::Information; use crate::{Color, Error, Size, Viewport}; use core::ffi::c_void; -- cgit From 005e516b5e1e8bb22f2da8524ffe4529f3b60ba1 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 26 Apr 2022 19:20:38 -0300 Subject: Rename `get_information` to `fetch_information` --- graphics/src/window/compositor.rs | 2 +- graphics/src/window/gl_compositor.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'graphics/src') diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs index 3f1165d4..7525de1d 100644 --- a/graphics/src/window/compositor.rs +++ b/graphics/src/window/compositor.rs @@ -41,7 +41,7 @@ pub trait Compositor: Sized { ); /// Returns [`GraphicsInformation`] used by this [`Compositor`]. - fn get_information(&self) -> Information; + fn fetch_information(&self) -> Information; /// Presents the [`Renderer`] primitives to the next frame of the given [`Surface`]. /// diff --git a/graphics/src/window/gl_compositor.rs b/graphics/src/window/gl_compositor.rs index 3adde8e6..4ff17366 100644 --- a/graphics/src/window/gl_compositor.rs +++ b/graphics/src/window/gl_compositor.rs @@ -52,7 +52,7 @@ pub trait GLCompositor: Sized { fn resize_viewport(&mut self, physical_size: Size); /// Returns [`GraphicsInformation`] used by this [`Compositor`]. - fn get_information(&self) -> Information; + fn fetch_information(&self) -> Information; /// Presents the primitives of the [`Renderer`] to the next frame of the /// [`GLCompositor`]. -- cgit