From f2c54d47e6b61198520824117339aaa21c32accd Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 2 Nov 2023 18:43:35 +0100 Subject: chore: use Object builder --- src/main.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index eb89fef..f594c7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::error::Error; use engine::color::Color; -use engine::object::{Id as ObjectId, Object}; +use engine::object::{Builder as ObjectBuilder, Id as ObjectId}; use engine::vector::Vec3; use engine::vertex::Builder as VertexBuilder; use engine::{Engine, Key, WindowSize}; @@ -22,9 +22,8 @@ fn main() -> Result<(), Box> let mut engine = Engine::new(&WINDOW_SIZE, "Yaaay lmao")?; - let mut triangle = Object::new( - ObjectId::new(1), - &[ + let mut triangle = ObjectBuilder::new() + .vertices([ VertexBuilder::new() .pos(Vec3 { x: -0.5, y: -0.5, z: 0.0 }) .color(Color { red: 1.0, green: 0.0, blue: 0.0 }) @@ -40,17 +39,15 @@ fn main() -> Result<(), Box> .color(Color { red: 0.0, green: 0.0, blue: 1.0 }) .build() .unwrap(), - ], - None, - )?; + ]) + .build(ObjectId::new(1))?; triangle.translate(Vec3 { x: 0.0, y: 0.4, z: 0.0 }); engine.add_object(triangle); - let square = Object::new( - ObjectId::new(2), - &[ + let square = ObjectBuilder::new() + .vertices([ VertexBuilder::new() .pos(Vec3 { x: 0.5, y: 0.5, z: 0.0 }) .color(BLUE) @@ -71,9 +68,9 @@ fn main() -> Result<(), Box> .color(BLUE) .build() .unwrap(), - ], - Some(&[0, 1, 3, 1, 2, 3]), - )?; + ]) + .indices([0, 1, 3, 1, 2, 3]) + .build(ObjectId::new(2))?; engine.add_object(square); -- cgit v1.2.3-18-g5258