summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/error.rs18
-rw-r--r--graphics/src/lib.rs1
-rw-r--r--graphics/src/window.rs6
-rw-r--r--graphics/src/window/compositor.rs14
-rw-r--r--graphics/src/window/gl_compositor.rs6
5 files changed, 39 insertions, 6 deletions
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),
}
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs
index 9661f6ef..370f70d6 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 67ec3322..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, 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 04a87bc6..0c4cadcd 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;
@@ -38,6 +40,9 @@ pub trait Compositor: Sized {
height: u32,
);
+ /// Returns [`GraphicsInformation`] used by this [`Compositor`].
+ fn fetch_information(&self) -> Information;
+
/// Presents the [`Renderer`] primitives to the next frame of the given [`Surface`].
///
/// [`Renderer`]: Self::Renderer
@@ -72,3 +77,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 Information {
+ /// Contains the graphics adapter.
+ pub adapter: String,
+ /// Contains the graphics backend.
+ pub backend: String,
+}
diff --git a/graphics/src/window/gl_compositor.rs b/graphics/src/window/gl_compositor.rs
index b1b995f1..4ff17366 100644
--- a/graphics/src/window/gl_compositor.rs
+++ b/graphics/src/window/gl_compositor.rs
@@ -1,3 +1,6 @@
+//! 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;
@@ -48,6 +51,9 @@ pub trait GLCompositor: Sized {
/// Resizes the viewport of the [`GLCompositor`].
fn resize_viewport(&mut self, physical_size: Size<u32>);
+ /// Returns [`GraphicsInformation`] used by this [`Compositor`].
+ fn fetch_information(&self) -> Information;
+
/// Presents the primitives of the [`Renderer`] to the next frame of the
/// [`GLCompositor`].
///