summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
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);