summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-23 20:28:13 +0200
committerHampusM <hampus@hampusmat.com>2023-10-23 20:28:13 +0200
commitfee2320189d6e758748a939c56d539043cbffde6 (patch)
tree61253cb2df4cee8fb33eacaf067f02b657f6bbc3 /src/main.rs
parentc12966c5b69841f49713f97f3d9fa7ba99fc42e7 (diff)
feat: add square together with triangle
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs60
1 files changed, 59 insertions, 1 deletions
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<f32> = Color {
+ red: 0.0,
+ blue: 1.0,
+ green: 0.0,
+};
+
fn main() -> Result<(), Box<dyn Error>>
{
let subscriber = FmtSubscriber::builder()
@@ -23,7 +29,7 @@ fn main() -> Result<(), Box<dyn Error>>
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<dyn Error>>
.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));
})?;