diff options
Diffstat (limited to 'src/renderer.rs')
| -rw-r--r-- | src/renderer.rs | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index 20edf34..a1e2c09 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -1,9 +1,7 @@ use std::{convert::TryInto, num::NonZeroU32}; use crate::{ - texture::{TextureError, TextureId}, - vertex::SQUARE, - Camera, ImageFormat, Instance, InstanceBuffer, RenderWindowConfig, Vertex, WgpuTextures, + vertex::SQUARE, Camera, Instance, InstanceBuffer, RenderWindowConfig, TextureAtlas, Vertex, }; use pollster::FutureExt; use thiserror::Error; @@ -53,7 +51,7 @@ pub struct Renderer { square_vertices: u32, instances: InstanceBuffer, camera: Camera, - textures: WgpuTextures, + textures: TextureAtlas, window: Window, } @@ -200,7 +198,7 @@ impl Renderer { let instances = InstanceBuffer::new(&device, config.instance_capacity); // TODO make this configurable - let (textures, texture_layout) = WgpuTextures::new( + let (textures, texture_layout) = TextureAtlas::new( &device, window.inner_size().width, window.inner_size().height, @@ -289,38 +287,12 @@ impl Renderer { &mut self.camera } - /// Loads a texture from memory, in the given file format - /// - /// # Errors - /// - /// This returns an error if the texture is not in the given format, or if - /// the texture is so large that it cannot fit in the texture atlas. - pub fn texture_from_memory( - &mut self, - texture: &[u8], - format: ImageFormat, - ) -> Result<TextureId, TextureError> { - self.textures.texture_from_memory(texture, format) - } - - pub fn texture_width(&self, id: TextureId) -> Option<f32> { - self.textures.texture_width(id) - } - - pub fn texture_height(&self, id: TextureId) -> Option<f32> { - self.textures.texture_height(id) - } - - pub fn texture_x(&self, id: TextureId) -> Option<f32> { - self.textures.texture_x(id) - } - - pub fn texture_y(&self, id: TextureId) -> Option<f32> { - self.textures.texture_y(id) + pub const fn textures(&self) -> &TextureAtlas { + &self.textures } - pub fn clear_textures(&mut self) { - self.textures.clear_textures(); + pub fn textures_mut(&mut self) -> &mut TextureAtlas { + &mut self.textures } /// Renders a new frame to the window |
