From 67c53d78bbd721a6b5b86c233de740fa3afaf0a8 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Wed, 18 Jan 2023 03:06:13 +0100 Subject: [PATCH] update textures --- assets/blocks/grass_side_snow.png | Bin 0 -> 367 bytes assets/blocks/{grass.png => grass_top.png} | Bin assets/blocks/snow.png | Bin 0 -> 221 bytes assets/blocks/{tree.png => wood.png} | Bin assets/blocks/{tree_top.png => wood_top.png} | Bin src/game/assets/textures.rs | 23 ++++++++++++------- 6 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 assets/blocks/grass_side_snow.png rename assets/blocks/{grass.png => grass_top.png} (100%) create mode 100644 assets/blocks/snow.png rename assets/blocks/{tree.png => wood.png} (100%) rename assets/blocks/{tree_top.png => wood_top.png} (100%) diff --git a/assets/blocks/grass_side_snow.png b/assets/blocks/grass_side_snow.png new file mode 100644 index 0000000000000000000000000000000000000000..4b2fa73297b938a59bd1a2675f938d766bdcec27 GIT binary patch literal 367 zcmV-#0g(QQP)Px#1ZP1_K>z@;j|==^1poj5T~JI^Mep$M?(gp6Dk)Z=I7@1_VwiD+I`x zQa6)nN4A1lgoK1~RY0z@roaFI010qNS#tmY4#EHc4#EKyC`y0;005gwL_t(2QzcFd z7J@JgD-#rih$1Ss#rq$VWbW;CZJN)_tSRNxc4xcvWw?%J-DHMoXm4{fbp72PSe^wd z*4Mn?{efWvz5rT`aKJ4*65;Hzc@S^}F^%sV9e|T7w?KN!QHBWF&VT zi3n7EAQ=|BVoBy^qlEELY(@SjQxgBl5eX`lf}}Yuw5ou@`?Fus|vx3IvM z^=gILu^c|FTmR$Fy!ksthwtaIbG*^Tr+IHK_z`;Lk literal 0 HcmV?d00001 diff --git a/assets/blocks/tree.png b/assets/blocks/wood.png similarity index 100% rename from assets/blocks/tree.png rename to assets/blocks/wood.png diff --git a/assets/blocks/tree_top.png b/assets/blocks/wood_top.png similarity index 100% rename from assets/blocks/tree_top.png rename to assets/blocks/wood_top.png diff --git a/src/game/assets/textures.rs b/src/game/assets/textures.rs index 15fe37e..c7cf857 100644 --- a/src/game/assets/textures.rs +++ b/src/game/assets/textures.rs @@ -31,11 +31,11 @@ fn load_png(file_path: &str, display: &glium::Display) -> SrgbTexture2d { fn load_png_array(file_paths: &[PathBuf], display: &glium::Display) -> SrgbTexture2dArray { let counter = AtomicU16::new(0); let raw_images: Vec> = file_paths.par_iter().enumerate().map(|(_, file_path)| { - let counter = counter.fetch_add(1, std::sync::atomic::Ordering::SeqCst); - log::info!("loading texture {}/{}: {}", counter, file_paths.len(), file_path.to_str().unwrap()); + + let fname: &str = file_path.file_name().unwrap_or_default().to_str().unwrap(); //Load file - let data = fs::read(file_path).expect("Failed to load texture"); + let data = fs::read(file_path).expect(&format!("Failed to load texture {}", fname)); //decode image data let image_data = image::load( @@ -50,6 +50,9 @@ fn load_png_array(file_paths: &[PathBuf], display: &glium::Display) -> SrgbTextu image_dimensions ); + let counter = counter.fetch_add(1, std::sync::atomic::Ordering::SeqCst) + 1; + log::info!("loaded texture {}/{}: {}", counter, file_paths.len(), fname); + raw_image }).collect(); SrgbTexture2dArray::new(display, raw_images).unwrap() @@ -65,15 +68,17 @@ impl Textures { blocks: load_png_array(&[ "./assets/blocks/stone.png".into(), "./assets/blocks/dirt.png".into(), - "./assets/blocks/grass.png".into(), + "./assets/blocks/grass_top.png".into(), "./assets/blocks/grass_side.png".into(), "./assets/blocks/sand.png".into(), "./assets/blocks/bedrock.png".into(), - "./assets/blocks/tree.png".into(), - "./assets/blocks/tree_top.png".into(), + "./assets/blocks/wood.png".into(), + "./assets/blocks/wood_top.png".into(), "./assets/blocks/leaf.png".into(), "./assets/blocks/torch.png".into(), "./assets/blocks/tall_grass.png".into(), + "./assets/blocks/snow.png".into(), + "./assets/blocks/grass_side_snow.png".into(), ], display) } } @@ -88,9 +93,11 @@ pub enum BlockTexture { GrassSide = 3, Sand = 4, Bedrock = 5, - Tree = 6, - TreeTop = 7, + Wood = 6, + WoodTop = 7, Leaf = 8, Torch = 9, TallGrass = 10, + Snow = 11, + GrassSideSnow = 12, }