From fe975af71dbb7c615a1e36920c6b8df3d41d1bdb Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 27 Nov 2023 20:09:42 +0100 Subject: chore: make compile again & remove colored cube --- src/main.rs | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'src') 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 = Color { red: 0.0, blue: 1.0, green: 0.0 }; -const RED: Color = Color { red: 1.0, green: 0.0, blue: 0.0 }; -const GREEN: Color = Color { red: 0.0, green: 1.0, blue: 0.0 }; -const ORANGE: Color = Color { red: 1.0, green: 0.5, blue: 0.0 }; -const PURPLE: Color = Color { red: 0.5, green: 0.0, blue: 1.0 }; -const CYAN: Color = Color { red: 0.0, green: 1.0, blue: 1.0 }; - fn main() -> Result<(), Box> { let subscriber = FmtSubscriber::builder() @@ -33,20 +26,6 @@ fn main() -> Result<(), Box> 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> 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 }); -- cgit v1.2.3-18-g5258