summaryrefslogtreecommitdiff
path: root/alligator_render/src/texture.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alligator_render/src/texture.rs')
-rw-r--r--alligator_render/src/texture.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/alligator_render/src/texture.rs b/alligator_render/src/texture.rs
index b60eade..2a86501 100644
--- a/alligator_render/src/texture.rs
+++ b/alligator_render/src/texture.rs
@@ -2,6 +2,7 @@ use std::error::Error;
use std::num::NonZeroU32;
use std::sync::atomic::{AtomicUsize, Ordering};
+use alligator_resources::texture::TextureManager;
use image::error::DecodingError;
use image::{EncodableLayout, GenericImage, ImageError, RgbaImage};
use texture_packer::TexturePacker;
@@ -84,6 +85,7 @@ const fn extent_3d(width: u32, height: u32) -> wgpu::Extent3d {
// TODO make this Debug
// TODO make these resizable
pub struct TextureAtlas {
+ textures: TextureManager,
packer: TexturePacker<'static, image::RgbaImage, TextureId>,
diffuse_texture: wgpu::Texture,
diffuse_bind_group: wgpu::BindGroup,
@@ -108,7 +110,12 @@ impl TextureAtlas {
/// Creates a new texture atlas, with the given size
// TODO why is this u32?
// TODO this is still too large
- pub fn new(device: &wgpu::Device, width: u32, height: u32) -> (Self, wgpu::BindGroupLayout) {
+ pub fn new(
+ device: &wgpu::Device,
+ textures: TextureManager,
+ width: u32,
+ height: u32,
+ ) -> (Self, wgpu::BindGroupLayout) {
let atlas_size = extent_3d(width, height);
let diffuse_texture = device.create_texture(&wgpu::TextureDescriptor {
label: Some("Diffuse Texture"),
@@ -167,6 +174,7 @@ impl TextureAtlas {
(
Self {
+ textures,
packer: TexturePacker::new_skyline(TexturePackerConfig {
max_width: width,
max_height: height,
@@ -243,7 +251,7 @@ impl TextureAtlas {
/// Fill the GPU texture atlas
#[profiling::function]
- pub fn fill_textures(&mut self, queue: &wgpu::Queue) {
+ pub(crate) fn fill_textures(&mut self, queue: &wgpu::Queue) {
// saves time if nothing changed since the last time we did this
// FIXME This doesn't do much good once we get procedurally generated animation
// We'll have to create our own texture packer, with mutable subtextures,