summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/icon.icobin0 -> 5694 bytes
-rw-r--r--src/main.rs15
2 files changed, 14 insertions, 1 deletions
diff --git a/res/icon.ico b/res/icon.ico
new file mode 100644
index 0000000..e0f8c4a
--- /dev/null
+++ b/res/icon.ico
Binary files differ
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(())
}