impl VertexAttribute for T and Vector4<T>
@@ -16,8 +16,10 @@ pub trait VertexAttribute<T: VertexBufferDataType>:
{
}
+impl<T: VertexBufferDataType> VertexAttribute<T> for T {}
impl<T: VertexBufferDataType> VertexAttribute<T> for Vector2<T> {}
impl<T: VertexBufferDataType> VertexAttribute<T> for Vector3<T> {}
+impl<T: VertexBufferDataType> VertexAttribute<T> for Vector4<T> {}
pub(crate) mod vertex_attribute {
use crate::core::*;
@@ -27,6 +29,16 @@ pub(crate) mod vertex_attribute {
fn flatten(data: &[Self]) -> Vec<T>;
}
+ impl<T: VertexBufferDataType> Extension<T> for T {
+ fn length() -> u32 {
+ 1
+ }
+
+ fn flatten(data: &[Self]) -> Vec<T> {
+ data.to_vec()
+ }
+ }
+
impl<T: VertexBufferDataType> Extension<T> for Vector2<T> {
fn length() -> u32 {
2
@@ -57,6 +69,23 @@ pub(crate) mod vertex_attribute {
res
}
}
+
+ impl<T: VertexBufferDataType> Extension<T> for Vector4<T> {
+ fn length() -> u32 {
+ 4
+ }
+
+ fn flatten(data: &[Self]) -> Vec<T> {
+ let mut res = Vec::with_capacity(data.len() * Self::length() as usize);
+ for d in data {
+ res.push(d.x);
+ res.push(d.y);
+ res.push(d.z);
+ res.push(d.w);
+ }
+ res
+ }
+ }
}
///
