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
This commit is contained in:
Gered 2023-04-09 20:33:44 -04:00
parent cf6b7e5e3c
commit 4069a92843
3 changed files with 7 additions and 0 deletions

View file

@ -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);

View file

@ -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>;

View file

@ -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);