Skip to content

Commit

Permalink
Mark image and dependencies of winit as optional
Browse files Browse the repository at this point in the history
This allows people who do not wish to use these crates to not pull them.
  • Loading branch information
grego committed Mar 7, 2024
1 parent 447dc9e commit 1141142
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 4 additions & 1 deletion src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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],
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 2 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use std::sync::Arc;

#[cfg(feature = "image")]
use image::RgbaImage;
use vulkano::{
buffer::{AllocateBufferError, Buffer, BufferCreateInfo, BufferUsage},
Expand Down Expand Up @@ -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<Queue>,
Expand Down

0 comments on commit 1141142

Please sign in to comment.