Make imgui build successfully with directx even when not on windows

This commit is contained in:
Michael Tang 2019-04-23 17:37:46 -07:00
parent 041098da85
commit b97bb58a56
2 changed files with 12 additions and 11 deletions

View File

@ -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"] }

View File

@ -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
}
}
}