diff options
author | HampusM <hampus@hampusmat.com> | 2024-04-14 23:20:33 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-04-14 23:20:42 +0200 |
commit | 8b0c61a061f6515c20f230bdcb2013cba9473e69 (patch) | |
tree | d8c22f3e78208586f1f00365fe013eed9d9c2587 /src | |
parent | fffb401638ac08e395785eadb1ab0ae1d17613aa (diff) |
chore: use automatic texture ID creation
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 97c7615..03fb441 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use engine::lighting::{LightSource, LightSourceBuilder}; use engine::material::Builder as MaterialBuilder; use engine::renderer::Extension as RendererExtension; use engine::shader::Program as ShaderProgram; -use engine::texture::{Id as TextureId, Map as TextureMap, Texture}; +use engine::texture::{List as TextureList, Texture}; use engine::transform::Transform; use engine::vector::{Vec2, Vec3}; use engine::vertex::Builder as VertexBuilder; @@ -126,16 +126,17 @@ fn main() -> Result<(), Box<dyn Error>> transform.set_position(Vec3 { x: 1.6, y: 0.0, z: 0.0 }); + let texture = Texture::open(Path::new("vent.png"))?; + + let texture_id = texture.id(); + engine.spawn(( create_cube_mesh(cube_vertex_builder_cb), - TextureMap::from_iter([( - TextureId::new(0), - Texture::open(Path::new("vent.png"))?, - )]), + TextureList::from_iter([texture]), MaterialBuilder::new() - .ambient_map(TextureId::new(0)) - .diffuse_map(TextureId::new(0)) - .specular_map(TextureId::new(0)) + .ambient_map(texture_id) + .diffuse_map(texture_id) + .specular_map(texture_id) .build(), transform, ShaderProgram::new()?, |