summaryrefslogtreecommitdiff
path: root/src/instance.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/instance.rs')
-rw-r--r--src/instance.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/instance.rs b/src/instance.rs
index 6ea5321..eded8cf 100644
--- a/src/instance.rs
+++ b/src/instance.rs
@@ -12,6 +12,12 @@ pub struct Instance {
pub position: [f32; 2],
/// Relative size
pub size: [f32; 2],
+ /// The location of the texture in the texture atlas
+ pub texture_coordinates: [f32; 2],
+ /// The size of the sprite's texture
+ pub texture_size: [f32; 2],
+ /// The index of the texture atlas to use
+ pub texture_atlas_index: u32,
/// Rotation, in radians
pub rotation: f32,
/// z-index
@@ -25,14 +31,19 @@ impl Default for Instance {
size: [1.0; 2],
rotation: 0.0,
z_index: 0,
+ texture_coordinates: [0.0; 2],
+ texture_size: [1.0; 2],
+ texture_atlas_index: 0,
}
}
}
impl Instance {
// whenever this is updated, please also update `sprite.wgsl`
- const ATTRIBUTES: [wgpu::VertexAttribute; 4] =
- wgpu::vertex_attr_array![1 => Float32x2, 2 => Float32x2, 3 => Float32, 4 => Uint32];
+ const ATTRIBUTES: [wgpu::VertexAttribute; 7] = wgpu::vertex_attr_array![
+ 1 => Float32x2, 2 => Float32x2, 3 => Float32x2, 4 => Float32x2,
+ 5 => Uint32, 6 => Float32, 7 => Uint32
+ ];
pub(crate) fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
// make sure these two don't conflict