diff options
-rw-r--r-- | src/main.rs | 95 |
1 files changed, 51 insertions, 44 deletions
diff --git a/src/main.rs b/src/main.rs index ebdf491..e9ca506 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::error::Error; use engine::color::Color; -use engine::object::Object; +use engine::object::{Id as ObjectId, Object}; use engine::vector::Vec3; use engine::vertex::Builder as VertexBuilder; use engine::{Engine, WindowSize}; @@ -21,51 +21,58 @@ fn main() -> Result<(), Box<dyn Error>> tracing::subscriber::set_global_default(subscriber)?; - let engine = Engine::new(&WINDOW_SIZE, "Yaaay lmao")?; + let mut engine = Engine::new(&WINDOW_SIZE, "Yaaay lmao")?; - let triangle = Object::new(&[ - VertexBuilder::new() - .pos(Vec3 { - x: -0.5, - y: -0.5, - z: 0.0, - }) - .color(Color { - red: 1.0, - green: 0.0, - blue: 0.0, - }) - .build() - .unwrap(), - VertexBuilder::new() - .pos(Vec3 { - x: 0.5, - y: -0.5, - z: 0.0, - }) - .color(Color { - red: 0.0, - green: 1.0, - blue: 0.0, - }) - .build() - .unwrap(), - VertexBuilder::new() - .pos(Vec3 { - x: 0.0, - y: 0.5, - z: 0.0, - }) - .color(Color { - red: 0.0, - green: 0.0, - blue: 1.0, - }) - .build() - .unwrap(), - ])?; + let triangle = Object::new( + ObjectId::new(1), + &[ + VertexBuilder::new() + .pos(Vec3 { + x: -0.5, + y: -0.5, + z: 0.0, + }) + .color(Color { + red: 1.0, + green: 0.0, + blue: 0.0, + }) + .build() + .unwrap(), + VertexBuilder::new() + .pos(Vec3 { + x: 0.5, + y: -0.5, + z: 0.0, + }) + .color(Color { + red: 0.0, + green: 1.0, + blue: 0.0, + }) + .build() + .unwrap(), + VertexBuilder::new() + .pos(Vec3 { + x: 0.0, + y: 0.5, + z: 0.0, + }) + .color(Color { + red: 0.0, + green: 0.0, + blue: 1.0, + }) + .build() + .unwrap(), + ], + )?; - engine.start(&[triangle], || {})?; + engine.add_object(triangle); + + engine.start(|engine| { + let obj = engine.get_object_by_id_mut(ObjectId::new(1)); + })?; Ok(()) } |