summaryrefslogtreecommitdiffstats
path: root/graphics/src/window
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src/window')
-rw-r--r--graphics/src/window/compositor.rs19
-rw-r--r--graphics/src/window/gl_compositor.rs9
2 files changed, 26 insertions, 2 deletions
diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs
index 9ea040cd..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,9 +40,13 @@ 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`].
///
- /// [`SwapChain`]: Self::SwapChain
+ /// [`Renderer`]: Self::Renderer
+ /// [`Surface`]: Self::Surface
fn present<T: AsRef<str>>(
&mut self,
renderer: &mut Self::Renderer,
@@ -51,7 +57,7 @@ pub trait Compositor: Sized {
) -> Result<(), SurfaceError>;
}
-/// Result of an unsuccessful call to [`Compositor::draw`].
+/// Result of an unsuccessful call to [`Compositor::present`].
#[derive(Clone, PartialEq, Eq, Debug, Error)]
pub enum SurfaceError {
/// A timeout was encountered while trying to acquire the next frame.
@@ -71,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..722e4d9c 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;
@@ -32,6 +35,9 @@ pub trait GLCompositor: Sized {
/// Creates a new [`GLCompositor`] and [`Renderer`] with the given
/// [`Settings`] and an OpenGL address loader function.
///
+ /// # Safety
+ /// The `loader_function` should resolve to valid OpenGL bindings.
+ ///
/// [`Renderer`]: crate::Renderer
/// [`Backend`]: crate::Backend
/// [`Settings`]: Self::Settings
@@ -48,6 +54,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`].
///