Skip to content

Commit

Permalink
use correct size of pixel instead of 4 (#2977)
Browse files Browse the repository at this point in the history
# Objective

- Fixes #2919 
- Initial pixel was hard coded and not dependent on texture format
- Replace #2920 as I noticed this needed to be done also on pipeline rendering branch

## Solution

- Replace the hard coded pixel with one using the texture pixel size
  • Loading branch information
mockersf committed Oct 28, 2021
1 parent dacc9d0 commit a2ea927
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions crates/bevy_sprite/src/texture_atlas_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ impl TextureAtlasBuilder {
&contains_smallest_box,
) {
Ok(rect_placements) => {
atlas_texture = Texture::new_fill(
Extent3d::new(current_width, current_height, 1),
let size = Extent3d::new(current_width, current_height, 1);
atlas_texture = Texture::new(
size,
TextureDimension::D2,
&[0, 0, 0, 0],
vec![0; self.format.pixel_size() * size.volume()],
self.format,
);
Some(rect_placements)
Expand Down
7 changes: 5 additions & 2 deletions pipelined/bevy_sprite2/src/texture_atlas_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,17 @@ impl TextureAtlasBuilder {
&contains_smallest_box,
) {
Ok(rect_placements) => {
atlas_texture = Image::new_fill(
atlas_texture = Image::new(
Extent3d {
width: current_width,
height: current_height,
depth_or_array_layers: 1,
},
TextureDimension::D2,
&[0, 0, 0, 0],
vec![
0;
self.format.pixel_size() * (current_width * current_height) as usize
],
self.format,
);
Some(rect_placements)
Expand Down

0 comments on commit a2ea927

Please sign in to comment.