refactor: use 'unsafe_textures' sdl2 feature to hide lifetimes & obscure leaks into upstream

This commit is contained in:
Ryan Walters
2025-09-02 12:59:06 -05:00
parent d0a68faa51
commit 7cdd1b6ad9
6 changed files with 13 additions and 18 deletions

View File

@@ -23,7 +23,7 @@ fn f32_to_u8(value: f32) -> u8 {
}
/// Resource to hold the debug texture for persistent rendering
pub struct DebugTextureResource(pub Texture<'static>);
pub struct DebugTextureResource(pub Texture);
/// Resource to hold the debug font
pub struct DebugFontResource(pub Font<'static, 'static>);

View File

@@ -100,10 +100,10 @@ pub fn linear_render_system(dt: Res<DeltaTime>, mut query: Query<(&mut LinearAni
}
/// A non-send resource for the map texture. This just wraps the texture with a type so it can be differentiated when exposed as a resource.
pub struct MapTextureResource(pub Texture<'static>);
pub struct MapTextureResource(pub Texture);
/// A non-send resource for the backbuffer texture. This just wraps the texture with a type so it can be differentiated when exposed as a resource.
pub struct BackbufferResource(pub Texture<'static>);
pub struct BackbufferResource(pub Texture);
/// Renders the HUD (score, lives, etc.) on top of the game.
pub fn hud_render_system(

View File

@@ -79,7 +79,7 @@ impl AtlasTile {
/// and optional default color modulation configuration.
pub struct SpriteAtlas {
/// The combined texture containing all sprite frames
texture: Texture<'static>,
texture: Texture,
/// Mapping from sprite names to their pixel coordinates within the texture
tiles: HashMap<String, MapperFrame>,
default_color: Option<Color>,
@@ -88,7 +88,7 @@ pub struct SpriteAtlas {
}
impl SpriteAtlas {
pub fn new(texture: Texture<'static>, mapper: AtlasMapper) -> Self {
pub fn new(texture: Texture, mapper: AtlasMapper) -> Self {
Self {
texture,
tiles: mapper.frames,
@@ -117,7 +117,7 @@ impl SpriteAtlas {
}
#[allow(dead_code)]
pub fn texture(&self) -> &Texture<'static> {
pub fn texture(&self) -> &Texture {
&self.texture
}