diff --git a/imgui-gfx-renderer/Cargo.toml b/imgui-gfx-renderer/Cargo.toml index 495036b..e93979a 100644 --- a/imgui-gfx-renderer/Cargo.toml +++ b/imgui-gfx-renderer/Cargo.toml @@ -21,6 +21,7 @@ travis-ci = { repository = "Gekkio/imgui-rs" } gfx = "0.18" imgui = { version = "0.0.24-pre", path = "../" } imgui-sys = { version = "0.0.24-pre", path = "../imgui-sys", features = ["gfx"] } +cfg-if = "0.1" [target.'cfg(windows)'.build-dependencies] winapi = { version = "0.3", features = ["d3dcompiler"] } diff --git a/imgui-gfx-renderer/src/lib.rs b/imgui-gfx-renderer/src/lib.rs index 5c3d636..dbe1bec 100644 --- a/imgui-gfx-renderer/src/lib.rs +++ b/imgui-gfx-renderer/src/lib.rs @@ -168,19 +168,19 @@ impl Shaders { include_bytes!("shader/glsles_100.frag"), ), HlslSm40 => { - #[cfg(not(feature = "directx"))] - { - // panic instead? - (&[0], &[0]) + cfg_if::cfg_if! { + if #[cfg(all(feature = "directx", windows))] { + const HLSL_BYTECODE: (&[u8], &[u8]) = ( + include_bytes!(concat!(env!("OUT_DIR"), "/hlsl_vertex_shader_bytecode")), + include_bytes!(concat!(env!("OUT_DIR"), "/hlsl_pixel_shader_bytecode")), + ); + } else { + // panic instead? + const HLSL_BYTECODE: (&[u8], &[u8]) = (&[0], &[0]); + } } - #[cfg(feature = "directx")] - { - ( - include_bytes!(concat!(env!("OUT_DIR"), "/hlsl_vertex_shader_bytecode")), - include_bytes!(concat!(env!("OUT_DIR"), "/hlsl_pixel_shader_bytecode")), - ) - } + HLSL_BYTECODE } } }