summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--engine/Cargo.toml1
-rw-r--r--engine/build.rs34
-rw-r--r--engine/src/rendering/backend/opengl/glutin_compat.rs34
-rw-r--r--engine/src/windowing.rs29
-rw-r--r--engine/src/windowing/window/platform.rs2
6 files changed, 30 insertions, 71 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1d810e3..4fe3592 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -607,7 +607,6 @@ version = "0.1.0"
dependencies = [
"bitflags 2.11.1",
"build-rs",
- "cfg_aliases",
"crossbeam-queue",
"engine-ecs",
"engine-macros",
diff --git a/engine/Cargo.toml b/engine/Cargo.toml
index df03251..4e3968b 100644
--- a/engine/Cargo.toml
+++ b/engine/Cargo.toml
@@ -51,7 +51,6 @@ default-features = false
features = ["wayland", "gtk3"]
[build-dependencies]
-cfg_aliases = "0.2.1"
build-rs = "0.3.4"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
diff --git a/engine/build.rs b/engine/build.rs
index 7ad5a9b..e9a8322 100644
--- a/engine/build.rs
+++ b/engine/build.rs
@@ -1,7 +1,6 @@
use std::path::{Path, PathBuf};
use std::process::Command;
-use cfg_aliases::cfg_aliases;
use serde::Deserialize;
fn main()
@@ -52,39 +51,6 @@ fn main()
)
.unwrap();
}
-
- // Setup alias to reduce `cfg` boilerplate.
- cfg_aliases! {
- // Systems.
- android_platform: { target_os = "android" },
- wasm_platform: { target_family = "wasm" },
- macos_platform: { target_os = "macos" },
- ios_platform: { target_os = "ios" },
- apple: { any(ios_platform, macos_platform) },
- free_unix: { all(unix, not(apple), not(android_platform)) },
-
- // Native displays.
- x11_platform: { all(free_unix, not(wasm_platform)) },
- wayland_platform: { all(free_unix, not(wasm_platform)) },
- // x11_platform: { all(feature = "x11", free_unix, not(wasm_platform)) },
- // wayland_platform: { all(feature = "wayland", free_unix, not(wasm_platform)) },
-
- // Backends.
- egl_backend: {
- all(any(windows, unix), not(apple), not(wasm_platform))
- },
- glx_backend: { all(x11_platform, not(wasm_platform)) },
- wgl_backend: { all(windows, not(wasm_platform)) },
- cgl_backend: { all(macos_platform, not(wasm_platform)) },
-
- // Backends.
- // egl_backend: {
- // all(feature = "egl", any(windows, unix), not(apple), not(wasm_platform))
- // },
- // glx_backend: { all(feature = "glx", x11_platform, not(wasm_platform)) },
- // wgl_backend: { all(feature = "wgl", windows, not(wasm_platform)) },
- // cgl_backend: { all(macos_platform, not(wasm_platform)) },
- }
}
#[derive(Debug, Deserialize)]
diff --git a/engine/src/rendering/backend/opengl/glutin_compat.rs b/engine/src/rendering/backend/opengl/glutin_compat.rs
index 4cdf18a..ab8df90 100644
--- a/engine/src/rendering/backend/opengl/glutin_compat.rs
+++ b/engine/src/rendering/backend/opengl/glutin_compat.rs
@@ -35,15 +35,16 @@
use glutin::config::{Config, ConfigTemplateBuilder};
use glutin::display::{Display, DisplayApiPreference};
use glutin::error::Error as GlutinError;
-// #[cfg(x11_platform)]
-// use glutin::platform::x11::X11GlConfigExt;
use glutin::prelude::*;
use raw_window_handle::{DisplayHandle, RawWindowHandle, WindowHandle};
use crate::windowing::window::CreationAttributes as WindowCreationAttributes;
-#[cfg(all(not(egl_backend), not(glx_backend), not(wgl_backend), not(cgl_backend)))]
-compile_error!("Please select at least one api backend");
+#[cfg(all(not(windows), not(target_os = "macos"), not(target_os = "linux")))]
+compile_error!("Unsupported platform");
+
+#[cfg(target_family = "wasm")]
+compile_error!("Wasm targets are not supported");
/// The helper to perform [`Display`] creation and OpenGL platform
/// bootstrapping with the help of [`winit`] with little to no platform specific
@@ -115,7 +116,7 @@ impl DisplayBuilder
ConfigPickerFn: FnOnce(Box<dyn Iterator<Item = Config> + '_>) -> Option<Config>,
{
// XXX with WGL backend window should be created first.
- let raw_window_handle = if cfg!(wgl_backend) {
+ let raw_window_handle = if cfg!(windows) {
let Some(window_handle) = window_handle else {
return Err(Error::WindowRequired);
};
@@ -132,7 +133,7 @@ impl DisplayBuilder
// XXX the native window must be passed to config picker when WGL is used
// otherwise very limited OpenGL features will be supported.
let template_builder = if let Some(raw_window_handle) =
- raw_window_handle.filter(|_| cfg!(wgl_backend))
+ raw_window_handle.filter(|_| cfg!(windows))
{
template_builder.compatible_with_native_window(raw_window_handle)
} else {
@@ -142,7 +143,7 @@ impl DisplayBuilder
let template = template_builder.build();
// SAFETY: The RawWindowHandle passed on the config template
- // (when cfg(wgl_backend)) will always point to a valid object since it is
+ // (when cfg(windows)) will always point to a valid object since it is
// derived from the window_handle argument which when Some is a WindowHandle and
// WindowHandles always point to a valid object
let gl_configs = unsafe { gl_display.find_configs(template) }
@@ -152,7 +153,7 @@ impl DisplayBuilder
config_picker_fn(gl_configs).ok_or(Error::NoConfigPicked)?;
let window_attrs = cfg_select! {
- wgl_backend => { self.window_attributes }
+ windows => { self.window_attributes }
_ => {
finalize_window_creation_attrs(self.window_attributes, &picked_gl_config)
}
@@ -185,7 +186,7 @@ fn create_display(
) -> Result<Display, GlutinError>
{
let preference = cfg_select! {
- all(wgl_backend, egl_backend) => {
+ windows => {
match _api_preference {
ApiPreference::PreferEgl => {
DisplayApiPreference::EglThenWgl(_raw_window_handle)
@@ -195,7 +196,7 @@ fn create_display(
}
}
}
- all(egl_backend, glx_backend) => {
+ target_os = "linux" => {
match _api_preference {
ApiPreference::PreferEgl => DisplayApiPreference::EglThenGlx(Box::new(
crate::windowing::window::platform::x11::register_xlib_error_hook,
@@ -205,14 +206,7 @@ fn create_display(
)),
}
}
- wgl_backend => { DisplayApiPreference::Wgl(_raw_window_handle) }
- cgl_backend => { DisplayApiPreference::Cgl }
- glx_backend => {
- DisplayApiPreference::Glx(Box::new(
- crate::windowing::window::platform::x11::register_xlib_error_hook,
- ))
- }
- egl_backend => { DisplayApiPreference::Egl }
+ target_os = "macos" => { DisplayApiPreference::Cgl }
};
let handle = display_handle.as_raw();
@@ -226,7 +220,7 @@ fn create_display(
///
/// [`Window`]: winit::window::Window
/// [`Config`]: glutin::config::Config
-#[cfg(not(wgl_backend))]
+#[cfg(not(windows))]
fn finalize_window_creation_attrs(
mut attributes: WindowCreationAttributes,
gl_config: &Config,
@@ -237,7 +231,7 @@ fn finalize_window_creation_attrs(
attributes = attributes.with_transparent(false);
}
- #[cfg(x11_platform)]
+ #[cfg(target_os = "linux")]
if let Some(x11_visual) = glutin::platform::x11::X11GlConfigExt::x11_visual(gl_config)
{
return attributes.with_x11_visual(x11_visual.visual_id() as _);
diff --git a/engine/src/windowing.rs b/engine/src/windowing.rs
index bf29453..3163869 100644
--- a/engine/src/windowing.rs
+++ b/engine/src/windowing.rs
@@ -499,20 +499,21 @@ fn create_event_loop() -> Result<EventLoop<()>, EventLoopError>
{
let mut event_loop_builder = EventLoop::builder();
- #[cfg(any(x11_platform, wayland_platform))]
- winit::platform::x11::EventLoopBuilderExtX11::with_any_thread(
- &mut event_loop_builder,
- true,
- );
-
- #[cfg(windows)]
- winit::platform::windows::EventLoopBuilderExtWindows::with_any_thread(
- &mut event_loop_builder,
- true,
- );
-
- #[cfg(not(any(x11_platform, wayland_platform, windows)))]
- compile_error!("Unsupported platform");
+ cfg_select! {
+ target_os = "linux" => {
+ winit::platform::x11::EventLoopBuilderExtX11::with_any_thread(
+ &mut event_loop_builder,
+ true,
+ );
+ }
+ windows => {
+ winit::platform::windows::EventLoopBuilderExtWindows::with_any_thread(
+ &mut event_loop_builder,
+ true,
+ );
+ }
+ _ => { compile_error!("Unsupported platform") }
+ }
event_loop_builder.build()
}
diff --git a/engine/src/windowing/window/platform.rs b/engine/src/windowing/window/platform.rs
index f3908a2..1f38f3b 100644
--- a/engine/src/windowing/window/platform.rs
+++ b/engine/src/windowing/window/platform.rs
@@ -1,4 +1,4 @@
-#[cfg(x11_platform)]
+#[cfg(target_os = "linux")]
pub mod x11
{
use std::ffi::c_void;