Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoqsh committed Jan 15, 2024
1 parent 02a7247 commit 5bf0d2d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 53 deletions.
33 changes: 0 additions & 33 deletions dunge/src/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReadVertex, types::Vec2<f32>>;

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<ReadVertex, types::Vec3<f32>>;

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<ReadVertex, types::Vec4<f32>>;

fn input_projection(id: u32, index: u32) -> Self::Field {
ReadVertex::new(id, index)
}
}

mod private {
pub trait Sealed {}
}
16 changes: 8 additions & 8 deletions dunge/tests/triangle_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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.],
},
];

Expand Down
7 changes: 4 additions & 3 deletions dunge/tests/triangle_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Error = Box<dyn error::Error>;
#[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.;

Expand Down Expand Up @@ -52,7 +53,7 @@ fn render() -> Result<(), Error> {

let triangle = |t: InInstance<Transform>, 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.),
Expand All @@ -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)
};
Expand Down
18 changes: 9 additions & 9 deletions dunge/tests/triangle_vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
state::Render,
texture, Vertex,
},
glam::{Vec2, Vec3},
glam::Vec2,
helpers::Image,
std::{error, fs},
};
Expand All @@ -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<Vert>| Out {
Expand All @@ -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.],
},
];

Expand Down

0 comments on commit 5bf0d2d

Please sign in to comment.