summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-16 21:58:53 +0200
committerHampusM <hampus@hampusmat.com>2023-10-16 21:58:53 +0200
commit6e49565a62ec6e675525646217578cf52413bd92 (patch)
treec2905f75a7532c28f0cd8dc9a4f12f47b6487503
parent58b8df3f51ade9d8c689e0421272295038757d06 (diff)
chore: use engine object storage
-rw-r--r--src/main.rs95
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(())
}