pub struct SpritePool {
textures: Vec<Arc<SpriteTexture>>,
fallback: Arc<SpriteTexture>,
sampler: Sampler,
}Expand description
Sprite texture pool: one texture per sprite def, in load order.
Engine-side SpriteRenderInstance::texture_index indexes into
textures directly. Missing / undecodable files get a 1×1
transparent fallback so the bind group always populates.
Fields§
§textures: Vec<Arc<SpriteTexture>>§fallback: Arc<SpriteTexture>§sampler: SamplerImplementations§
Source§impl SpritePool
impl SpritePool
Sourcepub fn new(device: &Device, queue: &Queue) -> Self
pub fn new(device: &Device, queue: &Queue) -> Self
Build an empty pool with just the transparent fallback. Used
by tests and as the renderer default when no MILK_IMG.INI
has been loaded yet.
Sourcepub fn sampler(&self) -> &Sampler
pub fn sampler(&self) -> &Sampler
Borrow the GPU sampler for this pool. The sprite pipeline binds it identically across every draw.
pub fn is_empty(&self) -> bool
Sourcepub fn get_or_fallback(&self, idx: u32) -> &Arc<SpriteTexture>
pub fn get_or_fallback(&self, idx: u32) -> &Arc<SpriteTexture>
Resolve a sprite by index. Returns the fallback for any out-of-range or missing entry — keeps the per-frame draw path branchless on the renderer side.
Sourcepub fn load_from_defs(
&mut self,
device: &Device,
queue: &Queue,
dir: &Path,
def_imgs: &[String],
)
pub fn load_from_defs( &mut self, device: &Device, queue: &Queue, dir: &Path, def_imgs: &[String], )
Reload the pool from a directory of image files, indexed by
the engine’s SpriteDef list. Missing files / decode failures
emit a single warn log and substitute the fallback so the
engine’s texture_index mapping stays dense.
def_imgs is the parallel list of img= filenames from the
MILK_IMG.INI; dir is the directory those filenames resolve
against (e.g. ~/.local/share/onedrop/sprites).
Auto Trait Implementations§
impl Freeze for SpritePool
impl !RefUnwindSafe for SpritePool
impl Send for SpritePool
impl Sync for SpritePool
impl Unpin for SpritePool
impl !UnwindSafe for SpritePool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more