summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-05-18 12:02:59 +0200
committerHampusM <hampus@hampusmat.com>2024-05-18 12:02:59 +0200
commit68f9e80863a0ac73fcbd14693ad559728ca655dc (patch)
treebef289b52bfafc59be1f494f43d229a19ff87718
parentf82ceb5587954802352e00ffacd229559a2ca4df (diff)
fix: add GlobalLight sole
-rw-r--r--src/main.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 8f01cd2..358b15b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,7 +8,7 @@ use engine::data_types::dimens::Dimens;
use engine::ecs::sole::Single;
use engine::event::Start as StartEvent;
use engine::input::Extension as InputExtension;
-use engine::lighting::LightSource;
+use engine::lighting::{GlobalLight, LightSource};
use engine::material::Builder as MaterialBuilder;
use engine::renderer::Extension as RendererExtension;
use engine::shader::Program as ShaderProgram;
@@ -66,7 +66,7 @@ fn main() -> Result<(), Box<dyn Error>>
let light_source_texture_id = light_source_texture.id();
engine.spawn((
- LightSource { ..Default::default() },
+ LightSource::default(),
Transform {
position: Vec3 { x: -2.0, y: 3.0, z: 3.0 },
..Default::default()
@@ -75,7 +75,7 @@ fn main() -> Result<(), Box<dyn Error>>
MaterialBuilder::new()
.textures([light_source_texture])
.diffuse(Color::WHITE_F32)
- .ambient(Color::WHITE_F32)
+ .ambient(Color::WHITE_F32 * 3.0)
.specular(Color::WHITE_F32)
.ambient_map(light_source_texture_id)
.diffuse_map(light_source_texture_id)
@@ -86,6 +86,12 @@ fn main() -> Result<(), Box<dyn Error>>
engine.spawn((Camera { current: true, ..Default::default() },));
+ engine.add_sole(
+ GlobalLight::builder()
+ .ambient_offset(-Color::WHITE_F32)
+ .build(),
+ )?;
+
engine.register_system(StartEvent, prepare_window);
engine.add_extension(RendererExtension::default());