summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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));
})?;