diff options
author | HampusM <hampus@hampusmat.com> | 2023-11-02 18:43:35 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-11-02 18:43:35 +0100 |
commit | f2c54d47e6b61198520824117339aaa21c32accd (patch) | |
tree | 53d917c02adb681cbd043b455c271e8193a97b74 /src | |
parent | 6cb496b5b8b085ea46549ba7a3593c28a40be7e9 (diff) |
chore: use Object builder
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 23 |
1 files changed, 10 insertions, 13 deletions
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<dyn Error>> 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<dyn Error>> .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<dyn Error>> .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); |