From 01fe7d3c892c5d8580ed05f1f6ee9362e1f02855 Mon Sep 17 00:00:00 2001 From: Micha White Date: Sat, 19 Nov 2022 14:37:35 -0500 Subject: Quick fix to already loaded textures --- alligator_resources/src/texture.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'alligator_resources/src') diff --git a/alligator_resources/src/texture.rs b/alligator_resources/src/texture.rs index 81c2105..2255b3f 100644 --- a/alligator_resources/src/texture.rs +++ b/alligator_resources/src/texture.rs @@ -192,6 +192,13 @@ impl Texture { TextureBuffer::Disk(file) => file.allocated_size(), } } + + const fn is_loaded(&self) -> bool { + match &self.buffer { + TextureBuffer::Memory(_) => true, + TextureBuffer::Disk(file) => file.is_loaded(), + } + } } pub struct TextureRef<'a> { @@ -375,7 +382,7 @@ impl TextureManager { let size = texture.allocated_size(); let priority = texture.priority(); - if priority == Priority::Urgent || self.can_load(size, priority) { + if !texture.is_loaded() && (priority == Priority::Urgent || self.can_load(size, priority)) { let texture = self.textures.get_mut(&id).expect("invalid texture id"); texture.load_texture()?; } -- cgit v1.2.3