From c043241b1c5eae8f68a9e6fc083175939b882c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maro=C5=A1=20Grego?= Date: Thu, 7 Mar 2024 16:28:20 +0100 Subject: [PATCH 1/3] Mark image and dependencies of winit as optional This allows people who do not wish to use these crates to not pull them. --- Cargo.toml | 10 ++++++---- src/integration.rs | 5 ++++- src/lib.rs | 4 +++- src/utils.rs | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c7d41a9..ed03414 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,16 +12,18 @@ categories = ["gui", "game-development"] keywords = ["gui", "imgui", "immediate", "portable", "gamedev"] [features] -default = ["clipboard", "links"] +default = ["clipboard", "links", "wayland", "x11"] links = ["egui-winit/links"] clipboard = ["egui-winit/clipboard"] +wayland = ["winit/wayland", "winit/wayland-dlopen", "egui-winit/wayland"] +x11 = ["winit/x11", "egui-winit/x11"] [dependencies] ahash = "0.8.3" -egui-winit = "0.24" +egui-winit = { version = "0.24", default-features = false } egui = "0.24" -image = "0.24.5" -winit = "0.28.2" +image = { version = "0.24.5", optional = true } +winit = { version = "0.28", default-features = false } vulkano = "0.34" vulkano-shaders = "0.34" diff --git a/src/integration.rs b/src/integration.rs index e2b712b..08205d9 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -23,8 +23,10 @@ use winit::window::Window; use crate::{ renderer::{RenderResources, Renderer}, - utils::{immutable_texture_from_bytes, immutable_texture_from_file}, + utils::immutable_texture_from_bytes, }; +#[cfg(feature = "image")] +use crate::utils::immutable_texture_from_file; pub struct GuiConfig { /// Allows supplying sRGB ImageViews as render targets instead of just UNORM ImageViews, defaults to false. @@ -267,6 +269,7 @@ impl Gui { /// Registers a user image to be used by egui /// - `image_file_bytes`: e.g. include_bytes!("./assets/tree.png") /// - `format`: e.g. vulkano::format::Format::R8G8B8A8Unorm + #[cfg(feature = "image")] pub fn register_user_image( &mut self, image_file_bytes: &[u8], diff --git a/src/lib.rs b/src/lib.rs index 0337445..07ce925 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,4 +14,6 @@ mod utils; pub use egui; pub use integration::*; pub use renderer::{CallbackContext, CallbackFn, RenderResources}; -pub use utils::{immutable_texture_from_bytes, immutable_texture_from_file}; +pub use utils::immutable_texture_from_bytes; +#[cfg(feature = "image")] +pub use utils::immutable_texture_from_file; diff --git a/src/utils.rs b/src/utils.rs index e69b815..e6aa93b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -9,6 +9,7 @@ use std::sync::Arc; +#[cfg(feature = "image")] use image::RgbaImage; use vulkano::{ buffer::{AllocateBufferError, Buffer, BufferCreateInfo, BufferUsage}, @@ -82,6 +83,7 @@ pub fn immutable_texture_from_bytes( Ok(ImageView::new_default(texture).unwrap()) } +#[cfg(feature = "image")] pub fn immutable_texture_from_file( allocators: &Allocators, queue: Arc, From 7a3baa013f47d34c67c886c41f94769ba2b08c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maro=C5=A1=20Grego?= Date: Fri, 8 Mar 2024 18:23:03 +0100 Subject: [PATCH 2/3] Add image as default dependency --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ed03414..95b4eaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ categories = ["gui", "game-development"] keywords = ["gui", "imgui", "immediate", "portable", "gamedev"] [features] -default = ["clipboard", "links", "wayland", "x11"] +default = ["clipboard", "links", "wayland", "x11", "image"] links = ["egui-winit/links"] clipboard = ["egui-winit/clipboard"] wayland = ["winit/wayland", "winit/wayland-dlopen", "egui-winit/wayland"] From 3734e5b538789d94f03b0b2fe0927318b9465aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maro=C5=A1=20Grego?= Date: Mon, 11 Mar 2024 09:10:03 +0100 Subject: [PATCH 3/3] Fix rustfmt --- src/integration.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/integration.rs b/src/integration.rs index 08205d9..d9ab63c 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -21,12 +21,12 @@ use vulkano::{ }; use winit::window::Window; +#[cfg(feature = "image")] +use crate::utils::immutable_texture_from_file; use crate::{ renderer::{RenderResources, Renderer}, utils::immutable_texture_from_bytes, }; -#[cfg(feature = "image")] -use crate::utils::immutable_texture_from_file; pub struct GuiConfig { /// Allows supplying sRGB ImageViews as render targets instead of just UNORM ImageViews, defaults to false.