diff options
author | HampusM <hampus@hampusmat.com> | 2023-10-16 21:58:53 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-10-16 21:58:53 +0200 |
commit | 6e49565a62ec6e675525646217578cf52413bd92 (patch) | |
tree | c2905f75a7532c28f0cd8dc9a4f12f47b6487503 /src | |
parent | 58b8df3f51ade9d8c689e0421272295038757d06 (diff) |
chore: use engine object storage
Diffstat (limited to 'src')
-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(()) } |