From fee2320189d6e758748a939c56d539043cbffde6 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 23 Oct 2023 20:28:13 +0200 Subject: feat: add square together with triangle --- src/main.rs | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e9ca506..e4afeac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,12 @@ const WINDOW_SIZE: WindowSize = WindowSize { height: 600, }; +const BLUE: Color = Color { + red: 0.0, + blue: 1.0, + green: 0.0, +}; + fn main() -> Result<(), Box> { let subscriber = FmtSubscriber::builder() @@ -23,7 +29,7 @@ fn main() -> Result<(), Box> let mut engine = Engine::new(&WINDOW_SIZE, "Yaaay lmao")?; - let triangle = Object::new( + let mut triangle = Object::new( ObjectId::new(1), &[ VertexBuilder::new() @@ -66,10 +72,62 @@ fn main() -> Result<(), Box> .build() .unwrap(), ], + None, )?; + triangle.translate(Vec3 { + x: 0.0, + y: 0.4, + z: 0.0, + }); + engine.add_object(triangle); + let square = Object::new( + ObjectId::new(2), + &[ + VertexBuilder::new() + .pos(Vec3 { + x: 0.5, + y: 0.5, + z: 0.0, + }) + .color(BLUE) + .build() + .unwrap(), + VertexBuilder::new() + .pos(Vec3 { + x: 0.5, + y: -0.5, + z: 0.0, + }) + .color(BLUE) + .build() + .unwrap(), + VertexBuilder::new() + .pos(Vec3 { + x: -0.5, + y: -0.5, + z: 0.0, + }) + .color(BLUE) + .build() + .unwrap(), + VertexBuilder::new() + .pos(Vec3 { + x: -0.5, + y: 0.5, + z: 0.0, + }) + .color(BLUE) + .build() + .unwrap(), + ], + Some(&[0, 1, 3, 1, 2, 3]), + )?; + + engine.add_object(square); + engine.start(|engine| { let obj = engine.get_object_by_id_mut(ObjectId::new(1)); })?; -- cgit v1.2.3-18-g5258