From 4069a92843c3ab6e4d94ae6cb5b7e2988c7b8940 Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 9 Apr 2023 20:33:44 -0400 Subject: [PATCH] add generic pixel type parameter to SystemResources this has no immediate use, but i think it will be useful in the future for writing generic constraints requiring 32-bit color support while not forcing use of any specific SystemResources implementation --- ggdt/src/system/res/dos_like.rs | 2 ++ ggdt/src/system/res/mod.rs | 3 +++ ggdt/src/system/res/standard.rs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/ggdt/src/system/res/dos_like.rs b/ggdt/src/system/res/dos_like.rs index cb32c2d..618b944 100644 --- a/ggdt/src/system/res/dos_like.rs +++ b/ggdt/src/system/res/dos_like.rs @@ -251,6 +251,8 @@ impl std::fmt::Debug for DosLike { } impl SystemResources for DosLike { + type PixelType = u8; + fn update(&mut self) -> Result<(), SystemResourcesError> { self.cursor.update(&self.mouse); diff --git a/ggdt/src/system/res/mod.rs b/ggdt/src/system/res/mod.rs index c4378fc..7abf0f5 100644 --- a/ggdt/src/system/res/mod.rs +++ b/ggdt/src/system/res/mod.rs @@ -2,6 +2,7 @@ use thiserror::Error; use crate::audio::device::AudioDeviceError; use crate::audio::AudioError; +use crate::graphics::Pixel; use crate::system::event::SystemEvent; use crate::system::framebuffer::SdlFramebufferError; @@ -41,6 +42,8 @@ pub trait SystemResourcesConfig { /// Trait used to implement structs which get used by [`System`] to provide access to hardware resources like /// audio, video and input devices. pub trait SystemResources: std::fmt::Debug { + type PixelType: Pixel; + /// Perform any per-frame hardware resource updates. You should prefer to call [`System::update`] instead of this /// in your main loop. fn update(&mut self) -> Result<(), SystemResourcesError>; diff --git a/ggdt/src/system/res/standard.rs b/ggdt/src/system/res/standard.rs index b6e229a..8d35125 100644 --- a/ggdt/src/system/res/standard.rs +++ b/ggdt/src/system/res/standard.rs @@ -205,6 +205,8 @@ impl std::fmt::Debug for Standard { } impl SystemResources for Standard { + type PixelType = u32; + fn update(&mut self) -> Result<(), SystemResourcesError> { self.cursor.update(&self.mouse);