44 lines
853 B
Rust

use bytemuck::{Pod, Zeroable};
use galactica_constants::IMAGE_LIMIT;
use std::mem;
use wgpu;
#[repr(C)]
#[derive(Debug, Copy, Clone, Pod, Zeroable, Default)]
pub struct AtlasImageLocation {
// Image box, in texture coordinates
pub xpos: f32,
pub ypos: f32,
pub width: f32,
pub height: f32,
// The index of the texture this image is in
pub atlas_texture: u32,
pub _padding: [f32; 3],
}
#[derive(Debug, Copy, Clone)]
pub struct AtlasArray {
pub data: [AtlasImageLocation; IMAGE_LIMIT as usize],
}
unsafe impl Pod for AtlasArray {}
unsafe impl Zeroable for AtlasArray {
fn zeroed() -> Self {
Self {
data: [AtlasImageLocation::zeroed(); IMAGE_LIMIT as usize],
}
}
}
impl Default for AtlasArray {
fn default() -> Self {
Self::zeroed()
}
}
impl AtlasArray {
pub const SIZE: u64 = mem::size_of::<Self>() as wgpu::BufferAddress;
}