From 6c1b21d50ae0c4a05732a11ba8fe92b58b073c8f Mon Sep 17 00:00:00 2001 From: tuckie <22203973+twuky@users.noreply.github.com> Date: Sun, 15 Oct 2023 21:03:10 -0700 Subject: [PATCH] compress color data to [u8;4] --- comfy-core/src/lib.rs | 6 +++--- comfy-wgpu/src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/comfy-core/src/lib.rs b/comfy-core/src/lib.rs index 41005f1..ed6f366 100644 --- a/comfy-core/src/lib.rs +++ b/comfy-core/src/lib.rs @@ -582,7 +582,7 @@ pub struct RawDrawParams { pub pivot: Option, } -const WHITE_ARRAY: [f32; 4] = [1.0, 1.0, 1.0, 1.0]; +const WHITE_ARRAY: [u8; 4] = [255, 255, 255, 255]; pub const QUAD_VERTICES: &[SpriteVertex] = &[ SpriteVertex { @@ -620,7 +620,7 @@ pub struct Mesh { pub struct SpriteVertex { pub position: [f32; 3], pub tex_coords: [f32; 2], - pub color: [f32; 4], + pub color: [u8; 4], } impl SpriteVertex { @@ -628,7 +628,7 @@ impl SpriteVertex { Self { position: [position.x, position.y, position.z], tex_coords: [tex_coords.x, tex_coords.y], - color: [color.r, color.g, color.b, color.a], + color: color.to_array(), } } } diff --git a/comfy-wgpu/src/lib.rs b/comfy-wgpu/src/lib.rs index 3dc4be0..ce8fa6f 100644 --- a/comfy-wgpu/src/lib.rs +++ b/comfy-wgpu/src/lib.rs @@ -54,7 +54,7 @@ pub trait Vertex { const ATTRIBS: [wgpu::VertexAttribute; 3] = wgpu::vertex_attr_array![ 0 => Float32x3, 1 => Float32x2, - 2 => Float32x4, + 2 => Unorm8x4, ]; impl Vertex for SpriteVertex {