From 5bf0d2d5d93018b4e10677ac30d53b8543409255 Mon Sep 17 00:00:00 2001 From: nanoqsh Date: Mon, 15 Jan 2024 21:43:54 +0600 Subject: [PATCH] Fix --- dunge/src/vertex.rs | 33 -------------------------------- dunge/tests/triangle_group.rs | 16 ++++++++-------- dunge/tests/triangle_instance.rs | 7 ++++--- dunge/tests/triangle_vertex.rs | 18 ++++++++--------- 4 files changed, 21 insertions(+), 53 deletions(-) diff --git a/dunge/src/vertex.rs b/dunge/src/vertex.rs index b69aedc..534b144 100644 --- a/dunge/src/vertex.rs +++ b/dunge/src/vertex.rs @@ -47,39 +47,6 @@ impl InputProjection for [f32; 4] { } } -impl private::Sealed for glam::Vec2 {} - -impl InputProjection for glam::Vec2 { - const TYPE: VectorType = VectorType::Vec2f; - type Field = Ret>; - - fn input_projection(id: u32, index: u32) -> Self::Field { - ReadVertex::new(id, index) - } -} - -impl private::Sealed for glam::Vec3 {} - -impl InputProjection for glam::Vec3 { - const TYPE: VectorType = VectorType::Vec3f; - type Field = Ret>; - - fn input_projection(id: u32, index: u32) -> Self::Field { - ReadVertex::new(id, index) - } -} - -impl private::Sealed for glam::Vec4 {} - -impl InputProjection for glam::Vec4 { - const TYPE: VectorType = VectorType::Vec4f; - type Field = Ret>; - - fn input_projection(id: u32, index: u32) -> Self::Field { - ReadVertex::new(id, index) - } -} - mod private { pub trait Sealed {} } diff --git a/dunge/tests/triangle_group.rs b/dunge/tests/triangle_group.rs index a4ddd4b..007f8e9 100644 --- a/dunge/tests/triangle_group.rs +++ b/dunge/tests/triangle_group.rs @@ -26,8 +26,8 @@ fn render() -> Result<(), Error> { #[repr(C)] #[derive(Vertex)] struct Vert { - pos: Vec2, - tex: Vec2, + pos: [f32; 2], + tex: [f32; 2], } #[derive(Group)] @@ -76,16 +76,16 @@ fn render() -> Result<(), Error> { const VERTS: [Vert; 3] = [ Vert { - pos: Vec2::new(0., -0.75), - tex: Vec2::new(0., 1.), + pos: [0., -0.75], + tex: [0., 1.], }, Vert { - pos: Vec2::new(0.866, 0.75), - tex: Vec2::new(1., 1.), + pos: [0.866, 0.75], + tex: [1., 1.], }, Vert { - pos: Vec2::new(-0.866, 0.75), - tex: Vec2::new(1., 0.), + pos: [-0.866, 0.75], + tex: [1., 0.], }, ]; diff --git a/dunge/tests/triangle_instance.rs b/dunge/tests/triangle_instance.rs index d2fedec..3dc00b1 100644 --- a/dunge/tests/triangle_instance.rs +++ b/dunge/tests/triangle_instance.rs @@ -22,6 +22,7 @@ type Error = Box; #[test] fn render() -> Result<(), Error> { const SIZE: (u32, u32) = (300, 300); + const TRIANGLE_SIZE: f32 = 0.4; const THIRD: f32 = consts::TAU / 3.; const R_OFFSET: f32 = -consts::TAU / 4.; @@ -52,7 +53,7 @@ fn render() -> Result<(), Error> { let triangle = |t: InInstance, Index(index): Index| { let [x, y] = sl::thunk(sl::f32(index) * THIRD + R_OFFSET); - let p = sl::vec2(sl::cos(x) * 0.4, sl::sin(y) * 0.4) + t.pos; + let p = sl::vec2(sl::cos(x), sl::sin(y)) * TRIANGLE_SIZE + t.pos; Out { place: sl::concat(p, Vec2::new(0., 1.)), color: sl::vec4_with(sl::fragment(t.col), 1.), @@ -72,10 +73,10 @@ fn render() -> Result<(), Error> { let table = { use dunge::table::{Data, Row}; - const ROS: [[f32; 2]; 3] = [[0.0, -0.375], [0.433, 0.375], [-0.433, 0.375]]; + const POS: [[f32; 2]; 3] = [[0.0, -0.375], [0.433, 0.375], [-0.433, 0.375]]; const COL: [[f32; 3]; 3] = [[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]; - let rows = [Row::new(&ROS), Row::new(&COL)]; + let rows = [Row::new(&POS), Row::new(&COL)]; let data = Data::new(&rows).expect("create table"); cx.make_table(data) }; diff --git a/dunge/tests/triangle_vertex.rs b/dunge/tests/triangle_vertex.rs index 0dbb888..2b94943 100644 --- a/dunge/tests/triangle_vertex.rs +++ b/dunge/tests/triangle_vertex.rs @@ -10,7 +10,7 @@ use { state::Render, texture, Vertex, }, - glam::{Vec2, Vec3}, + glam::Vec2, helpers::Image, std::{error, fs}, }; @@ -24,8 +24,8 @@ fn render() -> Result<(), Error> { #[repr(C)] #[derive(Vertex)] struct Vert { - pos: Vec2, - col: Vec3, + pos: [f32; 2], + col: [f32; 3], } let triangle = |vert: InVertex| Out { @@ -48,16 +48,16 @@ fn render() -> Result<(), Error> { const VERTS: [Vert; 3] = [ Vert { - pos: Vec2::new(0., -0.75), - col: Vec3::new(1., 0., 0.), + pos: [0., -0.75], + col: [1., 0., 0.], }, Vert { - pos: Vec2::new(0.866, 0.75), - col: Vec3::new(0., 1., 0.), + pos: [0.866, 0.75], + col: [0., 1., 0.], }, Vert { - pos: Vec2::new(-0.866, 0.75), - col: Vec3::new(0., 0., 1.), + pos: [-0.866, 0.75], + col: [0., 0., 1.], }, ];