Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark image and dependencies of winit as optional #64

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "image"]
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 @@ -21,9 +21,11 @@ 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, immutable_texture_from_file},
utils::immutable_texture_from_bytes,
};

pub struct GuiConfig {
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
Loading