diff options
| author | HampusM <hampus@hampusmat.com> | 2026-07-05 18:50:45 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-07-05 18:50:45 +0200 |
| commit | f3ddd36d2ce9d02da65bbebfd5c14c55a9939e63 (patch) | |
| tree | 8085f83ce4b963a827a141ac4175e4ed21ff10a3 /src/main.rs | |
| parent | cca13077329c2c42f456c573ba9e094f1195efe9 (diff) | |
feat: add window icon
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 6b8d1a7..c895a98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")] use std::error::Error; +use std::io::Cursor; use std::path::Path; use engine::asset::Assets; @@ -12,8 +13,10 @@ use engine::camera::{Active as ActiveCamera, Camera}; use engine::color::Color; use engine::data_types::dimens::Dimens3; use engine::ecs::actions::Actions; +use engine::ecs::error::Error as EcsError; use engine::ecs::phase::START as START_PHASE; use engine::ecs::sole::Single; +use engine::image::{Format as ImageFormat, Image}; use engine::input::Extension as InputExtension; use engine::lighting::{AttenuationParams, GlobalLight, PointLight}; use engine::material::{Flags as MaterialFlags, Material}; @@ -32,6 +35,7 @@ use engine::vector::Vec3; use engine::windowing::window::{ CreationAttributes as WindowCreationAttributes, CursorGrabMode as WindowCursorGrabMode, + Icon as WindowIcon, }; use engine::Engine; use tracing::level_filters::LevelFilter; @@ -95,11 +99,18 @@ impl engine::ecs::extension::Extension for Application } } -fn init(mut assets: Single<Assets>, mut actions: Actions) +fn init(mut assets: Single<Assets>, mut actions: Actions) -> Result<(), EcsError> { actions.spawn(( WindowCreationAttributes::default() .with_title("Game") + .with_icon(Some(WindowIcon::Image( + Image::from_reader( + Cursor::new(include_bytes!("../res/icon.ico")), + ImageFormat::Ico, + ) + .map_err(|_| "Invalid icon image")?, + ))) .with_cursor_visible(false) .with_cursor_grab_mode(WindowCursorGrabMode::Locked), RenderingTargetWindow, @@ -153,4 +164,6 @@ fn init(mut assets: Single<Assets>, mut actions: Actions) Model::new(assets.load::<ModelSpec>(Path::new(RESOURCE_DIR).join("teapot.obj"))), WorldPosition::from(Vec3 { x: 1.6, y: 0.0, z: 0.0 }), )); + + Ok(()) } |
