summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs36
1 files changed, 11 insertions, 25 deletions
diff --git a/src/main.rs b/src/main.rs
index 2488d16..e7486b2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,28 +1,21 @@
use std::error::Error;
use std::path::Path;
-use engine::color::Color;
use engine::lighting::LightSourceBuilder;
+use engine::material::Builder as MaterialBuilder;
use engine::object::Id as ObjectId;
-use engine::texture::Texture;
+use engine::texture::{Id as TextureId, Texture};
use engine::vector::{Vec2, Vec3};
use engine::{Engine, Key, WindowSize};
use tracing::Level;
use tracing_subscriber::FmtSubscriber;
-use crate::cube::{create_cube, Corner as CubeCorner, Side as CubeSide};
+use crate::cube::{create_cube, Corner as CubeCorner};
mod cube;
const WINDOW_SIZE: WindowSize = WindowSize { width: 500, height: 600 };
-const BLUE: Color<f32> = Color { red: 0.0, blue: 1.0, green: 0.0 };
-const RED: Color<f32> = Color { red: 1.0, green: 0.0, blue: 0.0 };
-const GREEN: Color<f32> = Color { red: 0.0, green: 1.0, blue: 0.0 };
-const ORANGE: Color<f32> = Color { red: 1.0, green: 0.5, blue: 0.0 };
-const PURPLE: Color<f32> = Color { red: 0.5, green: 0.0, blue: 1.0 };
-const CYAN: Color<f32> = Color { red: 0.0, green: 1.0, blue: 1.0 };
-
fn main() -> Result<(), Box<dyn Error>>
{
let subscriber = FmtSubscriber::builder()
@@ -33,20 +26,6 @@ fn main() -> Result<(), Box<dyn Error>>
let mut engine = Engine::new(&WINDOW_SIZE, "Yaaay lmao")?;
- let cube = create_cube(|vertex_builder, side, _| {
- vertex_builder.color(match side {
- CubeSide::Top => BLUE,
- CubeSide::Back => RED,
- CubeSide::Left => PURPLE,
- CubeSide::Front => ORANGE,
- CubeSide::Right => GREEN,
- CubeSide::Bottom => CYAN,
- })
- })
- .build(ObjectId::new(3))?;
-
- engine.add_object(cube);
-
let texture = Texture::open(Path::new("vent.png"))?;
let mut textured_cube = create_cube(|vertex_builder, _, corner| {
@@ -57,7 +36,14 @@ fn main() -> Result<(), Box<dyn Error>>
CubeCorner::BottomLeft => Vec2 { x: 0.0, y: 0.0 },
})
})
- .texture(texture)
+ .texture(TextureId::new(0), texture)
+ .material(
+ MaterialBuilder::new()
+ .ambient_map(TextureId::new(0))
+ .diffuse_map(TextureId::new(0))
+ .specular_map(TextureId::new(0))
+ .build(),
+ )
.build(ObjectId::new(4))?;
textured_cube.translate(Vec3 { x: 1.6, y: 0.0, z: 0.0 });